text:
<?xml version="1.0" encoding="UTF-8"?>

PROSTAT BURN FIRST AID- benzethonium chloride, benzocaine and menthol aerosol, spray
ProStat First Aid

Disclaimer: Most OTC drugs are not reviewed and approved by FDA, however they may be marketed if they comply with applicable regulations and policies. FDA has not evaluated whether this product complies.

ProStat Pain Relieving Burn Spray

Active Ingredients

Benzocaine 10% w/w
Benzethonium Chloride .2% w/w
Menthol .33% w/w

Purpose

Topical Anesthetic
Topical Antiseptic
Topical Anesthetic

Uses

For temporary relief of pain, itching and to help protect against infection in

minor cuts and scrapes
burns
sunburns
insect bites
minor skin irritations

Warnings

For external use only

Flammable
keep away from fire or flame
contents under pressure
do not puncture or incinerate container
do not expose to temperatures above 120° F

Do not use

in or near eyes or other mucous membranes
in case of serious burns
in deep puncture wounds
for prolonged period of time
on large portions of the body

Stop use and ask a doctor if

redness, swelling, or irritation occurs
infection occurs
conditions worsen or symptoms persist for more than 7 days

Keep out of reach of children. If swallowed, get medical help or contact a Poison Control Center right away.

Directions

clean the affected area
shake can well before using
hold 4-6 inches from surface and spray area until wet
for adult institutional use only
not intended for use on children

Other information

avoid spraying in eyes
use only as directed
intentional misuse by deliberately concentrating and inhaling the contents may be harmful or fatal

Inactive Ingredients

dipropylene glycol, isobutane, n-butane, propane

Principal Display

PROSTAT BURN FIRST AID

benzethonium chloride, benzocaine, and menthol aerosol, spray

Product Information

Product Type
HUMAN OTC DRUG LABEL
Item Code (Source)
NDC:58228-0105(NDC:52982-101)

Route of Administration
TOPICAL
DEA Schedule

Active Ingredient/Active Moiety

Ingredient Name
Basis of Strength
Strength

BENZETHONIUM CHLORIDE (BENZETHONIUM)
BENZETHONIUM CHLORIDE
170 mg  in 85 g

BENZOCAINE (BENZOCAINE)
BENZOCAINE
8500 mg  in 85 g

MENTHOL (MENTHOL)
MENTHOL
281 mg  in 85 g

Inactive Ingredients

Ingredient Name
Strength

DIPROPYLENE GLYCOL

ISOBUTANE

BUTANE

PROPANE

Packaging

#
Item Code
Package Description
Marketing Start Date
Marketing End Date

1
NDC:58228-0105-3
85 g in 1 BOTTLE, SPRAY

Marketing Information

Marketing Category
Application Number or Monograph Citation
Marketing Start Date
Marketing End Date

OTC monograph not final
part348
02/18/2014

Labeler - ProStat First Aid
							(061263699)

Registrant - Dixon Investments, Inc. (115315822)

Establishment

Name
Address
ID/FEI
Business Operations

Dixon Investments, Inc.

115315822
manufacture(58228-0105)

Revised: 3/2014

Document Id: 7518092e-2c65-42be-bf2e-8a665defe6c1

Set id: 0d490ebb-adc9-4f06-8e23-992abafbf151

Version: 4

Effective Time: 20140307

ProStat First Aid


text:
from __future__ import unicode_literals
import frappe

def execute(filters=None):
	columns, data = [], []
	return columns, data

redpajama_set_name: RedPajamaGithub


text:
/// <reference path="../../../definitions/mocha.d.ts"/>
/// <reference path="../../../definitions/node.d.ts"/>

import assert = require('assert');
import trm = require('../../lib/taskRunner');
import path = require('path');

function setResponseFile(name: string) {
    process.env['MOCK_RESPONSES'] = path.join(__dirname, name);
}

