hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r430802 - in /hivemind/branches/branch-2-0-annot: framework/src/java/org/apache/hivemind/impl/ framework/src/java/org/apache/hivemind/service/impl/ framework/src/test/hivemind/test/services/ framework/src/test/hivemind/test/services/impl/ f...
Date Fri, 11 Aug 2006 15:08:07 GMT
Author: ahuegen
Date: Fri Aug 11 08:08:06 2006
New Revision: 430802

URL: http://svn.apache.org/viewvc?rev=430802&view=rev
Log:
Switched more unit tests in framework from xml to registry api.


Added:
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.properties
  (contents, props changed)
      - copied, changed from r430299, hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/Privates.properties
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/StringHolderModule.java
    hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/BeanService.xml
    hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/Pooled.xml
  (contents, props changed)
      - copied, changed from r430299, hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/Pooled.xml
    hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryBeanService.java
    hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryServiceModel.java
Removed:
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/Pooled.xml
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/StringHolder.xml
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/ThreadedDiscardable.xml
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/ThreadedRegistryShutdown.xml
    hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/BeanService.xml
    hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/Privates.properties
Modified:
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/MessageFinderImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/LoggingInterceptorFactory.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestPooledServiceModel.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestShutdown.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestThreadedModel.java
    hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/DiscardableStringHolderImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestBeanService.java
    hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryImpl.java
    hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/service/impl/TestLoggingInterceptorFactory.java

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/MessageFinderImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/MessageFinderImpl.java?rev=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/MessageFinderImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/MessageFinderImpl.java
Fri Aug 11 08:08:06 2006
@@ -85,8 +85,11 @@
 
         String name = _baseResource.getName();
         int dotx = name.lastIndexOf('.');
-
-        _baseName = name.substring(0, dotx);
+        if (dotx < 1) {
+            _baseName = name;
+        } else {
+            _baseName = name.substring(0, dotx);
+        }
     }
 
     public String getMessage(String key, Locale locale)

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/LoggingInterceptorFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/LoggingInterceptorFactory.java?rev=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/LoggingInterceptorFactory.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/LoggingInterceptorFactory.java
Fri Aug 11 08:08:06 2006
@@ -253,7 +253,7 @@
      * for the same extension point, then the previously constructed class
      * is reused (this can happen with the threaded service model, for example,
      * when a thread-local service implementation is created for different threads).
