You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/10 11:30:01 UTC

svn commit: r527067 [1/2] - in /incubator/tuscany/java/sca/modules: ./ host-embedded/ host-embedded/src/test/resources/META-INF/services/ implementation-java-runtime/src/main/resources/META-INF/ implementation-java-runtime/src/main/resources/META-INF/s...

Author: jsdelfino
Date: Tue Apr 10 02:29:58 2007
New Revision: 527067

URL: http://svn.apache.org/viewvc?view=rev&rev=527067
Log:
Integrated Java implementation runtime module in the build. Renamed the test cases that have not been ported yet to FIXME. Moved declaration of the Java runtime ModuleActivator to the Java runtime module.

Added:
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/services/
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java.FIXME
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCaseFIXME.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCaseFIXME.java   (with props)
Removed:
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java
Modified:
    incubator/tuscany/java/sca/modules/host-embedded/pom.xml
    incubator/tuscany/java/sca/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java
    incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/interfacedef/java/impl/JavaInterfaceImpl.java
    incubator/tuscany/java/sca/modules/pom.xml

Modified: incubator/tuscany/java/sca/modules/host-embedded/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/pom.xml?view=diff&rev=527067&r1=527066&r2=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/pom.xml Tue Apr 10 02:29:58 2007
@@ -34,11 +34,13 @@
             <artifactId>tuscany-core</artifactId>
             <version>1.0-incubating-SNAPSHOT</version>
         </dependency>
+
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-assembly-xml</artifactId>
             <version>1.0-incubating-SNAPSHOT</version>
         </dependency>        
+
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-contribution-impl</artifactId>

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator?view=diff&rev=527067&r1=527066&r2=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator Tue Apr 10 02:29:58 2007
@@ -1,2 +1,2 @@
 # Implementation class for the ExtensionActivator
