Author: ahuegen
Date: Fri Aug 4 07:45:25 2006
New Revision: 428738
URL: http://svn.apache.org/viewvc?rev=428738&view=rev
Log:
Fixed and restructured some more unit tests.
Moved core services to CoreServicesProvider
Added:
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java
hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/ComplexModule.xml (contents, props changed)
- copied, changed from r419477, hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/ComplexModule.xml
hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java (contents, props changed)
- copied, changed from r419477, hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java
hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestTranslatorManager.java (contents, props changed)
- copied, changed from r419477, hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestTranslatorManager.java
Removed:
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/ComplexModule.xml
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.xml
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestTranslatorManager.java
Modified:
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestServices.java
hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/CglibBeanInterfaceFactory.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JavassistBeanInterfaceFactory.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JdkBeanInterfaceFactory.java
hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java
hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml
hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java
hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties
hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleReader.java
hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java
hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestInvokeFactoryServiceConstructor.java
hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/definition/ModuleDefinition.java Fri Aug 4 07:45:25 2006
@@ -7,7 +7,6 @@
import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.Location;
-import org.apache.hivemind.util.Defense;
public class ModuleDefinition
{
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java Fri Aug 4 07:45:25 2006
@@ -16,10 +16,12 @@
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.internal.Visibility;
import org.apache.hivemind.service.ClassFactory;
+import org.apache.hivemind.service.InterfaceSynthesizer;
import org.apache.hivemind.service.ThreadEventNotifier;
import org.apache.hivemind.service.ThreadLocalStorage;
import org.apache.hivemind.service.ThreadLocale;
import org.apache.hivemind.service.impl.ClassFactoryImpl;
+import org.apache.hivemind.service.impl.InterfaceSynthesizerImpl;
import org.apache.hivemind.service.impl.ThreadEventNotifierImpl;
import org.apache.hivemind.service.impl.ThreadLocalStorageImpl;
import org.apache.hivemind.service.impl.ThreadLocaleImpl;
@@ -37,8 +39,10 @@
{
DefaultClassResolver resolver = new DefaultClassResolver();
- // Don't do this at home: For the sake of backward compatibility add the core
+ // For the sake of backward compatibility add the core
// to an existing module that may have been created by the XmlRegistryProvider
+ // This way the core services and the hivemodule.xml from the xml package share
+ // the same module name "hivemind"
ModuleDefinition md = registryDefinition.getModule("hivemind");
if (md == null)
@@ -48,6 +52,7 @@
registryDefinition.addModule(md);
}
+
addClassFactory(md);
addThreadEventNotifier(md);
@@ -57,6 +62,8 @@
addThreadLocale(md);
addShutdownCoordinator(md);
+
+ addInterfaceSynthesizer(md);
}
/**
@@ -159,4 +166,31 @@
return result;
}
-}
+ /**
+ * Synthesizes a service interface from an ordinary JavaBean.
+ */
+ private void addInterfaceSynthesizer(ModuleDefinition md)
+ {
+ ServicePointDefinition spd = addServicePoint(md, "InterfaceSynthesizer", InterfaceSynthesizer.class);
+
+ // Define inline implementation constructor
+ ServiceImplementationConstructor constructor = new AbstractServiceImplementationConstructor(md.getLocation(),
+ md.getId())
+ {
+
+ public Object constructCoreServiceImplementation(ServicePoint servicePoint,
+ Module contributingModule)
+ {
+ InterfaceSynthesizerImpl result = new InterfaceSynthesizerImpl();
+ // Manual wiring of the class factory
+ result.setClassFactory((ClassFactory) contributingModule.getService(ClassFactory.class));
+ return result;
+ }
+
+ };
+
+ ServiceImplementationDefinition sid = new ServiceImplementationDefinition(md.getLocation(),
+ constructor, ServiceModel.SINGLETON, true);
+ spd.addImplementation(sid);
+ }
+ }
Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java Fri Aug 4 07:45:25 2006
@@ -32,7 +32,6 @@
import org.apache.hivemind.impl.DefaultClassResolver;
import org.apache.hivemind.impl.LocationImpl;
import org.apache.hivemind.impl.RegistryBuilder;
-import org.apache.hivemind.impl.XmlModuleReader;
import org.apache.hivemind.internal.ser.ServiceSerializationHelper;
import org.apache.hivemind.util.ClasspathResource;
import org.apache.hivemind.util.PropertyUtils;
@@ -425,7 +424,7 @@
{
Resource resource = getResource(files[i]);
- XmlModuleReader reader = new XmlModuleReader(builder.getRegistryDefinition(),
+ org.apache.hivemind.impl.XmlModuleReader reader = new org.apache.hivemind.impl.XmlModuleReader(builder.getRegistryDefinition(),
resolver, builder.getErrorHandler());
reader.readModule(resource);
}
Added: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java?rev=428738&view=auto
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java (added)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/ModuleDefinitionHelper.java Fri Aug 4 07:45:25 2006
@@ -0,0 +1,52 @@
+package hivemind.test;
+
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServiceImplementationDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.impl.CreateClassServiceConstructor;
+import org.apache.hivemind.internal.ServiceModel;
+import org.apache.hivemind.internal.Visibility;
+
+public class ModuleDefinitionHelper
+{
+ private ModuleDefinition _module;
+
+ public ModuleDefinitionHelper(ModuleDefinition module)
+ {
+ _module = module;
+ }
+
+ public ServicePointDefinition addServicePoint(String servicePointId, Class serviceInterface)
+ {
+ ServicePointDefinition result = new ServicePointDefinition(servicePointId, _module
+ .getLocation(), Visibility.PUBLIC, serviceInterface.getName());
+
+ _module.addServicePoint(result);
+ return result;
+ }
+
+ public ServicePointDefinition addServicePointWithDefaultImplementation(String servicePointId, Class serviceInterface)
+ {
+ ServicePointDefinition result = addServicePoint(servicePointId, serviceInterface);
+ String defaultImplementationName = serviceInterface.getName() + "Impl";
+ addSimpleServiceImplementation(result, defaultImplementationName, ServiceModel.SINGLETON);
+ return result;
+ }
+
+ public ServiceImplementationDefinition addSimpleServiceImplementation(
+ ServicePointDefinition servicePoint,
+ String serviceImplementationClass, String serviceModel)
+ {
+ ServiceImplementationDefinition result = new ServiceImplementationDefinition(_module
+ .getLocation(), new CreateClassServiceConstructor(_module.getLocation(), _module.getId(),
+ serviceImplementationClass), serviceModel, true);
+ servicePoint.addImplementation(result);
+ return result;
+ }
+
+ public ModuleDefinition getModule()
+ {
+ return _module;
+ }
+
+}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestMisc.java Fri Aug 4 07:45:25 2006
@@ -14,14 +14,11 @@
package hivemind.test;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.SymbolSource;
import org.apache.hivemind.impl.CreateClassServiceConstructor;
-import org.apache.hivemind.impl.InvokeFactoryServiceConstructor;
import org.apache.hivemind.impl.ModuleImpl;
import org.apache.hivemind.impl.ServicePointImpl;
import org.apache.hivemind.impl.SystemPropertiesSymbolSource;
@@ -58,18 +55,6 @@
assertEquals("Now it can be told.", ex.getMessage());
assertSame(re, ex.getRootCause());
- }
-
- public void testInvokeFactoryServiceConstructorAccessors()
- {
- String moduleId = "module";
- List p = new ArrayList();
- InvokeFactoryServiceConstructor c = new InvokeFactoryServiceConstructor(newLocation(), moduleId);
-
- c.setParameters(p);
-
- assertSame(moduleId, c.getContributingModuleId());
- assertSame(p, c.getParameters());
}
public void testCreateClassServiceConstructorAccessors()
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/TestRegistryBuilder.java Fri Aug 4 07:45:25 2006
@@ -14,20 +14,11 @@
package hivemind.test;
-import hivemind.test.config.impl.Datum;
-
-import java.io.File;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.List;
-import java.util.Locale;
-import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.Registry;
import org.apache.hivemind.definition.ModuleDefinition;
-import org.apache.hivemind.impl.DefaultClassResolver;
import org.apache.hivemind.impl.RegistryBuilder;
-import org.apache.hivemind.impl.XmlRegistryProvider;
import org.apache.hivemind.service.ClassFactory;
/**
@@ -37,41 +28,6 @@
*/
public class TestRegistryBuilder extends FrameworkTestCase
{
- /**
- * Reproduce test {@link hivemind.test.config.TestConfiguration#testValueVariables()} using
- * dynamic lookup of hivemodule resources.
- */
-
- public void testLookup() throws Exception
- {
- // JDK 1.3 URLClassLoader doesn't seem to work properly for directories, so
- // the contents of the TestRegistryBuilder folder are packaged inside this JAR.
-
- File f = new File(getFrameworkPath("/test-data/TestRegistryBuilder.jar"));
-
- URL[] urls = new URL[]
- { f.toURL() };
-
- ClassLoader loader = new URLClassLoader(urls, Thread.currentThread()
- .getContextClassLoader());
-
- ClassResolver resolver = new DefaultClassResolver(loader);
-
- RegistryBuilder b = new RegistryBuilder();
-
- XmlRegistryProvider provider = new XmlRegistryProvider(resolver, XmlRegistryProvider.HIVE_MODULE_XML);
- provider.process(b.getRegistryDefinition(), b.getErrorHandler());
-
- Registry r = b.constructRegistry(Locale.getDefault());
-
- List l = (List) r.getConfiguration("hivemind.test.config.Symbols");
- assertEquals(1, l.size());
-
- Datum d = (Datum) l.get(0);
-
- assertEquals("wife", d.getKey());
- assertEquals("wilma", d.getValue());
- }
public void testConstructDefaultRegistry() throws Exception
{
Added: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java?rev=428738&view=auto
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java (added)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java Fri Aug 4 07:45:25 2006
@@ -0,0 +1,24 @@
+package hivemind.test.services;
+
+import hivemind.test.ModuleDefinitionHelper;
+import hivemind.test.services.impl.SimpleServiceImpl;
+
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.impl.DefaultClassResolver;
+import org.apache.hivemind.internal.ServiceModel;
+
+/**
+ * Defines a module with one service.
+ */
+public class SimpleModule extends ModuleDefinition
+{
+ public SimpleModule()
+ {
+ super("hivemind.test.services", null, new DefaultClassResolver(), null);
+
+ ModuleDefinitionHelper helper = new ModuleDefinitionHelper(this);
+ ServicePointDefinition sp = helper.addServicePoint("Simple", SimpleService.class);
+ helper.addSimpleServiceImplementation(sp, SimpleServiceImpl.class.getName(), ServiceModel.SINGLETON);
+ }
+}
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestServices.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestServices.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestServices.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestServices.java Fri Aug 4 07:45:25 2006
@@ -15,13 +15,20 @@
package hivemind.test.services;
import hivemind.test.FrameworkTestCase;
-import hivemind.test.services.impl.CountFactory;
import hivemind.test.services.impl.TrackerFactory;
import java.util.List;
import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.InterceptorStack;
+import org.apache.hivemind.Location;
+import org.apache.hivemind.Orderable;
import org.apache.hivemind.Registry;
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServiceInterceptorDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.internal.ServiceInterceptorConstructor;
import org.apache.hivemind.service.ThreadLocalStorage;
/**
@@ -34,7 +41,7 @@
public void testSimple() throws Exception
{
- Registry r = buildFrameworkRegistry("SimpleModule.xml");
+ Registry r = buildFrameworkRegistry(new SimpleModule());
assertNotNull(r);
@@ -50,7 +57,7 @@
*/
public void testCache() throws Exception
{
- Registry r = buildFrameworkRegistry("SimpleModule.xml");
+ Registry r = buildFrameworkRegistry(new SimpleModule());
assertNotNull(r);
@@ -62,40 +69,21 @@
assertSame(s1, s2);
}
- public void testComplex() throws Exception
- {
- Registry r = buildFrameworkRegistry("ComplexModule.xml");
-
- SimpleService s =
- (SimpleService) r.getService("hivemind.test.services.Simple", SimpleService.class);
- CountFactory.reset();
-
- assertEquals(
- "<SingletonProxy for hivemind.test.services.Simple(hivemind.test.services.SimpleService)>",
- s.toString());
-
- assertEquals(7, s.add(4, 3));
-
- assertEquals(1, CountFactory.getCount());
-
- assertEquals(19, s.add(11, 8));
-
- assertEquals(2, CountFactory.getCount());
- }
-
// Note: this works when run by Maven, but for some reason
// is failing inside Eclipse. It appears the be a Log4J
// configuration problem ... but I have no idea why.
public void testInterceptorSort() throws Exception
{
+ ModuleDefinition module = new SimpleModule();
+ ServicePointDefinition servicePoint = module.getServicePoint("Simple");
+
+ servicePoint.addInterceptor(new ServiceInterceptorDefinition(newLocation(), new TrackerServiceInterceptorConstructor("Fred", null, "Barney")));
+ servicePoint.addInterceptor(new ServiceInterceptorDefinition(newLocation(), new TrackerServiceInterceptorConstructor("Barney", null, null)));
+ servicePoint.addInterceptor(new ServiceInterceptorDefinition(newLocation(), new TrackerServiceInterceptorConstructor("Wilma", "Barney", null)));
+
Registry r =
- buildFrameworkRegistry(
- new String[] {
- "SimpleModule.xml",
- "AddSimpleInterceptors1.xml",
- "AddSimpleInterceptors2.xml",
- "Tracker.xml" });
+ buildFrameworkRegistry(module);
SimpleService s =
(SimpleService) r.getService("hivemind.test.services.Simple", SimpleService.class);
@@ -109,7 +97,56 @@
TrackerFactory.getInvocations().toArray());
}
+
+ class TrackerServiceInterceptorConstructor implements ServiceInterceptorConstructor, Orderable
+ {
+ private String _name;
+ private String _before;
+ private String _after;
+
+ public TrackerServiceInterceptorConstructor(String name, String before, String after)
+ {
+ super();
+ _name = name;
+ _before = before;
+ _after = after;
+ }
+
+ public void constructServiceInterceptor(InterceptorStack interceptorStack,
+ Module contributingModule)
+ {
+ TrackerFactory factory = new TrackerFactory();
+ factory.setName(_name);
+ factory.createInterceptor(interceptorStack, contributingModule, null);
+ }
+
+ public String getContributingModuleId()
+ {
+ return "hivemind.test.services";
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public Location getLocation()
+ {
+ return newLocation();
+ }
+
+ public String getFollowingNames()
+ {
+ return _before;
+ }
+
+ public String getPrecedingNames()
+ {
+ return _after;
+ }
+ }
+
public void testLogging() throws Exception
{
interceptLogging("hivemind.test.services.Demo");
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java Fri Aug 4 07:45:25 2006
@@ -29,7 +29,7 @@
public void testShutdownSingleton() throws Exception
{
- Registry r = buildFrameworkRegistry("SimpleModule.xml");
+ Registry r = buildFrameworkRegistry(new SimpleModule());
SimpleService s = (SimpleService) r.getService(
"hivemind.test.services.Simple",
SimpleService.class);
@@ -51,7 +51,7 @@
public void testRegistryShutdownUnrepeatable() throws Exception
{
- Registry r = buildFrameworkRegistry("SimpleModule.xml");
+ Registry r = buildFrameworkRegistry(new SimpleModule());
r.shutdown();
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryInfrastructureConstructor.java Fri Aug 4 07:45:25 2006
@@ -55,7 +55,7 @@
definition.addModule(zipZoop);
RegistryInfrastructureConstructor ric = new RegistryInfrastructureConstructor(errorHandler,
- LogFactory.getLog(TestXmlModuleDescriptorProcessor.class), null);
+ LogFactory.getLog(TestRegistryInfrastructureConstructor.class), null);
RegistryInfrastructure registryInfrastructure = ric.constructRegistryInfrastructure(definition);
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestVisibility.java Fri Aug 4 07:45:25 2006
@@ -29,7 +29,7 @@
import org.apache.hivemind.parse.InterceptorDescriptor;
import org.apache.hivemind.parse.ModuleDescriptor;
import org.apache.hivemind.parse.XmlResourceProcessor;
-import org.apache.hivemind.service.ObjectProvider;
+import org.apache.hivemind.service.ClassFactory;
import org.apache.hivemind.test.HiveMindTestCase;
import org.easymock.MockControl;
@@ -230,7 +230,7 @@
MockControl spc2 = newControl(ServicePoint.class);
ServicePoint sp2 = (ServicePoint) spc2.getMock();
- ObjectProvider service = (ObjectProvider) newMock(ObjectProvider.class);
+ ClassFactory service = (ClassFactory) newMock(ClassFactory.class);
// Training
@@ -238,13 +238,13 @@
spc1.setReturnValue("foo.Private");
sp1.getServiceInterfaceClassName();
- spc1.setReturnValue(ObjectProvider.class.getName());
+ spc1.setReturnValue(ClassFactory.class.getName());
sp2.getExtensionPointId();
spc2.setReturnValue("foo.Public");
sp2.getServiceInterfaceClassName();
- spc2.setReturnValue(ObjectProvider.class.getName());
+ spc2.setReturnValue(ClassFactory.class.getName());
sp1.visibleToModule(null);
spc1.setReturnValue(false);
@@ -252,7 +252,7 @@
sp2.visibleToModule(null);
spc2.setReturnValue(true);
- sp2.getService(ObjectProvider.class);
+ sp2.getService(ClassFactory.class);
spc2.setReturnValue(service);
replayControls();
@@ -262,7 +262,7 @@
r.addServicePoint(sp1);
r.addServicePoint(sp2);
- Object actual = r.getService(ObjectProvider.class, null);
+ Object actual = r.getService(ClassFactory.class, null);
assertSame(service, actual);
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/CglibBeanInterfaceFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/CglibBeanInterfaceFactory.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/CglibBeanInterfaceFactory.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/CglibBeanInterfaceFactory.java Fri Aug 4 07:45:25 2006
@@ -16,25 +16,33 @@
import java.lang.reflect.Method;
+import org.apache.hivemind.Location;
+import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
+import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.internal.ServicePoint;
+
import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.CallbackFilter;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.FixedValue;
import net.sf.cglib.proxy.NoOp;
-import org.apache.hivemind.ServiceImplementationFactory;
-import org.apache.hivemind.ServiceImplementationFactoryParameters;
-
/**
*
* @author James Carman
*/
-public class CglibBeanInterfaceFactory implements ServiceImplementationFactory
+public class CglibBeanInterfaceFactory extends AbstractServiceImplementationConstructor
{
- public Object createCoreServiceImplementation(ServiceImplementationFactoryParameters factoryParameters) {
- return createCglibBean();
- }
+ public CglibBeanInterfaceFactory(Location location, String contributingModuleId)
+ {
+ super(location, contributingModuleId);
+ }
+
+ public Object constructCoreServiceImplementation(ServicePoint servicePoint, Module contributingModule)
+ {
+ return createCglibBean();
+ }
/**
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JavassistBeanInterfaceFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JavassistBeanInterfaceFactory.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JavassistBeanInterfaceFactory.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JavassistBeanInterfaceFactory.java Fri Aug 4 07:45:25 2006
@@ -20,20 +20,27 @@
import javassist.LoaderClassPath;
import org.apache.hivemind.ApplicationRuntimeException;
-import org.apache.hivemind.ServiceImplementationFactory;
-import org.apache.hivemind.ServiceImplementationFactoryParameters;
+import org.apache.hivemind.Location;
+import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
+import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.service.ClassFabUtils;
/**
* @author James Carman
*/
-public class JavassistBeanInterfaceFactory implements
- ServiceImplementationFactory {
+public class JavassistBeanInterfaceFactory extends AbstractServiceImplementationConstructor
+{
- public Object createCoreServiceImplementation(
- ServiceImplementationFactoryParameters factoryParameters) {
- return createJavassistBean();
- }
+ public JavassistBeanInterfaceFactory(Location location, String contributingModuleId)
+ {
+ super(location, contributingModuleId);
+ }
+
+ public Object constructCoreServiceImplementation(ServicePoint servicePoint, Module contributingModule)
+ {
+ return createJavassistBean();
+ }
/**
* @return
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JdkBeanInterfaceFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JdkBeanInterfaceFactory.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JdkBeanInterfaceFactory.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/JdkBeanInterfaceFactory.java Fri Aug 4 07:45:25 2006
@@ -18,19 +18,28 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import org.apache.hivemind.ServiceImplementationFactory;
-import org.apache.hivemind.ServiceImplementationFactoryParameters;
+import org.apache.hivemind.Location;
+import org.apache.hivemind.internal.AbstractServiceImplementationConstructor;
+import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.internal.ServicePoint;
/**
*
* @author James Carman
*
*/
-public class JdkBeanInterfaceFactory implements ServiceImplementationFactory {
+public class JdkBeanInterfaceFactory extends AbstractServiceImplementationConstructor
+{
- public Object createCoreServiceImplementation(ServiceImplementationFactoryParameters factoryParameters) {
- return createJdkBean();
- }
+ public JdkBeanInterfaceFactory(Location location, String contributingModuleId)
+ {
+ super(location, contributingModuleId);
+ }
+
+ public Object constructCoreServiceImplementation(ServicePoint servicePoint, Module contributingModule)
+ {
+ return createJdkBean();
+ }
/**
* @return
Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java (original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java Fri Aug 4 07:45:25 2006
@@ -14,15 +14,23 @@
package org.apache.hivemind.service.impl;
+import hivemind.test.FrameworkTestCase;
+
import java.util.Collections;
import org.apache.commons.logging.Log;
import org.apache.hivemind.Registry;
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.RegistryDefinition;
+import org.apache.hivemind.definition.ServiceImplementationDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.impl.DefaultErrorHandler;
import org.apache.hivemind.impl.InterceptorStackImpl;
import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.internal.ServiceImplementationConstructor;
+import org.apache.hivemind.internal.ServiceModel;
import org.apache.hivemind.internal.ServicePoint;
import org.apache.hivemind.service.ClassFactory;
-import org.apache.hivemind.test.HiveMindTestCase;
import org.easymock.MockControl;
/**
@@ -31,7 +39,7 @@
* @author Howard Lewis Ship
* @author James Carman
*/
-public class TestLoggingInterceptorFactory extends HiveMindTestCase
+public class TestLoggingInterceptorFactory extends FrameworkTestCase
{
/**
* A test for HIVEMIND-55 ... ensure that the LoggingInterceptor can work on
@@ -89,21 +97,43 @@
}
public void testJavassistProxies() throws Exception {
- final Registry reg = buildFrameworkRegistry("generated.xml" );
- final BeanInterface bean = ( BeanInterface )reg.getService( "generated.JavassistBeanInterface", BeanInterface.class );
+
+ Registry reg = buildRegistry(new JavassistBeanInterfaceFactory(newLocation(), "module"));
+ final BeanInterface bean = ( BeanInterface )reg.getService( "BeanInterface", BeanInterface.class );
bean.interfaceMethod();
}
public void testCglibProxies() throws Exception {
- final Registry reg = buildFrameworkRegistry("generated.xml" );
+ Registry reg = buildRegistry(new CglibBeanInterfaceFactory(newLocation(), "module"));
final BeanInterface bean = ( BeanInterface )reg.getService( "generated.CglibBeanInterface", BeanInterface.class );
bean.interfaceMethod();
}
public void testJdkProxies() throws Exception {
- final Registry reg = buildFrameworkRegistry("generated.xml" );
+ Registry reg = buildRegistry(new JdkBeanInterfaceFactory(newLocation(), "module"));
final BeanInterface bean = ( BeanInterface )reg.getService( "generated.JdkBeanInterface", BeanInterface.class );
bean.interfaceMethod();
}
+
+ /**
+ * Builds a registry containing a service "BeanInterface" that constructs its instance
+ * by using the passed constructor.
+ */
+ private Registry buildRegistry(ServiceImplementationConstructor constructor)
+ {
+ RegistryDefinition definition = new RegistryDefinition(new DefaultErrorHandler());
+
+ ModuleDefinition module = createModuleDefinition("hivemind.tests.serviceByInterface");
+ definition.addModule(module);
+
+ ServicePointDefinition sp1 = createServicePointDefinition("BeanInterface", BeanInterface.class);
+ ServiceImplementationDefinition impl = new ServiceImplementationDefinition(newLocation(),
+ constructor, ServiceModel.SINGLETON, true);
+ sp1.addImplementation(impl);
+ module.addServicePoint(sp1);
+ Registry reg = buildFrameworkRegistry(module);
+ return reg;
+ }
+
}
Modified: hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/descriptor/META-INF/hivemodule.xml Fri Aug 4 07:45:25 2006
@@ -670,16 +670,5 @@
<provider prefix="class" service-id="ClassObjectProvider"/>
</contribution>
- <service-point id="InterfaceSynthesizer" interface="org.apache.hivemind.service.InterfaceSynthesizer">
-
- Synthesizes a service interface from an ordinary JavaBean.
-
- <invoke-factory>
- <construct class="service.impl.InterfaceSynthesizerImpl">
- <set-service property="classFactory" service-id="ClassFactory"/>
- </construct>
- </invoke-factory>
-
- </service-point>
</module>
Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplMessages.java Fri Aug 4 07:45:25 2006
@@ -126,9 +126,13 @@
return _formatter.format("sub-module-does-not-exist", subModuleDescriptor);
}
- static String unableToFindModules(ClassResolver resolver, Throwable cause)
+ static String unableToFindModulesError(ClassResolver resolver, Throwable cause)
{
return _formatter.format("unable-to-find-modules", resolver, cause);
}
+ static String unableToFindModuleResource(Resource resource)
+ {
+ return _formatter.format("unable-to-find-module-resource", resource);
+ }
}
Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlImplStrings.properties Fri Aug 4 07:45:25 2006
@@ -37,4 +37,5 @@
incomplete-translator=Translator contribution ''{0}'' must specify either the service-id or class attribute.
sub-module-does-not-exist=Sub-module {0} does not exist.
-unable-to-find-modules=Unable to locate HiveMind module deployment descriptors in {0}: {1}
+unable-to-find-modules-error=Unable to locate HiveMind module deployment descriptors in {0}: {1}
+unable-to-find-module-resource=Unable to locate HiveMind module deployment descriptors in {0}
Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleReader.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleReader.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleReader.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleReader.java Fri Aug 4 07:45:25 2006
@@ -1,10 +1,14 @@
package org.apache.hivemind.impl;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.HiveMind;
@@ -14,7 +18,19 @@
import org.apache.hivemind.parse.SubModuleDescriptor;
import org.apache.hivemind.parse.XmlResourceProcessor;
import org.apache.hivemind.util.ClasspathResource;
+import org.apache.hivemind.util.URLResource;
+/**
+ * Reads a hivemind xml module into a {@link RegistryDefinition}. Thus the defined
+ * services configurations and contributions are added to the registry.
+ * Contains convenience methods for reading xml modules from file system and classpath.
+ *
+ * The module files are parsed by {@link XmlResourceProcessor} and handed over
+ * to {@link XmlModuleDescriptorProcessor} for interpretation and addition
+ * to the registry definition.
+ *
+ * @author Achim Huegen
+ */
public class XmlModuleReader
{
private static final Log LOG = LogFactory.getLog(XmlModuleReader.class);
@@ -47,16 +63,67 @@
_parser = new XmlResourceProcessor(_classResolver, _errorHandler);
}
- public void readModule(Resource moduleResource)
+ /**
+ * Reads a module specified bye a {@link Resource}
+ *
+ * @param moduleResource the resource specifying the location of the module
+ * @throws ApplicationRuntimeException if resource wasn't found
+ */
+ public void readModule(Resource moduleResource)
{
+ if (moduleResource.getResourceURL() == null)
+ throw new ApplicationRuntimeException(XmlImplMessages.unableToFindModuleResource(moduleResource));
+
processResource(moduleResource);
}
- public void readClassPathModule(String moduleResourceFileName)
+ /**
+ * Reads the first module named <code>moduleResourceFileName</code> found in the classpath.
+ * Uses the instance of {@link ClassResolver} provided during construction or the {@link DefaultClassResolver}
+ * for searching the classpath.
+ *
+ * @param moduleFileName filename of module. For format see {@link ClassLoader#getResource(String)}
+ * @throws ApplicationRuntimeException if module wasn't found
+ */
+ public void readClassPathModule(String moduleFileName)
{
- readModule(new ClasspathResource(_classResolver, moduleResourceFileName));
+ readModule(new ClasspathResource(_classResolver, moduleFileName));
}
+ /**
+ * Reads all modules named <code>moduleResourceFileName</code> found in the classpath.
+ * Uses the instance of {@link ClassResolver} provided during construction or the {@link DefaultClassResolver}
+ * for searching the classpath.
+ *
+ * @param moduleFileName filename of modules. For format see {@link ClassLoader#getResource(String)}
+ * @throws ApplicationRuntimeException if no modules were found
+ */
+ public void readClassPathModules(String moduleFileName)
+ {
+ Enumeration foundResources = null;
+ ClassLoader loader = _classResolver.getClassLoader();
+
+ try
+ {
+ foundResources = loader.getResources(moduleFileName);
+ }
+ catch (IOException ex)
+ {
+ throw new ApplicationRuntimeException(XmlImplMessages.unableToFindModulesError(_classResolver, ex),
+ ex);
+ }
+
+ if (!foundResources.hasMoreElements())
+ throw new ApplicationRuntimeException(XmlImplMessages.unableToFindModuleResource(new ClasspathResource(_classResolver, moduleFileName)));
+
+ while (foundResources.hasMoreElements())
+ {
+ URL descriptorURL = (URL) foundResources.nextElement();
+
+ readModule(new URLResource(descriptorURL));
+ }
+ }
+
private void processResource(Resource resource)
{
try
Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlRegistryProvider.java Fri Aug 4 07:45:25 2006
@@ -1,16 +1,10 @@
package org.apache.hivemind.impl;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.definition.RegistryDefinition;
-import org.apache.hivemind.util.URLResource;
public class XmlRegistryProvider implements RegistryProvider
{
@@ -50,26 +44,7 @@
if (LOG.isDebugEnabled())
LOG.debug("Processing modules visible to " + _classResolver);
- ClassLoader loader = _classResolver.getClassLoader();
- Enumeration e = null;
-
- try
- {
- e = loader.getResources(_resourcePath);
- }
- catch (IOException ex)
- {
- throw new ApplicationRuntimeException(XmlImplMessages.unableToFindModules(_classResolver, ex),
- ex);
- }
-
- while (e.hasMoreElements())
- {
- URL descriptorURL = (URL) e.nextElement();
-
- xmlModuleReader.readModule(new URLResource(descriptorURL));
- }
-
+ xmlModuleReader.readClassPathModules(_resourcePath);
}
}
Copied: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/ComplexModule.xml (from r419477, hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/ComplexModule.xml)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/ComplexModule.xml?p2=hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/ComplexModule.xml&p1=hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/ComplexModule.xml&r1=419477&r2=428738&rev=428738&view=diff
==============================================================================
(empty)
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/ComplexModule.xml
------------------------------------------------------------------------------
cvs2svn:cvs-rev = 1.8
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/ComplexModule.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/ComplexModule.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestInvokeFactoryServiceConstructor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestInvokeFactoryServiceConstructor.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestInvokeFactoryServiceConstructor.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestInvokeFactoryServiceConstructor.java Fri Aug 4 07:45:25 2006
@@ -14,11 +14,16 @@
package org.apache.hivemind.impl;
+import hivemind.test.services.SimpleService;
+import hivemind.test.services.impl.CountFactory;
+
import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import org.apache.hivemind.ErrorLog;
import org.apache.hivemind.Occurances;
+import org.apache.hivemind.Registry;
import org.apache.hivemind.ServiceImplementationFactory;
import org.apache.hivemind.impl.natures.XmlRegistryNature;
import org.apache.hivemind.impl.natures.XmlServicePointNature;
@@ -108,4 +113,38 @@
verifyControls();
}
+
+ public void testInvokeFactoryServiceConstructorAccessors()
+ {
+ String moduleId = "module";
+ List p = new ArrayList();
+ InvokeFactoryServiceConstructor c = new InvokeFactoryServiceConstructor(newLocation(), moduleId);
+
+ c.setParameters(p);
+
+ assertSame(moduleId, c.getContributingModuleId());
+ assertSame(p, c.getParameters());
+ }
+
+ public void testComplex() throws Exception
+ {
+ Registry r = buildFrameworkRegistry("ComplexModule.xml");
+
+ SimpleService s =
+ (SimpleService) r.getService("hivemind.test.services.Simple", SimpleService.class);
+ CountFactory.reset();
+
+ assertEquals(
+ "<SingletonProxy for hivemind.test.services.Simple(hivemind.test.services.SimpleService)>",
+ s.toString());
+
+ assertEquals(7, s.add(4, 3));
+
+ assertEquals(1, CountFactory.getCount());
+
+ assertEquals(19, s.add(11, 8));
+
+ assertEquals(2, CountFactory.getCount());
+ }
+
}
Copied: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java (from r419477, hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java?p2=hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java&p1=hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java&r1=419477&r2=428738&rev=428738&view=diff
==============================================================================
(empty)
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java
------------------------------------------------------------------------------
cvs2svn:cvs-rev = 1.1
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestServiceImplementationFactoryParametersImpl.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestTranslatorManager.java (from r419477, hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestTranslatorManager.java)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestTranslatorManager.java?p2=hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestTranslatorManager.java&p1=hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestTranslatorManager.java&r1=419477&r2=428738&rev=428738&view=diff
==============================================================================
(empty)
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestTranslatorManager.java
------------------------------------------------------------------------------
cvs2svn:cvs-rev = 1.5
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestTranslatorManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestTranslatorManager.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java?rev=428738&r1=428737&r2=428738&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java (original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/impl/TestBuilderPropertyFacet.java Fri Aug 4 07:45:25 2006
@@ -16,6 +16,9 @@
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ServiceImplementationFactoryParameters;
+import org.apache.hivemind.TranslatorManager;
+import org.apache.hivemind.impl.DefaultErrorHandler;
+import org.apache.hivemind.impl.natures.XmlRegistryNature;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.schema.Translator;
import org.apache.hivemind.test.HiveMindTestCase;
@@ -34,6 +37,9 @@
MockControl paramsControl = newControl(ServiceImplementationFactoryParameters.class);
ServiceImplementationFactoryParameters params = (ServiceImplementationFactoryParameters) paramsControl
.getMock();
+
+ MockControl tmControl = newControl(TranslatorManager.class);
+ TranslatorManager tm = (TranslatorManager) tmControl.getMock();
BuilderPropertyFacet facet = new BuilderPropertyFacet();
@@ -43,8 +49,14 @@
params.getInvokingModule();
paramsControl.setDefaultReturnValue(module);
- module.getTranslator("foo");
- moduleControl.setDefaultReturnValue(translator);
+ XmlRegistryNature xmlNature = new XmlRegistryNature(new DefaultErrorHandler());
+ xmlNature.setTranslationManager(tm);
+
+ module.getRegistryNature(XmlRegistryNature.class);
+ moduleControl.setReturnValue(xmlNature);
+
+ tm.getTranslator("foo");
+ tmControl.setReturnValue(translator);
translator.translate(module, Object.class, "bar", null);
translatorControl.setReturnValue("BAR");
@@ -68,6 +80,9 @@
MockControl paramsControl = newControl(ServiceImplementationFactoryParameters.class);
ServiceImplementationFactoryParameters params = (ServiceImplementationFactoryParameters) paramsControl
.getMock();
+
+ MockControl tmControl = newControl(TranslatorManager.class);
+ TranslatorManager tm = (TranslatorManager) tmControl.getMock();
BuilderPropertyFacet facet = new BuilderPropertyFacet();
@@ -77,8 +92,14 @@
params.getInvokingModule();
paramsControl.setDefaultReturnValue(module);
- module.getTranslator("foo");
- moduleControl.setDefaultReturnValue(translator);
+ XmlRegistryNature xmlNature = new XmlRegistryNature(new DefaultErrorHandler());
+ xmlNature.setTranslationManager(tm);
+
+ module.getRegistryNature(XmlRegistryNature.class);
+ moduleControl.setReturnValue(xmlNature);
+
+ tm.getTranslator("foo");
+ tmControl.setReturnValue(translator);
translator.translate(module, Object.class, "bar", null);
ApplicationRuntimeException exception = new ApplicationRuntimeException("");
|