use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testNone.
public void testNone() throws Exception {
Map<String, String> fwkConfig = new HashMap<String, String>();
fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA + EquinoxLocations.READ_ONLY_AREA_SUFFIX, "true");
fwkConfig.put(EquinoxLocations.PROP_USER_AREA, "@none");
fwkConfig.put(EquinoxLocations.PROP_INSTANCE_AREA, "@none");
// TODO framework does not handle no config area well
// fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA, "@none");
fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file:" + prefix + "/g");
Equinox equinox = new Equinox(fwkConfig);
equinox.init();
try {
Map<String, Location> locations = getLocations(equinox);
assertNull("User location should be null", locations.get(Location.USER_FILTER));
assertNull("Instance location should be null", locations.get(Location.INSTANCE_FILTER));
// TODO assertNull("Configuration location should be null", locations.get(Location.CONFIGURATION_FILTER));
} finally {
equinox.stop();
}
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testCreateLocation03.
public void testCreateLocation03() {
Location configLocation = configLocationTracker.getService();
File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testCreateLocation03");
Location testLocation = configLocation.createLocation(null, null, false);
try {
testLocation.set(testLocationFile.toURL(), true);
} catch (Throwable t) {
fail("Failed to set location", t);
}
try {
assertTrue("Could not lock location", testLocation.isLocked());
} catch (IOException e) {
fail("Failed to lock location", e);
}
testLocation.release();
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testNoDefault.
public void testNoDefault() throws Exception {
Map<String, String> fwkConfig = new HashMap<String, String>();
fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA + EquinoxLocations.READ_ONLY_AREA_SUFFIX, "true");
fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file:" + prefix + "/g");
fwkConfig.put(EquinoxLocations.PROP_INSTANCE_AREA, "@noDefault");
fwkConfig.put(EquinoxLocations.PROP_USER_AREA, "@noDefault");
Equinox equinox = new Equinox(fwkConfig);
equinox.init();
try {
Map<String, Location> locations = getLocations(equinox);
Location userLocation = locations.get(Location.USER_FILTER);
Location instanceLocation = locations.get(Location.INSTANCE_FILTER);
assertNull("User locatoin is not null.", userLocation.getURL());
assertNull("Instance location is not null.", instanceLocation.getURL());
} finally {
equinox.stop();
}
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class LocationAreaSessionTest method doLock.
static void doLock(String testLocationDir, boolean release, boolean succeed) {
if (testLocationDir == null)
fail("The testLocationDir is not set");
ServiceReference[] refs = null;
try {
refs = OSGiTestsActivator.getContext().getServiceReferences(Location.class.getName(), "(type=osgi.configuration.area)");
} catch (InvalidSyntaxException e) {
fail("failed to create filter", e);
}
// this is test code so we are not very careful; just assume there is at lease one service. Do not copy and paste this code!!!
Location configLocation = (Location) OSGiTestsActivator.getContext().getService(refs[0]);
Location testLocation = null;
try {
testLocation = configLocation.createLocation(null, new File(testLocationDir).toURL(), false);
testLocation.setURL(testLocation.getDefault(), false);
// try locking location
if (succeed ? testLocation.isLocked() : !testLocation.isLocked())
fail("location should " + (succeed ? "not " : "") + "be locked");
if (succeed ? !testLocation.lock() : testLocation.lock())
fail((succeed ? "Could not" : "Could") + " lock location");
if (!testLocation.isLocked())
fail("location should be locked");
} catch (MalformedURLException e) {
fail("failed to create the location URL", e);
} catch (IOException e) {
fail("failed to lock with IOExcetpion", e);
} finally {
if (release && testLocation != null)
testLocation.release();
if (!release)
lockedTestLocation = testLocation;
OSGiTestsActivator.getContext().ungetService(refs[0]);
}
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testSystemBundle08.
public void testSystemBundle08() {
// create/start/stop/start/stop test
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile("testSystemBundle08_1");
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
Equinox equinox = new Equinox(configuration);
try {
equinox.init();
equinox.start();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to start the framework", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState());
try {
equinox.stop();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected erorr stopping framework", e);
}
try {
equinox.waitForStop(10000);
} catch (InterruptedException e) {
// $NON-NLS-1$
fail("Unexpected interrupted exception", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState());
// $NON-NLS-1$
config = OSGiTestsActivator.getContext().getDataFile("testSystemBundle08_2");
configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
equinox = new Equinox(configuration);
try {
equinox.init();
equinox.start();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to start the framework", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState());
ServiceReference[] refs = null;
try {
// $NON-NLS-1$
refs = equinox.getBundleContext().getServiceReferences(Location.class.getName(), "(type=osgi.configuration.area)");
} catch (InvalidSyntaxException e) {
// $NON-NLS-1$
fail("Unexpected syntax error", e);
}
// $NON-NLS-1$
assertNotNull("Configuration Location refs is null", refs);
// $NON-NLS-1$
assertEquals("config refs length is wrong", 1, refs.length);
Location configLocation = (Location) equinox.getBundleContext().getService(refs[0]);
URL configURL = configLocation.getURL();
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("incorrect configuration location", configURL.toExternalForm().endsWith("testSystemBundle08_2/"));
try {
equinox.stop();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected erorr stopping framework", e);
}
try {
equinox.waitForStop(10000);
} catch (InterruptedException e) {
// $NON-NLS-1$
fail("Unexpected interrupted exception", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState());
}
Aggregations