Search in sources :

Example 11 with Location

use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.

the class BasicLocationTests method testLocationDataArea01.

public void testLocationDataArea01() {
    Location instance = instanceLocationTracker.getService();
    doAllTestLocationDataArea(instance, INSTANCE_DATA_AREA_PREFIX);
    Location configuration = configLocationTracker.getService();
    doAllTestLocationDataArea(configuration, "");
}
Also used : Location(org.eclipse.osgi.service.datalocation.Location)

Example 12 with Location

use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.

the class BasicLocationTests method testSchemes.

public void testSchemes() 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, "http://example.com/a");
    fwkConfig.put(EquinoxLocations.PROP_INSTANCE_AREA, "ftp://example.com/c/d");
    fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA, "platform:/base/e/f");
    fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file:" + prefix + "/g");
    Equinox equinox = new Equinox(fwkConfig);
    equinox.init();
    try {
        Map<String, Location> locations = getLocations(equinox);
        checkSlashes(locations);
        checkLocation(locations.get(Location.USER_FILTER), true, true, "http");
        checkLocation(locations.get(Location.INSTANCE_FILTER), true, true, "ftp");
        checkLocation(locations.get(Location.CONFIGURATION_FILTER), true, true, "platform");
        checkLocation(locations.get(Location.INSTALL_FILTER), true, true, "file");
    } finally {
        equinox.stop();
    }
}
Also used : Equinox(org.eclipse.osgi.launch.Equinox) Location(org.eclipse.osgi.service.datalocation.Location)

Example 13 with Location

use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.

the class BasicLocationTests method testUserDir.

public void testUserDir() throws Exception {
    Map<String, String> fwkConfig = new HashMap<String, String>();
    fwkConfig.put(EquinoxLocations.PROP_USER_AREA, "@user.dir");
    fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA + EquinoxLocations.READ_ONLY_AREA_SUFFIX, "true");
    fwkConfig.put(EquinoxLocations.PROP_INSTANCE_AREA, "@user.dir");
    fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA, "@user.dir");
    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();
    }
}
Also used : Equinox(org.eclipse.osgi.launch.Equinox) Location(org.eclipse.osgi.service.datalocation.Location)

Example 14 with Location

use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.

the class BasicLocationTests method testCreateLocation02.

public void testCreateLocation02() {
    Location configLocation = configLocationTracker.getService();
    File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testCreateLocation02");
    Location testLocation = configLocation.createLocation(null, null, true);
    try {
        testLocation.set(testLocationFile.toURL(), false);
    } catch (Throwable t) {
        fail("Failed to set location", t);
    }
    try {
        assertTrue("Could not lock location", testLocation.lock());
        testLocation.release();
        fail("Should not be able to lock read-only location");
    } catch (IOException e) {
    // expected
    }
}
Also used : Location(org.eclipse.osgi.service.datalocation.Location)

Example 15 with Location

use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.

the class BasicLocationTests method testCreateLocation05.

public void testCreateLocation05() {
    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());
        assertFalse("Could lock a secend time", testLocation.lock());
        assertFalse("Could lock a third time", testLocation.lock());
    } catch (IOException e) {
        fail("Failed to lock location", e);
    } finally {
        testLocation.release();
    }
    try {
        assertTrue("Could not lock location", testLocation.lock());
    } catch (IOException e) {
        fail("Failed to lock location", e);
    } finally {
        testLocation.release();
    }
}
Also used : Location(org.eclipse.osgi.service.datalocation.Location)

Aggregations

Location (org.eclipse.osgi.service.datalocation.Location)42 File (java.io.File)14 URL (java.net.URL)13 IOException (java.io.IOException)12 Equinox (org.eclipse.osgi.launch.Equinox)10 MalformedURLException (java.net.MalformedURLException)9 FileNotFoundException (java.io.FileNotFoundException)4 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)4 ServiceReference (org.osgi.framework.ServiceReference)4 BufferedReader (java.io.BufferedReader)3 FileReader (java.io.FileReader)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Bundle (org.osgi.framework.Bundle)3 BundleContext (org.osgi.framework.BundleContext)3 BundleException (org.osgi.framework.BundleException)3 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2