Search in sources :

Example 1 with SetupException

use of org.eclipse.core.tests.session.SetupManager.SetupException in project rt.equinox.framework by eclipse.

the class ApplicationAdminTest method suite.

public static Test suite() {
    TestSuite suite = new TestSuite(ApplicationAdminTest.class.getName());
    ConfigurationSessionTestSuite appAdminSessionTest = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, ApplicationAdminTest.class.getName());
    String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
    for (int i = 0; i < ids.length; i++) appAdminSessionTest.addBundle(ids[i]);
    appAdminSessionTest.addBundle(PI_OSGI_UTIL);
    appAdminSessionTest.addBundle(PI_OSGI_SERVICES);
    appAdminSessionTest.addBundle(PI_OSGI_TESTS);
    appAdminSessionTest.setApplicationId(testRunnerApp);
    try {
        // $NON-NLS-1$//$NON-NLS-2$
        appAdminSessionTest.getSetup().setSystemProperty("eclipse.application.registerDescriptors", "true");
    } catch (SetupException e) {
        throw new RuntimeException(e);
    }
    // we add tests the hard way so we can control the order of the tests.
    for (int i = 0; i < tests.length; i++) appAdminSessionTest.addTest(new ApplicationAdminTest(tests[i]));
    suite.addTest(appAdminSessionTest);
    return suite;
}
Also used : SetupException(org.eclipse.core.tests.session.SetupManager.SetupException) TestSuite(junit.framework.TestSuite) ConfigurationSessionTestSuite(org.eclipse.core.tests.session.ConfigurationSessionTestSuite) ConfigurationSessionTestSuite(org.eclipse.core.tests.session.ConfigurationSessionTestSuite)

Example 2 with SetupException

use of org.eclipse.core.tests.session.SetupManager.SetupException in project rt.equinox.framework by eclipse.

the class LocationAreaSessionTest method suite.

public static Test suite() {
    TestSuite suite = new TestSuite(LocationAreaSessionTest.class.getName());
    // first lock with java.nio
    suite.addTest(new TestCase("testLockJavaNIO") {

        public void runBare() throws Throwable {
            doLock(testLocationLockDir, JAVA_NIO, false, true);
        }
    });
    // attempt to lock same location with a session
    ConfigurationSessionTestSuite sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
    String[] ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
    for (int i = 0; i < ids.length; i++) sessionLock.addBundle(ids[i]);
    sessionLock.addBundle(PI_OSGI_TESTS);
    try {
        sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
    } catch (SetupException e) {
        // what can we do; just fail the testcase later when the prop is not set.
        e.printStackTrace();
    }
    sessionLock.addTest(new LocationAreaSessionTest("testSessionFailLockJavaNIO"));
    suite.addTest(sessionLock);
    // now release lock
    suite.addTest(new TestCase("testReleaseJavaNIO") {

        public void runBare() throws Throwable {
            doRelease();
        }
    });
    // attempt to lock the location with a session
    sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
    for (int i = 0; i < ids.length; i++) sessionLock.addBundle(ids[i]);
    sessionLock.addBundle(PI_OSGI_TESTS);
    try {
        sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
    } catch (SetupException e) {
        // what can we do; just fail the testcase later when the prop is not set.
        e.printStackTrace();
    }
    sessionLock.addTest(new LocationAreaSessionTest("testSessionSuccessLockJavaNIO"));
    suite.addTest(sessionLock);
    // now test with java.io
    suite.addTest(new TestCase("testLockJavaIO") {

        public void runBare() throws Throwable {
            // Note that java.io locking only seems to work reliably on windows
            if (!Constants.OS_WIN32.equals(System.getProperty("osgi.os")))
                return;
            doLock(testLocationLockDir, JAVA_IO, false, true);
        }
    });
    // attempt to lock same location with a session
    sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
    ids = ConfigurationSessionTestSuite.MINIMAL_BUNDLE_SET;
    for (int i = 0; i < ids.length; i++) sessionLock.addBundle(ids[i]);
    sessionLock.addBundle(PI_OSGI_TESTS);
    try {
        sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
    } catch (SetupException e) {
        // what can we do; just fail the testcase later when the prop is not set.
        e.printStackTrace();
    }
    sessionLock.addTest(new LocationAreaSessionTest("testSessionFailLockJavaIO"));
    suite.addTest(sessionLock);
    // now release lock
    suite.addTest(new TestCase("testReleaseJavaIO") {

        public void runBare() throws Throwable {
            if (!Constants.OS_WIN32.equals(System.getProperty("osgi.os")))
                return;
            doRelease();
        }
    });
    // attempt to lock the location with a session
    sessionLock = new ConfigurationSessionTestSuite(PI_OSGI_TESTS, LocationAreaSessionTest.class.getName());
    for (int i = 0; i < ids.length; i++) sessionLock.addBundle(ids[i]);
    sessionLock.addBundle(PI_OSGI_TESTS);
    try {
        sessionLock.getSetup().setSystemProperty(TEST_LOCATION_DIR, testLocationLockDir);
    } catch (SetupException e) {
        // what can we do; just fail the testcase later when the prop is not set.
        e.printStackTrace();
    }
    sessionLock.addTest(new LocationAreaSessionTest("testSessionSuccessLockJavaIO"));
    suite.addTest(sessionLock);
    return suite;
}
Also used : SetupException(org.eclipse.core.tests.session.SetupManager.SetupException) ConfigurationSessionTestSuite(org.eclipse.core.tests.session.ConfigurationSessionTestSuite) ConfigurationSessionTestSuite(org.eclipse.core.tests.session.ConfigurationSessionTestSuite)

Aggregations

ConfigurationSessionTestSuite (org.eclipse.core.tests.session.ConfigurationSessionTestSuite)2 SetupException (org.eclipse.core.tests.session.SetupManager.SetupException)2 TestSuite (junit.framework.TestSuite)1