1 15 package hivemind.test; 16 17 import java.net.URL ; 18 import java.util.ArrayList ; 19 20 import org.apache.hivemind.ClassResolver; 21 import org.apache.hivemind.definition.ConfigurationPointDefinition; 22 import org.apache.hivemind.definition.ModuleDefinition; 23 import org.apache.hivemind.definition.Occurances; 24 import org.apache.hivemind.definition.ImplementationDefinition; 25 import org.apache.hivemind.definition.Visibility; 26 import org.apache.hivemind.definition.impl.ConfigurationPointDefinitionImpl; 27 import org.apache.hivemind.definition.impl.ModuleDefinitionImpl; 28 import org.apache.hivemind.definition.impl.ImplementationDefinitionImpl; 29 import org.apache.hivemind.definition.impl.ServicePointDefinitionImpl; 30 import org.apache.hivemind.impl.CreateClassServiceConstructor; 31 import org.apache.hivemind.impl.DefaultClassResolver; 32 import org.apache.hivemind.test.HiveMindTestCase; 33 34 39 public abstract class FrameworkTestCase extends HiveMindTestCase 40 { 41 42 protected ClassResolver _resolver = new DefaultClassResolver(); 43 44 45 protected String getFrameworkPath(String path) 46 { 47 URL url = getClass().getResource(path); 48 49 String protocol = url.getProtocol(); 50 51 if (!protocol.equals("file")) 52 throw new RuntimeException ("Classpath resource " + path 53 + " is not stored on the filesystem. It is available as " + url); 54 55 return url.getPath(); 56 } 57 58 protected void interceptLogging() 59 { 60 interceptLogging("org.apache.hivemind"); 61 } 62 63 66 protected ModuleDefinitionImpl createModuleDefinition(String moduleId) 67 { 68 ModuleDefinitionImpl result = new ModuleDefinitionImpl(moduleId, newLocation(), 69 getClassResolver(), ""); 70 71 return result; 72 } 73 74 77 protected ServicePointDefinitionImpl createServicePointDefinition(ModuleDefinition module, String pointId, Class serviceInterface) 78 { 79 ServicePointDefinitionImpl result = new ServicePointDefinitionImpl(module, pointId, 80 newLocation(), Visibility.PUBLIC, serviceInterface.getName()); 81 82 return result; 83 } 84 85 88 protected ImplementationDefinition createServiceImplementationDefinition(ModuleDefinition module, Class serviceImplementationClass) 89 { 90 ImplementationDefinition result = new ImplementationDefinitionImpl(module, newLocation(), 91 new CreateClassServiceConstructor(newLocation(), serviceImplementationClass.getName()), 92 "singleton", true); 93 94 return result; 95 } 96 97 100 protected ConfigurationPointDefinition createConfigurationPointDefinition(ModuleDefinition module, String pointId) 101 { 102 ConfigurationPointDefinitionImpl result = new ConfigurationPointDefinitionImpl(module, pointId, 103 newLocation(), Visibility.PUBLIC, ArrayList .class.getName(), 104 Occurances.UNBOUNDED); 105 106 return result; 107 } 108 } 109 | Popular Tags |