tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r416333 [4/5] - in /incubator/tuscany/sandbox/jboynes/sca: containers/ containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ containers/container.java/ core2/src/main/java/org/apache/tuscany/core/bootstrap/ core2/sr...
Date Thu, 22 Jun 2006 11:20:33 GMT
Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,137 @@
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponent;
+import org.apache.tuscany.core.mock.component.OrderedEagerInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl;
+import org.apache.tuscany.core.mock.component.RequestScopeDestroyOnlyComponent;
+import org.apache.tuscany.core.mock.component.RequestScopeInitDestroyComponent;
+import org.apache.tuscany.core.mock.component.RequestScopeInitOnlyComponent;
+import org.apache.tuscany.core.mock.factories.MockFactory;
+
+/**
+ * Lifecycle unit tests for the module scope container
+ *
+ * @version $Rev: 415162 $ $Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $
+ */
+public class RequestScopeInstanceLifecycleTestCase extends TestCase {
+
+    public void testInitDestroy() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        RequestScopeContainer scope = new RequestScopeContainer(ctx);
+        scope.start();
+
+        SystemAtomicComponent initDestroyContext = MockFactory
+            .createAtomicComponent("InitDestroy", scope, RequestScopeInitDestroyComponent.class);
+        initDestroyContext.start();
+
+        SystemAtomicComponent initOnlyContext =
+            MockFactory.createAtomicComponent("InitOnly", scope, RequestScopeInitOnlyComponent.class);
+        initOnlyContext.start();
+
+        SystemAtomicComponent destroyOnlyContext = MockFactory
+            .createAtomicComponent("DestroyOnly", scope, RequestScopeDestroyOnlyComponent.class);
+        destroyOnlyContext.start();
+
+        scope.onEvent(new RequestStart(this));
+        RequestScopeInitDestroyComponent initDestroy =
+            (RequestScopeInitDestroyComponent) scope.getInstance(initDestroyContext);
+        Assert.assertNotNull(initDestroy);
+
+        RequestScopeInitOnlyComponent initOnly = (RequestScopeInitOnlyComponent) scope.getInstance(initOnlyContext);
+        Assert.assertNotNull(initOnly);
+
+        RequestScopeDestroyOnlyComponent destroyOnly =
+            (RequestScopeDestroyOnlyComponent) scope.getInstance(destroyOnlyContext);
+        Assert.assertNotNull(destroyOnly);
+
+        Assert.assertTrue(initDestroy.isInitialized());
+        Assert.assertTrue(initOnly.isInitialized());
+        Assert.assertFalse(initDestroy.isDestroyed());
+        Assert.assertFalse(destroyOnly.isDestroyed());
+
+        // expire module
+        scope.onEvent(new RequestEnd(this));
+
+        Assert.assertTrue(initDestroy.isDestroyed());
+        Assert.assertTrue(destroyOnly.isDestroyed());
+
+        scope.stop();
+    }
+
+    public void testDestroyOrder() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        RequestScopeContainer scope = new RequestScopeContainer(ctx);
+        scope.start();
+
+        SystemAtomicComponent oneCtx =
+            MockFactory.createAtomicComponent("one", scope, OrderedInitPojoImpl.class);
+        scope.register(oneCtx);
+        SystemAtomicComponent twoCtx =
+            MockFactory.createAtomicComponent("two", scope, OrderedInitPojoImpl.class);
+        scope.register(twoCtx);
+        SystemAtomicComponent threeCtx =
+            MockFactory.createAtomicComponent("three", scope, OrderedInitPojoImpl.class);
+        scope.register(threeCtx);
+
+        scope.onEvent(new RequestStart(this));
+        OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneCtx);
+        Assert.assertNotNull(one);
+        Assert.assertEquals(1, one.getNumberInstantiated());
+        Assert.assertEquals(1, one.getInitOrder());
+
+        OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoCtx);
+        Assert.assertNotNull(two);
+        Assert.assertEquals(2, two.getNumberInstantiated());
+        Assert.assertEquals(2, two.getInitOrder());
+
+        OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeCtx);
+        Assert.assertNotNull(three);
+        Assert.assertEquals(3, three.getNumberInstantiated());
+        Assert.assertEquals(3, three.getInitOrder());
+
+        // expire module
+        scope.onEvent(new RequestEnd(this));
+        Assert.assertEquals(0, one.getNumberInstantiated());
+        scope.stop();
+    }
+
+    public void testEagerInitDestroyOrder() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        RequestScopeContainer scope = new RequestScopeContainer(ctx);
+        scope.start();
+
+        SystemAtomicComponent oneCtx =
+            MockFactory.createAtomicComponent("one", scope, OrderedEagerInitPojo.class);
+        scope.register(oneCtx);
+        SystemAtomicComponent twoCtx =
+            MockFactory.createAtomicComponent("two", scope, OrderedEagerInitPojo.class);
+        scope.register(twoCtx);
+        SystemAtomicComponent threeCtx =
+            MockFactory.createAtomicComponent("three", scope, OrderedEagerInitPojo.class);
+        scope.register(threeCtx);
+
+        scope.onEvent(new RequestStart(this));
+        OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getInstance(oneCtx);
+        Assert.assertNotNull(one);
+
+        OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getInstance(twoCtx);
+        Assert.assertNotNull(two);
+
+        OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getInstance(threeCtx);
+        Assert.assertNotNull(three);
+
+        // expire module
+        scope.onEvent(new RequestEnd(this));
+        Assert.assertEquals(0, one.getNumberInstantiated());
+        scope.stop();
+    }
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeInstanceLifecycleTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,81 @@
+package org.apache.tuscany.core.component.scope;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponent;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+
+/**
+ * Verifies the scope container properly disposes resources and canbe restarted
+ *
+ * @version $$Rev: 415162 $$ $$Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $$
+ */
+public class RequestScopeRestartTestCase extends TestCase {
+
+    public void testRestart() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        RequestScopeContainer scope = new RequestScopeContainer(ctx);
+        scope.start();
+        MethodEventInvoker<Object> initInvoker =
+            new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("init"));
+        MethodEventInvoker<Object> destroyInvoker =
+            new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("destroy"));
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setScopeContainer(scope);
+        configuration.addServiceInterface(InitDestroyOnce.class);
+        configuration.setInitInvoker(initInvoker);
+        configuration.setDestroyInvoker(destroyInvoker);
+        Constructor<InitDestroyOnce> ctr = InitDestroyOnce.class.getConstructor((Class<?>[]) null);
+        configuration.setObjectFactory(new PojoObjectFactory<InitDestroyOnce>(ctr));
+        SystemAtomicComponent context = new SystemAtomicComponentImpl("InitDestroy", configuration);
+        context.start();
+
+        Object instance = context.getServiceInstance();
+        assertSame(instance, context.getServiceInstance());
+
+        scope.onEvent(new RequestEnd(this));
+        scope.stop();
+        context.stop();
+
+        scope.start();
+        context.start();
+        assertNotSame(instance, context.getServiceInstance());
+        scope.onEvent(new RequestEnd(this));
+        scope.stop();
+        context.stop();
+    }
+
+    public static class InitDestroyOnce {
+
+        private boolean initialized;
+        private boolean destroyed;
+
+        public InitDestroyOnce() {
+        }
+
+        public void init() {
+            if (!initialized) {
+                initialized = true;
+            } else {
+                fail("Scope did not clean up properly - Init called more than once");
+            }
+        }
+
+        public void destroy() {
+            if (!destroyed) {
+                destroyed = true;
+            } else {
+                fail("Scope did not clean up properly - Destroyed called more than once");
+            }
+        }
+
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/RequestScopeRestartTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,70 @@
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeNotFoundException;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Scope;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * Verifies retrieval of standard scope contexts from the default scope registry
+ *
+ * @version $$Rev: 415162 $$ $$Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $$
+ */
+public class ScopeRegistryTestCase extends MockObjectTestCase {
+    public void testScopeContextCreation() throws Exception {
+        WorkContext workContext = new WorkContextImpl();
+        ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
+        scopeRegistry.registerFactory(Scope.REQUEST, new RequestScopeObjectFactory());
+        scopeRegistry.registerFactory(Scope.SESSION, new HttpSessionScopeObjectFactory());
+        ScopeContainer request = scopeRegistry.getScopeContainer(Scope.REQUEST);
+        assertTrue(request instanceof RequestScopeContainer);
+        assertSame(request, scopeRegistry.getScopeContainer(Scope.REQUEST));
+        ScopeContainer session = scopeRegistry.getScopeContainer(Scope.SESSION);
+        assertTrue(session instanceof HttpSessionScopeContainer);
+        assertSame(session, scopeRegistry.getScopeContainer(Scope.SESSION));
+        assertNotSame(request, session);
+    }
+
+    public void testDeregisterFactory() throws Exception {
+        WorkContext workContext = new WorkContextImpl();
+        ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
+        RequestScopeObjectFactory factory = new RequestScopeObjectFactory();
+        scopeRegistry.registerFactory(Scope.REQUEST, factory);
+        scopeRegistry.deregisterFactory(Scope.REQUEST);
+        try {
+            scopeRegistry.getScopeContainer(Scope.REQUEST);
+            fail();
+        } catch (ScopeNotFoundException e) {
+            // expected
+        }
+    }
+
+    public void testScopeNotRegistered() throws Exception {
+        WorkContext workContext = new WorkContextImpl();
+        ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
+        try {
+            scopeRegistry.getScopeContainer(Scope.REQUEST);
+            fail();
+        } catch (ScopeNotFoundException e) {
+            // expected
+        }
+        try {
+            scopeRegistry.getScopeContainer(Scope.SESSION);
+            fail();
+        } catch (ScopeNotFoundException e) {
+            // expected
+        }
+        try {
+            scopeRegistry.getScopeContainer(Scope.STATELESS);
+            fail();
+        } catch (ScopeNotFoundException e) {
+            // expected
+        }
+    }
+
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,30 @@
+package org.apache.tuscany.core.component.scope;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeContainerTestCase extends TestCase {
+
+    public void testBadStopWithoutStart() throws Exception {
+        StatelessScopeContainer container = new StatelessScopeContainer();
+        try {
+            container.stop();
+            fail();
+        } catch (IllegalStateException e) {
+            //expected
+        }
+    }
+
+    public void testBadDoubleStart() throws Exception {
+        StatelessScopeContainer container = new StatelessScopeContainer();
+        try {
+            container.start();
+            container.start();
+            fail();
+        } catch (IllegalStateException e) {
+            //expected
+        }
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeContainerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,13 @@
+package org.apache.tuscany.core.component.scope;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatelessScopeObjectFactoryTestCase extends TestCase {
+
+    public void testCreation() {
+        assertNotNull(new StatelessScopeObjectFactory().getInstance());
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/StatelessScopeObjectFactoryTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,77 @@
+package org.apache.tuscany.core.component.scope;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WorkContextTestCase extends MockObjectTestCase {
+
+    public void testRemoteComponent() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        Mock mock = mock(CompositeComponent.class);
+        CompositeComponent component = (CompositeComponent) mock.proxy();
+        Mock mock2 = mock(CompositeComponent.class);
+        CompositeComponent component2 = (CompositeComponent) mock2.proxy();
+        ctx.setRemoteComponent(component);
+        assertEquals(component, ctx.getRemoteComponent());
+        ctx.setRemoteComponent(component2);
+        assertEquals(component2, ctx.getRemoteComponent());
+    }
+
+    public void testNonSetRemoteComponent() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        assertNull(ctx.getRemoteComponent());
+    }
+
+    public void testIndentifier() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        Object id = new Object();
+        ctx.setIdentifier(this, id);
+        assertEquals(id, ctx.getIdentifier(this));
+    }
+
+    public void testClearIndentifier() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        Object id = new Object();
+        ctx.setIdentifier(this, id);
+        ctx.clearIdentifier(this);
+        assertNull(ctx.getIdentifier(this));
+    }
+
+    public void testClearIndentifiers() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        Object id = new Object();
+        Object id2 = new Object();
+        ctx.setIdentifier(id, id);
+        ctx.setIdentifier(id2, id2);
+        ctx.clearIdentifiers();
+        assertNull(ctx.getIdentifier(id));
+        assertNull(ctx.getIdentifier(id2));
+    }
+
+    public void testClearNonExistentIndentifier() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        ctx.clearIdentifier(this);
+    }
+
+    public void testNullIndentifier() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        Object id = new Object();
+        ctx.setIdentifier(this, id);
+        ctx.clearIdentifier(null);
+        assertEquals(id, ctx.getIdentifier(this));
+    }
+
+    public void testNoIndentifier() throws Exception {
+        WorkContext ctx = new WorkContextImpl();
+        assertNull(ctx.getIdentifier(this));
+    }
+
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java?rev=416333&r1=416332&r2=416333&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java Thu Jun 22 04:20:25 2006
@@ -24,20 +24,20 @@
 import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
 import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.ComponentType;
 import org.apache.tuscany.spi.model.CompositeComponentType;
