1 15 package hivemind.test; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.hivemind.Registry; 19 import org.apache.hivemind.definition.RegistryDefinition; 20 import org.apache.hivemind.definition.impl.ModuleDefinitionImpl; 21 import org.apache.hivemind.definition.impl.RegistryDefinitionImpl; 22 import org.apache.hivemind.impl.RegistryBuilder; 23 import org.apache.hivemind.service.ClassFactory; 24 25 30 public class TestRegistryBuilder extends FrameworkTestCase 31 { 32 33 public void testConstructDefaultRegistry() throws Exception 34 { 35 Registry r = RegistryBuilder.constructDefaultRegistry(); 36 37 ClassFactory factory = (ClassFactory) r.getService( 38 "hivemind.ClassFactory", 39 ClassFactory.class); 40 41 assertNotNull(factory); 42 } 43 44 public void testDuplicateModuleId() throws Exception 45 { 46 String duplicateModuleId = "non.unique.module"; 47 48 RegistryDefinition registryDefinition = new RegistryDefinitionImpl(); 49 registryDefinition.addModule(createModuleDefinition(duplicateModuleId)); 50 try 51 { 52 registryDefinition.addModule(createModuleDefinition(duplicateModuleId)); 53 fail("Duplicate module id not detected"); 54 } 55 catch (RuntimeException expected) 56 { 57 } 58 } 59 60 public void testDuplicateExtensionPoints() throws Exception 61 { 62 ModuleDefinitionImpl testModule = createModuleDefinition("hivemind.test"); 63 64 testModule.addServicePoint(createServicePointDefinition(testModule, "MyService", Comparable .class)); 65 try 66 { 67 testModule.addServicePoint(createServicePointDefinition(testModule, "MyService", Comparable .class)); 68 fail("duplicate service point not detected"); 69 } 70 catch (ApplicationRuntimeException expected) 71 { 72 } 73 74 testModule.addConfigurationPoint(createConfigurationPointDefinition(testModule, "MyConfig")); 75 try 76 { 77 testModule.addConfigurationPoint(createConfigurationPointDefinition(testModule, "MyConfig")); 78 fail("duplicate configuration point not detected"); 79 } 80 catch (ApplicationRuntimeException expected) 81 { 82 } 83 } 84 } | Popular Tags |