@Test
  public void testNameLookupReturnsAllMatches() throws Exception {
    AddonRegistry registry =
        SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry();
    Imported<PublishedService> instance = registry.getServices(PublishedService.class.getName());
    Assert.assertTrue(instance.isAmbiguous());
    Assert.assertFalse(instance.isUnsatisfied());

    Assert.assertNotNull(instance);
    Iterator<PublishedService> iterator = instance.iterator();
    Assert.assertTrue(iterator.hasNext());
    Object first = iterator.next();
    Assert.assertNotNull(first);
    Assert.assertTrue(iterator.hasNext());
    Assert.assertTrue(iterator.hasNext());
    Object second = iterator.next();
    Assert.assertNotNull(second);
    Assert.assertFalse(iterator.hasNext());

    boolean typeMatchFound = false;
    if (first instanceof PublishedService) typeMatchFound = true;
    if (second instanceof PublishedService) typeMatchFound = true;

    Assert.assertTrue(typeMatchFound);
  }
 @Test
 public void testMissingTypedLookupReturnsEmptyInstance() throws Exception {
   AddonRegistry registry =
       SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry();
   Imported<AddonDependencyEntry> instance = registry.getServices(AddonDependencyEntry.class);
   Assert.assertNotNull(instance);
   Assert.assertFalse(instance.isAmbiguous());
   Assert.assertTrue(instance.isUnsatisfied());
 }
 @Test
 public void testMissingNamedLookupReturnsEmptyInstance() throws Exception {
   AddonRegistry registry =
       SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry();
   Imported<PublishedService> instance =
       registry.getServices("org.example.blah.NotExistsBadClassThing");
   Assert.assertNotNull(instance);
   Assert.assertFalse(instance.isAmbiguous());
   Assert.assertTrue(instance.isUnsatisfied());
 }
 @Test
 public void testTypedLookupCanBeIterated() throws Exception {
   AddonRegistry registry =
       SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry();
   Imported<PublishedService> instance = registry.getServices(PublishedService.class);
   Assert.assertFalse(instance.isAmbiguous());
   Assert.assertFalse(instance.isUnsatisfied());
   Iterator<PublishedService> iterator = instance.iterator();
   Assert.assertTrue(iterator.hasNext());
   Assert.assertNotNull(iterator.next());
   Assert.assertFalse(iterator.hasNext());
 }
示例#5
0
 private void initConfigureMetadata() {
   configureMetadata.setDefaultValue(Boolean.FALSE);
   if (metaModelFacets.isUnsatisfied()) {
     configureMetadata.setEnabled(false);
   }
 }