-org.apache.tuscany.core.implementation.java.bootstrap.RuntimeJavaModuleActivator
+org.apache.tuscany.container.crud.CRUDModuleActivator

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.spi.bootstrap.ModuleActivator Tue Apr 10 02:29:58 2007
@@ -0,0 +1,2 @@
+# Implementation class for the ExtensionActivator
+org.apache.tuscany.core.implementation.java.bootstrap.RuntimeJavaModuleActivator

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/PojoAtomicComponentTestCase.java.FIXME Tue Apr 10 02:29:58 2007
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.introspection.impl.IntrospectionRegistryImpl;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev: 526976 $ $Date: 2007-04-09 17:38:35 -0700 (Mon, 09 Apr 2007) $
+ */
+public class PojoAtomicComponentTestCase extends TestCase {
+    private PojoConfiguration config;
+    private URI groupId;
+
+    @SuppressWarnings({"unchecked"})
+    public void testNoCallbackWires() throws Exception {
+        AtomicComponent component = new TestAtomicComponent(config);
+        ScopeContainer container = EasyMock.createMock(ScopeContainer.class);
+        EasyMock.expect(container.getScope()).andReturn(Scope.CONVERSATION);
+        container.register(component, groupId);
+        EasyMock.replay(container);
+        config.addCallbackSite("callback", Foo.class.getMethod("setCallback", Object.class));
+        component.setScopeContainer(container);
+        component.start();
+        EasyMock.verify(container);
+    }
+
+    public void testOptimizable() throws Exception {
+        TestAtomicComponent component = new TestAtomicComponent(config);
+        assertTrue(component.isOptimizable());
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public void testDestroyableButOptimizable() throws Exception {
+        EventInvoker<Object> invoker = EasyMock.createMock(EventInvoker.class);
+        invoker.invokeEvent(EasyMock.notNull());
+        EasyMock.replay(invoker);
+        config.setDestroyInvoker(invoker);
+        TestAtomicComponent component = new TestAtomicComponent(config);
+        assertTrue(component.isOptimizable());
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public void testStatelessOptimizable() throws Exception {
+        TestAtomicComponent component = new TestAtomicComponent(config, Scope.STATELESS);
+        assertTrue(component.isOptimizable());
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public void testNotOptimizable() throws Exception {
+        EventInvoker<Object> invoker = EasyMock.createMock(EventInvoker.class);
+        invoker.invokeEvent(EasyMock.notNull());
+        EasyMock.replay(invoker);
+        config.setDestroyInvoker(invoker);
+        TestAtomicComponent component = new TestAtomicComponent(config, Scope.STATELESS);
+        assertFalse(component.isOptimizable());
+    }
+
+    public void testPropertyAccess() {
+        String value = "Foo!";
+        ObjectFactory objectFactory = EasyMock.createMock(ObjectFactory.class);
+        EasyMock.expect(objectFactory.getInstance()).andReturn(value);
+        EasyMock.replay(objectFactory);
+
+        TestAtomicComponent component = new TestAtomicComponent(config);
+        component.addPropertyFactory("foo", objectFactory);
+        assertSame(value, component.getProperty(String.class, "foo"));
+    }
+
+    public void testServiceLookup() {
+        URI uri = URI.create("#service");
+        FooService foo = EasyMock.createMock(FooService.class);
+        Wire wire = EasyMock.createMock(Wire.class);
+        EasyMock.expect(wire.getSourceUri()).andReturn(uri).atLeastOnce();
+        EasyMock.replay(wire);
+        ObjectFactory factory = EasyMock.createMock(ObjectFactory.class);
+        EasyMock.expect(factory.getInstance()).andReturn(foo);
+        EasyMock.replay(factory);
+        TestAtomicComponent component = new TestAtomicComponent(config, Scope.COMPOSITE, factory);
+        component.attachWire(wire);
+        assertSame(foo, component.getService(FooService.class, "service"));
+        EasyMock.verify(wire);
+        EasyMock.verify(factory);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        JavaImplementationDefinition definition = new JavaImplementationDefinition();
+        definition.setName("foo");
+        
+        PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(Foo.class.getConstructor());
+
+        config = new PojoConfiguration(definition);
+        groupId = URI.create("parent");
+        config.setGroupId(groupId);
+    }
+
+    private class TestAtomicComponent extends PojoAtomicComponent {
+        private final ObjectFactory factory;
+        private final Scope scope;
+
+        public TestAtomicComponent(PojoConfiguration configuration) {
+            this(configuration, Scope.COMPOSITE, null);
+        }
+
+        public TestAtomicComponent(PojoConfiguration configuration, Scope scope) {
+            this(configuration, scope, null);
+        }
+
+        public TestAtomicComponent(PojoConfiguration configuration, Scope scope, ObjectFactory factory) {
+            super(configuration);
+            this.scope = scope;
+            this.factory = factory;
+        }
+
+        public Scope getScope() {
+            return scope;
+        }
+
+        @SuppressWarnings({"unchecked"})
+        protected <B> ObjectFactory<B> createWireFactory(Class<B> interfaze, Wire wire) {
+            return factory;
+        }
+
+        public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean isCallback)
+            throws TargetInvokerCreationException {
+            return null;
+        }
+    }
+
+    private static class Foo {
+        public Foo() {
+        }
+
+        public void setCallback(Object callback) {
+
+        }
+    }
+
+    public static interface FooService {
+    }
+
+}
+
+

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.ComponentProperty;
+import org.apache.tuscany.assembly.Property;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.implementation.java.impl.JavaElement;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Scope;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies that the java component builder handles configured properties
+ * correctly
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JavaBuilderPropertyTestCaseFIXME extends TestCase {
+    private DeploymentContext deploymentContext;
+    private Component parent;
+    private ScopeRegistry registry;
+    private AssemblyFactory factory = new DefaultAssemblyFactory();
+
+    @SuppressWarnings("unchecked")
+    public void testPropertyHandling() throws Exception {
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        builder.setScopeRegistry(registry);
+        JavaImplementationDefinition type = new JavaImplementationDefinition();
+        Property property = factory.createProperty();
+        property.setName("test");
+        // property.setDefaultValueFactory(new
+        // SingletonObjectFactory<String>("foo"));
+        JavaElement element = new JavaElement(JavaBuilderPropertyTestCaseFIXME.Foo.class.getMethod("setTest", String.class),
+                                              0);
+        type.getPropertyMembers().put("test", element);
+        type.getProperties().add(property);
+        type.setConstructorDefinition(new ConstructorDefinition<Foo>(Foo.class.getConstructor((Class[])null)));
+        type.setScope(Scope.STATELESS);
+        type.setJavaClass(Foo.class);
+        org.apache.tuscany.assembly.Component definition = factory.createComponent();
+        definition.setImplementation(type);
+        definition.setName("component");
+        ComponentProperty propertyValue = factory.createComponentProperty();
+        propertyValue.setName(property.getName());
+        definition.getProperties().add(propertyValue);
+        AtomicComponent component = builder.build(definition, deploymentContext);
+        JavaBuilderPropertyTestCaseFIXME.Foo foo = (JavaBuilderPropertyTestCaseFIXME.Foo)component.createInstance();
+        assertEquals("foo", foo.getTest());
+    }
+
+    public void testIntPropertyHandling() throws Exception {
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        builder.setScopeRegistry(registry);
+        JavaImplementationDefinition type = new JavaImplementationDefinition();
+        Property property = factory.createProperty();
+        property.setName("test");
+        // property.setDefaultValueFactory(new
+        // SingletonObjectFactory<Integer>(1));
+        JavaElement element = new JavaElement(JavaBuilderPropertyTestCaseFIXME.Foo.class.getMethod("setTest", String.class),
+                                              0);
+        type.getPropertyMembers().put("test", element);
+        type.getProperties().add(property);
+        type.setConstructorDefinition(new ConstructorDefinition<FooInt>(FooInt.class.getConstructor((Class[])null)));
+        type.setScope(Scope.STATELESS);
+        type.setJavaClass(Foo.class);
+        org.apache.tuscany.assembly.Component definition = factory.createComponent();
+        definition.setImplementation(type);
+        definition.setName("component");
+        // ObjectFactory<Integer> defaultValueFactory =
+        // property.getDefaultValueFactory();
+        ComponentProperty propertyValue = factory.createComponentProperty();
+        propertyValue.setName(property.getName());
+        definition.getProperties().add(propertyValue);
+        AtomicComponent component = builder.build(definition, deploymentContext);
+        FooInt foo = (FooInt)component.createInstance();
+        assertEquals(1, foo.getTest());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        deploymentContext = EasyMock.createMock(DeploymentContext.class);
+        EasyMock.expect(deploymentContext.getGroupId()).andStubReturn(URI.create("composite"));
+        EasyMock.replay(deploymentContext);
+        parent = EasyMock.createNiceMock(Component.class);
+        ScopeContainer mockContainer = EasyMock.createNiceMock(ScopeContainer.class);
+        EasyMock.replay(mockContainer);
+        registry = EasyMock.createMock(ScopeRegistry.class);
+        EasyMock.expect(registry.getScopeContainer(EasyMock.isA(org.apache.tuscany.spi.Scope.class)))
+            .andReturn(mockContainer);
+        EasyMock.replay(registry);
+    }
+
+    private static class Foo {
+        private String test;
+
+        public Foo() {
+        }
+
+        public String getTest() {
+            return test;
+        }
+
+        public void setTest(String test) {
+            this.test = test;
+        }
+    }
+
+    private static class FooInt {
+        private int test;
+
+        public FooInt() {
+        }
+
+        public int getTest() {
+            return test;
+        }
+
+        public void setTest(int test) {
+            this.test = test;
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaBuilderPropertyTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Field;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.easymock.EasyMock;
+import org.osoa.sca.annotations.ConversationID;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentBuilderConversationIDTestCaseFIXME extends TestCase {
+
+    @SuppressWarnings("unchecked")
+    public void testResourceInjection() throws Exception {
+        DeploymentContext ctx = EasyMock.createNiceMock(DeploymentContext.class);
+        EasyMock.expect(ctx.getGroupId()).andStubReturn(URI.create("composite"));
+        EasyMock.replay(ctx);
+        ScopeContainer container = EasyMock.createNiceMock(ScopeContainer.class);
+        ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class);
+        EasyMock.expect(registry.getScopeContainer(Scope.STATELESS)).andReturn(container);
+        EasyMock.replay(registry);
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        builder.setScopeRegistry(registry);
+        WorkContext workContext = new WorkContextImpl();
+        workContext.setIdentifier(Scope.CONVERSATION, "convID");
+        builder.setWorkContext(workContext);
+
+        ConstructorDefinition<Foo> ctorDef = new ConstructorDefinition<Foo>(Foo.class.getConstructor());
+        JavaImplementationDefinition type = new JavaImplementationDefinition();
+        Field field = Foo.class.getDeclaredField("conversationID");
+        type.setConversationIDMember(field);
+        type.setScope(org.apache.tuscany.implementation.java.impl.Scope.STATELESS);
+        type.setConstructorDefinition(ctorDef);
+        type.setJavaClass(Foo.class);
+
+        Component definition = new DefaultAssemblyFactory().createComponent();
+        definition.setName("foo");
+        definition.setImplementation(type);
+        JavaAtomicComponent component = (JavaAtomicComponent)builder.build(definition, ctx);
+        Foo foo = (Foo)component.createInstance();
+        assertEquals("convID", foo.conversationID);
+    }
+
+    private static class Foo {
+
+        @ConversationID
+        protected String conversationID;
+
+        public Foo() {
+        }
+
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderConversationIDTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Constructor;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.ComponentReference;
+import org.apache.tuscany.assembly.ComponentService;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.core.mock.component.Source;
+import org.apache.tuscany.core.mock.component.SourceImpl;
+import org.apache.tuscany.core.mock.component.Target;
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.implementation.java.impl.JavaElement;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Scope;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.easymock.EasyMock;
+
+/**
+ * Verifies component type metadata is properly applied to the component
+ * 
+ * @version $$Rev$$ $$Date: 2007-03-29 20:36:39 -0700 (Thu, 29 Mar
+ *          2007) $$
+ */
+public class JavaComponentBuilderMetadataTestCaseFIXME extends TestCase {
+    private DeploymentContext deploymentContext;
+    private Constructor<SourceImpl> constructor;
+    private Component parent;
+    private JavaImplementationDefinition type;
+    private org.apache.tuscany.assembly.Component definition;
+    private ScopeContainer scopeContainer;
+    private AssemblyFactory factory = new DefaultAssemblyFactory();
+
+    public void testMaxAge() throws Exception {
+        type.setMaxAge(100);
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        JavaAtomicComponent component = (JavaAtomicComponent)builder.build(definition, deploymentContext);
+        assertEquals(100, component.getMaxAge());
+    }
+
+    public void testMaxIdleTime() throws Exception {
+        type.setMaxIdleTime(100);
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        JavaAtomicComponent component = (JavaAtomicComponent)builder.build(definition, deploymentContext);
+        assertEquals(100, component.getMaxIdleTime());
+    }
+
+    public void testNoMaxAgeNoMaxIdleTime() throws Exception {
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        JavaAtomicComponent component = (JavaAtomicComponent)builder.build(definition, deploymentContext);
+        assertEquals(-1, component.getMaxAge());
+        assertEquals(-1, component.getMaxIdleTime());
+    }
+
+    public void testScope() throws Exception {
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        JavaAtomicComponent component = (JavaAtomicComponent)builder.build(definition, deploymentContext);
+        component.setScopeContainer(scopeContainer);
+        assertEquals(Scope.COMPOSITE, component.getScope());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        parent = EasyMock.createMock(Component.class);
+        EasyMock.expect(parent.getUri()).andReturn(URI.create("parent")).anyTimes();
+        EasyMock.replay(parent);
+        constructor = SourceImpl.class.getConstructor((Class[])null);
+        createDeploymentContext();
+        createComponentDefinitionAndType();
+    }
+
+    private void createDeploymentContext() {
+        scopeContainer = EasyMock.createMock(ScopeContainer.class);
+        scopeContainer.start();
+        scopeContainer.stop();
+        scopeContainer.register(EasyMock.isA(AtomicComponent.class), EasyMock.isA(URI.class));
+        EasyMock.expectLastCall().atLeastOnce();
+        EasyMock.expect(scopeContainer.getScope()).andReturn(org.apache.tuscany.spi.Scope.COMPOSITE).atLeastOnce();
+        EasyMock.replay(scopeContainer);
+        deploymentContext = EasyMock.createMock(DeploymentContext.class);
+        EasyMock.expect(deploymentContext.getGroupId()).andStubReturn(URI.create("composite"));
+        EasyMock.replay(deploymentContext);
+    }
+
+    private void createComponentDefinitionAndType() throws Exception {
+        type = new JavaImplementationDefinition();
+        type.setScope(Scope.COMPOSITE);
+        ComponentReference reference = factory.createComponentReference();
+        reference.setName("target");
+        type.getReferenceMembers().put("target",
+                                       new JavaElement(SourceImpl.class.getMethod("setTarget", Target.class), 0));
+        type.getReferences().add(reference);
+
+        ComponentService serviceDefinition = ModelHelper.createService(Source.class);
+        serviceDefinition.setName("Source");
+        type.getServices().add(serviceDefinition);
+        type.setConstructorDefinition(new ConstructorDefinition<SourceImpl>(constructor));
+        type.setJavaClass(SourceImpl.class);
+        definition.setImplementation(type);
+        definition.setName("component");
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderMetadataTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.implementation.java.impl.JavaElement;
+import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
+import org.apache.tuscany.implementation.java.impl.Resource;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.host.ResourceHost;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaComponentBuilderResourceTestCaseFIXME extends TestCase {
+
+    @SuppressWarnings("unchecked")
+    public void testResourceInjection() throws Exception {
+        DeploymentContext ctx = EasyMock.createNiceMock(DeploymentContext.class);
+        EasyMock.expect(ctx.getGroupId()).andStubReturn(URI.create("composite"));
+        EasyMock.replay(ctx);
+        ScopeContainer container = EasyMock.createNiceMock(ScopeContainer.class);
+        ScopeRegistry registry = EasyMock.createMock(ScopeRegistry.class);
+        EasyMock.expect(registry.getScopeContainer(Scope.STATELESS)).andReturn(container);
+        EasyMock.replay(registry);
+        ResourceHost host = EasyMock.createMock(ResourceHost.class);
+        EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn("result");
+        EasyMock.replay(host);
+        JavaComponentBuilder builder = new JavaComponentBuilder();
+        builder.setHost(host);
+        builder.setScopeRegistry(registry);
+        ConstructorDefinition<Foo> ctorDef = new ConstructorDefinition<Foo>(Foo.class.getConstructor());
+        JavaImplementationDefinition type = new JavaImplementationDefinition();
+        Resource resource = new Resource(new JavaElement(Foo.class.getDeclaredField("resource")));
+        type.add(resource);
+        type.setScope(org.apache.tuscany.implementation.java.impl.Scope.STATELESS);
+        type.setConstructorDefinition(ctorDef);
+        type.setJavaClass(Foo.class);
+        URI uri = URI.create("foo");
+        Component definition = new DefaultAssemblyFactory().createComponent();
+        definition.setImplementation(type);
+        definition.setName("foo");
+        Wire resourceWire = EasyMock.createMock(Wire.class);
+        EasyMock.expect(resourceWire.getTargetInstance()).andReturn("result");
+        EasyMock.replay(resourceWire);
+
+        JavaAtomicComponent component = (JavaAtomicComponent) builder.build(definition, ctx);
+        Foo foo = (Foo) component.createInstance();
+        assertEquals("result", foo.resource);
+    }
+
+    private static class Foo {
+
+        protected String resource;
+
+        public Foo() {
+        }
+
+    }
+}
+
+

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderResourceTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java.FIXME Tue Apr 10 02:29:58 2007
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Constructor;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.ProxyService;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * Validates wiring from a Java atomic context
+ *
+ * @version $$Rev: 526852 $$ $$Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $$
+ */
+public class JavaReferenceWireTestCase extends TestCase {
+
+    @SuppressWarnings({"unchecked"})
+    public void testReferenceSet() throws Exception {
+        ScopeContainer scope = createMock();
+        scope.start();
+        final Target target = new TargetImpl();
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.addReferenceSite("target", SourceImpl.class.getMethod("setTarget", Target.class));
+        Constructor<SourceImpl> ctr = SourceImpl.class.getConstructor();
+        configuration.setInstanceFactory(new PojoObjectFactory<SourceImpl>(ctr));
+        Wire wire = EasyMock.createMock(Wire.class);
+        wire.getInvocationChains();
+        EasyMock.expectLastCall().andReturn(new HashMap<Operation, InvocationChain>()).atLeastOnce();
+        URI uri = URI.create("#target");
+        EasyMock.expect(wire.getSourceUri()).andReturn(uri).atLeastOnce();
+        EasyMock.expect(wire.isOptimizable()).andReturn(false);
+        EasyMock.replay(wire);
+        ProxyService service = EasyMock.createMock(ProxyService.class);
+        EasyMock.expect(service.createProxy(EasyMock.eq(Target.class), EasyMock.eq(wire), EasyMock.isA(Map.class)))
+            .andAnswer(new IAnswer<Target>() {
+                public Target answer() throws Throwable {
+                    Wire wire = (Wire) EasyMock.getCurrentArguments()[1];
+                    wire.getInvocationChains();
+                    return target;
+                }
+
+            }).atLeastOnce();
+        EasyMock.replay(service);
+        configuration.setProxyService(service);
+        configuration.setName(new URI("source"));
+        configuration.setGroupId(URI.create("composite"));
+        JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+        component.setScopeContainer(scope);
+        component.attachWire(wire);
+        component.start();
+        Source source = (Source) component.getTargetInstance();
+        assertSame(target, source.getTarget());
+        scope.stop();
+        EasyMock.verify(wire);
+        EasyMock.verify(scope);
+        EasyMock.verify(service);
+    }
+
+    private ScopeContainer createMock() throws TargetException {
+        ScopeContainer scope = EasyMock.createMock(ScopeContainer.class);
+        scope.start();
+        scope.stop();
+        scope.register(EasyMock.isA(AtomicComponent.class), EasyMock.eq(URI.create("composite")));
+        EasyMock.expectLastCall().atLeastOnce();
+        EasyMock.expect(scope.getScope()).andReturn(Scope.COMPOSITE).atLeastOnce();
+        scope.getWrapper(EasyMock.isA(AtomicComponent.class), EasyMock.eq(URI.create("composite")));
+        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+            private Map<AtomicComponent, InstanceWrapper> cache = new HashMap<AtomicComponent, InstanceWrapper>();
+
+            public Object answer() throws Throwable {
+                AtomicComponent component = (AtomicComponent) EasyMock.getCurrentArguments()[0];
+                InstanceWrapper instance = cache.get(component);
+                if (instance == null) {
+                    instance = component.createInstanceWrapper();
+                    cache.put(component, instance);
+                }
+                return instance;
+            }
+        }).anyTimes();
+        EasyMock.replay(scope);
+        return scope;
+    }
+
+    private interface Source {
+        Target getTarget();
+    }
+
+    private static class SourceImpl implements Source {
+        private Target target;
+
+        public SourceImpl() {
+        }
+
+        public Target getTarget() {
+            return target;
+        }
+
+        public void setTarget(Target target) {
+            this.target = target;
+        }
+    }
+
+    private interface Target {
+
+        String getString();
+
+        void setString(String val);
+    }
+
+    private static class TargetImpl implements Target {
+        private String string;
+
+        public TargetImpl() {
+        }
+
+        public String getString() {
+            return string;
+        }
+
+        public void setString(String string) {
+            this.string = string;
+        }
+
+    }
+}

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 static org.apache.tuscany.spi.wire.TargetInvoker.NONE;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+
+public class JavaTargetInvokerBasicInvocationTestCaseFIXME extends TestCase {
+    private Method echoMethod;
+    private Method arrayMethod;
+    private Method nullParamMethod;
+    private Method primitiveMethod;
+    private Method checkedMethod;
+    private Method runtimeMethod;
+    private Wire wire;
+    private WorkContext context;
+    private ScopeContainer scopeContainer;
+    private InstanceWrapper wrapper;
+    private TestBean bean;
+    private JavaAtomicComponent component;
+
+    public JavaTargetInvokerBasicInvocationTestCaseFIXME(String arg0) {
+        super(arg0);
+    }
+
+    public void setUp() throws Exception {
+        echoMethod = TestBean.class.getDeclaredMethod("echo", String.class);
+        arrayMethod = TestBean.class.getDeclaredMethod("arrayEcho", String[].class);
+        nullParamMethod = TestBean.class.getDeclaredMethod("nullParam", (Class[]) null);
+        primitiveMethod = TestBean.class.getDeclaredMethod("primitiveEcho", Integer.TYPE);
+        checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
+        runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
+        assertNotNull(echoMethod);
+        assertNotNull(checkedMethod);
+        assertNotNull(runtimeMethod);
+
+        wire = EasyMock.createNiceMock(Wire.class);
+        context = EasyMock.createNiceMock(WorkContext.class);
+        component = EasyMock.createMock(JavaAtomicComponent.class);
+        scopeContainer = EasyMock.createNiceMock(ScopeContainer.class);
+        wrapper = EasyMock.createNiceMock(InstanceWrapper.class);
+        bean = new TestBean();
+        EasyMock.replay(component);
+        EasyMock.expect(scopeContainer.getScope()).andReturn(Scope.COMPOSITE);
+        EasyMock.expect(scopeContainer.getWrapper(component, null)).andReturn(wrapper);
+        EasyMock.replay(scopeContainer);
+        EasyMock.expect(wrapper.getInstance()).andReturn(bean);
+        EasyMock.replay(wrapper);
+    }
+
+
+    protected void tearDown() throws Exception {
+        EasyMock.verify(component);
+        EasyMock.verify(scopeContainer);
+        EasyMock.verify(wrapper);
+        super.tearDown();
+    }
+
+    public void testObjectInvoke() throws Throwable {
+        JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component, scopeContainer);
+        Object ret = invoker.invokeTarget("foo", NONE, context);
+        assertEquals("foo", ret);
+    }
+
+    public void testArrayInvoke() throws Throwable {
+        JavaTargetInvoker invoker = new JavaTargetInvoker(arrayMethod, component, scopeContainer);
+        String[] args = new String[]{"foo", "bar"};
+        Object ret = invoker.invokeTarget(new Object[]{args}, NONE, context);
+        String[] retA = (String[]) ret;
+        assertNotNull(retA);
+        assertEquals(2, retA.length);
+        assertEquals("foo", retA[0]);
+        assertEquals("bar", retA[1]);
+    }
+
+    public void testNullInvoke() throws Throwable {
+        JavaTargetInvoker invoker = new JavaTargetInvoker(nullParamMethod, component, scopeContainer);
+        Object ret = invoker.invokeTarget(null, NONE, context);
+        String retS = (String) ret;
+        assertEquals("foo", retS);
+    }
+
+    public void testPrimitiveInvoke() throws Throwable {
+        JavaTargetInvoker invoker = new JavaTargetInvoker(primitiveMethod, component, scopeContainer);
+        Object ret = invoker.invokeTarget(new Integer[]{1}, NONE, context);
+        Integer retI = (Integer) ret;
+        assertEquals(1, retI.intValue());
+    }
+
+    public void testInvokeCheckedException() throws Throwable {
+        JavaTargetInvoker invoker = new JavaTargetInvoker(checkedMethod, component, scopeContainer);
+        try {
+            invoker.invokeTarget(null, NONE, context);
+            fail(TestException.class.getName() + " should have been thrown");
+        } catch (InvocationTargetException e) {
+            assertTrue(e.getCause() instanceof TestException);
+        }
+    }
+
+    public void testInvokeRuntimeException() throws Throwable {
+        JavaTargetInvoker invoker = new JavaTargetInvoker(runtimeMethod, component, scopeContainer);
+        try {
+            invoker.invokeTarget(null, NONE, context);
+            fail(TestException.class.getName() + " should have been thrown");
+        } catch (InvocationTargetException e) {
+            assertTrue(e.getCause() instanceof TestRuntimeException);
+        }
+    }
+
+    private class TestBean {
+
+        public String echo(String msg) throws Exception {
+            assertEquals("foo", msg);
+            return msg;
+        }
+
+        public String[] arrayEcho(String[] msg) throws Exception {
+            assertNotNull(msg);
+            assertEquals(2, msg.length);
+            assertEquals("foo", msg[0]);
+            assertEquals("bar", msg[1]);
+            return msg;
+        }
+
+        public String nullParam() throws Exception {
+            return "foo";
+        }
+
+        public int primitiveEcho(int i) throws Exception {
+            return i;
+        }
+
+        public void checkedException() throws TestException {
+            throw new TestException();
+        }
+
+        public void runtimeException() throws TestRuntimeException {
+            throw new TestRuntimeException();
+        }
+    }
+
+    public class TestException extends Exception {
+    }
+
+    public class TestRuntimeException extends RuntimeException {
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerBasicInvocationTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 junit.framework.TestCase;
+
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaTargetInvokerSequenceTestCaseFIXME extends TestCase {
+    private Method method;
+    private Foo foo;
+    private JavaAtomicComponent component;
+    private ScopeContainer scopeContainer;
+    private InstanceWrapper wrapper;
+    private WorkContext workContext;
+    private Object contextId;
+    private JavaTargetInvoker invoker;
+    private Message msg;
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        method = Foo.class.getMethod("invoke");
+        foo = EasyMock.createMock(Foo.class);
+        foo.invoke();
+        EasyMock.replay(foo);
+
+        contextId = new Object();
+        workContext = EasyMock.createMock(WorkContext.class);
+        EasyMock.expect(workContext.getIdentifier(Scope.CONVERSATION)).andStubReturn(contextId);
+        EasyMock.replay(workContext);
+
+        msg = new MessageImpl();
+        msg.setWorkContext(workContext);
+
+        component = EasyMock.createMock(JavaAtomicComponent.class);
+        scopeContainer = EasyMock.createMock(ScopeContainer.class);
+        wrapper = EasyMock.createMock(InstanceWrapper.class);
+        EasyMock.expect(wrapper.getInstance()).andReturn(foo);
+        EasyMock.replay(wrapper);
+
+        EasyMock.expect(scopeContainer.getScope()).andStubReturn(Scope.CONVERSATION);
+        EasyMock.replay(scopeContainer);
+        invoker = new JavaTargetInvoker(method, component, scopeContainer);
+        EasyMock.reset(scopeContainer);
+        EasyMock.expect(scopeContainer.getScope()).andStubReturn(Scope.CONVERSATION);
+    }
+
+    /**
+     * Verifies an invocation marked as non-conversational has an existing or new instance returned
+     */
+    public void testNoSequence() throws Exception {
+        EasyMock.expect(scopeContainer.getWrapper(component, contextId)).andReturn(wrapper);
+        scopeContainer.returnWrapper(component, wrapper, contextId);
+        EasyMock.replay(component);
+        EasyMock.replay(scopeContainer);
+        msg.setConversationSequence(TargetInvoker.NONE);
+        invoker.invoke(msg);
+        EasyMock.verify(foo);
+        EasyMock.verify(component);
+        EasyMock.verify(scopeContainer);
+        EasyMock.verify(wrapper);
+    }
+
+    /**
+     * Verifies that an invocation marked as starting a conversation has a new instance returned
+     */
+    public void testStartSequence() throws Exception {
+        EasyMock.replay(component);
+        EasyMock.expect(scopeContainer.getWrapper(component, contextId)).andReturn(wrapper);
+        scopeContainer.returnWrapper(component, wrapper, contextId);
+        EasyMock.replay(scopeContainer);
+        msg.setConversationSequence(TargetInvoker.START);
+        invoker.invoke(msg);
+        EasyMock.verify(foo);
+        EasyMock.verify(component);
+        EasyMock.verify(scopeContainer);
+        EasyMock.verify(wrapper);
+    }
+
+    /**
+     * Verifies that an invocation marked as continuing a conversation has an associated instance returned
+     */
+    public void testContinueSequence() throws Exception {
+        EasyMock.replay(component);
+        EasyMock.expect(scopeContainer.getAssociatedWrapper(component, contextId)).andReturn(wrapper);
+        scopeContainer.returnWrapper(component, wrapper, contextId);
+        EasyMock.replay(scopeContainer);
+        msg.setConversationSequence(TargetInvoker.CONTINUE);
+        invoker.invoke(msg);
+        EasyMock.verify(foo);
+        EasyMock.verify(component);
+        EasyMock.verify(scopeContainer);
+        EasyMock.verify(wrapper);
+    }
+
+    /**
+     * Verifies that an invocation marked as ending a conversation has an associated instance returned and it is removed
+     * following the dispatch to the instance
+     */
+    public void testEndSequence() throws Exception {
+        EasyMock.replay(component);
+        EasyMock.expect(scopeContainer.getAssociatedWrapper(component, contextId)).andReturn(wrapper);
+        scopeContainer.returnWrapper(component, wrapper, contextId);
+        scopeContainer.remove(component);
+        EasyMock.replay(scopeContainer);
+        msg.setConversationSequence(TargetInvoker.END);
+        invoker.invoke(msg);
+        EasyMock.verify(foo);
+        EasyMock.verify(component);
+        EasyMock.verify(scopeContainer);
+        EasyMock.verify(wrapper);
+    }
+
+
+    private interface Foo {
+        void invoke();
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerSequenceTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 junit.framework.TestCase;
+
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.easymock.EasyMock;
+
+public class JavaTargetInvokerStatelessDestroyTestCaseFIXME extends TestCase {
+    private JavaAtomicComponent component;
+    private ScopeContainer scopeContainer;
+    private InstanceWrapper wrapper;
+    private Method echoMethod;
+    private WorkContext workContext;
+
+    public void testDestroy() throws Exception {
+        EasyMock.expect(scopeContainer.getWrapper(component, null)).andReturn(wrapper);
+        EasyMock.expect(wrapper.getInstance()).andReturn(new Echo());
+        scopeContainer.returnWrapper(component, wrapper, null);
+        EasyMock.replay(component);
+        EasyMock.replay(scopeContainer);
+        EasyMock.replay(wrapper);
+        JavaTargetInvoker invoker = new JavaTargetInvoker(echoMethod, component, scopeContainer);
+        invoker.setCacheable(false);
+        assertEquals("foo", invoker.invokeTarget("foo", JavaTargetInvoker.NONE, workContext));
+        EasyMock.verify(component);
+        EasyMock.verify(scopeContainer);
+        EasyMock.verify(wrapper);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        echoMethod = Echo.class.getDeclaredMethod("echo", String.class);
+        component = EasyMock.createMock(JavaAtomicComponent.class);
+        scopeContainer = EasyMock.createNiceMock(ScopeContainer.class);
+        EasyMock.expect(scopeContainer.getScope()).andStubReturn(Scope.STATELESS);
+        wrapper = EasyMock.createNiceMock(InstanceWrapper.class);
+        workContext = EasyMock.createMock(WorkContext.class);
+        EasyMock.expect(workContext.getIdentifier(Scope.STATELESS)).andStubReturn(null);
+        EasyMock.replay(workContext);
+    }
+
+    public static class Echo {
+        public String echo(String message) throws Exception {
+            return message;
+        }
+
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/JavaTargetInvokerStatelessDestroyTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/implementation/java/ResourceInjectionTestCase.java.FIXME Tue Apr 10 02:29:58 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.Constructor;
+import java.lang.reflect.Field;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.annotation.Resource;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.injection.ResourceObjectFactory;
+import org.apache.tuscany.implementation.java.impl.ConstructorDefinition;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.host.ResourceHost;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $
+ */
+public class ResourceInjectionTestCase extends TestCase {
+
+    public void testResourceMemberInjection() throws Exception {
+        ScopeContainer containter = EasyMock.createNiceMock(ScopeContainer.class);
+        Constructor<Foo> ctor = Foo.class.getConstructor();
+        Field field = Foo.class.getDeclaredField("resource");
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setName(new URI("component"));
+        configuration.setGroupId(URI.create("composite"));
+        configuration.setInstanceFactory(new PojoObjectFactory<Foo>(ctor));
+        configuration.addResourceSite("bar", field);
+        JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+        component.setScopeContainer(containter);
+
+        Wire wire = EasyMock.createMock(Wire.class);
+        EasyMock.expect(wire.getTargetInstance()).andReturn("result");
+        EasyMock.replay(wire);
+
+        ResourceHost host = EasyMock.createMock(ResourceHost.class);
+        EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn("result");
+        EasyMock.replay(host);
+
+        ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host);
+        component.addResourceFactory("bar", factory);
+
+        Foo foo = (Foo) component.createInstance();
+        assertEquals("result", foo.resource);
+    }
+
+
+    public void testResourceConstructorInjection() throws Exception {
+        ScopeContainer containter = EasyMock.createNiceMock(ScopeContainer.class);
+        Constructor<FooConstructor> ctor = FooConstructor.class.getConstructor(String.class);
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setName(new URI("component"));
+        configuration.setGroupId(URI.create("composite"));
+        configuration.setInstanceFactory(new PojoObjectFactory<FooConstructor>(ctor));
+        ConstructorDefinition<?> definition = new ConstructorDefinition(ctor);
+        definition.getParameters()[0].setName("bar");
+        definition.getParameters()[0].setClassifer(Resource.class);
+        configuration.setConstructor(definition);
+        JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+        component.setScopeContainer(containter);
+
+        Wire wire = EasyMock.createMock(Wire.class);
+        EasyMock.expect(wire.getTargetInstance()).andReturn("result");
+        EasyMock.replay(wire);
+        ResourceHost host = EasyMock.createMock(ResourceHost.class);
+        EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn("result");
+        EasyMock.replay(host);
+
+        ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host);
+        component.addResourceFactory("bar", factory);
+
+        FooConstructor foo = (FooConstructor) component.createInstance();
+        assertEquals("result", foo.resource);
+    }
+
+    public static class Foo {
+        protected String resource;
+
+        public Foo() {
+        }
+
+    }
+
+    public static class FooConstructor {
+        protected String resource;
+
+        public FooConstructor(String resource) {
+            this.resource = resource;
+        }
+
+    }
+}

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java.FIXME Tue Apr 10 02:29:58 2007
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.integration.conversation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URI;
+
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.integration.mock.MockFactory;
+import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.component.TargetNotFoundException;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+
+/**
+ * Verifies conversational resources are cleaned up if the maximum idle time is exceeded
+ *
+ * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $
+ */
+public abstract class ConversationIdleExpireTestCase extends AbstractConversationTestCase {
+    protected AtomicComponent target;
+    private JDKInvocationHandler handler;
+    private FooImpl targetInstance;
+    private Method operation1;
+    private Method operation2;
+    private final Object mutex = new Object();
+
+    public void testConversationExpire() throws Throwable {
+        workContext.setIdentifier(Scope.CONVERSATION, "12345A");
+        // start the conversation
+        handler.invoke(operation1, null);
+        // verify the instance was persisted
+        assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance());
+        synchronized (mutex) {
+            mutex.wait(100);
+        }
+        // verify the instance was expired
+        assertNull(store.readRecord(target, "12345A"));
+        // continue the conversation - should throw an error
+        try {
+            handler.invoke(operation2, null);
+            fail();
+        } catch (TargetNotFoundException e) {
+            // expected
+        }
+    }
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        createRuntime();
+        store.setReaperInterval(10);
+        initializeRuntime();
+
+        targetInstance = EasyMock.createMock(FooImpl.class);
+        targetInstance.operation1();
+        targetInstance.operation2();
+        targetInstance.end();
+        EasyMock.replay(targetInstance);
+        target = createTarget();
+
+        Wire wire = MockFactory.createWire("foo", Foo.class);
+        for (InvocationChain chain : wire.getInvocationChains().values()) {
+            chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false));
+        }
+        handler = new JDKInvocationHandler(Foo.class, wire, workContext);
+        operation1 = Foo.class.getMethod("operation1");
+        operation2 = Foo.class.getMethod("operation2");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        container.stop();
+        store.destroy();
+    }
+
+    private JavaAtomicComponent createTarget() throws Exception {
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setName(new URI("target"));
+        configuration.setMaxIdleTime(50);
+        configuration.setInstanceFactory(new MockPojoFactory(FooImpl.class.getConstructor()));
+        configuration.setImplementationClass(FooImpl.class);
+        JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+        component.setScopeContainer(container);
+        component.start();
+        return component;
+    }
+
+    private class MockPojoFactory extends PojoObjectFactory<FooImpl> {
+        public MockPojoFactory(Constructor<FooImpl> ctr) {
+            super(ctr);
+        }
+
+        public FooImpl getInstance() throws ObjectCreationException {
+            return targetInstance;
+        }
+    }
+
+    @Conversational
+    public static interface Foo {
+
+        void operation1();
+
+        void operation2();
+
+        @EndsConversation
+        void end();
+
+    }
+
+    public static class FooImpl implements Foo {
+
+        public void operation1() {
+        }
+
+        public void operation2() {
+        }
+
+        @EndsConversation
+        public void end() {
+        }
+    }
+}

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java.FIXME Tue Apr 10 02:29:58 2007
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.integration.conversation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URI;
+
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.integration.mock.MockFactory;
+import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Wire;
+import org.easymock.EasyMock;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+
+/**
+ * Verifies conversational resources are cleaned up if the maximum age is exceeded
+ *
+ * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $
+ */
+public abstract class ConversationMaxAgeExpireTestCase extends AbstractConversationTestCase {
+    protected AtomicComponent target;
+    private JDKInvocationHandler handler;
+    private FooImpl targetInstance;
+    private Method operation1;
+    private Method operation2;
+    private final Object mutex = new Object();
+
+    public void testConversationExpire() throws Throwable {
+/*
+        workContext.setIdentifier(org.apache.tuscany.spi.model.Scope.CONVERSATION, "12345A");
+        // start the conversation
+        handler.invoke(operation1, null);
+        // verify the instance was persisted
+        assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance());
+        synchronized (mutex) {
+            mutex.wait(100);
+        }
+        // verify the instance was expired
+        assertNull(store.readRecord(target, "12345A"));
+        // continue the conversation - should throw an error
+        try {
+            handler.invoke(operation2, null);
+            fail();
+        } catch (TargetNotFoundException e) {
+            // expected
+        }
+*/
+    }
+
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        createRuntime();
+        store.setReaperInterval(10);
+        initializeRuntime();
+
+        targetInstance = EasyMock.createMock(FooImpl.class);
+        targetInstance.operation1();
+        targetInstance.operation2();
+        targetInstance.end();
+        EasyMock.replay(targetInstance);
+        target = createTarget();
+        // create source component mock
+        JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class);
+        EasyMock.expect(source.getUri()).andReturn(URI.create("source")).atLeastOnce();
+        EasyMock.replay(source);
+
+        Wire wire = MockFactory.createWire("foo", Foo.class);
+        for (InvocationChain chain : wire.getInvocationChains().values()) {
+            chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false));
+        }
+        handler = new JDKInvocationHandler(Foo.class, wire, workContext);
+        operation1 = Foo.class.getMethod("operation1");
+        operation2 = Foo.class.getMethod("operation2");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        container.stop();
+        store.destroy();
+    }
+
+    private AtomicComponent createTarget() throws Exception {
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setName(new URI("target"));
+        configuration.setMaxAge(50);
+        Constructor<FooImpl> ctor = FooImpl.class.getConstructor();
+        configuration.setInstanceFactory(new MockPojoFactory(ctor));
+        configuration.setImplementationClass(FooImpl.class);
+        JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+        component.setScopeContainer(container);
+        component.start();
+        return component;
+    }
+
+    private class MockPojoFactory extends PojoObjectFactory<FooImpl> {
+        public MockPojoFactory(Constructor<FooImpl> ctr) {
+            super(ctr);
+        }
+
+        public FooImpl getInstance() throws ObjectCreationException {
+            return targetInstance;
+        }
+    }
+
+    @Conversational
+    public static interface Foo {
+
+        void operation1();
+
+        void operation2();
+
+        @EndsConversation
+        void end();
+
+    }
+
+    public static class FooImpl implements Foo {
+
+        public void operation1() {
+        }
+
+        public void operation2() {
+        }
+
+        @EndsConversation
+        public void end() {
+        }
+    }
+}



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