describe('Xcode Suite', function() {
    this.timeout(20000);

    before((done) => {
        // init here
        done();
    });

    after(function () {
    });

    it('run Xcode with all default inputs', (done) => {
        setResponseFile('responseDefaultInputs.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'build');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', '');
        tr.setInput('packageApp', 'true');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'false');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
        .then(() => {
            assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
            assert(tr.ran('/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) ' +
                    '-workspace /user/build/fun.xcodeproj/project.xcworkspace build ' +
                    'DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst ' +
                    'OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj ' +
                    'SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym ' +
                    'SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch'),
                'xcodebuild for building the ios project/workspace should have been run.');
            assert(tr.ran('/home/bin/xcrun -sdk $(SDK) PackageApplication ' +
                    '-v /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.app ' +
                    '-o /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.ipa'),
                "xcrun to package the app and generate an .ipa should have been run.");
            assert(tr.invokedToolCount == 3, 'should have xcodebuild for version, xcodebuild for build and xcrun for packaging');
            assert(tr.resultWasSet, 'task should have set a result');
            assert(tr.stderr.length == 0, 'should not have written to stderr');
            assert(tr.succeeded, 'task should have succeeded');
            done();
        })
        .fail((err) => {
            done(err);
        })
    })

    it('run Xcode with xctool as build tool', (done) => {
        setResponseFile('responseXctool.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'build');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', '');
        tr.setInput('packageApp', 'true');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'true');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xctool -version'), 'xctool for version should have been run.');

                assert(tr.ran('/home/bin/xctool -sdk $(SDK) -configuration $(Configuration) ' +
                        '-workspace /user/build/fun.xcodeproj/project.xcworkspace build ' +
                        'DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst ' +
                        'OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj ' +
                        'SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym ' +
                        'SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch'),
                    'xctool for building the ios project/workspace should have been run.');

                assert(tr.ran('/home/bin/xcrun -sdk $(SDK) PackageApplication ' +
                        '-v /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.app ' +
                        '-o /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.ipa'),
                    "xcrun to package the app and generate an .ipa should have been run.");

                assert(tr.invokedToolCount == 3, 'should have xctool for version, xctool for build and xcrun for packaging');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode with project and no workspace', (done) => {
        setResponseFile('responseProject.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'build');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '/user/build');
        tr.setInput('scheme', '');
        tr.setInput('packageApp', 'true');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '-project test.xcodeproj');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'false');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
                assert(tr.ran('/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) ' +
                        'build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst ' +
                        'OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj ' +
                        'SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym ' +
                        'SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch ' +
                        '-project test.xcodeproj'),
                    'xcodebuild for building the ios project should have been run.');
                assert(tr.ran('/home/bin/xcrun -sdk $(SDK) PackageApplication ' +
                        '-v /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.app ' +
                        '-o /user/build/output/$(SDK)/$(Configuration)/build.sym/Release.iphoneos/fun.ipa'),
                    "xcrun to package the app and generate an .ipa should have been run.");
                assert(tr.invokedToolCount == 3, 'should have xcodebuild for version, xcodebuild for build and xcrun for packaging');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode build with test action, publish test results', (done) => {
        setResponseFile('responseXctool.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'test');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', '');
        tr.setInput('packageApp', 'false');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'true');
        tr.setInput('xctoolReporter', 'junit:test-results.xml');
        tr.setInput('publishJUnitResults', 'true');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xctool -version'), 'xctool for version should have been run.');

                assert(tr.ran('/home/bin/xctool -sdk $(SDK) -configuration $(Configuration) ' +
                        '-workspace /user/build/fun.xcodeproj/project.xcworkspace ' +
                        '-reporter plain -reporter junit:test-results.xml test ' +
                        'DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj ' +
                        'SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym ' +
                        'SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch'),
                    'xctool for building the ios project/workspace should have been run.');

                assert(tr.stdout.search(/##vso\[results.publish type=JUnit;publishRunAttachments=true;resultFiles=\/user\/build\/test-results.xml;\]/) > 0,
                    'publish test results should have been called');

                assert(tr.invokedToolCount == 2, 'should have xctool for version, xctool for build and xcrun for packaging');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode build with test action, publish test results by searching for result files with a pattern', (done) => {
        setResponseFile('responseXctool.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'test');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', '');
        tr.setInput('packageApp', 'false');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'true');
        tr.setInput('xctoolReporter', 'junit:**/*test*.xml');
        tr.setInput('publishJUnitResults', 'true');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xctool -version'), 'xctool for version should have been run.');

                assert(tr.ran('/home/bin/xctool -sdk $(SDK) -configuration $(Configuration) ' +
                        '-workspace /user/build/fun.xcodeproj/project.xcworkspace ' +
                        '-reporter plain -reporter junit:**/*test*.xml test ' +
                        'DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj ' +
                        'SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym ' +
                        'SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch'),
                    'xctool for building the ios project/workspace should have been run.');

                assert(tr.stdout.search(/##vso\[results.publish type=JUnit;publishRunAttachments=true;resultFiles=\/user\/build\/test1\/test-results.xml,\/user\/build\/test2\/testresults.xml;\]/) > 0,
                    'publish test results should have been called');

                assert(tr.invokedToolCount == 2, 'should have xctool for version, xctool for build and xcrun for packaging');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode build, signing with P12 and provisioning profile', (done) => {
        setResponseFile('responseSigningFile.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'build');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', 'fun');
        tr.setInput('packageApp', 'false');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build/cert.p12');
        tr.setInput('p12pwd', 'p12password');
        tr.setInput('provProfile', '/user/build/testuuid.mobileprovision');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'false');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
                assert(tr.ran('/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) -workspace /user/build/fun.xcodeproj/project.xcworkspace -scheme fun build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch OTHER_CODE_SIGN_FLAGS=--keychain=/user/build/_xcodetasktmp.keychain CODE_SIGN_IDENTITY=iPhone Developer: XcodeTask Tester (HE432Y3E2Q) PROVISIONING_PROFILE=testuuid'),
                    'xcodebuild for building the ios project/workspace should have been run with signing options.');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode build, signing with P12 only, no provisioning profile', (done) => {
        setResponseFile('responseSigningFile.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'build');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', 'fun');
        tr.setInput('packageApp', 'false');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build/cert.p12');
        tr.setInput('p12pwd', 'p12password');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'false');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
                assert(tr.ran('/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) -workspace /user/build/fun.xcodeproj/project.xcworkspace -scheme fun build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch OTHER_CODE_SIGN_FLAGS=--keychain=/user/build/_xcodetasktmp.keychain CODE_SIGN_IDENTITY=iPhone Developer: XcodeTask Tester (HE432Y3E2Q)'),
                    'xcodebuild for building the ios project/workspace should have been run with signing options with P12 only, no provisioning profile.');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode build, signing with provisioning profile only, no P12', (done) => {
        setResponseFile('responseSigningFile.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'build');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', 'fun');
        tr.setInput('packageApp', 'false');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build/testuuid.mobileprovision');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'false');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
                assert(tr.ran('/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) -workspace /user/build/fun.xcodeproj/project.xcworkspace -scheme fun build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch PROVISIONING_PROFILE=testuuid'),
                    'xcodebuild for building the ios project/workspace should have been run with signing options with provisioning profile only.');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode build, signing with identifiers', (done) => {
        setResponseFile('responseSigningId.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'build');
        tr.setInput('configuration', '$(Configuration)');
        tr.setInput('sdk', '$(SDK)');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', 'fun');
        tr.setInput('packageApp', 'false');
        tr.setInput('signMethod', 'id');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'true');
        tr.setInput('defaultKeychainPassword', 'defaultKeychainPWD');
        tr.setInput('iosSigningIdentity', 'testSignIdentity');
        tr.setInput('provProfileUuid', 'testUUID');
        tr.setInput('args', '');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
        tr.setInput('xcodeDeveloperDir', '');
        tr.setInput('useXctool', 'false');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
                assert(tr.ran('/home/bin/xcodebuild -sdk $(SDK) -configuration $(Configuration) -workspace /user/build/fun.xcodeproj/project.xcworkspace -scheme fun build DSTROOT=/user/build/output/$(SDK)/$(Configuration)/build.dst OBJROOT=/user/build/output/$(SDK)/$(Configuration)/build.obj SYMROOT=/user/build/output/$(SDK)/$(Configuration)/build.sym SHARED_PRECOMPS_DIR=/user/build/output/$(SDK)/$(Configuration)/build.pch CODE_SIGN_IDENTITY=testSignIdentity PROVISIONING_PROFILE=testUUID'),
                    'xcodebuild for building the ios project/workspace should have been run with signing options.');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })

    it('run Xcode with required args not specified', (done) => {
     setResponseFile('responseErrorArgs.json');

     var tr = new trm.TaskRunner('Xcode', true, true);
     tr.setInput('actions', '');
     tr.setInput('configuration', '');
     tr.setInput('sdk', '');
     tr.setInput('xcWorkspacePath', '/user/build');
     tr.setInput('scheme', '');
     tr.setInput('packageApp', 'false');
     tr.setInput('signMethod', 'file');
     tr.setInput('p12', '/user/build');
     tr.setInput('p12pwd', '');
     tr.setInput('provProfile', '/user/build');
     tr.setInput('removeProfile', 'false');
     tr.setInput('unlockDefaultKeychain', 'false');
     tr.setInput('defaultKeychainPassword', '');
     tr.setInput('iosSigningIdentity', '');
     tr.setInput('provProfileUuid', '');
     tr.setInput('args', '');
     tr.setInput('cwd', '/user/build');
     tr.setInput('outputPattern', '');
     tr.setInput('xcodeDeveloperDir', '');
     tr.setInput('useXctool', 'false');
     tr.setInput('xctoolReporter', '');
     tr.setInput('publishJUnitResults', 'false');

     tr.run()
         .then(() => {
             assert(tr.stdout.search(/Input required: outputPattern/) > 0, 'Error should be shown if outputPath is not specified.');
             tr.setInput('outputPattern', 'output/$(SDK)/$(Configuration)');
             tr.run()
                 .then(() => {
                     assert(tr.stdout.search(/Input required: actions/) > 0, 'Error should be shown if actions are not specified.');
                     tr.setInput('actions', 'build');
                     tr.run()
                        .then(() => {
                             assert(tr.succeeded, 'Task should have run successfully with required inputs');
                             done();
                         })
                        .fail((err) => {
                             done(err);
                         })
                 })
                 .fail((err) => {
                     done(err);
                 })
         })
         .fail((err) => {
             done(err);
         })
    })

    it('run Xcode with optional args specified', (done) => {
        setResponseFile('responseOptionalArgs.json');

        var tr = new trm.TaskRunner('Xcode', true, true);
        tr.setInput('actions', 'clean build');
        tr.setInput('configuration', 'Release');
        tr.setInput('sdk', 'iphone');
        tr.setInput('xcWorkspacePath', '**/*.xcodeproj/*.xcworkspace');
        tr.setInput('scheme', 'fun');
        tr.setInput('packageApp', 'false');
        tr.setInput('signMethod', 'file');
        tr.setInput('p12', '/user/build');
        tr.setInput('p12pwd', '');
        tr.setInput('provProfile', '/user/build');
        tr.setInput('removeProfile', 'false');
        tr.setInput('unlockDefaultKeychain', 'false');
        tr.setInput('defaultKeychainPassword', '');
        tr.setInput('iosSigningIdentity', '');
        tr.setInput('provProfileUuid', '');
        tr.setInput('args', '-exportArchive -exportPath /user/build/output/iphone/release');
        tr.setInput('cwd', '/user/build');
        tr.setInput('outputPattern', 'output/iphone/release');
        tr.setInput('xcodeDeveloperDir', '/Applications/Xcode5');
        tr.setInput('useXctool', 'false');
        tr.setInput('xctoolReporter', '');
        tr.setInput('publishJUnitResults', 'false');

        tr.run()
            .then(() => {
                assert(tr.ran('/home/bin/xcodebuild -version'), 'xcodebuild for version should have been run.');
                assert(tr.ran('/home/bin/xcodebuild -sdk iphone -configuration Release -workspace /user/build/fun.xcodeproj/project.xcworkspace -scheme fun clean build DSTROOT=/user/build/output/iphone/release/build.dst OBJROOT=/user/build/output/iphone/release/build.obj SYMROOT=/user/build/output/iphone/release/build.sym SHARED_PRECOMPS_DIR=/user/build/output/iphone/release/build.pch -exportArchive -exportPath /user/build/output/iphone/release'),
                    'xcodebuild for building the ios project/workspace should have been run with all optional args.');
                assert(tr.resultWasSet, 'task should have set a result');
                assert(tr.stderr.length == 0, 'should not have written to stderr');
                assert(tr.succeeded, 'task should have succeeded');
                done();
            })
            .fail((err) => {
                done(err);
            })
    })
});