-import org.apache.tuscany.spi.model.ServiceDefinition;
 import org.apache.tuscany.spi.model.Implementation;
-import org.apache.tuscany.spi.model.ComponentType;
-import org.apache.tuscany.spi.model.PropertyValue;
 import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
 import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
 
 import junit.framework.TestCase;
 import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
+import org.apache.tuscany.core.implementation.system.model.SystemBinding;
+import org.apache.tuscany.core.implementation.system.model.SystemCompositeImplementation;
 import org.apache.tuscany.core.mock.component.BasicInterface;
 import org.apache.tuscany.core.monitor.NullMonitorFactory;
-import org.apache.tuscany.core.system.model.SystemBinding;
-import org.apache.tuscany.core.system.model.SystemCompositeImplementation;
 
 /**
  * Verifies the default boostrap deployer
@@ -76,7 +76,7 @@
         assertEquals("propval", propVal.getValueFactory().getInstance());
 
         // check introspection of implementation
-        ComponentType<?,?,?> componentType = component.getImplementation().getComponentType();
+        ComponentType<?, ?, ?> componentType = component.getImplementation().getComponentType();
         ServiceDefinition service = componentType.getServices().get(BasicInterface.class.getName());
         assertEquals(BasicInterface.class, service.getServiceContract().getInterfaceClass());
         Property<?> property = componentType.getProperties().get("publicProperty");

Copied: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTestCase.java (from r415960, incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/CompositeComponentTestCase.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTestCase.java?p2=incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTestCase.java&p1=incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/CompositeComponentTestCase.java&r1=415960&r2=416333&rev=416333&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/component/CompositeComponentTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTestCase.java Thu Jun 22 04:20:25 2006
@@ -1,4 +1,4 @@
-package org.apache.tuscany.core.component;
+package org.apache.tuscany.core.implementation.composite;
 
 import junit.framework.TestCase;
 

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,123 @@
+/**
+ * 
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ * 
+ * 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.tuscany.core.implementation.java;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.implementation.java.mock.components.OtherTarget;
+import org.apache.tuscany.core.implementation.java.mock.components.OtherTargetImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.jmock.core.Invocation;
+import org.jmock.core.Stub;
+
+
+/**
+ * Tests wires that have different interfaces on the source and target side
+ *
+ * @version $Rev: 415162 $ $Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $
+ */
+public class DifferentInterfaceWireTestCase extends MockObjectTestCase {
+
+    public void testDifferentInterfaceInjection() throws Exception {
+        Map<String, Member> members = new HashMap<String, Member>();
+        Method m = SourceImpl.class.getMethod("setTarget", Target.class);
+        members.put("target", m);
+        ScopeContainer scope = createMock();
+        scope.start();
+        Map<String, AtomicComponent> contexts =
+            MockFactory.createWiredComponents("source",
+                SourceImpl.class,
+                Target.class,
+                scope,
+                members,
+                "target",
+                OtherTarget.class,
+                OtherTargetImpl.class,
+                scope);
+        AtomicComponent sourceComponent = contexts.get("source");
+        Source source = (Source) sourceComponent.getServiceInstance();
+        Target target = source.getTarget();
+        assertTrue(Proxy.isProxyClass(target.getClass()));
+        assertNotNull(target);
+        scope.stop();
+    }
+
+    public void testDifferentInterfaceMultiplicityInjection() throws Exception {
+        Map<String, Member> members = new HashMap<String, Member>();
+        Method m = SourceImpl.class.getMethod("setTargets", List.class);
+        members.put("target", m);
+        ScopeContainer scope = createMock();
+        scope.start();
+        Map<String, AtomicComponent> contexts =
+            MockFactory.createWiredMultiplicity("source", SourceImpl.class, Target.class, scope,
+                "target", OtherTarget.class, OtherTargetImpl.class, members, scope);
+        AtomicComponent sourceComponent = contexts.get("source");
+        Source source = (Source) sourceComponent.getServiceInstance();
+        List<Target> targets = source.getTargets();
+        assertEquals(1, targets.size());
+        Target target = targets.get(0);
+        target.setString("foo");
+        assertEquals("foo", target.getString());
+        assertTrue(Proxy.isProxyClass(target.getClass()));
+        scope.stop();
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    private ScopeContainer createMock() {
+        Mock mock = mock(ScopeContainer.class);
+        mock.expects(once()).method("start");
+        mock.expects(once()).method("stop");
+        mock.expects(atLeastOnce()).method("register");
+        mock.expects(atLeastOnce()).method("getScope").will(returnValue(Scope.MODULE));
+        mock.expects(atLeastOnce()).method("getInstance").will(new Stub() {
+            private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
+
+            public Object invoke(Invocation invocation) throws Throwable {
+                AtomicComponent component = (AtomicComponent) invocation.parameterValues.get(0);
+                Object instance = cache.get(component);
+                if (instance == null) {
+                    instance = component.createInstance();
+                    cache.put(component, instance);
+                }
+                return instance;
+            }
+
+            public StringBuffer describeTo(StringBuffer stringBuffer) {
+                return null;
+            }
+        });
+        return (ScopeContainer) mock.proxy();
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/DifferentInterfaceWireTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,46 @@
+package org.apache.tuscany.core.implementation.java;
+
+import java.util.Collections;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * @version $$Rev: 415162 $$ $$Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $$
+ */
+public class GetServiceByNameTestCase extends MockObjectTestCase {
+
+    public void testServiceLocate() throws Exception {
+        Mock mockScope = mock(ScopeContainer.class);
+        mockScope.expects(atLeastOnce()).method("register");
+        mockScope.expects(atLeastOnce()).method("getScope").will(returnValue(Scope.MODULE));
+        ScopeContainer scope = (ScopeContainer) mockScope.proxy();
+
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setScopeContainer(scope);
+        configuration.setObjectFactory(new PojoObjectFactory<TargetImpl>(TargetImpl.class.getConstructor()));
+        configuration.addServiceInterface(Target.class);
+        configuration.setWireService(new JDKWireService());
+        final JavaAtomicComponent<?> component = new JavaAtomicComponent("target", configuration);
+
+        Mock mock = mock(InboundWire.class);
+        mock.stubs().method("getBusinessInterface").will(returnValue(Target.class));
+        mock.stubs().method("getServiceName").will(returnValue("Target"));
+        mock.expects(atLeastOnce()).method("getInvocationChains").will(returnValue(Collections.emptyMap()));
+
+        InboundWire<Target> wire = (InboundWire<Target>) mock.proxy();
+        component.addInboundWire(wire);
+        component.prepare();
+        component.start();
+        assertTrue(component.getServiceInstance("Target") instanceof Target);
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/GetServiceByNameTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,17 @@
+package org.apache.tuscany.core.implementation.java;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests SCA metadata such as <code>@ComponentName</code> and <code>@SCAObject</code> are handled properly
+ *
+ * @version $Rev: 411441 $ $Date: 2006-06-03 07:52:56 -0700 (Sat, 03 Jun 2006) $
+ */
+public class JavaAtomicComponentMetadataInjectionTestCase extends TestCase {
+
+    public void testComponentNameSet() throws Exception {
+    }
+
+    public void testModuleContextSet() throws Exception {
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentMetadataInjectionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,65 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.tuscany.core.implementation.java;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Performs rudimentary negative testing by using malformed metadata on a POJO
+ *
+ * @version $Rev $Date
+ */
+public class JavaAtomicComponentNegativeMetadataTestCase extends TestCase {
+
+    /**
+     * Tests that a pojo with <code>@ComponentName</code> specified on a non-String type generates an error.
+     * <p/>
+     * <strong>NB:</strong> the test assumes an error with a message containing "@ComponentName" is generated
+     */
+    public void testBadNameType() throws Exception {
+//        CompositeComponent mc = new CompositeComponentImpl();
+//        mc.setName("mc");
+//        try {
+//            MockFactory.createPojoContext("BadNamePojo", BadNamePojo.class, Scope.MODULE, mc);
+//        } catch (NoSuchMethodException e) {
+//            if (e.getMessage().indexOf("@ComponentName") < 0) {
+//                throw e;
+//            }
+//        }
+//
+    }
+
+    /**
+     * Tests that a pojo with <code>@Context</code> specified on a non-ModuleContext type generates an error.
+     * <p/>
+     * <strong>NB:</strong> the test assumes an error with a message containing "@Context" is generated
+     */
+    public void testContextType() throws Exception {
+//        CompositeComponent mc = new CompositeComponentImpl();
+//        mc.setName("mc");
+//        try {
+//            MockFactory.createPojoContext("BadContextPojo", BadContextPojo.class, Scope.MODULE, mc);
+//        } catch (NoSuchMethodException e) {
+//            if (e.getMessage().indexOf("@SCAObject") < 0) {
+//                throw e;
+//            }
+//        }
+//
+    }
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponentNegativeMetadataTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,94 @@
+package org.apache.tuscany.core.implementation.java;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.JavaServiceContract;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import org.apache.tuscany.core.implementation.composite.CompositeComponentImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.PojoComponentType;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.jmock.core.Invocation;
+import org.jmock.core.Stub;
+
+/**
+ * @version $$Rev: 415162 $$ $$Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $$
+ */
+public class JavaComponentBuilderTestCase extends MockObjectTestCase {
+    private DeploymentContext deploymentContext;
+
+    @SuppressWarnings("unchecked")
+    public void testBuild() throws Exception {
+        CompositeComponent parent = new CompositeComponentImpl(null, null, null, new JDKWireService());
+
+        PojoComponentType sourceType = new PojoComponentType();
+        sourceType.setLifecycleScope(Scope.MODULE);
+        sourceType.addReferenceMember("target", SourceImpl.class.getMethod("setTarget", Target.class));
+
+        ServiceContract sourceContract = new JavaServiceContract();
+        sourceContract.setInterfaceClass(Source.class);
+        ServiceDefinition sourceServiceDefinition = new ServiceDefinition();
+        sourceServiceDefinition.setName("Source");
+        sourceServiceDefinition.setServiceContract(sourceContract);
+
+        sourceType.add(sourceServiceDefinition);
+        JavaImplementation sourceImpl = new JavaImplementation();
+        sourceImpl.setComponentType(sourceType);
+        sourceImpl.setImplementationClass(SourceImpl.class);
+        ComponentDefinition<JavaImplementation> sourceComponentDefinition =
+            new ComponentDefinition<JavaImplementation>(sourceImpl);
+
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        JavaAtomicComponent<Source> ctx =
+            (JavaAtomicComponent<Source>) builder.build(parent, sourceComponentDefinition, deploymentContext);
+        deploymentContext.getModuleScope().start();
+        ctx.start();
+        Source source = ctx.getServiceInstance();
+        assertNotNull(source);
+        ctx.stop();
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        deploymentContext = new DeploymentContext(null, null, createMock());
+    }
+
+    private ScopeContainer createMock() {
+        Mock mock = mock(ScopeContainer.class);
+        mock.expects(once()).method("start");
+        mock.expects(atLeastOnce()).method("register");
+        mock.expects(atLeastOnce()).method("getScope").will(returnValue(Scope.MODULE));
+        mock.expects(atLeastOnce()).method("getInstance").will(new Stub() {
+            private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
+
+            public Object invoke(Invocation invocation) throws Throwable {
+                AtomicComponent component = (AtomicComponent) invocation.parameterValues.get(0);
+                Object instance = cache.get(component);
+                if (instance == null) {
+                    instance = component.createInstance();
+                    cache.put(component, instance);
+                }
+                return instance;
+            }
+
+            public StringBuffer describeTo(StringBuffer stringBuffer) {
+                return null;
+            }
+        });
+        return (ScopeContainer) mock.proxy();
+    }
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,92 @@
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+import org.jmock.core.Invocation;
+import org.jmock.core.Stub;
+
+/**
+ * Validates wiring from a Java atomic context
+ *
+ * @version $$Rev: 415162 $$ $$Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $$
+ */
+public class JavaReferenceWireTestCase extends MockObjectTestCase {
+
+    public void testReferenceSet() throws Exception {
+        ScopeContainer scope = createMock();
+        scope.start();
+        final Target target = new TargetImpl();
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.addMember("target", SourceImpl.class.getMethod("setTarget", Target.class));
+        configuration.addServiceInterface(Source.class);
+        Constructor<SourceImpl> ctr = SourceImpl.class.getConstructor();
+        configuration.setObjectFactory(new PojoObjectFactory<SourceImpl>(ctr));
+        configuration.setScopeContainer(scope);
+        Mock mock = mock(OutboundWire.class);
+        mock.expects(atLeastOnce()).method("getInvocationChains");
+        mock.expects(atLeastOnce()).method("getReferenceName").will(returnValue("target"));
+        OutboundWire<Target> wire = (OutboundWire<Target>) mock.proxy();
+
+        Mock mockService = mock(WireService.class);
+        mockService.expects(atLeastOnce()).method("createProxy").with(eq(wire)).will(new Stub() {
+            public Object invoke(Invocation invocation) throws Throwable {
+                OutboundWire wire = (OutboundWire) invocation.parameterValues.get(0);
+                wire.getInvocationChains();
+                return target;
+            }
+
+            public StringBuffer describeTo(StringBuffer stringBuffer) {
+                return null;
+            }
+        });
+        configuration.setWireService((WireService) mockService.proxy());
+        JavaAtomicComponent sourceContext = new JavaAtomicComponent("source", configuration);
+        sourceContext.addOutboundWire(wire);
+        sourceContext.start();
+        Source source = (Source) sourceContext.getServiceInstance();
+        assertSame(target, source.getTarget());
+        scope.stop();
+    }
+
+    private ScopeContainer createMock() {
+        Mock mock = mock(ScopeContainer.class);
+        mock.expects(once()).method("start");
+        mock.expects(once()).method("stop");
+        mock.expects(atLeastOnce()).method("register");
+        mock.expects(atLeastOnce()).method("getScope").will(returnValue(Scope.MODULE));
+        mock.expects(atLeastOnce()).method("getInstance").will(new Stub() {
+            private Map<AtomicComponent, Object> cache = new HashMap<AtomicComponent, Object>();
+
+            public Object invoke(Invocation invocation) throws Throwable {
+                AtomicComponent component = (AtomicComponent) invocation.parameterValues.get(0);
+                Object instance = cache.get(component);
+                if (instance == null) {
+                    instance = component.createInstance();
+                    cache.put(component, instance);
+                }
+                return instance;
+            }
+
+            public StringBuffer describeTo(StringBuffer stringBuffer) {
+                return null;
+            }
+        });
+        return (ScopeContainer) mock.proxy();
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,65 @@
+/**
+ *
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.tuscany.core.implementation.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.Assert;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.jmock.MockObjectTestCase;
+
+public class JavaTargetInvokerTestCase extends MockObjectTestCase {
+
+    private Method echoMethod;
+
+    public JavaTargetInvokerTestCase() {
+        super();
+    }
+
+    public JavaTargetInvokerTestCase(String arg0) {
+        super(arg0);
+    }
+
+    public void setUp() throws Exception {
+        echoMethod = Echo.class.getDeclaredMethod("echo", String.class);
+        Assert.assertNotNull(echoMethod);
+    }
+
+    public void testScopedInvoke() throws Exception {
+        ScopeContainer scope = new ModuleScopeContainer(null);
+        scope.start();
+        JavaAtomicComponent context =
+            MockFactory.createJavaAtomicContext("foo", scope, Echo.class, Scope.MODULE);
+        scope.register(context);
+        JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, context);
+        invoker.setCacheable(false);
+        assertEquals("foo", invoker.invokeTarget("foo"));
+        scope.stop();
+    }
+
+    public static class Echo {
+        public String echo(String message) throws Exception {
+            return message;
+        }
+
+    }
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,56 @@
+/**
+ * 
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ * 
+ * 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.tuscany.core.implementation.java;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests wires that are configured with a multiplicity
+ *
+ * @version $Rev: 415145 $ $Date: 2006-06-18 07:54:49 -0700 (Sun, 18 Jun 2006) $
+ */
+public class MultiplicityTestCase extends TestCase {
+
+    public void testMultiplicity() throws Exception {
+//        CompositeComponent context = createContext();
+//        context.start();
+//        context.registerModelObject(MockFactory.createModuleWithWiredComponents(Scope.MODULE, Scope.MODULE));
+//        context.publish(new CompositeStart(this));
+//        Source source = (Source) ((AtomicComponent) context.getContext("source")).getTargetInstance();
+//        Assert.assertNotNull(source);
+//        Target target = (Target) ((AtomicComponent)context.getContext("target")).getTargetInstance();
+//        Assert.assertNotNull(target);
+//        // test setter injection
+//        List<Target> targets = source.getTargets();
+//        Assert.assertEquals(1, targets.size());
+//
+//        // test field injection
+//        targets = source.getTargetsThroughField();
+//        Assert.assertEquals(1, targets.size());
+    }
+
+//    private CompositeComponent createContext() {
+//        CompositeComponentImpl context = new CompositeComponentImpl();
+//        context.setName("system.context");
+//        List<ContextFactoryBuilder>builders = MockFactory.createSystemBuilders();
+//        WireService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(),
+// new JDKWireFactoryService(), new DefaultPolicyBuilderRegistry());
+//        builders.add(new JavaContextFactoryBuilder(wireService));
+//        List<WireBuilder> wireBuilders = new ArrayList<WireBuilder>();
+//        wireBuilders.add(new JavaTargetWireBuilder());
+//        context.setConfigurationContext(new MockConfigContext(builders,wireBuilders));
+//        return context;
+//    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/MultiplicityTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,52 @@
+package org.apache.tuscany.core.implementation.java;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+
+/**
+ * @version $$Rev: 415162 $$ $$Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $$
+ */
+public class ReferenceInjectionTestCase extends TestCase {
+
+    private Map<String, Member> members;
+
+    public void testProxiedReferenceInjection() throws Exception {
+        ScopeContainer scope = new ModuleScopeContainer(null);
+        scope.start();
+        Map<String, AtomicComponent> contexts =
+            MockFactory.createWiredContexts("source", SourceImpl.class, scope,
+                members, "target", Target.class, TargetImpl.class, scope);
+        AtomicComponent sourceComponent = contexts.get("source");
+        Source source = (Source) sourceComponent.getServiceInstance();
+        Target target = source.getTarget();
+        assertTrue(Proxy.isProxyClass(target.getClass()));
+
+        assertNotNull(target);
+        scope.stop();
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        members = new HashMap<String, Member>();
+        Method m = SourceImpl.class.getMethod("setTarget", Target.class);
+        members.put("target", m);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/ReferenceInjectionTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java?rev=416333&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java Thu Jun 22 04:20:25 2006
@@ -0,0 +1,193 @@
+package org.apache.tuscany.core.implementation.java.integration.component;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.component.WorkContextImpl;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
+import org.apache.tuscany.core.implementation.java.mock.MockFactory;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.builder.Connector;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.event.CompositeStart;
+import org.apache.tuscany.core.component.event.CompositeStop;
+import org.apache.tuscany.core.component.event.HttpSessionEnd;
+import org.apache.tuscany.core.component.event.HttpSessionStart;
+import org.apache.tuscany.core.component.event.RequestEnd;
+import org.apache.tuscany.core.component.event.RequestStart;
+import org.apache.tuscany.core.component.scope.HttpSessionScopeContainer;
+import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
+import org.apache.tuscany.core.component.scope.RequestScopeContainer;
+import org.apache.tuscany.core.component.scope.StatelessScopeContainer;
+import org.apache.tuscany.core.util.MethodHashMap;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
+
+/**
+ * Validates wiring from a service context to Java atomic contexts by scope
+ *
+ * @version $$Rev: 415162 $$ $$Date: 2006-06-18 11:19:43 -0700 (Sun, 18 Jun 2006) $$
+ */
+public class OutboundWireToJavaTestCase extends TestCase {
+    private WorkContext workContext;
+    private WireService wireService = new JDKWireService();
+
+    public void testToStatelessScope() throws Exception {
+        StatelessScopeContainer scope = new StatelessScopeContainer(workContext);
+        scope.start();
+        final OutboundWire<Target> wire = getWire(scope);
+        Target service = wireService.createProxy(wire);
+        assertNotNull(service);
+        service.setString("foo");
+        assertEquals(null, service.getString());
+        scope.stop();
+    }
+
+    public void testToRequestScope() throws Exception {
+        final RequestScopeContainer scope = new RequestScopeContainer(workContext);
+        scope.start();
+
+        scope.onEvent(new RequestStart(this));
+
+        final OutboundWire<Target> wire = getWire(scope);
+        Target service = wireService.createProxy(wire);
+        assertNotNull(service);
+        service.setString("foo");
+
+        // another request
+        Executor executor = Executors.newSingleThreadExecutor();
+        FutureTask<Void> future = new FutureTask<Void>(new Runnable() {
+            public void run() {
+                scope.onEvent(new RequestStart(this));
+                Target service2 = wireService.createProxy(wire);
+                Target target2 = wireService.createProxy(wire);
+                assertEquals(null, service2.getString());
+                service2.setString("bar");
+                assertEquals("bar", service2.getString());
+                assertEquals("bar", target2.getString());
+                scope.onEvent(new RequestEnd(this));
+            }
+        }, null);
+        executor.execute(future);
+        future.get();
+
+        assertEquals("foo", service.getString());
+        scope.onEvent(new RequestEnd(this));
+        scope.stop();
+    }
+
+    public void testToSessionScope() throws Exception {
+        HttpSessionScopeContainer scope = new HttpSessionScopeContainer(workContext);
+        scope.start();
+        Object session1 = new Object();
+        workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+        scope.onEvent(new HttpSessionStart(this, session1));
+
+        final OutboundWire<Target> wire = getWire(scope);
+        Target service = wireService.createProxy(wire);
+        Target target = wireService.createProxy(wire);
+        assertNotNull(service);
+        service.setString("foo");
+        assertEquals("foo", service.getString());
+        assertEquals("foo", target.getString());
+
+        workContext.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+
+        //second session
+        Object session2 = new Object();
+        workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session2);
+        scope.onEvent(new HttpSessionStart(this, session2));
+
+        Target service2 = wireService.createProxy(wire);
+        assertNotNull(service2);
+        assertNull(service2.getString());
+        Target target2 = wireService.createProxy(wire);
+        service2.setString("bar");
+        assertEquals("bar", service2.getString());
+        assertEquals("bar", target2.getString());
+
+        scope.onEvent(new HttpSessionEnd(this, session2));
+        workContext.clearIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER);
+
+        workContext.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
+        assertEquals("foo", service.getString());
+
+        scope.onEvent(new HttpSessionEnd(this, session1));
+
+        scope.stop();
+    }
+
+    public void testToModuleScope() throws Exception {
+
+        ModuleScopeContainer scope = new ModuleScopeContainer(workContext);
+        scope.start();
+        scope.onEvent(new CompositeStart(this, null));
+        final OutboundWire<Target> wire = getWire(scope);
+        Target service = wireService.createProxy(wire);
+        Target target = wireService.createProxy(wire);
+        assertNotNull(service);
+        service.setString("foo");
+        assertEquals("foo", service.getString());
+        assertEquals("foo", target.getString());
+        scope.onEvent(new CompositeStop(this, null));
+        scope.stop();
+    }
+
+    @SuppressWarnings("unchecked")
+    private OutboundWire<Target> getWire(ScopeContainer scope) throws NoSuchMethodException {
+        Connector connector = new ConnectorImpl();
+        OutboundWire<Target> wire = createOutboundWire(new QualifiedName("target/Target"), Target.class);
+
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setScopeContainer(scope);
+        configuration.setObjectFactory(new PojoObjectFactory<TargetImpl>(TargetImpl.class.getConstructor()));
+        configuration.addServiceInterface(Target.class);
+        JavaAtomicComponent<?> atomicComponent = new JavaAtomicComponent("target", configuration);
+        InboundWire targetWire = MockFactory.createTargetWire("Target", Target.class);
+        atomicComponent.addInboundWire(targetWire);
+        connector.connect(wire, atomicComponent.getInboundWire("Target"), atomicComponent, false);
+        atomicComponent.start();
+        return wire;
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        workContext = new WorkContextImpl();
+    }
+
+    public static <T> OutboundWire<T> createOutboundWire(QualifiedName targetName, Class<T> interfaze) {
+        OutboundWire<T> wire = new OutboundWireImpl<T>();
+        wire.setBusinessInterface(interfaze);
+        wire.setTargetName(targetName);
+        wire.addInvocationChains(createInvocationChains(interfaze));
+        return wire;
+    }
+
+    private static Map<Method, OutboundInvocationChain> createInvocationChains(Class<?> interfaze) {
+        Map<Method, OutboundInvocationChain> invocations = new MethodHashMap<OutboundInvocationChain>();
+        Method[] methods = interfaze.getMethods();
+        for (Method method : methods) {
+            OutboundInvocationChain chain = new OutboundInvocationChainImpl(method);
+            invocations.put(method, chain);
+        }
+        return invocations;
+    }
+
+}

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message