addSourceAutoCleanup(ApplicationDef.class, baseContents, String.format("%s:houseparty", namespace));
addSourceAutoCleanup(ApplicationDef.class, baseContents, String.format("%s:pantsparty", namespace));
StringSourceLoader loader = StringSourceLoader.getInstance();
List<SourceLoader> loaders = Lists.newArrayList((SourceLoader) loader);
RootDefFactory factory = new RootDefFactory(new SourceFactory(loaders));
assertTrue("RootDefFactory should have a find() method", factory.hasFind());
assertTrue("find() not finding all sources",
factory.find(new DescriptorFilter(String.format("markup://%s:*", namespace))).size() == 3);
assertEquals("find() fails with wildcard as prefix", 1,
factory.find(new DescriptorFilter("*://" + houseboat.getDescriptorName())).size());
assertEquals("find() fails with wildcard as namespace", 1,
factory.find(new DescriptorFilter("markup://*:" + houseboat.getName())).size());
assertEquals("find() fails with wildcard as name", 1,
factory.find(new DescriptorFilter(houseboat.getQualifiedName())).size());
assertEquals("find() fails with wildcard at end of name", 2,
factory.find(new DescriptorFilter(String.format("markup://%s:house*", namespace))).size());
assertEquals("find() fails with wildcard at beginning of name", 2,
factory.find(new DescriptorFilter(String.format("markup://%s:*party*", namespace))).size());
assertEquals("find() should not find nonexistent name", 0,
factory.find(new DescriptorFilter(String.format("markup://%s:househunters", namespace))).size());
assertEquals("find() should not find nonexistent name ending with wildcard", 0,
factory.find(new DescriptorFilter(String.format("markup://%s:househunters*", namespace))).size());
assertEquals("find() should not find nonexistent name with preceeding wildcard", 0,
factory.find(new DescriptorFilter(String.format("markup://%s:*notherecaptain", namespace))).size());
}