text:
  {{subject.name}}

{{(((userModules[subject.name.toLowerCase()].length/subject.modules.length)||0)*100|number:0)+'%'}}
      Clear

      40% Complete (success)


text:
package org.jbpm.runtime.manager.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.drools.core.command.CommandService;
import org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession;
import org.drools.persistence.SingleSessionCommandService;
import org.drools.persistence.jpa.OptimisticLockRetryInterceptor;
import org.drools.persistence.jta.TransactionLockInterceptor;
import org.jbpm.process.audit.AuditLogService;
import org.jbpm.process.audit.JPAAuditLogService;
import org.jbpm.process.instance.event.listeners.RuleAwareProcessEventLister;
import org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory;
import org.jbpm.runtime.manager.util.TestUtil;
import org.jbpm.services.task.identity.JBossUserGroupCallbackImpl;
import org.jbpm.test.util.AbstractBaseTest;
import org.jbpm.workflow.instance.WorkflowRuntimeException;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.kie.api.event.process.DefaultProcessEventListener;
import org.kie.api.event.process.ProcessCompletedEvent;
import org.kie.api.event.process.ProcessEventListener;
import org.kie.api.event.process.ProcessStartedEvent;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.manager.RuntimeEngine;
import org.kie.api.runtime.manager.RuntimeEnvironment;
import org.kie.api.runtime.manager.RuntimeEnvironmentBuilder;
import org.kie.api.runtime.manager.RuntimeManager;
import org.kie.api.runtime.manager.RuntimeManagerFactory;
import org.kie.api.runtime.manager.audit.AuditService;
import org.kie.api.runtime.manager.audit.NodeInstanceLog;
import org.kie.api.runtime.manager.audit.ProcessInstanceLog;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.api.task.TaskService;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.runtime.manager.context.EmptyContext;
import org.kie.internal.runtime.manager.context.ProcessInstanceIdContext;
import org.kie.internal.task.api.UserGroupCallback;