-     * @param parameters  list with instances of {@link MethodContribution}
+     * @param parameters  list with instances of {@link MethodContribution}. If empty all
methods are intercepted.
      */
     public void createInterceptor(
             InterceptorStack stack,

Modified: 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=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.java
Fri Aug 11 08:08:06 2006
@@ -3,10 +3,14 @@
 import hivemind.test.ModuleDefinitionHelper;
 import hivemind.test.services.impl.SimpleServiceImpl;
 
+import org.apache.hivemind.Location;
+import org.apache.hivemind.Resource;
 import org.apache.hivemind.definition.ModuleDefinition;
 import org.apache.hivemind.definition.ServicePointDefinition;
 import org.apache.hivemind.impl.DefaultClassResolver;
+import org.apache.hivemind.impl.LocationImpl;
 import org.apache.hivemind.internal.ServiceModel;
+import org.apache.hivemind.util.ClasspathResource;
 
 /**
  * Defines a module with one service.
@@ -15,10 +19,20 @@
 {
     public SimpleModule()
     {
-        super("hivemind.test.services", null, new DefaultClassResolver(), null);
+        super("hivemind.test.services", createLocation(), new DefaultClassResolver(), null);
         
         ModuleDefinitionHelper helper = new ModuleDefinitionHelper(this);
         ServicePointDefinition sp = helper.addServicePoint("Simple", SimpleService.class.getName());
         helper.addSimpleServiceImplementation(sp, SimpleServiceImpl.class.getName(), ServiceModel.SINGLETON);
     }
+    
+    private static Location createLocation()
+    {
+        String path = "/" + SimpleModule.class.getName().replace('.', '/');
+
+        Resource r = new ClasspathResource(new DefaultClassResolver(), path);
+
+        return new LocationImpl(r, 1);
+    }
+    
 }

Copied: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.properties
(from r430299, hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/Privates.properties)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.properties?p2=hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.properties&p1=hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/Privates.properties&r1=430299&r2=430802&rev=430802&view=diff
==============================================================================
    (empty)

Propchange: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.properties
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.1

Propchange: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/SimpleModule.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/StringHolderModule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/StringHolderModule.java?rev=430802&view=auto
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/StringHolderModule.java
(added)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/StringHolderModule.java
Fri Aug 11 08:08:06 2006
@@ -0,0 +1,44 @@
+package hivemind.test.services;
+
+import hivemind.test.ModuleDefinitionHelper;
+import hivemind.test.services.impl.StringHolderImpl;
+
+import java.util.Collections;
+
+import org.apache.hivemind.InterceptorStack;
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServiceInterceptorDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.impl.DefaultClassResolver;
+import org.apache.hivemind.internal.AbstractServiceInterceptorConstructor;
+import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.internal.ServiceInterceptorConstructor;
+import org.apache.hivemind.service.ClassFactory;
+import org.apache.hivemind.service.impl.LoggingInterceptorFactory;
+
+/**
+ * Defines a module with one threaded service. The service is intercepted by a LoggingInterceptor.
+ */
+public class StringHolderModule extends ModuleDefinition
+{
+    public StringHolderModule(String serviceModel)
+    {
+        super("hivemind.test.services", null, new DefaultClassResolver(), null);
+        
+        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(this);
+        ServicePointDefinition sp = helper.addServicePoint("StringHolder", StringHolder.class.getName());
+        helper.addSimpleServiceImplementation(sp, StringHolderImpl.class.getName(), serviceModel);
+        
+        ServiceInterceptorConstructor constructor = new AbstractServiceInterceptorConstructor(getLocation(),

+                this.getId(), "hivemind.LoggingInterceptor") {
+
+            public void constructServiceInterceptor(InterceptorStack interceptorStack, Module
contributingModule)
+            {
+                LoggingInterceptorFactory factory = new LoggingInterceptorFactory();
+                factory.setFactory((ClassFactory) contributingModule.getService(ClassFactory.class));
+                factory.createInterceptor(interceptorStack, contributingModule, Collections.emptyList());
+            }};
+        ServiceInterceptorDefinition interceptor = new ServiceInterceptorDefinition(getLocation(),
constructor);
+        sp.addInterceptor(interceptor);
+    }
+}

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestPooledServiceModel.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestPooledServiceModel.java?rev=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestPooledServiceModel.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestPooledServiceModel.java
Fri Aug 11 08:08:06 2006
@@ -18,6 +18,7 @@
 
 import org.apache.hivemind.HiveMind;
 import org.apache.hivemind.Registry;
+import org.apache.hivemind.internal.ServiceModel;
 import org.apache.hivemind.service.ThreadEventNotifier;
 
 /**
@@ -28,43 +29,12 @@
 public class TestPooledServiceModel extends FrameworkTestCase
 {
 
-    /**
-     * Tests basic interaction of pooling with thread cleanup.
-     */
-    public void testManaged() throws Exception
-    {
-        Registry r = buildFrameworkRegistry("Pooled.xml");
-
-        StringHolder s =
-            (StringHolder) r.getService("hivemind.test.services.Managed", StringHolder.class);
-
-        interceptLogging("hivemind.test.services.Managed");
-
-        assertNull(s.getValue());
-
-        assertLoggedMessage("activateService()");
-
-        s.setValue("funky monkey");
-        assertEquals("funky monkey", s.getValue());
-
-        ThreadEventNotifier n =
-            (ThreadEventNotifier) r.getService(
-                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
-                ThreadEventNotifier.class);
-
-        n.fireThreadCleanup();
-
-        assertLoggedMessage("passivateService()");
-
-        assertNull(s.getValue());
-    }
-
     public void testUnmanaged() throws Exception
     {
-        Registry r = buildFrameworkRegistry("Pooled.xml");
+        Registry r = buildFrameworkRegistry(new StringHolderModule(ServiceModel.POOLED));
 
         StringHolder s =
-            (StringHolder) r.getService("hivemind.test.services.Unmanaged", StringHolder.class);
+            (StringHolder) r.getService("hivemind.test.services.StringHolder", StringHolder.class);
 
         assertNull(s.getValue());
 

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=430802&r1=430801&r2=430802&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 11 08:08:06 2006
@@ -88,7 +88,7 @@
 
     public void testShutdownThreaded() throws Exception
     {
-        Registry r = buildFrameworkRegistry("StringHolder.xml");
+        Registry r = buildFrameworkRegistry(new StringHolderModule(ServiceModel.THREADED));
 
         StringHolder h = (StringHolder) r.getService(
                 "hivemind.test.services.StringHolder",

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestThreadedModel.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestThreadedModel.java?rev=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestThreadedModel.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/TestThreadedModel.java
Fri Aug 11 08:08:06 2006
@@ -15,9 +15,15 @@
 package hivemind.test.services;
 
 import hivemind.test.FrameworkTestCase;
+import hivemind.test.ModuleDefinitionHelper;
+import hivemind.test.services.impl.DiscardableStringHolderImpl;
+import hivemind.test.services.impl.RegistryShutdownStringHolderImpl;
 
 import org.apache.hivemind.HiveMind;
 import org.apache.hivemind.Registry;
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.internal.ServiceModel;
 import org.apache.hivemind.service.ThreadEventNotifier;
 
 /**
@@ -51,7 +57,7 @@
 
     public void testSingleThread() throws Exception
     {
-        Registry r = buildFrameworkRegistry("StringHolder.xml");
+        Registry r = buildFrameworkRegistry(new StringHolderModule(ServiceModel.THREADED));
 
         StringHolder h = (StringHolder) r.getService(
                 "hivemind.test.services.StringHolder",
@@ -96,7 +102,7 @@
      */
     public void testThreaded() throws Exception
     {
-        Registry r = buildFrameworkRegistry("StringHolder.xml");
+        Registry r = buildFrameworkRegistry(new StringHolderModule(ServiceModel.THREADED));
 
         StringHolder h = (StringHolder) r.getService(
                 "hivemind.test.services.StringHolder",
@@ -158,10 +164,10 @@
 
     public void testIgnoreRegistyShutdownListener() throws Exception
     {
-        Registry r = buildFrameworkRegistry("ThreadedRegistryShutdown.xml");
+        Registry r = createRegistryShutdownListener(RegistryShutdownStringHolderImpl.class);
 
         StringHolder h = (StringHolder) r.getService(
-                "hivemind.test.services.ThreadedRegistryShutdown",
+                "hivemind.test.services.StringHolder",
                 StringHolder.class);
 
         interceptLogging("hivemind.test.services");
@@ -175,12 +181,27 @@
         assertEquals(false, _didShutdown);
     }
 
+    /**
+     * Creates a Registry with one module, that defines a threaded Service "StringHolder"
+     * @param implementationClass  implementation class of the service
+     */
+    private Registry createRegistryShutdownListener(Class implementationClass)
+    {
+        ModuleDefinition module = createModuleDefinition("hivemind.test.services");
+        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
+
+        ServicePointDefinition sp1 = helper.addServicePoint("StringHolder", StringHolder.class.getName());
+        helper.addSimpleServiceImplementation(sp1, implementationClass.getName(), ServiceModel.THREADED);
+
+        return buildFrameworkRegistry(module);
+    }  
+    
     public void testDiscardable() throws Exception
     {
-        Registry r = buildFrameworkRegistry("ThreadedDiscardable.xml");
+        Registry r = createRegistryShutdownListener(DiscardableStringHolderImpl.class);
 
         StringHolder h = (StringHolder) r.getService(
-                "hivemind.test.services.ThreadedDiscardable",
+                "hivemind.test.services.StringHolder",
                 StringHolder.class);
 
         h.setValue("bar");

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/DiscardableStringHolderImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/DiscardableStringHolderImpl.java?rev=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/DiscardableStringHolderImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/impl/DiscardableStringHolderImpl.java
Fri Aug 11 08:08:06 2006
@@ -14,7 +14,10 @@
 
 package hivemind.test.services.impl;
 
+import hivemind.test.services.StringHolder;
+
 import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hivemind.Discardable;
 
 /**
@@ -25,16 +28,11 @@
  */
 public class DiscardableStringHolderImpl extends StringHolderImpl implements Discardable
 {
-    private Log _log;
+    private Log _log = LogFactory.getLog(StringHolder.class);
 
     public void threadDidDiscardService()
     {
         _log.info("threadDidDiscardService() has been invoked.");
-    }
-
-    public void setLog(Log log)
-    {
-        _log = log;
     }
 
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestBeanService.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestBeanService.java?rev=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestBeanService.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/TestBeanService.java
Fri Aug 11 08:08:06 2006
@@ -14,7 +14,12 @@
 
 package org.apache.hivemind;
 
-import org.apache.hivemind.test.HiveMindTestCase;
+import hivemind.test.FrameworkTestCase;
+import hivemind.test.ModuleDefinitionHelper;
+
+import org.apache.hivemind.definition.ModuleDefinition;
+import org.apache.hivemind.definition.ServicePointDefinition;
+import org.apache.hivemind.internal.ServiceModel;
 
 /**
  * Integration tests to prove that HiveMind supports JavaBeans classes as the "interface"
of a
@@ -23,14 +28,14 @@
  * @author Howard M. Lewis Ship
  * @since 1.1
  */
-public class TestBeanService extends HiveMindTestCase
+public class TestBeanService extends FrameworkTestCase
 {
 
-    private void attempt(String name) throws Exception
+    private void attempt(String serviceModel) throws Exception
     {
-        Registry reg = buildFrameworkRegistry("BeanService.xml");
+        Registry reg = createRegistryWithPojo(serviceModel);
 
-        Reverser r = (Reverser) reg.getService(name, Reverser.class);
+        Reverser r = (Reverser) reg.getService("bean.Reverser", Reverser.class);
 
         assertEquals("DNIMEVIH", r.reverse("HIVEMIND"));
         // Call reverse a second time to check for HIVEMIND-118
@@ -49,28 +54,30 @@
 
     public void testSimple() throws Exception
     {
-        attempt("bean.SimpleReverser");
-    }
-
-    public void testFactory() throws Exception
-    {
-        attempt("bean.FactoryReverser");
+        attempt(ServiceModel.SINGLETON);
     }
 
     public void testThreaded() throws Exception
     {
-        attempt("bean.ThreadedReverser");
+        attempt(ServiceModel.THREADED);
     }
     
     public void testPooled() throws Exception
     {
-        attempt("bean.PooledReverser");
+        attempt(ServiceModel.POOLED);
     }    
     
-    public void testAutowireBeanServiceProperty() throws Exception
+    /**
+     * Creates a Registry with one module, that defines a Service "Reverser" which is a POJO
+     */
+    private Registry createRegistryWithPojo(final String serviceModel)
     {
-        Registry reg = buildFrameworkRegistry("BeanService.xml");
-        BeanA beanA = ( BeanA )reg.getService( BeanA.class );
-        beanA.methodA();
-    }
+        ModuleDefinition module = createModuleDefinition("bean");
+        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
+
+        ServicePointDefinition sp1 = helper.addServicePoint("Reverser", Reverser.class.getName());
+        helper.addSimpleServiceImplementation(sp1, Reverser.class.getName(), serviceModel);
+
+        return buildFrameworkRegistry(module);
+    }    
 }

Modified: hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryImpl.java?rev=430802&r1=430801&r2=430802&view=diff
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/test/org/apache/hivemind/impl/TestRegistryImpl.java
Fri Aug 11 08:08:06 2006
@@ -14,6 +14,8 @@
 
 package org.apache.hivemind.impl;
 
+import hivemind.test.services.SimpleModule;
+
 import org.apache.hivemind.Messages;
 import org.apache.hivemind.Registry;
 import org.apache.hivemind.test.HiveMindTestCase;
@@ -26,8 +28,8 @@
 {
     public void testGetModuleMessages() throws Exception
     {
-        final Registry reg = buildFrameworkRegistry( "Privates.xml" );
-        final Messages msgs = reg.getModuleMessages( "hivemind.test.privates" );
+        final Registry reg = buildFrameworkRegistry(new SimpleModule());
+        final Messages msgs = reg.getModuleMessages( "hivemind.test.services" );
         assertEquals( "Test Message", msgs.getMessage( "test.message" ) );
     }
 }

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=430802&r1=430801&r2=430802&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 11 08:08:06 2006
@@ -98,19 +98,19 @@
     
     public void testJavassistProxies() throws Exception {
         
-        Registry reg = buildRegistry(new JavassistBeanInterfaceFactory(newLocation(), "module"));
+        Registry reg = createRegistry(new JavassistBeanInterfaceFactory(newLocation(), "module"));
 		final BeanInterface bean = ( BeanInterface )reg.getService( "BeanInterface", BeanInterface.class
);
 		bean.interfaceMethod();
 	}
 	
 	public void testCglibProxies() throws Exception {
-        Registry reg = buildRegistry(new CglibBeanInterfaceFactory(newLocation(), "module"));
+        Registry reg = createRegistry(new CglibBeanInterfaceFactory(newLocation(), "module"));
 		final BeanInterface bean = ( BeanInterface )reg.getService( "generated.CglibBeanInterface",
BeanInterface.class );
 		bean.interfaceMethod();
 	}
 	
 	public void testJdkProxies() throws Exception {
-        Registry reg = buildRegistry(new JdkBeanInterfaceFactory(newLocation(), "module"));
+        Registry reg = createRegistry(new JdkBeanInterfaceFactory(newLocation(), "module"));
 		final BeanInterface bean = ( BeanInterface )reg.getService( "generated.JdkBeanInterface",
BeanInterface.class );
 		bean.interfaceMethod();
 	}
@@ -120,7 +120,7 @@
      * Builds a registry containing a service "BeanInterface" that constructs its instance
      * by using the passed constructor.
      */
-    private Registry buildRegistry(ServiceImplementationConstructor constructor)
+    private Registry createRegistry(ServiceImplementationConstructor constructor)
     {
         RegistryDefinition definition = new RegistryDefinition(new DefaultErrorHandler());
 

Added: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/BeanService.xml
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/BeanService.xml?rev=430802&view=auto
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/BeanService.xml
(added)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/BeanService.xml
Fri Aug 11 08:08:06 2006
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!-- 
+   Copyright 2005 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<module id="bean" version="1.1.0" package="org.apache.hivemind">
+  
+  <service-point id="FactoryReverser" interface="Reverser">
+    
+    <invoke-factory>
+      <construct class="Reverser"/>
+    </invoke-factory>
+  </service-point>
+  
+  <service-point id="BeanA" interface="BeanA">
+    <invoke-factory>
+      <construct class="BeanA"/>
+    </invoke-factory>
+  </service-point>
+  
+  <service-point id="BeanB" interface="BeanB">
+    <invoke-factory>
+      <construct class="BeanB"/>
+    </invoke-factory>
+  </service-point>
+</module>
\ No newline at end of file

Copied: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/Pooled.xml
(from r430299, hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/Pooled.xml)
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/Pooled.xml?p2=hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/Pooled.xml&p1=hivemind/branches/branch-2-0-annot/framework/src/test/hivemind/test/services/Pooled.xml&r1=430299&r2=430802&rev=430802&view=diff
==============================================================================
    (empty)

Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/Pooled.xml
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.4

Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/Pooled.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/Pooled.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryBeanService.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryBeanService.java?rev=430802&view=auto
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryBeanService.java
(added)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryBeanService.java
Fri Aug 11 08:08:06 2006
@@ -0,0 +1,65 @@
+// Copyright 2005 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.hivemind.service;
+
+import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.BeanA;
+import org.apache.hivemind.Registry;
+import org.apache.hivemind.Reverser;
+import org.apache.hivemind.xml.XmlTestCase;
+
+/**
+ * Integration tests to prove that the builderFactory supports JavaBeans classes as the "interface"
of a
+ * service point.
+ * 
+ * @author Howard M. Lewis Ship
+ * @since 1.1
+ */
+public class TestBuilderFactoryBeanService extends XmlTestCase
+{
+
+    private void attempt(String name) throws Exception
+    {
+        Registry reg = buildFrameworkRegistry("BeanService.xml");
+
+        Reverser r = (Reverser) reg.getService(name, Reverser.class);
+
+        assertEquals("DNIMEVIH", r.reverse("HIVEMIND"));
+        // Call reverse a second time to check for HIVEMIND-118
+        r.reverse("HIVEMIND");
+        reg.shutdown();
+
+        try
+        {
+            r.reverse("SHUTDOWN");
+            unreachable();
+        }
+        catch (ApplicationRuntimeException ex)
+        {
+        }
+    }
+
+    public void testFactory() throws Exception
+    {
+        attempt("bean.FactoryReverser");
+    }
+
+    public void testAutowireBeanServiceProperty() throws Exception
+    {
+        Registry reg = buildFrameworkRegistry("BeanService.xml");
+        BeanA beanA = ( BeanA )reg.getService( BeanA.class );
+        beanA.methodA();
+    }
+}
\ No newline at end of file

Added: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryServiceModel.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryServiceModel.java?rev=430802&view=auto
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryServiceModel.java
(added)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/service/TestBuilderFactoryServiceModel.java
Fri Aug 11 08:08:06 2006
@@ -0,0 +1,63 @@
+// Copyright 2004, 2005 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.hivemind.service;
+
+import hivemind.test.FrameworkTestCase;
+import hivemind.test.services.StringHolder;
+
+import org.apache.hivemind.HiveMind;
+import org.apache.hivemind.Registry;
+import org.apache.hivemind.service.impl.BuilderFactory;
+
+/**
+ * Tests {@link org.apache.hivemind.impl.PooledServiceModel} integrated with {@link BuilderFactory}.

+ *
+ * @author Howard Lewis Ship
+ */
+public class TestBuilderFactoryServiceModel extends FrameworkTestCase
+{
+
+    /**
+     * Tests basic interaction of pooling with thread cleanup.
+     */
+    public void testManaged() throws Exception
+    {
+        Registry r = buildFrameworkRegistry("Pooled.xml");
+
+        StringHolder s =
+            (StringHolder) r.getService("hivemind.test.services.Managed", StringHolder.class);
+
+        interceptLogging("hivemind.test.services.Managed");
+
+        assertNull(s.getValue());
+
+        assertLoggedMessage("activateService()");
+
+        s.setValue("funky monkey");
+        assertEquals("funky monkey", s.getValue());
+
+        ThreadEventNotifier n =
+            (ThreadEventNotifier) r.getService(
+                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
+                ThreadEventNotifier.class);
+
+        n.fireThreadCleanup();
+
+        assertLoggedMessage("passivateService()");
+
+        assertNull(s.getValue());
+    }
+
+}



Mime
View raw message