summaryrefslogtreecommitdiffstats
path: root/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container')
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java52
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java73
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/TestClassResource.java45
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceWiringTestCase.java151
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java131
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java76
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java57
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java31
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java42
-rw-r--r--sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java8
10 files changed, 666 insertions, 0 deletions
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java
new file mode 100644
index 0000000000..13b2c684d7
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringConfigSchemaTestCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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.container.spring;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the SCA extensible schema elements for Spring's XML configuration files
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public class SpringConfigSchemaTestCase extends TestCase {
+
+// private ConfigurableApplicationContext applicationContext;
+//
+// public void setUp() {
+// applicationContext =
+// new ScaApplicationContext(null,
+// new ClassPathResource("org/apache/tuscany/container/spring/SpringConfigSchemaTest.xml"));
+// }
+//
+ public void testSCAService() {
+// ScaServiceExporter service = (ScaServiceExporter) applicationContext.getBean("fooService");
+// // FIXME andyp -- this is not really right.
+//// TestBean service = (TestBean) applicationContext.getBean("fooService");
+//// assertEquals("call me", service.echo("call me"));
+ }
+//
+// public void testSCAReference() {
+// ScaServiceProxyFactoryBean pf = (ScaServiceProxyFactoryBean) applicationContext.getBean("&fooReference");
+// assertEquals("fooReference", pf.getReferenceName());
+// TestReference ref = (TestReference) applicationContext.getBean("fooReference");
+//// assertNotNull(ref);
+// }
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
new file mode 100644
index 0000000000..4a73b6628b
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/SpringTestUtils.java
@@ -0,0 +1,73 @@
+/*
+ * 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.container.spring;
+
+import java.net.URI;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.builder.WiringException;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.extension.ServiceBindingExtension;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import org.apache.tuscany.container.spring.mock.TestBeanImpl;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.support.GenericApplicationContext;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+
+public final class SpringTestUtils {
+ private SpringTestUtils() {
+ }
+
+ public static <T> ServiceBinding createService(URI uri, Class<T> serviceInterface)
+ throws InvalidServiceContractException, WiringException {
+ return new ServiceBindingExtension(uri) {
+ public QName getBindingType() {
+ return null;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation)
+ throws TargetInvokerCreationException {
+ return null;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation)
+ throws TargetInvokerCreationException {
+ return null;
+ }
+ };
+ }
+
+
+ public static GenericApplicationContext createContext() {
+ GenericApplicationContext ctx = new GenericApplicationContext();
+ BeanDefinition definition = new RootBeanDefinition(TestBeanImpl.class);
+ ctx.registerBeanDefinition("foo", definition);
+ return ctx;
+ }
+
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/TestClassResource.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/TestClassResource.java
new file mode 100644
index 0000000000..f93957cb8b
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/TestClassResource.java
@@ -0,0 +1,45 @@
+/*
+ * 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.container.spring;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import org.springframework.core.io.AbstractResource;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TestClassResource extends AbstractResource {
+ private Class<?> clazz;
+ private String fileName;
+
+ public TestClassResource(Class<?> clazz, String fileName) {
+ this.clazz = clazz;
+ this.fileName = fileName;
+ }
+
+ public String getDescription() {
+ return "test resource";
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return clazz.getResourceAsStream(fileName);
+ }
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceWiringTestCase.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceWiringTestCase.java
new file mode 100644
index 0000000000..b1e5733cd8
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/ReferenceWiringTestCase.java
@@ -0,0 +1,151 @@
+/*
+ * 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.container.spring.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.osoa.sca.CallableReference;
+
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.ReferenceBinding;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
+import org.apache.tuscany.spi.wire.ChainHolder;
+import org.apache.tuscany.spi.wire.IncompatibleServiceContractException;
+import org.apache.tuscany.spi.wire.ProxyCreationException;
+import org.apache.tuscany.spi.wire.ProxyService;
+import org.apache.tuscany.spi.wire.Wire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.extension.ReferenceBindingExtension;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.container.spring.mock.TestBean;
+import org.easymock.EasyMock;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * Verifies wiring from a Spring bean to an SCA composite reference
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ReferenceWiringTestCase extends TestCase {
+
+ public void testInvocation() throws Exception {
+ ClassLoader loader = getClass().getClassLoader();
+ URL url = loader.getResource("META-INF/sca/testReferenceContext.xml");
+ Resource resource = new UrlResource(url);
+ URI uri = URI.create("spring");
+ ProxyService proxyService = new MockProxyService();
+ SpringCompositeComponent parent = new SpringCompositeComponent(uri, resource, proxyService, null, loader);
+ Wire wire = EasyMock.createMock(Wire.class);
+ ServiceContract<?> contract = new ServiceContract(TestBean.class) {
+ };
+ EasyMock.expect(wire.getSourceContract()).andReturn(contract).atLeastOnce();
+ EasyMock.replay(wire);
+ ReferenceBinding referenceBinding = EasyMock.createMock(ReferenceBinding.class);
+ EasyMock.expect(referenceBinding.getWire()).andStubReturn(wire);
+ referenceBinding.start();
+ EasyMock.replay(referenceBinding);
+
+ URI referenceUri = URI.create("spring#testReference");
+ ReferenceBinding binding = new ReferenceBindingExtension(referenceUri, null){
+
+ public QName getBindingType() {
+ return null;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation)
+ throws TargetInvokerCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation)
+ throws TargetInvokerCreationException {
+ return null;
+ }
+ };
+ binding.setWire(wire);
+ List<ReferenceBinding> bindings = new ArrayList<ReferenceBinding>();
+ bindings.add(binding);
+ Reference reference = EasyMock.createMock(Reference.class);
+ EasyMock.expect(reference.getUri()).andReturn(referenceUri).anyTimes();
+ EasyMock.expect(reference.getReferenceBindings()).andReturn(bindings).atLeastOnce();
+ reference.start();
+ EasyMock.replay(reference);
+ parent.register(reference);
+ parent.start();
+ TestBean bean = parent.getBean(TestBean.class, "testBean");
+ assertNotNull(bean.getBean());
+ EasyMock.verify(reference);
+ }
+
+ private class MockInvocationHandler implements InvocationHandler {
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ return null;
+ }
+ }
+
+ private class MockProxyService implements ProxyService {
+
+ public <T> T createProxy(Class<T> interfaze, Wire wire) throws ProxyCreationException {
+ ClassLoader cl = interfaze.getClassLoader();
+ Class[] interfaces = new Class[]{interfaze};
+ MockInvocationHandler handler = new MockInvocationHandler();
+ return interfaze.cast(Proxy.newProxyInstance(cl, interfaces, handler));
+ }
+
+ public <T> T createProxy(Class<T> interfaze, Wire wire, Map<Method, ChainHolder> mapping)
+ throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object createCallbackProxy(Class<?> interfaze, List<Wire> wires) throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object createCallbackProxy(Class<?> interfaze) throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean checkCompatibility(ServiceContract<?> source,
+ ServiceContract<?> target,
+ boolean ignoreCallback,
+ boolean silent) throws IncompatibleServiceContractException {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java
new file mode 100644
index 0000000000..fb9d107b71
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeBuilderTestCase.java
@@ -0,0 +1,131 @@
+/*
+ * 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.container.spring.impl;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.container.spring.model.SpringComponentType;
+import org.apache.tuscany.container.spring.model.SpringImplementation;
+import org.easymock.EasyMock;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringCompositeBuilderTestCase extends TestCase {
+
+ /**
+ * Verifies that the builder calls back into the registry to load services and references when no
+ * <code>sca:service</code> tag is specified in the Spring application.xml
+ */
+ public void testImplicitServiceWiring() throws Exception {
+ Service service = EasyMock.createMock(Service.class);
+ // Configure the mock builder registry
+ BuilderRegistry registry = EasyMock.createMock(BuilderRegistry.class);
+ EasyMock.expect(registry.build(
+ EasyMock.isA(ServiceDefinition.class),
+ EasyMock.isA(DeploymentContext.class))).andStubReturn(service);
+ EasyMock.replay(registry);
+ SpringCompositeBuilder builder = new SpringCompositeBuilder();
+ builder.setBuilderRegistry(registry);
+ ComponentDefinition<SpringImplementation> definition = createDefinitionWithService();
+ Component component = builder.build(definition, null);
+ assertNotNull(component);
+ EasyMock.verify(registry);
+ }
+
+ /**
+ * Verifies that the builder calls back into the registry to load services and references when no
+ * <code>sca:reference</code> tag is specified in the Spring application.xml
+ */
+ public void testImplicitReferenceWiring() throws Exception {
+ Service service = EasyMock.createMock(Service.class);
+ // Configure the mock builder registry
+ BuilderRegistry registry = EasyMock.createMock(BuilderRegistry.class);
+ EasyMock.expect(registry.build(
+ EasyMock.isA(ServiceDefinition.class),
+ EasyMock.isA(DeploymentContext.class))).andStubReturn(service);
+ EasyMock.replay(registry);
+ SpringCompositeBuilder builder = new SpringCompositeBuilder();
+ builder.setBuilderRegistry(registry);
+ ComponentDefinition<SpringImplementation> definition = createDefinitionWithReference();
+ Component component = builder.build(definition, null);
+ assertNotNull(component);
+ EasyMock.verify(registry);
+ }
+
+ protected ComponentDefinition<SpringImplementation> createDefinitionWithService() throws Exception {
+ super.setUp();
+ ClassLoader loader = getClass().getClassLoader();
+ URL url = loader.getResource("META-INF/sca/testServiceContext.xml");
+ Resource resource = new UrlResource(url);
+ SpringComponentType<Property<?>> type = createComponentTypeWithService();
+ SpringImplementation impl = new SpringImplementation(loader);
+ impl.setComponentType(type);
+ URI uri = URI.create("composite");
+ ComponentDefinition<SpringImplementation> definition = new ComponentDefinition<SpringImplementation>(uri, impl);
+ impl.setApplicationResource(resource);
+ return definition;
+ }
+
+ protected ComponentDefinition<SpringImplementation> createDefinitionWithReference() throws Exception {
+ super.setUp();
+ ClassLoader loader = getClass().getClassLoader();
+ URL url = loader.getResource("META-INF/sca/testServiceContext.xml");
+ Resource resource = new UrlResource(url);
+ SpringComponentType<Property<?>> type = createComponentTypeWithReference();
+ SpringImplementation impl = new SpringImplementation(loader);
+ impl.setComponentType(type);
+ URI uri = URI.create("composite");
+ ComponentDefinition<SpringImplementation> definition = new ComponentDefinition<SpringImplementation>(uri, impl);
+ impl.setApplicationResource(resource);
+ return definition;
+ }
+
+ private SpringComponentType<Property<?>> createComponentTypeWithService() {
+ SpringComponentType<Property<?>> componentType = new SpringComponentType<Property<?>>();
+ ServiceDefinition serviceDefinition = new ServiceDefinition();
+ serviceDefinition.setUri(URI.create("fooService"));
+ serviceDefinition.setTarget(URI.create("testBean"));
+ componentType.add(serviceDefinition);
+ return componentType;
+ }
+
+ private SpringComponentType<Property<?>> createComponentTypeWithReference() {
+ SpringComponentType<Property<?>> componentType = new SpringComponentType<Property<?>>();
+ ReferenceDefinition referenceDefinition = new ReferenceDefinition();
+ referenceDefinition.setUri(URI.create("fooReference"));
+ componentType.add(referenceDefinition);
+ return componentType;
+ }
+
+
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java
new file mode 100644
index 0000000000..d014d99ad7
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringCompositeComponentTestCase.java
@@ -0,0 +1,76 @@
+/*
+ * 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.container.spring.impl;
+
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import junit.framework.TestCase;
+import org.easymock.classextension.EasyMock;
+import org.springframework.context.support.AbstractApplicationContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SpringCompositeComponentTestCase extends TestCase {
+ private SpringCompositeComponent component;
+
+ public void testChildStart() throws Exception {
+ AbstractApplicationContext appContext = EasyMock.createNiceMock(AbstractApplicationContext.class);
+ EasyMock.replay(appContext);
+ Service service = EasyMock.createMock(Service.class);
+ URI uri = URI.create("composite#service");
+ EasyMock.expect(service.getUri()).andReturn(uri).atLeastOnce();
+ service.start();
+ EasyMock.replay(service);
+ component.setSpringContext(appContext);
+ component.register(service);
+ component.start();
+ EasyMock.verify(service);
+ }
+
+ public void testTargetInvokerCreation() throws Exception {
+ ServiceContract<Type> contract = new ServiceContract<Type>(Foo.class) {
+ };
+ Operation<Type> operation = new Operation<Type>("operation", null, null, null);
+ Map<String, Operation<Type>> operations = new HashMap<String, Operation<Type>>();
+ operations.put("operation", operation);
+ contract.setOperations(operations);
+ operation.setServiceContract(contract);
+ component.createTargetInvoker("bean", operation);
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ URI compositeUri = URI.create("composite");
+ component = new SpringCompositeComponent(compositeUri, null, null, null, null);
+
+ }
+
+ private interface Foo {
+ void operation();
+ }
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java
new file mode 100644
index 0000000000..e4a6ad0eb7
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/impl/SpringInvocationTestCase.java
@@ -0,0 +1,57 @@
+/*
+ * 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.container.spring.impl;
+
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import junit.framework.TestCase;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * Verifies a simple invocation on a Spring bean
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class SpringInvocationTestCase extends TestCase {
+
+ /**
+ * Verifies the invoker can resolve a bean in an application context and call a method l
+ */
+ public void testInvocation() throws Exception {
+ TestBean bean = EasyMock.createMock(TestBean.class);
+ bean.test("bar");
+ EasyMock.expectLastCall();
+ EasyMock.replay(bean);
+ SpringCompositeComponent context = EasyMock.createMock(SpringCompositeComponent.class);
+ EasyMock.expect(context.getBean(Object.class, "foo")).andReturn(bean);
+ EasyMock.replay(context);
+ SpringInvoker invoker = new SpringInvoker("foo", TestBean.class.getMethod("test", String.class), context);
+ Message msg = new MessageImpl();
+ msg.setBody(new String[]{"bar"});
+ invoker.invoke(msg);
+ EasyMock.verify(context);
+ EasyMock.verify(bean);
+ }
+
+
+ private interface TestBean {
+ void test(String msg);
+ }
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java
new file mode 100644
index 0000000000..1c768e53cc
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBean.java
@@ -0,0 +1,31 @@
+/*
+ * 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.container.spring.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface TestBean {
+ String echo(String msg);
+
+ TestBean getBean();
+
+ void setBean(TestBean bean);
+
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java
new file mode 100644
index 0000000000..db04d8bcad
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestBeanImpl.java
@@ -0,0 +1,42 @@
+/*
+ * 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.container.spring.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class TestBeanImpl implements TestBean {
+
+ private TestBean bean;
+
+ public TestBeanImpl() {
+ }
+
+ public String echo(String msg) {
+ return msg;
+ }
+
+ public TestBean getBean() {
+ return bean;
+ }
+
+ public void setBean(TestBean bean) {
+ this.bean = bean;
+ }
+}
diff --git a/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java
new file mode 100644
index 0000000000..73d53bdbb7
--- /dev/null
+++ b/sandbox/old/contrib/implementation-spring/container/src/test/java/org/apache/tuscany/container/spring/mock/TestReference.java
@@ -0,0 +1,8 @@
+package org.apache.tuscany.container.spring.mock;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public interface TestReference {
+ String echo(String msg);
+}