import bitronix.tm.resource.jdbc.PoolingDataSource;

public class SingletonRuntimeManagerTest extends AbstractBaseTest {

    private PoolingDataSource pds;
    private UserGroupCallback userGroupCallback;
    private RuntimeManager manager;
    @Before
    public void setup() {
        TestUtil.cleanupSingletonSessionId();
        pds = TestUtil.setupPoolingDataSource();
        Properties properties= new Properties();
        properties.setProperty("mary", "HR");
        properties.setProperty("john", "HR");
        userGroupCallback = new JBossUserGroupCallbackImpl(properties);
    }

    @After
    public void teardown() {
        if (manager != null) {
            manager.close();
        }
        pds.close();
    }

    @Test
    public void testCreationOfSession() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newEmptyBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 0);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        ksession = manager.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    public void testCreationOfSessionWithPersistence() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        ksession = manager.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    public void testReCreationOfSessionWithPersistence() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        ksession = manager.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager.close();

        // recreate it once again to ensure it has right id
        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertNotNull(ksession);

        sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        ksession = manager.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    public void testCreationOfMultipleSingletonManagerWithPersistence() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2)
                .get();
        // create first manager
        //-----------------------------------------
        RuntimeManager manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "manager1");
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        ksession = manager.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager.close();

        // create another manager
        //-----------------------------------------
        RuntimeManager manager2 = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "manager2");
        assertNotNull(manager2);

        runtime = manager2.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertNotNull(ksession);

        sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 2);

        runtime = manager2.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager2.disposeRuntimeEngine(runtime);

        ksession = manager2.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager2.close();

        // recreate first manager
        //-----------------------------------------
        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "manager1");
        assertNotNull(manager);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertNotNull(ksession);

        sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        ksession = manager.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager.close();

        // create another manager
        //-----------------------------------------
        manager2 = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "manager2");
        assertNotNull(manager2);

        runtime = manager2.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertNotNull(ksession);

        sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 2);

        runtime = manager2.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager2.disposeRuntimeEngine(runtime);

        ksession = manager2.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager2.close();
    }

    @Test
    public void testCreationOfDuplicatedManagers() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);
        try {
            RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
            fail("Should fail as it's not allowed to have singleton manager with same identifier");
        } catch (IllegalStateException e) {

        }
        manager.close();

        // now it is possible to load the manager again
        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);
    }

    @Test
    public void testExecuteReusableSubprocess() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-CallActivity.bpmn2"), ResourceType.BPMN2)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-CallActivitySubProcess.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);
        // since there is no process instance yet we need to get new session
        RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
        KieSession ksession = runtime.getKieSession();

        assertNotNull(ksession);
        long ksession1Id = ksession.getIdentifier();
        assertTrue(ksession1Id == 1);

        ProcessInstance pi1 = ksession.startProcess("ParentProcess");

        assertEquals(ProcessInstance.STATE_ACTIVE, pi1.getState());

        ksession.getWorkItemManager().completeWorkItem(1, null);

        AuditService logService = runtime.getAuditService();

        List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("ParentProcess");
        assertNotNull(logs);
        assertEquals(0, logs.size());

        logs = logService.findActiveProcessInstances("SubProcess");
        assertNotNull(logs);
        assertEquals(0, logs.size());

        logs = logService.findProcessInstances("ParentProcess");
        assertNotNull(logs);
        assertEquals(1, logs.size());

        logs = logService.findProcessInstances("SubProcess");
        assertNotNull(logs);
        assertEquals(1, logs.size());

        manager.disposeRuntimeEngine(runtime);
        manager.close();
    }

    @Test
    public void testBusinessRuleTask() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.bpmn2"), ResourceType.BPMN2)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.drl"), ResourceType.DRL)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // start process
        ProcessInstance pi = ksession.createProcessInstance("BPMN2-BusinessRuleTask", null);
        ksession.insert(pi);

        ksession.startProcessInstance(pi.getId());

        assertNull(ksession.getProcessInstance(pi.getId()));

        AuditService logService = runtime.getAuditService();

        List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("BPMN2-BusinessRuleTask");
        assertNotNull(logs);
        assertEquals(0, logs.size());

        logs = logService.findProcessInstances("BPMN2-BusinessRuleTask");
        assertNotNull(logs);
        assertEquals(1, logs.size());

        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    public void testBusinessRuleTaskWithRuleAwareListener() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.bpmn2"), ResourceType.BPMN2)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.drl"), ResourceType.DRL)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // start process
        ksession.addEventListener(new RuleAwareProcessEventLister());
        ProcessInstance pi = ksession.startProcess("BPMN2-BusinessRuleTask");

        assertNull(ksession.getProcessInstance(pi.getId()));

        AuditService logService = runtime.getAuditService();

        List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("BPMN2-BusinessRuleTask");
        assertNotNull(logs);
        assertEquals(0, logs.size());

        logs = logService.findProcessInstances("BPMN2-BusinessRuleTask");
        assertNotNull(logs);
        assertEquals(1, logs.size());

        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    @Ignore //until KieSession is protected so it won't be possible to dispose it manually
    public void testCreationOfSessionProtectedDispose() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newEmptyBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 0);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());
        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        ksession = manager.getRuntimeEngine(EmptyContext.get()).getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        ksession.dispose();
        assertEquals(sessionId, ksession.getIdentifier());

        // close manager which will close session maintained by the manager
        manager.close();

    }

    @Test
    public void testCreationOfSessionTaskServiceNotConfigured() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newEmptyBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        try {
        	runtime.getTaskService();
        	fail("Should fail as task service is not configured");
        } catch (UnsupportedOperationException e) {
        	assertEquals("TaskService was not configured", e.getMessage());
        }

        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);
        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    public void testBusinessRuleTaskWithGlobal() {
    	final List<String> list = new ArrayList<String>();
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTask.bpmn2"), ResourceType.BPMN2)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-BusinessRuleTaskWithGlobal.drl"), ResourceType.DRL)
                .registerableItemsFactory(new DefaultRegisterableItemsFactory(){

					@Override
					public Map<String, Object> getGlobals(RuntimeEngine runtime) {
						Map<String, Object> globals = super.getGlobals(runtime);
						globals.put("list", list);
						return globals;
					}

                })
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        long sessionId = ksession.getIdentifier();
        assertTrue(sessionId == 1);

        runtime = manager.getRuntimeEngine(EmptyContext.get());
        ksession = runtime.getKieSession();
        assertEquals(sessionId, ksession.getIdentifier());

        // start process
        ProcessInstance pi = ksession.createProcessInstance("BPMN2-BusinessRuleTask", null);
        ksession.insert(pi);

        ksession.startProcessInstance(pi.getId());

        assertNull(ksession.getProcessInstance(pi.getId()));
        assertEquals(1, list.size());

        AuditService logService = runtime.getAuditService();

        List<? extends ProcessInstanceLog> logs = logService.findActiveProcessInstances("BPMN2-BusinessRuleTask");
        assertNotNull(logs);
        assertEquals(0, logs.size());

        logs = logService.findProcessInstances("BPMN2-BusinessRuleTask");
        assertNotNull(logs);
        assertEquals(1, logs.size());

        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime);

        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    public void testEventSignalingBetweenProcessesWithPeristence() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("events/throw-an-event.bpmn"), ResourceType.BPMN2)
                .addAsset(ResourceFactory.newClassPathResource("events/start-on-event.bpmn"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        ksession.startProcess("com.sample.bpmn.hello");

        AuditService auditService = runtime.getAuditService();

        List<? extends ProcessInstanceLog> throwProcessLogs = auditService.findProcessInstances("com.sample.bpmn.hello");
        List<? extends ProcessInstanceLog> catchProcessLogs = auditService.findProcessInstances("com.sample.bpmn.Second");

        assertNotNull(throwProcessLogs);
        assertEquals(1, throwProcessLogs.size());
        assertEquals(ProcessInstance.STATE_COMPLETED, throwProcessLogs.get(0).getStatus().intValue());

        assertNotNull(catchProcessLogs);
        assertEquals(1, catchProcessLogs.size());
        assertEquals(ProcessInstance.STATE_COMPLETED, catchProcessLogs.get(0).getStatus().intValue());

        manager.disposeRuntimeEngine(runtime);
        manager.close();
    }

    @Test
    public void testEventSignalingBetweenProcesses() {
    	final Map<String, Integer> processStates = new HashMap<String, Integer>();
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
    			.newDefaultInMemoryBuilder()
    			.persistence(false)
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("events/throw-an-event.bpmn"), ResourceType.BPMN2)
                .addAsset(ResourceFactory.newClassPathResource("events/start-on-event.bpmn"), ResourceType.BPMN2)
                .registerableItemsFactory(new DefaultRegisterableItemsFactory() {

					@Override
					public List<ProcessEventListener> getProcessEventListeners(RuntimeEngine runtime) {

						List<ProcessEventListener> listeners = new ArrayList<ProcessEventListener>();
						listeners.add(new DefaultProcessEventListener() {

							@Override
							public void afterProcessCompleted(ProcessCompletedEvent event) {
								processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
							}

							@Override
							public void beforeProcessStarted(ProcessStartedEvent event) {
								processStates.put(event.getProcessInstance().getProcessId(), event.getProcessInstance().getState());
							}

						});

						return listeners;
					}

                })
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();
        assertNotNull(ksession);

        ksession.startProcess("com.sample.bpmn.hello");

        assertEquals(2, processStates.size());
        assertTrue(processStates.containsKey("com.sample.bpmn.hello"));
        assertTrue(processStates.containsKey("com.sample.bpmn.Second"));

        assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.hello").intValue());
        assertEquals(ProcessInstance.STATE_COMPLETED, processStates.get("com.sample.bpmn.Second").intValue());

        manager.disposeRuntimeEngine(runtime);
        manager.close();
    }

    @Test
    public void testSignalEventViaRuntimeManager() {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
                .newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2IntermediateThrowEventScope.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        assertNotNull(manager);

        RuntimeEngine runtime1 = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession1 = runtime1.getKieSession();
        assertNotNull(ksession1);

        ProcessInstance processInstance = ksession1.startProcess("intermediate-event-scope");

        RuntimeEngine runtime2 = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession2 = runtime2.getKieSession();
        assertNotNull(ksession2);

        ProcessInstance processInstance2 = ksession2.startProcess("intermediate-event-scope");

        List<Long> tasks1 = runtime1.getTaskService().getTasksByProcessInstanceId(processInstance.getId());
        assertNotNull(tasks1);
        assertEquals(1, tasks1.size());

        List<Long> tasks2 = runtime1.getTaskService().getTasksByProcessInstanceId(processInstance2.getId());
        assertNotNull(tasks2);
        assertEquals(1, tasks2.size());

        Object data = "some data";

        runtime1.getTaskService().claim(tasks1.get(0), "john");
        runtime1.getTaskService().start(tasks1.get(0), "john");
        runtime1.getTaskService().complete(tasks1.get(0), "john", Collections.singletonMap("_output", data));

        AuditService auditService = runtime1.getAuditService();

        ProcessInstanceLog pi1Log = auditService.findProcessInstance(processInstance.getId());
        assertNotNull(pi1Log);
        assertEquals(ProcessInstance.STATE_COMPLETED, pi1Log.getStatus().intValue());
        ProcessInstanceLog pi2Log = auditService.findProcessInstance(processInstance2.getId());
        assertNotNull(pi2Log);
        assertEquals(ProcessInstance.STATE_ACTIVE, pi2Log.getStatus().intValue());

        List<? extends NodeInstanceLog> nLogs = auditService.findNodeInstances(processInstance2.getId(), "_527AF0A7-D741-4062-9953-A05E51479C80");
        assertNotNull(nLogs);
        assertEquals(2, nLogs.size());

        auditService.dispose();

        // dispose session that should not have affect on the session at all
        manager.disposeRuntimeEngine(runtime1);
        manager.disposeRuntimeEngine(runtime2);

        // close manager which will close session maintained by the manager
        manager.close();
    }

    @Test
    public void testInterceptorAfterRollback() throws Exception {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
                .newDefaultBuilder()
                .userGroupCallback(userGroupCallback)
                .addAsset(ResourceFactory.newClassPathResource("BPMN2-UserTaskWithRollback.bpmn2"), ResourceType.BPMN2)
                .get();

        manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
        RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
        KieSession ksession = runtime.getKieSession();

        ProcessInstance processInstance = ksession.startProcess("UserTaskWithRollback");

        CommandService commandService = ((CommandBasedStatefulKnowledgeSession)ksession).getCommandService();
        assertEquals(SingleSessionCommandService.class, commandService.getClass());

        CommandService internalCommandService = ((SingleSessionCommandService)commandService).getCommandService();
        assertEquals(TransactionLockInterceptor.class, internalCommandService.getClass());

        TaskService taskService = runtime.getTaskService();
        List<Long> taskIds = taskService.getTasksByProcessInstanceId(processInstance.getId());
        taskService.start(taskIds.get(0), "john");
        HashMap<String, Object> result = new HashMap<String, Object>();
        result.put("output1", "rollback");
        try {
            taskService.complete(taskIds.get(0), "john", result); // rollback transaction
        } catch (WorkflowRuntimeException e) {
            // ignore
        }

        result = new HashMap<String, Object>();
        result.put("output1", "ok");
        taskService.complete(taskIds.get(0), "john", result); // this time, execute normally

        internalCommandService =  ((SingleSessionCommandService)commandService).getCommandService();
        assertEquals(TransactionLockInterceptor.class, internalCommandService.getClass());

        internalCommandService = ((TransactionLockInterceptor) internalCommandService).getNext();
        assertEquals(OptimisticLockRetryInterceptor.class, internalCommandService.getClass());

        internalCommandService = ((OptimisticLockRetryInterceptor) internalCommandService).getNext();
        assertEquals("org.drools.persistence.SingleSessionCommandService$TransactionInterceptor", internalCommandService.getClass().getName());

        // close manager which will close session maintained by the manager
        manager.close();
    }
}


