use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testUserHome.
public void testUserHome() 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, "@user.home");
fwkConfig.put(EquinoxLocations.PROP_INSTANCE_AREA, "@user.home");
fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA, "@user.home");
fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file:" + prefix + "/g");
Equinox equinox = new Equinox(fwkConfig);
equinox.init();
try {
Map<String, Location> locations = getLocations(equinox);
checkLocation(locations.get(Location.USER_FILTER), true, true, "file");
checkLocation(locations.get(Location.INSTANCE_FILTER), true, true, "file");
checkLocation(locations.get(Location.CONFIGURATION_FILTER), true, true, "file");
checkLocation(locations.get(Location.INSTALL_FILTER), true, true, "file");
} finally {
equinox.stop();
}
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testCreateLocation01.
public void testCreateLocation01() {
Location configLocation = configLocationTracker.getService();
File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testCreateLocation01");
Location testLocation = configLocation.createLocation(null, null, false);
try {
testLocation.set(testLocationFile.toURL(), false);
} catch (Throwable t) {
fail("Failed to set location", t);
}
try {
assertTrue("Could not lock location", testLocation.lock());
} 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 testSetLocationWithEmptyLockFile.
public void testSetLocationWithEmptyLockFile() {
Location configLocation = configLocationTracker.getService();
// $NON-NLS-1$
File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testSetLocationWithEmptyLockFile");
Location testLocation = configLocation.createLocation(null, null, false);
try {
// $NON-NLS-1$
testLocation.set(testLocationFile.toURL(), true, "");
// Make sure it has created the default lock file
// $NON-NLS-1$
File lockFile = new File(testLocationFile, ".metadata/.lock");
// $NON-NLS-1$
assertTrue("Lock file does not exist!", lockFile.exists());
} catch (Throwable t) {
// $NON-NLS-1$
fail("Failed to set location", t);
}
try {
// $NON-NLS-1$
assertTrue("Could not lock location", testLocation.isLocked());
} catch (IOException e) {
// $NON-NLS-1$
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 testSetLocationWithRelLockFile.
public void testSetLocationWithRelLockFile() {
Location configLocation = configLocationTracker.getService();
// $NON-NLS-1$
File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testSetLocationWithRelLockFile");
Location testLocation = configLocation.createLocation(null, null, false);
try {
// $NON-NLS-1$
testLocation.set(testLocationFile.toURL(), true, ".mocklock");
// $NON-NLS-1$
File lockFile = new File(testLocationFile, ".mocklock");
// $NON-NLS-1$
assertTrue("Lock file does not exist!", lockFile.exists());
} catch (Throwable t) {
// $NON-NLS-1$
fail("Failed to set location", t);
}
try {
// $NON-NLS-1$
assertTrue("Could not lock location", testLocation.isLocked());
} catch (IOException e) {
// $NON-NLS-1$
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 testSetLocationWithAbsLockFile.
public void testSetLocationWithAbsLockFile() {
Location configLocation = configLocationTracker.getService();
// $NON-NLS-1$
File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testSetLocationWithAbsLockFile");
// $NON-NLS-1$
File testLocationLockFile = OSGiTestsActivator.getContext().getDataFile("testLocations/mock.lock");
assertTrue(testLocationLockFile.isAbsolute());
Location testLocation = configLocation.createLocation(null, null, false);
try {
testLocation.set(testLocationFile.toURL(), true, testLocationLockFile.getAbsolutePath());
// $NON-NLS-1$
assertTrue("The lock file should be present!", testLocationLockFile.exists());
} catch (Throwable t) {
// $NON-NLS-1$
fail("Failed to set location", t);
}
try {
// $NON-NLS-1$
assertTrue("Could not lock location", testLocation.isLocked());
} catch (IOException e) {
// $NON-NLS-1$
fail("Failed to lock location", e);
}
testLocation.release();
// $NON-NLS-1$
assertTrue("The lock file could not be removed!", testLocationLockFile.delete());
}
Aggregations