summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration')
-rw-r--r--sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java51
-rw-r--r--sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME149
-rw-r--r--sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME153
-rw-r--r--sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME147
-rw-r--r--sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME79
5 files changed, 579 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java
new file mode 100644
index 0000000000..738775b9a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sca.implementation.java.integration;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.core.scope.ConversationalScopeContainer;
+import org.apache.tuscany.sca.core.store.MemoryStore;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.scope.ScopeContainer;
+import org.apache.tuscany.sca.store.StoreMonitor;
+import org.easymock.EasyMock;
+
+/**
+ * Provides helper methods for setting up a partial runtime for conversational test cases.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractConversationTestCase extends TestCase {
+ protected ScopeContainer container;
+ protected MemoryStore store;
+ protected RuntimeComponent component;
+
+ protected void createRuntime() {
+ store = new MemoryStore(EasyMock.createNiceMock(StoreMonitor.class));
+ component = EasyMock.createMock(RuntimeComponent.class);
+ container = new ConversationalScopeContainer(store, component);
+ }
+
+ protected void initializeRuntime() {
+ store.init();
+ container.start();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME
new file mode 100644
index 0000000000..47fa0f0bc5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME
@@ -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() {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME
new file mode 100644
index 0000000000..36e221a1e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME
@@ -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() {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME
new file mode 100644
index 0000000000..1872eea709
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME
@@ -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.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.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 start, continue and end conversation invocations are processed properly. Checks that a target instance is
+ * properly instantiated and persisted in the store. Additionally verifies that invocations are dispatched to a target
+ * instance, and that start, continue, and end operations are performed correctly. Finally, verfies that the target
+ * instance is removed from the store when the conversation ends.
+ *
+ * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $
+ */
+public abstract class ConversationStartStopEndTestCase extends AbstractConversationTestCase {
+ protected AtomicComponent target;
+ private FooImpl targetInstance;
+ private JDKInvocationHandler handler;
+ private Method operation1;
+ private Method operation2;
+ private Method endOperation;
+
+ public void testConversationStartContinueEnd() 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());
+ // continue the conversation
+ handler.invoke(operation2, null);
+ // verify the instance was persisted
+ assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance());
+ // end the conversation
+ handler.invoke(endOperation, null);
+ workContext.clearIdentifier(Scope.CONVERSATION);
+ EasyMock.verify(targetInstance);
+ // verify the store has removed the instance
+ assertNull(store.readRecord(target, "12345A"));
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ createRuntime();
+ initializeRuntime();
+ targetInstance = EasyMock.createMock(FooImpl.class);
+ targetInstance.operation1();
+ targetInstance.operation2();
+ targetInstance.end();
+ EasyMock.replay(targetInstance);
+ // create target component mock
+ target = createAtomicComponent();
+ Wire wire = MockFactory.createWire("foo", Foo.class);
+ for (InvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(target.createTargetInvoker("foo", chain.getOperation(), false));
+ }
+ handler = new JDKInvocationHandler(Foo.class, wire, workContext);
+ operation1 = Foo.class.getMethod("operation1");
+ operation2 = Foo.class.getMethod("operation2");
+ endOperation = Foo.class.getMethod("end");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ container.stop();
+ store.destroy();
+ }
+
+ private JavaAtomicComponent createAtomicComponent() throws Exception {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setName(new URI("target"));
+ 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() {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME
new file mode 100644
index 0000000000..17a832b117
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-0.91/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME
@@ -0,0 +1,79 @@
+/*
+ * 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.wire;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+import java.net.URI;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.component.scope.CompositeScopeContainer;
+import org.apache.tuscany.core.integration.mock.MockFactory;
+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.core.mock.component.TargetImpl;
+
+/**
+ * @version $$Rev: 526399 $$ $$Date: 2007-04-07 01:14:49 -0700 (Sat, 07 Apr 2007) $$
+ */
+public class ReferenceInjectionTestCase extends TestCase {
+ private Map<String, Member> members;
+
+ public void testProxiedReferenceInjection() throws Exception {
+ ScopeContainer scope = new CompositeScopeContainer(null);
+ scope.start();
+ URI groupId = URI.create("composite");
+ scope.startContext(groupId, groupId);
+ Map<String, AtomicComponent> components = MockFactory.createWiredComponents("source",
+ SourceImpl.class,
+ scope,
+ members,
+ "target",
+ Target.class,
+ TargetImpl.class,
+ scope);
+ AtomicComponent sourceComponent = components.get("source");
+ Source source = (Source) sourceComponent.getTargetInstance();
+ Target target = source.getTarget();
+ assertTrue(Proxy.isProxyClass(target.getClass()));
+
+ assertNotNull(target);
+ scope.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ members = new HashMap<String, Member>();
+ Method m = SourceImpl.class.getMethod("setTarget", Target.class);
+ members.put("target", m);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+}