text:
<?php require_once('../Connections/basededatos.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_Profesor = 10;
$pageNum_Profesor = 0;
if (isset($_GET['pageNum_Profesor'])) {
  $pageNum_Profesor = $_GET['pageNum_Profesor'];
}
$startRow_Profesor = $pageNum_Profesor * $maxRows_Profesor;

mysql_select_db($database_basededatos, $basededatos);
$query_Profesor = "SELECT * FROM profesores";
$query_limit_Profesor = sprintf("%s LIMIT %d, %d", $query_Profesor, $startRow_Profesor, $maxRows_Profesor);
$Profesor = mysql_query($query_limit_Profesor, $basededatos) or die(mysql_error());
$row_Profesor = mysql_fetch_assoc($Profesor);

if (isset($_GET['totalRows_Profesor'])) {
  $totalRows_Profesor = $_GET['totalRows_Profesor'];
} else {
  $all_Profesor = mysql_query($query_Profesor);
  $totalRows_Profesor = mysql_num_rows($all_Profesor);
}
$totalPages_Profesor = ceil($totalRows_Profesor/$maxRows_Profesor)-1;
?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);

  $logoutGoTo = "../paginas/Sesion.php";// cambiar aca dependiendo donde nos ubicamos
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
  // For security, start by assuming the visitor is NOT authorized.
  $isValid = False;

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
  if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
      $isValid = true;
    }
    // Or, you may restrict access to only certain users based on their username.
    if (in_array($UserGroup, $arrGroups)) {
      $isValid = true;
    }
    if (($strUsers == "") && true) {
      $isValid = true;
    }
  }
  return $isValid;
}

