@Test public void testSpecialToNotSpecialBundles() { System.setProperty(WebAppBundleTrackerCustomizer.IMPL_BUNDLES, "b;bundle-version\\=1.0.0"); VirgoEEBundleComparable comparable = new VirgoEEBundleComparable(); Bundle b1 = EasyMock.createMock(Bundle.class); Bundle b2 = EasyMock.createMock(Bundle.class); EasyMock.expect(b1.getSymbolicName()).andReturn("a"); EasyMock.expect(b2.getSymbolicName()).andReturn("b"); EasyMock.replay(b1, b2); assertEquals("Bundle b is declared as impl - should be less", -1, comparable.compare(b2, b1)); }
@Override public int compare(Bundle b1, Bundle b2) { if(b1 == b2) { return 0; } String name1 = b1.getSymbolicName(); String name2 = b2.getSymbolicName(); Integer index1 = orderedImplBundles.indexOf(name1); Integer index2 = orderedImplBundles.indexOf(name2); if(index1 == -1 && index2 == -1) { return name1.compareTo(name2); } else if(index1 == -1) { return 1; } else if(index2 == -1) { return -1; } else { return index1.compareTo(index2); } }
VirgoEEBundleComparable implements Comparator<Bundle> { @Override public int compare(Bundle b1, Bundle b2) { if(b1 == b2) { return 0; } String name1 = b1.getSymbolicName(); String name2 = b2.getSymbolicName(); Integer index1 = orderedImplBundles.indexOf(name1); Integer index2 = orderedImplBundles.indexOf(name2); if(index1 == -1 && index2 == -1) { return name1.compareTo(name2); } else if(index1 == -1) { return 1; } else if(index2 == -1) { return -1; } else { return index1.compareTo(index2); } } }
VirgoEEBundleComparable implements Comparator<Bundle> { @Override public int compare(Bundle b1, Bundle b2) { if(b1 == b2) { return 0; } String name1 = b1.getSymbolicName(); String name2 = b2.getSymbolicName(); Integer index1 = orderedImplBundles.indexOf(name1); Integer index2 = orderedImplBundles.indexOf(name2); if(index1 == -1 && index2 == -1) { return name1.compareTo(name2); } else if(index1 == -1) { return 1; } else if(index2 == -1) { return -1; } else { return index1.compareTo(index2); } } VirgoEEBundleComparable(); }
VirgoEEBundleComparable implements Comparator<Bundle> { @Override public int compare(Bundle b1, Bundle b2) { if(b1 == b2) { return 0; } String name1 = b1.getSymbolicName(); String name2 = b2.getSymbolicName(); Integer index1 = orderedImplBundles.indexOf(name1); Integer index2 = orderedImplBundles.indexOf(name2); if(index1 == -1 && index2 == -1) { return name1.compareTo(name2); } else if(index1 == -1) { return 1; } else if(index2 == -1) { return -1; } else { return index1.compareTo(index2); } } VirgoEEBundleComparable(); @Override int compare(Bundle b1, Bundle b2); }
VirgoEEBundleComparable implements Comparator<Bundle> { @Override public int compare(Bundle b1, Bundle b2) { if(b1 == b2) { return 0; } String name1 = b1.getSymbolicName(); String name2 = b2.getSymbolicName(); Integer index1 = orderedImplBundles.indexOf(name1); Integer index2 = orderedImplBundles.indexOf(name2); if(index1 == -1 && index2 == -1) { return name1.compareTo(name2); } else if(index1 == -1) { return 1; } else if(index2 == -1) { return -1; } else { return index1.compareTo(index2); } } VirgoEEBundleComparable(); @Override int compare(Bundle b1, Bundle b2);  }