public void testRemoveRegion() throws BundleException { Region pp1Region = digraph.createRegion(PP1); pp1Region.addBundle(TEST_BUNDLE_ID); assertEquals("Region not associated with bundle id", pp1Region, digraph.getRegion(TEST_BUNDLE_ID)); digraph.removeRegion(pp1Region); assertNull("Region still associated with bundle id", digraph.getRegion(TEST_BUNDLE_ID)); // Adding a bundle to a removed region should not change the digraph and should error try { pp1Region.addBundle(TEST_BUNDLE_ID); fail("Added a bundle to a region which was not part of a digraph"); } catch (IllegalStateException e) { // expected } assertNull("Region now associated with bundle id", digraph.getRegion(TEST_BUNDLE_ID)); Region pp2Region = digraph.createRegion(PP2); pp2Region.addBundle(TEST_BUNDLE_ID); // removing a bundle from a removed region should not change the digraph and should error try { pp1Region.removeBundle(TEST_BUNDLE_ID); fail("Removed a bundle via a region which was not part of a digraph"); } catch (IllegalStateException e) { // Expected } assertEquals("Wrong region found for the bundle id", pp2Region, digraph.getRegion(TEST_BUNDLE_ID)); }
private Region createRegion(String regionName, String... bundleSymbolicNames) throws BundleException { Region region = this.digraph.createRegion(regionName); for (String bundleSymbolicName : bundleSymbolicNames) { Bundle stubBundle = createBundle(bundleSymbolicName); region.addBundle(stubBundle); } this.regions.put(regionName, region); return region; }