$MM_restrictGoTo = "../paginas/fail.html";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo);
  exit;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mostrar Registros de Alumnos </title>

<link href="../Css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="../Css/Styles.css" type="text/css">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximun-scale=1.0, minimum-scale=1.0">

	Inicio
    Registro
 	Inscripcion
    Buscador

    IDProfesor
    FotoProf
    profesores_nombres
    Sexo
    IDDepartamento
    Salario
    Dinero
    Nacimiento
    Tiempo de Trabajo
    Activo

  <?php do { ?>

      <?php echo $row_Profesor['idProfesores']; ?>
       <a href="#" onclick="javascript:emergente('profesor.php?idProfesores=<?php echo $row_Profesor["idProfesores"];?>') "><img src="data:image/jpeg;base64,<?php echo base64_encode($row_Profesor['FotoProf']); ?>" width="64px" height="50px" />
      <?php echo $row_Profesor['profesores_nombres']; ?>       <?php echo $row_Profesor['Profesores_apellidos']; ?>
      <?php echo $row_Profesor['Sexo']; ?>
      <?php echo $row_Profesor['IDDepartamento']; ?>
      <?php echo $row_Profesor['Salario']; ?>
      <?php echo $row_Profesor['Dinero']; ?>
      <?php echo $row_Profesor['ProfDia']; ?>/<?php echo $row_Profesor['ProfMes']; ?>/<?php echo $row_Profesor['ProfAnio']; ?>
      <?php echo $row_Profesor['id_Turno']; ?>
      <?php echo $row_Profesor['Activo']; ?>

    <?php } while ($row_Profesor = mysql_fetch_assoc($Profesor)); ?>

    <form id="reporte" name="Report" method="post" action="Reporte.php"><input type="submit" value=" Generar Reporte" /></form>

 Copyright Softeasy unt© - 2015

