public void testInstallAtLocation() throws BundleException, MalformedURLException, IOException { // create disconnected test regions Region r1 = digraph.createRegion(getName() + ".1"); Region r2 = digraph.createRegion(getName() + ".2"); String location = bundleInstaller.getBundleLocation(PP1); Bundle b1 = null; Bundle b2 = null; String l1 = null; String l2 = null; try { URL url = new URL(location); b1 = r1.installBundle(location + ".1", url.openStream()); l1 = b1.getLocation(); b2 = r2.installBundleAtLocation(location + ".2", url.openStream()); l2 = b2.getLocation(); } finally { if (b1 != null) { try { b1.uninstall(); } catch (BundleException e) { // ignore } } if (b2 != null) { try { b2.uninstall(); } catch (BundleException e) { // ignore } } } assertEquals("Wrong location found.", location + ".1#" + r1.getName(), l1); assertEquals("Wrong location found.", location + ".2", l2); }
/** {@inheritDoc} */ public Artifact getArtifact( @NonNull String type, @NonNull String name, @NonNull Version version, @NonNull Region region) { synchronized (this.monitor) { for (Artifact artifact : this.artifacts) { if (artifact.getType().equals(type) && artifact.getName().equals(name) && artifact.getVersion().equals(version) && artifact.getRegion().getName().equals(region.getName())) { return artifact; } } return null; } }