<?php
mysql_free_result($Profesor);
?>


text:
copyright:
  years: 2016

---

{:tsSymptoms: .tsSymptoms}
{:tsCauses: .tsCauses}
{:tsResolve: .tsResolve}
{:new_window: target="_blank"}
{:shortdesc: .shortdesc}

# {{site.data.keyword.iot_short_notm}} troubleshooting
{: #ts}
*Last updated: 6 June 2016*
{: .last-updated}

Here are the answers to common troubleshooting questions about using {{site.data.keyword.iot_full}} on {{site.data.keyword.Bluemix_notm}}.
{:shortdesc}

## Problem connecting to the {{site.data.keyword.iot_short_notm}}
{: #connection_problem}

Your connection to the {{site.data.keyword.iot_short_notm}} drops or disconnects unexpectedly.
{:shortdesc}

When you attempt to connect to the {{site.data.keyword.iot_short_notm}}, your device or application receives an error.
{: tsSymptoms}

You might have two devices trying to connect with the same clientID and credentials.Only one unique connection is allowed per clientID. You cannot have two concurrent connections using the same ID. Applications can share the same API key, but MQTT requires that the client ID is always unique.
{: tsCauses}

You can resolve this problem by confirming that you don't have two devices trying to connect by  using the same credentials.
{: tsResolve}

## Device intermittently disconnects from {{site.data.keyword.iot_short_notm}}
{: #disconnection_problem}

Your device connection to the {{site.data.keyword.iot_short_notm}} intermittently drops unexpectedly.
{:shortdesc}

A device that is connected to the {{site.data.keyword.iot_short_notm}} service is disconnected intermittently. The device reconnects, but it is unexpectedly disconnected again after a while.
{: tsSymptoms}

It might be that when you connect, you are using a value for an MQTT ping option that is too low, which makes it look like the connection timed out. For example, if the client MQTT is set incorrectly, pings are not received in a timely manner, and the connection is closed.
{: tsCauses}

You can fix this problem by confirming that you have properly set the ping and KeepAlive parameters for your connection.
{: tsResolve}