summaryrefslogtreecommitdiffstats
path: root/tags/java-stable-20060304/sca/core/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-stable-20060304/sca/core/src/test')
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java447
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java71
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java37
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java68
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java107
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java130
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java96
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java52
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java52
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java26
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java74
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java27
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java158
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java156
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java124
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java112
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java66
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java25
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java136
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java70
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java45
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java25
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java36
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java28
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java39
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java56
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java329
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java6
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java28
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java25
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java96
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java305
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java137
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java165
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java123
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java40
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java127
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java49
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java130
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java59
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java36
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module24
-rw-r--r--tags/java-stable-20060304/sca/core/src/test/resources/system.fragment21
43 files changed, 0 insertions, 3963 deletions
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java
deleted file mode 100644
index 6eaac60eaa..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilderTestCase.java
+++ /dev/null
@@ -1,447 +0,0 @@
-package org.apache.tuscany.core.builder.impl;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.invocation.InvocationConfiguration;
-import org.apache.tuscany.core.invocation.MethodHashMap;
-import org.apache.tuscany.core.invocation.ProxyConfiguration;
-import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
-import org.apache.tuscany.core.invocation.jdk.JDKProxyFactory;
-import org.apache.tuscany.core.invocation.mock.MockHandler;
-import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
-import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.core.invocation.mock.SimpleTarget;
-import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.core.message.Message;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-
-public class DefaultWireBuilderTestCase extends TestCase {
-
- private Method hello;
-
- private Method goodbye;
-
- public DefaultWireBuilderTestCase() {
- super();
- }
-
- public DefaultWireBuilderTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
- goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
- }
-
- public void testWireWithInterceptorsAndHandlers() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockHandler sourceRequestHandler = new MockHandler();
- MockHandler sourceResponseHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addResponseHandler(sourceResponseHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockHandler targetResponseHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addResponseHandler(targetResponseHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- // source.build();
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceRequestHandler.getCount());
- Assert.assertEquals(1, sourceResponseHandler.getCount());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetRequestHandler.getCount());
- Assert.assertEquals(1, targetResponseHandler.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- public void testWireWithSourceInterceptorTargetHandlersAndTargetInterceptor() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addSourceInterceptor(sourceInterceptor);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockHandler targetResponseHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addResponseHandler(targetResponseHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- // source.build();
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetRequestHandler.getCount());
- Assert.assertEquals(1, targetResponseHandler.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- public void testWireWithInterceptorsAndRequestHandlers() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockHandler sourceRequestHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- // source.build();
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceRequestHandler.getCount());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetRequestHandler.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- public void testWireWithSourceAndTargetInterceptors() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addSourceInterceptor(sourceInterceptor);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- // source.build();
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- public void testWireWithSourceInterceptorSourceHandlersAndTargetInterceptor() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockHandler sourceRequestHandler = new MockHandler();
- MockHandler sourceResponseHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addResponseHandler(sourceResponseHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- // source.build();
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceRequestHandler.getCount());
- Assert.assertEquals(1, sourceResponseHandler.getCount());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- public void testWireWithTargetInterceptorAndTargetHandlers() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockHandler targetResponseHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addResponseHandler(targetResponseHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- // source.build();
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, targetRequestHandler.getCount());
- Assert.assertEquals(1, targetResponseHandler.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- public void testWireWithTargetInterceptor() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- /**
- * When there are only {@link InvokerInterceptor}s in the source and target chain, we need to bypass one during
- * wire up so they are not chained together
- */
- public void testWireWithOnlyInvokerInterceptors() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
- source.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- // no need for scopes since we use a static invoker
- builder.connect(sourceFactory, targetFactory, null, true, null);
- target.build();
- // set a static invoker
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = msgFactory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java
deleted file mode 100644
index bf83bca5cb..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/builder/impl/NegativeDefaultWireBuilderTestCase.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.apache.tuscany.core.builder.impl;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.builder.BuilderConfigException;
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.invocation.InvocationConfiguration;
-import org.apache.tuscany.core.invocation.MethodHashMap;
-import org.apache.tuscany.core.invocation.ProxyConfiguration;
-import org.apache.tuscany.core.invocation.jdk.JDKProxyFactory;
-import org.apache.tuscany.core.invocation.mock.SimpleTarget;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-
-public class NegativeDefaultWireBuilderTestCase extends TestCase {
-
- private Method hello;
-
- private Method goodbye;
-
- public NegativeDefaultWireBuilderTestCase() {
- super();
- }
-
- public NegativeDefaultWireBuilderTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
- goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
- }
-
- public void testNoTargetInterceptorOrHandler() throws Exception {
- MessageFactory msgFactory = new MessageFactoryImpl();
-
- InvocationConfiguration source = new InvocationConfiguration(hello);
-
- ProxyFactory sourceFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
- sourceInvocationConfigs.put(hello, source);
- ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- sourceFactory.setProxyConfiguration(sourceConfig);
- sourceFactory.setBusinessInterface(SimpleTarget.class);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
-
- ProxyFactory targetFactory = new JDKProxyFactory();
- Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
- targetInvocationConfigs.put(hello, target);
- ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
- targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
- targetFactory.setProxyConfiguration(targetConfig);
- targetFactory.setBusinessInterface(SimpleTarget.class);
-
- // connect the source to the target
- DefaultWireBuilder builder = new DefaultWireBuilder();
- try {
- builder.connect(sourceFactory, targetFactory, null, true, null);
- fail("Expected " + BuilderConfigException.class.getName());
- } catch (BuilderConfigException e) {
- // success
- }
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java
deleted file mode 100644
index 9cd7a40e59..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/JavaIntrospectionHelperTestCase.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.config;
-
-import java.lang.reflect.Constructor;
-
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-
-import junit.framework.TestCase;
-
-/**
- * @version $Rev$ $Date$
- */
-public class JavaIntrospectionHelperTestCase extends TestCase {
- public void testDefaultConstructor() throws Exception {
- Constructor ctr = JavaIntrospectionHelper.getDefaultConstructor(SomeClass.class);
- assertEquals(ctr, SomeClass.class.getConstructor(new Class[]{}));
- assertTrue(SomeClass.class == ctr.newInstance((Object[]) null).getClass());
- }
-
- public static class SomeClass {
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java
deleted file mode 100644
index df4cace0f9..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/config/ModuleComponentConfigurationLoaderTestCase.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.config;
-
-import java.net.URL;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
-import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
-import org.apache.tuscany.model.assembly.AssemblyModelContext;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.ComponentImplementation;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.ModuleComponent;
-import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
-import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
-import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
-
-/**
- * @version $Rev: 379641 $ $Date: 2006-02-21 16:50:58 -0800 (Tue, 21 Feb 2006) $
- */
-public class ModuleComponentConfigurationLoaderTestCase extends TestCase {
- private ModuleComponentConfigurationLoader loader;
-
- public void testFoo() throws ConfigurationException {
- URL xml = ModuleComponentConfigurationLoaderTestCase.class.getResource("ModuleComponentLoaderTest1.module");
- ModuleComponent moduleComponent = loader.loadModuleComponent("test", "test", xml.toString());
- Assert.assertEquals("test", moduleComponent.getName());
- Module module = moduleComponent.getModuleImplementation();
- Assert.assertEquals("ModuleComponentLoaderTest1", module.getName());
- List<Component> components = module.getComponents();
- Assert.assertEquals(1,components.size());
- Component component = components.get(0);
- Assert.assertEquals("HelloWorldServiceComponent", component.getName());
-
- component = module.getComponent("HelloWorldServiceComponent");
- Assert.assertEquals("HelloWorldServiceComponent", component.getName());
-
- ComponentImplementation implementation = component.getComponentImplementation();
- Assert.assertNull(implementation);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- AssemblyModelContext modelContext=new AssemblyModelContextImpl(
- new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null),
- new ResourceLoaderImpl(this.getClass().getClassLoader()));
- loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java
deleted file mode 100644
index 87e8d091ce..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AbstractAggregateHierarchyTests.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.context;
-
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
-import org.apache.tuscany.core.mock.MockConfigContext;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.Scope;
-import org.osoa.sca.ModuleContext;
-
-/**
- * Performs testing of various hierarchical scenarios
- *
- * @version $Rev$ $Date$
- */
-public abstract class AbstractAggregateHierarchyTests extends TestCase {
- protected List<RuntimeConfigurationBuilder> builders;
-
- public void testParentContextIsolation() throws Exception {
- AggregateContext parent = createContextHierachy();
- AggregateContext child = (AggregateContext) parent.getContext("test.child");
- Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- parent.registerModelObject(component);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- parent.registerModelObject(ep);
- parent.fireEvent(EventContext.MODULE_START, null);
- child.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(parent.locateInstance("TestService1EP"));
- try {
- ((ModuleContext) child).locateService("TestService1EP");
- fail("Expexcted " + ServiceNotFoundException.class.getName());
- } catch (ServiceNotFoundException e) {
- // expect exception to be thrown
- }
- parent.fireEvent(EventContext.MODULE_STOP, null);
- child.fireEvent(EventContext.MODULE_STOP, null);
- parent.stop();
-
- }
-
- /**
- * Checks that registration of duplicate named model objects before context start throws an exception
- */
- public void testRegisterSameName() throws Exception {
- AggregateContext parent = new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
- parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
- try {
- parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
- parent.start();
- fail("Expected " + DuplicateNameException.class.getName());
- } catch (DuplicateNameException e) {
- // expected
- }
- }
-
- /**
- * Checks that registration of duplicate named model objects after context start throws an exception
- */
- public void testRegisterSameNameAfterStart() throws Exception {
- AggregateContext parent = new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
- parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
- parent.start();
- AggregateContext child = (AggregateContext) parent.getContext("test.child");
- Assert.assertNotNull(child);
- try {
- parent.registerModelObject(MockFactory.createSystemAggregateComponent("test.child"));
- fail("Expected " + DuplicateNameException.class.getName());
- } catch (DuplicateNameException e) {
- // expected
- }
- }
-
- protected abstract AggregateContext createContextHierachy() throws Exception;
-
- protected void setUp() throws Exception {
- super.setUp();
- builders = MockFactory.createSystemBuilders();
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java
deleted file mode 100644
index 924ce57939..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateComponentContextRegisterTestCase.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.context;
-
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
-import org.apache.tuscany.core.mock.MockConfigContext;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.core.mock.component.GenericSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Tests registration of model objects for an aggregate context
- *
- * @version $Rev$ $Date$
- */
-public class AggregateComponentContextRegisterTestCase extends TestCase {
-
- public void testModuleRegistration() throws Exception {
- AggregateContext moduleContext = createContext();
- Module module = MockFactory.createSystemModule();
- moduleContext.registerModelObject(module);
- moduleContext.start();
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- GenericSystemComponent component = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
- Assert.assertNotNull(component);
- GenericSystemComponent ep = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
- Assert.assertNotNull(ep);
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- moduleContext.stop();
- }
-
- public void testModuleRegistrationAfterStart() throws Exception {
- AggregateContext moduleContext = createContext();
- moduleContext.start();
- Module module = MockFactory.createSystemModule();
- moduleContext.registerModelObject(module);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- GenericSystemComponent component = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
- Assert.assertNotNull(component);
- GenericSystemComponent ep = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
- Assert.assertNotNull(ep);
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- moduleContext.stop();
- }
-
- public void testRegistration() throws Exception {
- AggregateContext moduleContext = createContext();
- Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- moduleContext.registerModelObject(component);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- moduleContext.registerModelObject(ep);
- moduleContext.start();
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- GenericSystemComponent test = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
- Assert.assertNotNull(test);
- GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
- Assert.assertNotNull(testEP);
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- moduleContext.stop();
- }
-
- public void testRegistrationAfterStart() throws Exception {
- AggregateContext moduleContext = createContext();
- Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- moduleContext.start();
- moduleContext.registerModelObject(component);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- moduleContext.registerModelObject(ep);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- GenericSystemComponent test = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
- Assert.assertNotNull(test);
- GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
- Assert.assertNotNull(testEP);
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- moduleContext.stop();
- }
-
- public void testEPRegistrationAfterModuleStart() throws Exception {
- AggregateContext moduleContext = createContext();
- Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- moduleContext.start();
- moduleContext.registerModelObject(component);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- GenericSystemComponent test = (GenericSystemComponent) moduleContext.locateInstance("TestService1");
- Assert.assertNotNull(test);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- moduleContext.registerModelObject(ep);
- GenericSystemComponent testEP = (GenericSystemComponent) moduleContext.locateInstance("TestService1EP");
- Assert.assertNotNull(testEP);
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- moduleContext.stop();
- }
-
- protected AggregateContext createContext() {
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
- return new AggregateContextImpl("test.context", null, new DefaultScopeStrategy(), new EventContextImpl(),
- new MockConfigContext(builders), new NullMonitorFactory());
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java
deleted file mode 100644
index 51d315e1cf..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/AggregateHierarchyTestCase.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.context;
-
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
-import org.apache.tuscany.core.mock.MockConfigContext;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.Scope;
-import org.osoa.sca.ModuleContext;
-import org.osoa.sca.ServiceUnavailableException;
-
-/**
- * Performs testing of various hierarchical scenarios
- *
- * @version $Rev$ $Date$
- */
-public class AggregateHierarchyTestCase extends AbstractAggregateHierarchyTests {
-
- /**
- * FIXME model Tests adding a component, accessing it and then exposing it as an entry point after the first access
- *
- * @throws Exception
- */
- public void testChildContextIsolation() throws Exception {
- AggregateContext parent = createContextHierachy();
- AggregateContext child = (AggregateContext) parent.getContext("test.child");
- Component component = MockFactory.createSystemInitializedComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- child.registerModelObject(component);
- parent.fireEvent(EventContext.MODULE_START, null);
- child.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(child.locateInstance("TestService1"));
- try {
- ((ModuleContext) parent).locateService("test.child/TestService1");
- fail("Expected " + ServiceUnavailableException.class.getName()
- + " since [test.child/TestService1] is not an entry point");
- } catch (ServiceUnavailableException e) {
- // should throw an exception since it is not an entry point
- }
-
- // now expose the service as an entry point
- // FIXME hack to get around initialization of component - just create another one ;-)
- component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class, Scope.MODULE);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- child.registerModelObject(ep);
- Assert.assertNotNull(child.locateInstance("TestService1EP"));
- Assert.assertNotNull(parent.locateInstance("test.child/TestService1EP"));
-
- // now expose the child entry point from the parent context
- EntryPoint parentEp = MockFactory.createEntryPointWithStringRef("TestService1EP", ModuleScopeSystemComponent.class,
- "TestService1", "test.child/TestService1EP");
- parent.registerModelObject(parentEp);
- Assert.assertNotNull(parent.locateInstance("TestService1EP"));
-
- parent.fireEvent(EventContext.MODULE_STOP, null);
- child.fireEvent(EventContext.MODULE_STOP, null);
- parent.stop();
- }
-
- protected AggregateContext createContextHierachy() throws Exception {
- List<RuntimeConfigurationBuilder> systemBuilders = MockFactory.createSystemBuilders();
- AggregateContext parent = new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(systemBuilders), new NullMonitorFactory());
- Component component = MockFactory.createAggregateComponent("test.child");
- parent.registerModelObject(component);
- parent.start();
- AggregateContext child = (AggregateContext) parent.getContext("test.child");
- Assert.assertNotNull(child);
- return parent;
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java
deleted file mode 100644
index 4f86d1aed5..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/QualifiedNameTestCase.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.context;
-
-import junit.framework.TestCase;
-
-/**
- * Tests parsing of naming patters
- *
- * @version $Rev$ $Date$
- */
-public class QualifiedNameTestCase extends TestCase {
-
- public void testSimpleName() throws Exception {
- QualifiedName name = new QualifiedName("Foo");
- assertEquals("Foo", name.getPartName());
- assertEquals(null, name.getPortName());
- }
-
- public void testCompoundName() throws Exception {
- QualifiedName name = new QualifiedName("Foo/Bar");
- assertEquals("Foo", name.getPartName());
- assertEquals("Bar", name.getPortName());
- }
-
- public void testCompoundMultiName() throws Exception {
- QualifiedName name = new QualifiedName("Foo/Bar/Baz");
- assertEquals("Foo", name.getPartName());
- assertEquals("Bar/Baz", name.getPortName());
- }
-
- public void testInvalidName() throws Exception {
- try {
- QualifiedName name = new QualifiedName("/Foo/Bar");
- fail("Invalid name exception not thrown");
- } catch (InvalidNameException e) {
-
- }
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java
deleted file mode 100644
index 2460d32793..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategyTestCase.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.context.scope;
-
-import org.apache.tuscany.model.assembly.Scope;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * Basic scope strategy tests, including downscope referencing
- *
- * @version $Rev$ $Date$
- */
-public class DefaultScopeStrategyTestCase extends TestCase {
-
- public void testDownScopeReferences() throws Exception{
- DefaultScopeStrategy strategy = new DefaultScopeStrategy();
-
- Assert.assertTrue(!strategy.downScopeReference(Scope.MODULE,Scope.MODULE));
- Assert.assertTrue(strategy.downScopeReference(Scope.MODULE,Scope.SESSION));
- Assert.assertTrue(strategy.downScopeReference(Scope.MODULE,Scope.REQUEST));
- Assert.assertTrue(strategy.downScopeReference(Scope.MODULE,Scope.INSTANCE));
-
- Assert.assertTrue(!strategy.downScopeReference(Scope.SESSION,Scope.MODULE));
- Assert.assertTrue(!strategy.downScopeReference(Scope.SESSION,Scope.SESSION));
- Assert.assertTrue(strategy.downScopeReference(Scope.SESSION,Scope.REQUEST));
- Assert.assertTrue(strategy.downScopeReference(Scope.SESSION,Scope.INSTANCE));
-
- Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.MODULE));
- Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.SESSION));
- Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.REQUEST));
- Assert.assertTrue(strategy.downScopeReference(Scope.REQUEST,Scope.INSTANCE));
-
- Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.MODULE));
- Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.SESSION));
- Assert.assertTrue(!strategy.downScopeReference(Scope.REQUEST,Scope.REQUEST));
- Assert.assertTrue(!strategy.downScopeReference(Scope.INSTANCE,Scope.INSTANCE));
- }
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java
deleted file mode 100644
index b9bc3a1660..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/Bean1.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.apache.tuscany.core.injection;
-
-
-public class Bean1 extends SuperBean {
-
- public static final int ALL_BEAN1_FIELDS = 3 + ALL_SUPER_FIELDS;
-
- public static final int ALL__BEAN1_METHODS = 4 + ALL_SUPER_METHODS - 1;
-
- private String field1;
-
- public void setMethod1(String param) {
- }
-
- public void setMethod1(int param) {
- }
-
- public void override(String param) throws Exception {
- }
-
-
- public void noOverride(String param) throws Exception {
- }
-
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java
deleted file mode 100644
index ca1f2012a5..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/ReflectionHelperTestCase.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.tuscany.core.injection;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Set;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-
-public class ReflectionHelperTestCase extends TestCase {
-
- public ReflectionHelperTestCase() {
- super();
- }
-
- public ReflectionHelperTestCase(String arg0) {
- super(arg0);
- }
-
- public void testGetSuperAllFields() throws Exception {
- Set<Field> superBeanFields = JavaIntrospectionHelper.getAllFields(SuperBean.class);
- Assert.assertEquals(SuperBean.ALL_SUPER_FIELDS, superBeanFields.size());
- }
-
- public void testBean1AllFields() throws Exception {
- Set<Field> beanFields = JavaIntrospectionHelper.getAllFields(Bean1.class);
- Assert.assertEquals(Bean1.ALL_BEAN1_FIELDS, beanFields.size());
- }
-
- public void testGetSuperAllMethods() throws Exception {
- Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniqueMethods(SuperBean.class);
- Assert.assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size());
- }
-
- public void testGetBean1AllMethods() throws Exception {
- Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniqueMethods(Bean1.class);
- Assert.assertEquals(Bean1.ALL__BEAN1_METHODS, beanMethods.size());
- }
-
- public void testOverrideMethod() throws Exception {
- Set<Method> beanFields = JavaIntrospectionHelper.getAllUniqueMethods(Bean1.class);
- boolean invoked = false;
- for (Method method : beanFields) {
- if (method.getName().equals("override")) {
- method.invoke(new Bean1(), new Object[]{"foo"});
- invoked = true;
- }
- }
- if (!invoked) {
- throw new Exception("Override never invoked");
- }
- }
-
- public void testNoOverrideMethod() throws Exception {
- Set<Method> beanFields = JavaIntrospectionHelper.getAllUniqueMethods(Bean1.class);
- boolean found = false;
- for (Method method : beanFields) {
- if (method.getName().equals("noOverride") && method.getParameterTypes().length == 0) {
- found = true;
- }
- }
- if (!found) {
- throw new Exception("No override not found");
- }
- }
-
- public void testGetBean1AllFields() throws Exception {
- Set<Field> bean1 = JavaIntrospectionHelper.getAllFields(Bean1.class);
- Assert.assertEquals(Bean1.ALL_BEAN1_FIELDS, bean1.size());
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java
deleted file mode 100644
index 5d88aeb1a8..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/injection/SuperBean.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.tuscany.core.injection;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SuperBean {
-
- public static final int ALL_SUPER_FIELDS = 3;
-
- public static final int ALL_SUPER_METHODS = 4;
-
- private String superField1;
-
- public void setSuperMethod1(String param) {
- }
-
- public void setSuperMethod1(int param) {
- }
-
- public void override(String param) throws Exception {
- throw new Exception("Override not handled");
- }
-
- public void noOverride() throws Exception {
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java
deleted file mode 100644
index 3d2fe482f1..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationErrorTestCase.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.invocation;
-
-import java.lang.reflect.Method;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
-import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
-import org.apache.tuscany.core.invocation.mock.MockHandler;
-import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
-import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.core.invocation.mock.SimpleTarget;
-import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
-import org.apache.tuscany.core.message.Message;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-
-/**
- * Tests error propagation through an innvocation
- *
- * @version $Rev$ $Date$
- */
-public class InvocationConfigurationErrorTestCase extends TestCase {
-
-
- private Method hello;
- private Method goodbye;
-
- private MessageFactory factory = new MessageFactoryImpl();
-
- public InvocationConfigurationErrorTestCase() {
- super();
- }
-
- public InvocationConfigurationErrorTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- hello = SimpleTarget.class.getMethod("hello", new Class[]{String.class});
- goodbye = SimpleTarget.class.getMethod("goodbye", new Class[]{String.class});
- }
-
- public void testInvokeWithHandlers() throws Exception{
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockHandler sourceRequestHandler = new MockHandler();
- MockHandler sourceResponseHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addResponseHandler(sourceResponseHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockHandler targetResponseHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addResponseHandler(targetResponseHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- // connect the source to the target
- source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
- source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
- source.build();
- target.build();
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = factory.createMessage();
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertTrue(response.getBody() instanceof IllegalArgumentException);
- Assert.assertEquals(1,sourceRequestHandler.getCount());
- Assert.assertEquals(1,sourceResponseHandler.getCount());
- Assert.assertEquals(1,sourceInterceptor.getCount());
- Assert.assertEquals(1,targetRequestHandler.getCount());
- Assert.assertEquals(1,targetResponseHandler.getCount());
- Assert.assertEquals(1,targetInterceptor.getCount());
- }
-
- public void testInvokeWithRequestHandlers() throws Exception{
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockHandler sourceRequestHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- // connect the source to the target
- source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
- source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
- source.build();
- target.build();
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = factory.createMessage();
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertTrue(response.getBody() instanceof IllegalArgumentException);
- Assert.assertEquals(1,sourceRequestHandler.getCount());
- Assert.assertEquals(1,sourceInterceptor.getCount());
- Assert.assertEquals(1,targetRequestHandler.getCount());
- Assert.assertEquals(1,targetInterceptor.getCount());
- }
-
- /**
- * Tests basic wiring of a source to a target, including handlers and interceptors
- */
- public void testInvokeWithInterceptorsOnly() throws Exception{
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addSourceInterceptor(sourceInterceptor);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- // connect the source to the target
- source.addTargetInterceptor(target.getTargetInterceptor());
- source.build();
- target.build();
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = factory.createMessage();
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertTrue(response.getBody() instanceof IllegalArgumentException);
- Assert.assertEquals(1,sourceInterceptor.getCount());
- Assert.assertEquals(1,targetInterceptor.getCount());
-
- }
-
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java
deleted file mode 100644
index 9e5fb80cad..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationConfigurationTestCase.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.invocation;
-
-import java.lang.reflect.Method;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
-import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
-import org.apache.tuscany.core.invocation.mock.MockHandler;
-import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
-import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.core.invocation.mock.SimpleTarget;
-import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
-import org.apache.tuscany.core.message.Message;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-
-public class InvocationConfigurationTestCase extends TestCase {
-
- private Method hello;
-
- private Method goodbye;
-
- private MessageFactory factory = new MessageFactoryImpl();
-
- public InvocationConfigurationTestCase() {
- super();
- }
-
- public InvocationConfigurationTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
- goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
- }
-
- /**
- * Tests basic wiring of a source to a target, including handlers and interceptors
- */
- public void testInvokeWithHandlers() throws Exception {
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockHandler sourceRequestHandler = new MockHandler();
- MockHandler sourceResponseHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addResponseHandler(sourceResponseHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockHandler targetResponseHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addResponseHandler(targetResponseHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- // connect the source to the target
- source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
- source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
- source.build();
- target.build();
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = factory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceRequestHandler.getCount());
- Assert.assertEquals(1, sourceResponseHandler.getCount());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetRequestHandler.getCount());
- Assert.assertEquals(1, targetResponseHandler.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- public void testInvokeWithRequestHandlers() throws Exception {
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockHandler sourceRequestHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockHandler targetRequestHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- // connect the source to the target
- source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
- source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
- source.build();
- target.build();
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = factory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceRequestHandler.getCount());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetRequestHandler.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-
- /**
- * Tests basic wiring of a source to a target, including handlers and interceptors
- */
- public void testInvokeWithInterceptorsOnly() throws Exception {
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addSourceInterceptor(sourceInterceptor);
-
- InvocationConfiguration target = new InvocationConfiguration(hello);
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- // connect the source to the target
- source.addTargetInterceptor(target.getTargetInterceptor());
- source.build();
- target.build();
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Message msg = factory.createMessage();
- msg.setBody("foo");
- msg.setTargetInvoker(invoker);
- Message response = (Message) source.getSourceInterceptor().invoke(msg);
- Assert.assertEquals("foo", response.getBody());
- Assert.assertEquals(1, sourceInterceptor.getCount());
- Assert.assertEquals(1, targetInterceptor.getCount());
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java
deleted file mode 100644
index 02929c9193..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/InvocationErrorTestCase.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.invocation;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
-import org.apache.tuscany.core.invocation.jdk.JDKInvocationHandler;
-import org.apache.tuscany.core.invocation.mock.MockHandler;
-import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
-import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-
-/**
- * Tests handling of exceptions thrown during an invocation
- *
- * @version $Rev: 377006 $ $Date: 2006-02-11 09:41:59 -0800 (Sat, 11 Feb 2006) $
- */
-public class InvocationErrorTestCase extends TestCase {
-
- private Method checkedMethod;
- private Method runtimeMethod;
-
- public InvocationErrorTestCase() {
- super();
- }
-
- public InvocationErrorTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- checkedMethod = TestBean.class.getDeclaredMethod("checkedException", (Class[]) null);
- runtimeMethod = TestBean.class.getDeclaredMethod("runtimeException", (Class[]) null);
- Assert.assertNotNull(checkedMethod);
- Assert.assertNotNull(runtimeMethod);
- }
-
- public void testCheckedException() throws Exception {
- Map<Method, InvocationConfiguration> config = new MethodHashMap();
- config.put(checkedMethod, getConfiguration(checkedMethod));
- InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
- try {
- TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
- new Class[]{TestBean.class}, handler);
- proxy.checkedException();
- } catch (TestException e) {
- return;
- }
- Assert.fail(TestException.class.getName() + " should have been thrown");
- }
-
- public void testRuntimeException() throws Exception {
- Map<Method, InvocationConfiguration> config = new MethodHashMap();
- config.put(runtimeMethod, getConfiguration(runtimeMethod));
- InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
- try {
- TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
- new Class[]{TestBean.class}, handler);
- proxy.runtimeException();
- } catch (TestRuntimeException e) {
- return;
- }
- Assert.fail(TestException.class.getName() + " should have been thrown");
- }
-
- private InvocationConfiguration getConfiguration(Method m) {
- MockStaticInvoker invoker = new MockStaticInvoker(m, new TestBeanImpl());
- InvocationConfiguration invocationConfiguration=new InvocationConfiguration(m);
- invocationConfiguration.addSourceInterceptor(new MockSyncInterceptor());
- invocationConfiguration.addRequestHandler(new MockHandler());
- invocationConfiguration.setTargetInvoker(invoker);
- invocationConfiguration.addTargetInterceptor(new InvokerInterceptor());
- invocationConfiguration.build();
- return invocationConfiguration;
- }
-
- public interface TestBean {
-
- public void checkedException() throws TestException;
-
- public void runtimeException() throws TestRuntimeException;
-
- }
-
- public class TestBeanImpl implements TestBean {
-
- 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 {
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java
deleted file mode 100644
index 758134fbba..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandlerTestCase.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.apache.tuscany.core.invocation.jdk;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.invocation.InvocationConfiguration;
-import org.apache.tuscany.core.invocation.MethodHashMap;
-import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
-import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
-import org.apache.tuscany.core.invocation.mock.MockHandler;
-import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
-import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.core.invocation.mock.SimpleTarget;
-import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-
-public class JDKInvocationHandlerTestCase extends TestCase {
-
- private Method hello;
-
- private Method goodbye;
-
- public JDKInvocationHandlerTestCase() {
- super();
- }
-
- public JDKInvocationHandlerTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
- goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
- }
-
- public void testBasicInvoke() throws Throwable {
- Map<Method, InvocationConfiguration> configs = new MethodHashMap();
- configs.put(hello, getInvocationHandler(hello));
- JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
- Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] { "foo" }));
- }
-
- public void testErrorInvoke() throws Throwable {
- Map<Method, InvocationConfiguration> configs = new MethodHashMap();
- configs.put(hello, getInvocationHandler(hello));
- JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
- try {
- Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] {}));
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (IllegalArgumentException e) {
- // should throw
- }
- }
-
- public void testDirectErrorInvoke() throws Throwable {
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Map<Method, InvocationConfiguration> configs = new MethodHashMap();
- configs.put(hello, source);
- JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
- try {
- Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] {}));
- fail("Expected " + IllegalArgumentException.class.getName());
- } catch (IllegalArgumentException e) {
- // should throw
- }
- }
-
- public void testDirectInvoke() throws Throwable {
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
-
- Map<Method, InvocationConfiguration> configs = new MethodHashMap();
- configs.put(hello, source);
- JDKInvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), configs);
- Assert.assertEquals("foo", handler.invoke(null, hello, new Object[] { "foo" }));
- }
-
- private InvocationConfiguration getInvocationHandler(Method m) {
- InvocationConfiguration source = new InvocationConfiguration(m);
- MockHandler sourceRequestHandler = new MockHandler();
- MockHandler sourceResponseHandler = new MockHandler();
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addRequestHandler(sourceRequestHandler);
- source.addResponseHandler(sourceResponseHandler);
- source.addSourceInterceptor(sourceInterceptor);
-
- InvocationConfiguration target = new InvocationConfiguration(m);
- MockHandler targetRequestHandler = new MockHandler();
- MockHandler targetResponseHandler = new MockHandler();
- MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- target.addRequestHandler(targetRequestHandler);
- target.addResponseHandler(targetResponseHandler);
- target.addTargetInterceptor(targetInterceptor);
- target.addTargetInterceptor(new InvokerInterceptor());
-
- // connect the source to the target
- source.setTargetRequestChannel(new MessageChannelImpl(target.getRequestHandlers()));
- source.setTargetResponseChannel(new MessageChannelImpl(target.getResponseHandlers()));
- source.build();
- target.build();
- MockStaticInvoker invoker = new MockStaticInvoker(m, new SimpleTargetImpl());
- source.setTargetInvoker(invoker);
- return source;
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java
deleted file mode 100644
index 98853a1469..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryTestCase.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.invocation.jdk;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.invocation.InvocationConfiguration;
-import org.apache.tuscany.core.invocation.MethodHashMap;
-import org.apache.tuscany.core.invocation.ProxyConfiguration;
-import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
-import org.apache.tuscany.core.invocation.mock.MockStaticInvoker;
-import org.apache.tuscany.core.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.core.invocation.mock.SimpleTarget;
-import org.apache.tuscany.core.invocation.mock.SimpleTargetImpl;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-
-public class JDKProxyFactoryTestCase extends TestCase {
-
- private Method hello;
-
- private Method goodbye;
-
- public JDKProxyFactoryTestCase(String arg0) {
- super(arg0);
- }
-
- public void setUp() throws Exception {
- hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
- goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
- }
-
- public void testProxyFactory() throws Exception {
- InvocationConfiguration source = new InvocationConfiguration(hello);
- MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- source.addSourceInterceptor(sourceInterceptor);
- source.addTargetInterceptor(new InvokerInterceptor());
- source.setTargetInvoker(new MockStaticInvoker(hello, new SimpleTargetImpl()));
- source.build();
- Map<Method, InvocationConfiguration> configs = new MethodHashMap();
- configs.put(hello, source);
- ProxyConfiguration config = new ProxyConfiguration(new QualifiedName("foo"), configs, Thread.currentThread()
- .getContextClassLoader(), new MessageFactoryImpl());
- JDKProxyFactory factory = new JDKProxyFactory();
- factory.setProxyConfiguration(config);
- factory.setBusinessInterface(SimpleTarget.class);
- factory.initialize();
- SimpleTarget instance = (SimpleTarget) factory.createProxy();
- Assert.assertEquals("foo",instance.hello("foo"));
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java
deleted file mode 100644
index ec52bee002..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockHandler.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- *
- */
-package org.apache.tuscany.core.invocation.mock;
-
-import org.apache.tuscany.core.invocation.MessageHandler;
-import org.apache.tuscany.core.message.Message;
-
-/**
- *
- */
-public class MockHandler implements MessageHandler {
-
- private int count =0;
-
- public boolean processMessage(Message message) {
- //System.out.println("Invoking handler");
- count++;
- return true;
- }
-
- public int getCount(){
- return count;
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java
deleted file mode 100644
index ec8a95d4be..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockScopeContext.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.invocation.mock;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tuscany.core.builder.RuntimeConfiguration;
-import org.apache.tuscany.core.context.InstanceContext;
-import org.apache.tuscany.core.context.EventException;
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.context.LifecycleEventListener;
-import org.apache.tuscany.core.context.ScopeContext;
-import org.apache.tuscany.core.context.ScopeRuntimeException;
-import org.apache.tuscany.core.context.SimpleComponentContext;
-import org.apache.tuscany.core.context.TargetException;
-import org.apache.tuscany.model.assembly.SimpleComponent;
-
-public class MockScopeContext implements ScopeContext {
-
- Map<String, Object> components;
-
- public MockScopeContext() {
- components = new HashMap();
- components.put("foo", new SimpleTargetImpl());
- components.put("bar", new SimpleTargetImpl());
- }
-
- public MockScopeContext(Map<String,Object> instances) {
- components = instances;
- }
-
-
- public void start() {
- }
-
- public void stop() {
- }
-
- public String getName() {
- return "Mock Scope Container";
- }
-
- public boolean isCacheable() {
- return false;
- }
-
- public int[] getEventTypes() {
- return null;
- }
-
- public SimpleComponentContext getContext(String name) {
- return null;
- }
-
- public Object getInstance(QualifiedName name) throws ScopeRuntimeException {
- return components.get(name.getPartName());
- }
-
- public Object getInstance(QualifiedName componentName, boolean notify) throws TargetException {
- return getInstance(componentName);
- }
-
- public SimpleComponentContext getContextByKey(String name, Object key) {
- return null;
- }
-
- public void setComponent(SimpleComponent component) throws ScopeRuntimeException {
- }
-
- public void removeContext(String name) throws ScopeRuntimeException {
- }
-
- public void removeContextByKey(String name, Object key) throws ScopeRuntimeException {
- }
-
- public SimpleComponent[] getComponents() {
- return null;
- }
-
- public void onEvent(int type, Object message) throws EventException {
- }
-
-
- public void registerConfigurations(List<RuntimeConfiguration<InstanceContext>> configurations) {
- }
-
- public void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) {
- }
-
- public int getLifecycleState(){
- return RUNNING;
- }
-
-
- public void setLifecycleState(int state) {
- }
-
-
- public void setName(String name) {
- }
-
-
- public void addContextListener(LifecycleEventListener listener) {
- }
-
-
- public void removeContextListener(LifecycleEventListener listener) {
- }
-
- public Object getImplementationInstance() throws TargetException{
- return this;
- }
-
- public Object getImplementationInstance(boolean notify) throws TargetException{
- return this;
- }
-
-
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java
deleted file mode 100644
index 27b3594ab7..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockStaticInvoker.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.apache.tuscany.core.invocation.mock;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.apache.tuscany.core.invocation.Interceptor;
-import org.apache.tuscany.core.invocation.InvocationRuntimeException;
-import org.apache.tuscany.core.invocation.TargetInvoker;
-import org.apache.tuscany.core.message.Message;
-
-/**
- * Caches component instances that do not need to be resolved for every invocation, e.g. an invocation originating from
- * a lesser scope intended for a target with a wider scope
- *
- * @version $Rev: 377006 $ $Date: 2006-02-11 09:41:59 -0800 (Sat, 11 Feb 2006) $
- */
-public class MockStaticInvoker implements TargetInvoker {
-
- private Object instance;
-
- private Method operation;
-
- public MockStaticInvoker(Method operation, Object instance) {
- this.operation = operation;
- this.instance = instance;
- }
-
- public boolean isCacheable() {
- return true;
- }
-
- public Object invokeTarget(Object payload) throws InvocationTargetException {
- try {
- if (payload != null && !payload.getClass().isArray()) {
- return operation.invoke(instance, payload);
- } else {
- return operation.invoke(instance, (Object[]) payload);
- }
- } catch (IllegalAccessException e) {
- throw new InvocationRuntimeException(e);
- }
- }
-
- public Message invoke(Message msg) {
- try {
- Object resp = invokeTarget(msg.getBody());
- msg.setBody(resp);
- } catch (InvocationTargetException e) {
- msg.setBody(e.getCause());
- } catch (Throwable e) {
- msg.setBody(e);
- }
- return msg;
- }
-
- public void setNext(Interceptor next) {
- throw new IllegalStateException("This interceptor must be the last interceptor in an interceptor chain");
- }
-
- public Object clone() {
- try {
- MockStaticInvoker invoker = (MockStaticInvoker) super.clone();
- invoker.instance = this.instance;
- invoker.operation = this.operation;
- return invoker;
- } catch (CloneNotSupportedException e) {
- return null; // will not happen
- }
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java
deleted file mode 100644
index 120b7654cd..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/MockSyncInterceptor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.invocation.mock;
-
-import org.apache.tuscany.core.invocation.Interceptor;
-import org.apache.tuscany.core.message.Message;
-
-public class MockSyncInterceptor implements Interceptor {
-
- private int count;
-
- private Interceptor next;
-
- public MockSyncInterceptor() {
- }
-
- public Message invoke(Message msg) {
- ++count;
- //System.out.println("Invoking interceptor");
- return next.invoke(msg);
- }
-
- public int getCount() {
- return count;
- }
-
- public void setNext(Interceptor next) {
- this.next=next;
- }
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java
deleted file mode 100644
index 5a68024f2a..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSource.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.invocation.mock;
-
-public interface SimpleSource {
-
- public void invokeHello() throws Exception;
-
- public void invokeGoodbye() throws Exception;
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java
deleted file mode 100644
index 51025ba3a0..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleSourceImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.invocation.mock;
-
-public class SimpleSourceImpl implements SimpleSource {
-
- private SimpleTarget proxy;
-
- public SimpleSourceImpl(SimpleTarget proxy) {
- this.proxy = proxy;
- }
-
- public void invokeHello() throws Exception {
- proxy.hello("hello");
- }
-
- public void invokeGoodbye() throws Exception {
- proxy.goodbye("hello");
- }
-
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java
deleted file mode 100644
index e4aabd72a2..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTarget.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.invocation.mock;
-
-public interface SimpleTarget {
-
- public String hello(String message) throws Exception;
-
- public String goodbye(String message) throws Exception;
-
- public String echo(String message) throws Exception;
-
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java
deleted file mode 100644
index 16f70c020f..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/invocation/mock/SimpleTargetImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.invocation.mock;
-
-public class SimpleTargetImpl implements SimpleTarget {
-
- public SimpleTargetImpl() {
- super();
- }
-
- public String hello(String message) throws Exception {
- return message;
- }
-
- public String goodbye(String message) throws Exception {
- return message;
- }
-
- public String echo(String message) throws Exception {
- return message;
- }
-
-
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java
deleted file mode 100644
index f7ed7654d6..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockConfigContext.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.mock;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.core.builder.BuilderConfigException;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.builder.impl.AssemblyVisitor;
-import org.apache.tuscany.core.config.ConfigurationException;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.ConfigurationContext;
-import org.apache.tuscany.core.context.ScopeContext;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.model.assembly.Extensible;
-
-/**
- * A mock configuration context
- *
- * @version $Rev$ $Date$
- */
-public class MockConfigContext implements ConfigurationContext {
-
- private List<RuntimeConfigurationBuilder> builders = new ArrayList();
-
- public MockConfigContext(List<RuntimeConfigurationBuilder> builders) {
- this.builders=builders;
- }
-
- public void configure(Extensible model) throws ConfigurationException {
- }
-
- public void build(AggregateContext parent, Extensible model) throws BuilderConfigException {
- AssemblyVisitor visitor = new AssemblyVisitor(parent, builders);
- visitor.start(model);
- }
-
- public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException {
- }
-
- public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java
deleted file mode 100644
index dca6e337f1..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/MockFactory.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.mock;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
-import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
-import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
-import org.apache.tuscany.core.system.context.SystemAggregateContextImpl;
-import org.apache.tuscany.model.assembly.AggregatePart;
-import org.apache.tuscany.model.assembly.AssemblyModelContext;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.ConfiguredReference;
-import org.apache.tuscany.model.assembly.ConfiguredService;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.ExternalService;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.Reference;
-import org.apache.tuscany.model.assembly.Scope;
-import org.apache.tuscany.model.assembly.Service;
-import org.apache.tuscany.model.assembly.SimpleComponent;
-import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
-import org.apache.tuscany.model.types.java.JavaServiceContract;
-
-/**
- * Generates test components, modules, and runtime artifacts
- *
- * @version $Rev$ $Date$
- */
-public class MockFactory {
-
- private static SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
-
- private static AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(systemFactory, null, null);
-
- private MockFactory() {
- }
-
-
- /**
- * Creates a system component of the given type with the given name and scope
- */
- public static Component createSystemComponent(String name, Class type, Scope scope) {
-
- Component sc = null;
- if (AggregateContext.class.isAssignableFrom(type)) {
- sc = systemFactory.createModuleComponent();
- } else {
- sc = systemFactory.createSimpleComponent();
- }
- SystemImplementation impl = systemFactory.createSystemImplementation();
- impl.setImplementationClass(type);
- sc.setComponentImplementation(impl);
- Service s = systemFactory.createService();
- JavaServiceContract ji = systemFactory.createJavaServiceContract();
- s.setServiceContract(ji);
- ji.setScope(scope);
- impl.setComponentType(systemFactory.createComponentType());
- impl.getComponentType().getServices().add(s);
- sc.setName(name);
- sc.setComponentImplementation(impl);
- return sc;
- }
-
- /**
- * Creates an aggregate component with the given name
- */
- public static Component createAggregateComponent(String name) {
- Component sc = sc = systemFactory.createModuleComponent();
- SystemImplementation impl = systemFactory.createSystemImplementation();
- impl.setImplementationClass(AggregateContextImpl.class);
- sc.setComponentImplementation(impl);
- Service s = systemFactory.createService();
- JavaServiceContract ji = systemFactory.createJavaServiceContract();
- s.setServiceContract(ji);
- ji.setScope(Scope.AGGREGATE);
- impl.setComponentType(systemFactory.createComponentType());
- impl.getComponentType().getServices().add(s);
- sc.setName(name);
- sc.setComponentImplementation(impl);
- return sc;
- }
-
- /**
- * Creates an aggregate component with the given name
- */
- public static Component createSystemAggregateComponent(String name) {
- Component sc = sc = systemFactory.createModuleComponent();
- SystemImplementation impl = systemFactory.createSystemImplementation();
- impl.setImplementationClass(SystemAggregateContextImpl.class);
- sc.setComponentImplementation(impl);
- Service s = systemFactory.createService();
- JavaServiceContract ji = systemFactory.createJavaServiceContract();
- s.setServiceContract(ji);
- ji.setScope(Scope.AGGREGATE);
- impl.setComponentType(systemFactory.createComponentType());
- impl.getComponentType().getServices().add(s);
- sc.setName(name);
- sc.setComponentImplementation(impl);
- return sc;
- }
-
- /**
- * Creates and initializes a system component of the given type with the given name and scope
- */
- public static Component createSystemInitializedComponent(String name, Class type, Scope scope) {
- Component sc = createSystemComponent(name,type,scope);
- sc.initialize(assemblyContext);
- return sc;
- }
-
- /**
- * Creates a basic entry point with no configured reference using the system binding
- *
- * @param name the name of the entry point
- * @param interfaz the inteface exposed by the entry point
- * @param refName the name of the entry point reference
- */
- public static EntryPoint createEPSystemBinding(String name, Class interfaz, String refName) {
- return createEPSystemBinding(name, interfaz, refName, null);
- }
-
- /**
- * Creates an entry point wired to the given target (e.g. component, external service) using the system binding
- *
- * @param name the name of the entry point
- * @param interfaz the inteface exposed by the entry point
- * @param refName the name of the entry point reference
- * @param target the target the entry point is wired to
- */
- public static EntryPoint createEPSystemBinding(String name, Class interfaz, String refName, AggregatePart target) {
- JavaServiceContract contract = systemFactory.createJavaServiceContract();
- contract.setInterface(interfaz);
-
- EntryPoint ep = systemFactory.createEntryPoint();
- ep.setName(name);
-
- Reference ref = systemFactory.createReference();
- ref.setName(refName);
- ref.setServiceContract(contract);
- ConfiguredReference configuredReference = systemFactory.createConfiguredReference();
- configuredReference.setReference(ref);
- Service service = systemFactory.createService();
- service.setServiceContract(contract);
-
- ConfiguredService cService = systemFactory.createConfiguredService();
- cService.setService(service);
- cService.initialize(assemblyContext);
-
- configuredReference.getTargetConfiguredServices().add(cService);
- ep.setConfiguredReference(configuredReference);
-
- Service epService = systemFactory.createService();
- epService.setServiceContract(contract);
-
- ConfiguredService epCService = systemFactory.createConfiguredService();
- epCService.initialize(assemblyContext);
- epCService.setService(epService);
-
- ep.setConfiguredService(epCService);
- SystemBinding binding = systemFactory.createSystemBinding();
- ep.getBindings().add(binding);
- if (target != null) {
- if (target instanceof Component) {
- ((Component) target).getConfiguredServices().add(cService);
- // cService.
- } else if (target instanceof ExternalService) {
- ((ExternalService) target).setConfiguredService(cService);
- }
- target.initialize(assemblyContext);
- }
- ep.initialize(null);
- return ep;
- }
-
- /**
- * Creates an entry point that should be wired to the given target (e.g. component, external service) using the
- * system binding. The system assembly process should resolve the target name to an actual target configuration.
- *
- * @param name the name of the entry point
- * @param interfaz the inteface exposed by the entry point
- * @param refName the name of the entry point reference
- * @param componentName the name of the target to resolve
- */
- public static EntryPoint createEntryPointWithStringRef(String name, Class interfaz, String refName, String componentName) {
- EntryPoint ep = createEPSystemBinding(name, interfaz, refName, null);
- ConfiguredReference cRef = systemFactory.createConfiguredReference();
- Reference ref = systemFactory.createReference();
- cRef.setReference(ref);
- Service service = systemFactory.createService();
- service.setName(componentName);
- ConfiguredService cService = systemFactory.createConfiguredService();
- cService.setService(service);
- cRef.getTargetConfiguredServices().add(cService);
- cRef.initialize(assemblyContext);
- cService.initialize(assemblyContext);
- ep.setConfiguredReference(cRef);
- ep.initialize(assemblyContext);
- return ep;
- }
-
- /**
- * Creates an external service configured with a {@link SystemBinding}
- */
- public static ExternalService createESSystemBinding(String name, String refName) {
- ExternalService es = systemFactory.createExternalService();
- es.setName(name);
- ConfiguredService configuredService = systemFactory.createConfiguredService();
- es.setConfiguredService(configuredService);
- SystemBinding binding = systemFactory.createSystemBinding();
- binding.setTargetName(refName);
- es.getBindings().add(binding);
- es.initialize(null);
- return es;
- }
-
- /**
- * Creates an external service that specifies an autowire of the given type
- */
- public static ExternalService createAutowirableExternalService(String name, Class type) {
- ExternalService es = systemFactory.createExternalService();
- es.setName(name);
- JavaServiceContract inter = systemFactory.createJavaServiceContract();
- inter.setInterface(type);
- Service service = systemFactory.createService();
- service.setServiceContract(inter);
- ConfiguredService cService = systemFactory.createConfiguredService();
- cService.setService(service);
- cService.initialize(assemblyContext);
- es.setConfiguredService(cService);
- es.getBindings().add(systemFactory.createSystemBinding());
- es.initialize(null);
- return es;
- }
-
- /**
- * Creates a test system module component with a module-scoped component and entry point
- */
- public static Module createSystemModule(){
- Module module = systemFactory.createModule();
- module.setName("system.module");
-
- // create test component
- SimpleComponent component = systemFactory.createSimpleComponent();
- component.setName("TestService1");
- SystemImplementation impl = systemFactory.createSystemImplementation();
- impl.setComponentType(systemFactory.createComponentType());
- impl.setImplementationClass(ModuleScopeSystemComponentImpl.class);
- component.setComponentImplementation(impl);
- Service s = systemFactory.createService();
- JavaServiceContract contract = systemFactory.createJavaServiceContract();
- s.setServiceContract(contract);
- contract.setScope(Scope.MODULE);
- impl.getComponentType().getServices().add(s);
- component.setComponentImplementation(impl);
-
- // create the entry point
- EntryPoint ep = createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "target", component);
-
- module.getEntryPoints().add(ep);
- module.getComponents().add(component);
- module.initialize(assemblyContext);
- return module;
- }
-
- /**
- * Creates a test system module component with a module-scoped component and entry point
- */
- public static Module createSystemChildModule() {
- Module module = systemFactory.createModule();
- module.setName("system.test.module");
-
- // create test component
- SimpleComponent component = systemFactory.createSimpleComponent();
- component.setName("TestService2");
- SystemImplementation impl = systemFactory.createSystemImplementation();
- impl.setImplementationClass(ModuleScopeSystemComponentImpl.class);
- component.setComponentImplementation(impl);
- Service s = systemFactory.createService();
- JavaServiceContract ji = systemFactory.createJavaServiceContract();
- s.setServiceContract(ji);
- ji.setScope(Scope.MODULE);
- impl.setComponentType(systemFactory.createComponentType());
- impl.getComponentType().getServices().add(s);
- component.setComponentImplementation(impl);
-
- // create the entry point
- EntryPoint ep = createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "target", component);
-
- module.getEntryPoints().add(ep);
- module.getComponents().add(component);
- module.initialize(assemblyContext);
- return module;
- }
-
- /**
- * Returns a collection of bootstrap configuration builders
- */
- public static List<RuntimeConfigurationBuilder> createSystemBuilders() {
- List<RuntimeConfigurationBuilder> builders = new ArrayList();
- builders.add((new SystemComponentContextBuilder()));
- builders.add(new SystemEntryPointBuilder());
- builders.add(new SystemExternalServiceBuilder());
- return builders;
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java
deleted file mode 100644
index 99aeb1b8f3..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/GenericSystemComponent.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.apache.tuscany.core.mock.component;
-
-public interface GenericSystemComponent {
-
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java
deleted file mode 100644
index dabbd9e4ef..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponent.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.mock.component;
-
-import org.osoa.sca.annotations.Scope;
-
-/**
- * @version $Rev$ $Date$
- */
-@Scope("MODULE")
-public interface ModuleScopeSystemComponent extends GenericSystemComponent {
-
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java
deleted file mode 100644
index 58afde9354..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/mock/component/ModuleScopeSystemComponentImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.mock.component;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ModuleScopeSystemComponentImpl implements ModuleScopeSystemComponent {
-
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java
deleted file mode 100644
index a0af27f563..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeBootTestCase.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.runtime;
-
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.Context;
-import org.apache.tuscany.core.context.EventContext;
-import org.apache.tuscany.core.mock.MockFactory;
-
-/**
- * Tests runtime boot scenarios
- *
- * @version $Rev$ $Date$
- */
-public class RuntimeBootTestCase extends TestCase {
- private RuntimeContext runtime;
-
- public void testContextParents() {
- AggregateContext rootContext = runtime.getRootContext();
- assertNotNull(rootContext);
- assertEquals("tuscany.root", rootContext.getName());
- assertSame(runtime, rootContext.getParent());
- assertSame(rootContext, runtime.getContext("tuscany.root"));
-
- AggregateContext systemContext = runtime.getSystemContext();
- assertNotNull(systemContext);
- assertEquals("tuscany.system", systemContext.getName());
- assertSame(runtime, systemContext.getParent());
- assertSame(systemContext, runtime.getContext("tuscany.system"));
- }
-
- public void testRuntimeLifecycle() {
- assertEquals(Context.RUNNING, runtime.getLifecycleState());
- runtime.stop();
-
- assertEquals(Context.STOPPED, runtime.getLifecycleState());
-
- runtime.start();
- assertEquals(Context.RUNNING, runtime.getLifecycleState());
- }
-
- public void testIncrementalBoot() throws Exception{
-
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
- // start the runtime context
- RuntimeContext runtimeContext = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtimeContext.start();
-
- AggregateContext system = runtimeContext.getSystemContext();
- Assert.assertNotNull(system);
- // register system components
- system.registerModelObject(MockFactory.createSystemModule());
- // start the module scope
- system.fireEvent(EventContext.MODULE_START, null);
- // register the first module
-
- // register the second module
-
- // start the modules
-
- system.fireEvent(EventContext.MODULE_STOP, null);
- runtimeContext.stop();
- Assert.assertEquals(Context.STOPPED,system.getLifecycleState());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- runtime = new RuntimeContextImpl();
- runtime.start();
- }
-
- protected void tearDown() throws Exception {
- runtime.stop();
- super.tearDown();
- }
-}
-
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java
deleted file mode 100644
index 0ea1ad7bb8..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/runtime/RuntimeContextImplTestCase.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.runtime;
-
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.config.ConfigurationException;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.Context;
-import org.apache.tuscany.core.context.EventContext;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.core.system.context.TestBuilder;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.ConfiguredService;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.ExternalService;
-import org.apache.tuscany.model.assembly.Scope;
-import org.apache.tuscany.model.assembly.Service;
-import org.apache.tuscany.model.types.java.JavaServiceContract;
-import org.osoa.sca.ServiceUnavailableException;
-
-/**
- * Performs basic tests on the runtime context
- *
- * @version $Rev$ $Date$
- */
-public class RuntimeContextImplTestCase extends TestCase {
-
- private SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
-
- private List<RuntimeConfigurationBuilder> builders;
-
- /**
- * Tests explicit wiring of an external service to a system entry point that is wired to a child system module entry
- * point
- */
- public void testSystemExplicitWiring() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
-
- AggregateContext root = runtime.getRootContext();
- Assert.assertNotNull(root);
- Assert.assertTrue(root.getLifecycleState() == Context.RUNNING);
-
- AggregateContext system = runtime.getSystemContext();
- Assert.assertNotNull(system);
- system.registerModelObject(MockFactory.createSystemModule());
-
- // register a child system context
- system.registerModelObject(MockFactory.createSystemAggregateComponent("system.child"));
- AggregateContext systemChild = (AggregateContext) system.getContext("system.child");
- systemChild.registerModelObject(MockFactory.createSystemChildModule());
-
- // register a top-level system entry point that exposes the child entry point
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "ref");
- ep.getBindings().add(systemFactory.createSystemBinding());
- Service service = systemFactory.createService();
- service.setName("system.child/TestService2EP");
- ((ConfiguredService) ep.getConfiguredReference().getTargetConfiguredServices().get(0)).setService(service);
- JavaServiceContract inter = systemFactory.createJavaServiceContract();
- inter.setInterface(ModuleScopeSystemComponentImpl.class);
- service.setServiceContract(inter);
- system.registerModelObject(ep);
- system.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(system.locateInstance("TestService1"));
- Assert.assertNotNull(system.locateInstance("TestService2EP"));
-
- // create a test module and wire an external service to the system entry point
- Component moduleComponent = MockFactory.createAggregateComponent("test.module");
- runtime.registerModelObject(moduleComponent);
- AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("test.module");
- Assert.assertNotNull(moduleContext);
- ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
- moduleContext.registerModelObject(es);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(moduleContext.locateInstance("TestService2ES"));
-
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- system.fireEvent(EventContext.MODULE_STOP, null);
- runtime.stop();
- }
-
- /**
- * Tests autowiring an external service to a system entry point
- */
- public void testSystemAutoWiring() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
-
- AggregateContext root = runtime.getRootContext();
- Assert.assertNotNull(root);
- Assert.assertTrue(root.getLifecycleState() == Context.RUNNING);
-
- AggregateContext system = runtime.getSystemContext();
- Assert.assertNotNull(system);
- system.registerModelObject(MockFactory.createSystemModule());
-
- // create a test module and wire an external service to the system entry point
- Component moduleComponent = MockFactory.createAggregateComponent("test.module");
- runtime.registerModelObject(moduleComponent);
- AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("test.module");
- Assert.assertNotNull(moduleContext);
- ExternalService es = MockFactory.createAutowirableExternalService("TestService2ES", ModuleScopeSystemComponent.class);
- moduleContext.registerModelObject(es);
-
- system.fireEvent(EventContext.MODULE_START, null);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- // test that the autowire was resolved
- Assert.assertNotNull(moduleContext.locateInstance("TestService2ES"));
-
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- system.fireEvent(EventContext.MODULE_STOP, null);
- runtime.stop();
- }
-
- public void testServiceNotFound() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
-
- // create a test module
- Component moduleComponent = MockFactory.createAggregateComponent("module");
- runtime.registerModelObject(moduleComponent);
- AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("module");
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- try {
- moduleContext.locateService("TestService");
- fail("Expected " + ServiceUnavailableException.class.getName());
- } catch (ServiceUnavailableException e) {
- // expected
- }
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- runtime.stop();
- }
-
- public void testExternalServiceReferenceNotFound() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
- AggregateContext system = runtime.getSystemContext();
-
- // create a test module
- Component moduleComponent = MockFactory.createAggregateComponent("module");
- runtime.registerModelObject(moduleComponent);
- AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("module");
- ExternalService es = MockFactory.createESSystemBinding("TestServiceES", "tuscany.system/TestService1xEP");
- moduleContext.registerModelObject(es);
-
- // start the modules and test inter-module system wires
- system.fireEvent(EventContext.MODULE_START, null);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- try {
- moduleContext.locateService("TestServiceES");
- fail("Expected " + ServiceUnavailableException.class.getName());
- } catch (ServiceUnavailableException e) {
- // expected
- }
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- system.fireEvent(EventContext.MODULE_STOP, null);
- runtime.stop();
- }
-
- public void testEntryPointReferenceNotFound() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
-
- // create a test module
- Component moduleComponent = MockFactory.createAggregateComponent("module");
- runtime.registerModelObject(moduleComponent);
-
- Component component = MockFactory.createSystemComponent("NoService", ModuleScopeSystemComponentImpl.class, Scope.MODULE);
- // do not register the above component!
-
- AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("module");
- moduleContext.registerModelObject(MockFactory.createEPSystemBinding("TestServiceEP", ModuleScopeSystemComponent.class,
- "NoReference", component));
-
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- try {
- moduleContext.locateService("TestServiceEP");
- fail("Expected " + ServiceUnavailableException.class.getName());
- } catch (ServiceUnavailableException e) {
- // expected
- }
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- runtime.stop();
- }
-
- /**
- * Test two module components that have external services wired to entry points contained in each
- */
- public void testCircularWires() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
-
- // create a test modules
- Component module1 = MockFactory.createAggregateComponent("module1");
- runtime.registerModelObject(module1);
- Component module2 = MockFactory.createAggregateComponent("module2");
- runtime.registerModelObject(module2);
-
- AggregateContextImpl moduleContext1 = (AggregateContextImpl) runtime.getContext("module1");
- AggregateContextImpl moduleContext2 = (AggregateContextImpl) runtime.getContext("module2");
-
- Component component1 = MockFactory.createSystemComponent("Component1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- EntryPoint entryPoint1 = MockFactory.createEPSystemBinding("EntryPoint1", ModuleScopeSystemComponent.class, "Component1",
- component1);
- ExternalService externalService1 = MockFactory.createESSystemBinding("ExternalService1", "module2/EntryPoint2");
- moduleContext1.registerModelObject(component1);
- moduleContext1.registerModelObject(entryPoint1);
- moduleContext1.registerModelObject(externalService1);
-
- Component component2 = MockFactory.createSystemComponent("Component2", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- EntryPoint entryPoint2 = MockFactory.createEPSystemBinding("EntryPoint2", ModuleScopeSystemComponent.class, "Component2",
- component2);
- ExternalService externalService2 = MockFactory.createESSystemBinding("ExternalService2", "module1/EntryPoint1");
- moduleContext2.registerModelObject(component2);
- moduleContext2.registerModelObject(entryPoint2);
- moduleContext2.registerModelObject(externalService2);
-
- moduleContext1.fireEvent(EventContext.MODULE_START, null);
- moduleContext2.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(moduleContext2.locateInstance("ExternalService2"));
- Assert.assertNotNull(moduleContext1.locateInstance("ExternalService1"));
- runtime.stop();
- }
-
- /**
- * Tests that a circular reference between an external service in one module and an entry point in another is caught
- * as an error condition FIXME this must be implemented
- */
- public void testInterModuleCircularReference() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
-
- // create a test modules
- Component module1 = MockFactory.createAggregateComponent("module1");
- runtime.registerModelObject(module1);
- Component module2 = MockFactory.createAggregateComponent("module2");
- runtime.registerModelObject(module2);
-
- AggregateContextImpl moduleContext1 = (AggregateContextImpl) runtime.getContext("module1");
- AggregateContextImpl moduleContext2 = (AggregateContextImpl) runtime.getContext("module2");
- ExternalService externalService1 = MockFactory.createESSystemBinding("ExternalService1", "module2/EntryPoint2");
- EntryPoint entryPoint1 = MockFactory.createEPSystemBinding("EntryPoint1", ModuleScopeSystemComponent.class,
- "ExternalService1", externalService1);
- ExternalService externalService2 = MockFactory.createESSystemBinding("ExternalService2", "module1/EntryPoint1");
- EntryPoint entryPoint2 = MockFactory.createEPSystemBinding("EntryPoint2", ModuleScopeSystemComponent.class,
- "ExternalService2", externalService2);
- try {
- // FIXME this should throw a circular reference exception
- moduleContext1.registerModelObject(externalService1);
- moduleContext1.registerModelObject(entryPoint1);
- moduleContext2.registerModelObject(externalService2);
- moduleContext2.registerModelObject(entryPoint2);
- // FIXME implement fail("Expected " + ConfigurationException.class.getName());
- } catch (ConfigurationException e) {
- // expected
- }
- }
-
- public void testRuntimeBuilderAutowire() throws Exception {
-
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders, null);
- runtime.start();
-
- AggregateContext system = runtime.getSystemContext();
- Component builder = MockFactory.createSystemComponent("TestBuilder", TestBuilder.class, Scope.MODULE);
- system.registerModelObject(builder);
- system.fireEvent(EventContext.MODULE_START, null);
- Component module1 = MockFactory.createAggregateComponent("module1");
- runtime.registerModelObject(module1);
- runtime.getContext("module1");
- Assert.assertTrue(((TestBuilder) system.locateInstance("TestBuilder")).invoked());
- system.fireEvent(EventContext.MODULE_STOP, null);
- runtime.stop();
-
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- builders = MockFactory.createSystemBuilders();
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java
deleted file mode 100644
index c73554a1df..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilderTestCase.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.system.builder;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfiguration;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.InstanceContext;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
-import org.apache.tuscany.core.mock.MockConfigContext;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.ConfiguredProperty;
-import org.apache.tuscany.model.assembly.Property;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Tests to that system components are built properly
- *
- * @version $Rev$ $Date$
- */
-public class SystemComponentContextBuilderTestCase extends TestCase {
-
- private SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
-
- public void testComponentContextBuilder() throws Exception {
- SystemComponentContextBuilder builder = new SystemComponentContextBuilder();
- Component component = MockFactory.createSystemComponent("test", SystemComponentImpl.class,
- Scope.AGGREGATE);
-
- ConfiguredProperty cProp = factory.createConfiguredProperty();
- Property prop = factory.createProperty();
- prop.setName("testInt");
- cProp.setValue(1);
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- cProp = factory.createConfiguredProperty();
- prop = factory.createProperty();
- prop.setName("testString");
- cProp.setValue("test");
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- cProp = factory.createConfiguredProperty();
- prop = factory.createProperty();
- prop.setName("testDouble");
- cProp.setValue(1d);
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- cProp = factory.createConfiguredProperty();
- prop = factory.createProperty();
- prop.setName("testFloat");
- cProp.setValue(1f);
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- cProp = factory.createConfiguredProperty();
- prop = factory.createProperty();
- prop.setName("testShort");
- cProp.setValue((short) 1);
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- cProp = factory.createConfiguredProperty();
- prop = factory.createProperty();
- prop.setName("testByte");
- cProp.setValue((byte) 1);
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- cProp = factory.createConfiguredProperty();
- prop = factory.createProperty();
- prop.setName("testBoolean");
- cProp.setValue(Boolean.TRUE);
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- cProp = factory.createConfiguredProperty();
- prop = factory.createProperty();
- prop.setName("testChar");
- cProp.setValue('1');
- cProp.setProperty(prop);
- component.getConfiguredProperties().add(cProp);
-
- builder.build(component, createContext());
- RuntimeConfiguration config = (RuntimeConfiguration) component.getComponentImplementation().getRuntimeConfiguration();
- Assert.assertNotNull(config);
- InstanceContext ctx = (InstanceContext) config.createInstanceContext();
-
- ctx.start();
- SystemComponentImpl instance = (SystemComponentImpl) ctx.getInstance(null);
- Assert.assertNotNull(instance.getConfigContext());
- Assert.assertNotNull(instance.getParentContext());
- Assert.assertNotNull(instance.getAutowireContext());
- Assert.assertNotNull(instance.getConfigContextSetter());
- Assert.assertNotNull(instance.getParentContextSetter());
- Assert.assertNotNull(instance.getAutowireContextSetter());
- Assert.assertEquals(1, instance.getTestInt());
- Assert.assertEquals(1d, instance.getTestDouble());
- Assert.assertEquals(1f, instance.getTestFloat());
- Assert.assertEquals((short) 1, instance.getTestShort());
- Assert.assertTrue(instance.getTestBoolean());
- Assert.assertEquals('1', instance.getTestChar());
- Assert.assertEquals((byte) 1, instance.getTestByte());
- Assert.assertEquals("test", instance.getTestString());
-
- Assert.assertTrue(instance.initialized());
- ctx.stop();
- Assert.assertTrue(instance.destroyed());
- }
-
- private static AggregateContext createContext() {
- return new AggregateContextImpl("test.parent", null, new DefaultScopeStrategy(), new EventContextImpl(),
- new MockConfigContext(null), new NullMonitorFactory());
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java
deleted file mode 100644
index b86f79e504..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/SystemComponentImpl.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.system.builder;
-
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.AutowireContext;
-import org.apache.tuscany.core.context.ConfigurationContext;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.system.annotation.ParentContext;
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Property;
-
-/**
- * A system component used for unit testing
- *
- * @version $Rev$ $Date$
- */
-public class SystemComponentImpl {
-
- @Autowire
- private ConfigurationContext ctx;
-
- @ParentContext
- private AggregateContext parent;
-
- @Autowire
- private AutowireContext autowireCtx;
-
- private ConfigurationContext ctxSetter;
-
- private AggregateContext parentSetter;
-
- private AutowireContext autowireCtxSetter;
-
- public ConfigurationContext getConfigContext() {
- return ctx;
- }
-
- public AggregateContext getParentContext() {
- return parent;
- }
-
- public AutowireContext getAutowireContext() {
- return autowireCtx;
- }
-
- @Autowire
- public void setConfigContext(ConfigurationContext configCtx) {
- ctxSetter = configCtx;
- }
-
- public ConfigurationContext getConfigContextSetter() {
- return ctxSetter;
- }
-
- @ParentContext
- public void setParentContex(AggregateContext ctx) {
- parentSetter = ctx;
- }
-
- public AggregateContext getParentContextSetter() {
- return parentSetter;
- }
-
- @Autowire
- public void setAutowireContext(AutowireContext ctx) {
- autowireCtxSetter = ctx;
- }
-
- public AutowireContext getAutowireContextSetter() {
- return autowireCtx;
- }
-
- private boolean inited;
-
- @Init
- public void init(){
- inited=true;
- }
-
- public boolean initialized(){
- return (inited == true);
- }
-
- private boolean destroyed;
-
- @Destroy
- public void destroy(){
- destroyed=true;
- }
-
- public boolean destroyed(){
- return (destroyed == true);
- }
-
- @Property
- private int testInt;
-
- public int getTestInt(){
- return testInt;
- }
-
- @Property
- private double testDouble;
-
- public double getTestDouble(){
- return testDouble;
- }
-
- @Property
- private float testFloat;
-
- public float getTestFloat(){
- return testFloat;
- }
-
- @Property
- private short testShort;
-
- public short getTestShort(){
- return testShort;
- }
-
- @Property
- private boolean testBoolean;
-
- public boolean getTestBoolean(){
- return testBoolean;
- }
-
- @Property
- private byte testByte;
-
- public byte getTestByte(){
- return testByte;
- }
-
- @Property
- private char testChar;
-
- public char getTestChar(){
- return testChar;
- }
-
- @Property
- private String testString;
-
- public String getTestString(){
- return testString;
- }
-
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java
deleted file mode 100644
index fe3d7f222b..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/builder/impl/AssemblyVisitorTestCase.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.system.builder.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.resource.ResourceLoader;
-import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
-import org.apache.tuscany.core.builder.BuilderException;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.builder.impl.AssemblyVisitor;
-import org.apache.tuscany.core.context.Context;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.AssemblyModelContext;
-import org.apache.tuscany.model.assembly.AssemblyModelObject;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.ConfiguredPort;
-import org.apache.tuscany.model.assembly.ConfiguredReference;
-import org.apache.tuscany.model.assembly.ConfiguredService;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.Reference;
-import org.apache.tuscany.model.assembly.RuntimeConfigurationHolder;
-import org.apache.tuscany.model.assembly.Service;
-import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
-import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
-import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
-import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
-import org.apache.tuscany.model.types.java.JavaServiceContract;
-
-/**
- * Tests decorating a logical configuration model
- *
- * @version $Rev$ $Date$
- */
-public class AssemblyVisitorTestCase extends TestCase {
-
- private static final Object MARKER = new Object();
-
- private SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
- private AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(factory, null, null);
-
- public void testModelVisit() throws Exception {
-
- Component component = factory.createSimpleComponent();
- SystemImplementation impl = factory.createSystemImplementation();
- impl.setComponentType(factory.createComponentType());
- component.setComponentImplementation(impl);
- ConfiguredReference cRef = factory.createConfiguredReference();
- Reference ref = factory.createReference();
- cRef.setReference(ref);
- component.getConfiguredReferences().add(cRef);
-
- EntryPoint ep = factory.createEntryPoint();
- JavaServiceContract contract = factory.createJavaServiceContract();
- contract.setInterface(ModuleScopeSystemComponent.class);
- Service service = factory.createService();
- service.setServiceContract(contract);
- ConfiguredService cService = factory.createConfiguredService();
- cService.setService(service);
- cService.initialize(assemblyContext);
- ep.setConfiguredService(cService);
- SystemBinding binding = factory.createSystemBinding();
- ep.getBindings().add(binding);
- ConfiguredReference cEpRef = factory.createConfiguredReference();
- Reference epRef = factory.createReference();
- cEpRef.setReference(epRef);
- ep.setConfiguredReference(cEpRef);
-
- ep.initialize(assemblyContext);
- Module module = factory.createModule();
- module.getComponents().add(component);
- module.getEntryPoints().add(ep);
-
- List<RuntimeConfigurationBuilder> builders = new ArrayList();
- builders.add(new TestBuilder());
- AssemblyVisitor visitor = new AssemblyVisitor(null, builders);
- module.initialize(assemblyContext);
- visitor.start(module);
-
- Assert.assertSame(MARKER, impl.getRuntimeConfiguration());
- Assert.assertSame(MARKER, cRef.getRuntimeConfiguration());
- Assert.assertSame(MARKER, cRef.getProxyFactory());
- Assert.assertSame(MARKER, binding.getRuntimeConfiguration());
- Assert.assertSame(MARKER, cEpRef.getRuntimeConfiguration());
- Assert.assertSame(MARKER, cEpRef.getProxyFactory());
- Assert.assertSame(MARKER, module.getRuntimeConfiguration());
-
- }
-
- private static class TestBuilder implements RuntimeConfigurationBuilder {
- public void build(AssemblyModelObject model, Context context) throws BuilderException {
- if (model instanceof ConfiguredPort) {
- ((ConfiguredPort) model).setProxyFactory(MARKER);
- }
- if (model instanceof RuntimeConfigurationHolder) {
- ((RuntimeConfigurationHolder) model).setRuntimeConfiguration(MARKER);
- }
- }
-
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java
deleted file mode 100644
index 40feca3b7c..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextRegisterTestCase.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.system.context;
-
-import java.util.List;
-
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateComponentContextRegisterTestCase;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
-import org.apache.tuscany.core.mock.MockConfigContext;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-
-/**
- * Tests registration of model objects for an system aggregate context
- *
- * @version $Rev$ $Date$
- */
-public class SystemAggregateComponentContextRegisterTestCase extends AggregateComponentContextRegisterTestCase {
-
- protected AggregateContext createContext() {
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
- AggregateContext moduleContext = new SystemAggregateContextImpl("test.context", null,
- null, new DefaultScopeStrategy(), new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
- return moduleContext;
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java
deleted file mode 100644
index 55fd6502f0..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateComponentContextTestCase.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.system.context;
-
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.EventContext;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.mock.MockConfigContext;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Tests the system aggregate context
- *
- * @version $Rev$ $Date$
- */
-public class SystemAggregateComponentContextTestCase extends TestCase {
-
- public void testChildLocate() throws Exception {
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
-
- SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
- system.start();
-
- Component aggregateComponent = MockFactory.createAggregateComponent("system.child");
- system.registerModelObject(aggregateComponent);
- AggregateContext childContext = (AggregateContext) system.getContext("system.child");
- Assert.assertNotNull(childContext);
-
- Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- childContext.registerModelObject(component);
- childContext.registerModelObject(ep);
- childContext.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(system.locateInstance("system.child/TestService1EP"));
- childContext.fireEvent(EventContext.MODULE_STOP, null);
- system.stop();
- }
-
- public void testAutowire() throws Exception {
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
- SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
-
- Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- system.registerModelObject(component);
- system.registerModelObject(ep);
- system.start();
- system.fireEvent(EventContext.MODULE_START, null);
- Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
- system.fireEvent(EventContext.MODULE_STOP, null);
- system.stop();
- }
-
- public void testAutowireRegisterAfterStart() throws Exception {
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
-
- SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
-
- Component component = MockFactory.createSystemComponent("TestService1", ModuleScopeSystemComponentImpl.class,
- Scope.MODULE);
- system.registerModelObject(component);
- system.start();
- system.fireEvent(EventContext.MODULE_START, null);
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService1EP", ModuleScopeSystemComponent.class, "TestService1",
- component);
- system.registerModelObject(ep);
- Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
- system.fireEvent(EventContext.MODULE_STOP, null);
- system.stop();
- }
-
- public void testAutowireModuleRegister() throws Exception {
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
-
- SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
- system.registerModelObject(MockFactory.createSystemModule());
- system.start();
- system.fireEvent(EventContext.MODULE_START, null);
- Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
- system.fireEvent(EventContext.MODULE_STOP, null);
- system.stop();
- }
-
- public void testAutowireModuleRegisterAfterStart() throws Exception {
- List<RuntimeConfigurationBuilder> builders = MockFactory.createSystemBuilders();
- SystemAggregateContextImpl system = new SystemAggregateContextImpl("system", null, null, new SystemScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(builders), new NullMonitorFactory());
- system.start();
- system.fireEvent(EventContext.MODULE_START, null);
- system.registerModelObject(MockFactory.createSystemModule());
- Assert.assertSame(system.locateInstance("TestService1EP"), system.resolveInstance(ModuleScopeSystemComponent.class));
- system.fireEvent(EventContext.MODULE_STOP, null);
- system.stop();
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java
deleted file mode 100644
index 39dd0c050a..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemAggregateHierarchyTestCase.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.system.context;
-
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AbstractAggregateHierarchyTests;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
-import org.apache.tuscany.core.mock.MockConfigContext;
-import org.apache.tuscany.core.mock.MockFactory;
-
-/**
- * Performs testing of various hierarchical scenarios
- *
- * @version $Rev$ $Date$
- */
-public class SystemAggregateHierarchyTestCase extends AbstractAggregateHierarchyTests {
-
-
-
- protected AggregateContext createContextHierachy() throws Exception {
- List<RuntimeConfigurationBuilder> mockBuilders = MockFactory.createSystemBuilders();
- AggregateContext parent = new SystemAggregateContextImpl("test.parent", null, null, new DefaultScopeStrategy(),
- new EventContextImpl(), new MockConfigContext(mockBuilders), new NullMonitorFactory());
- parent.registerModelObject(MockFactory.createAggregateComponent("test.child"));
- parent.start();
- AggregateContext child = (AggregateContext) parent.getContext("test.child");
- Assert.assertNotNull(child);
- return parent;
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java
deleted file mode 100644
index 62f4b689c3..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemBootstrapTestCase.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
- * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-package org.apache.tuscany.core.system.context;
-
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.AutowireContext;
-import org.apache.tuscany.core.context.EventContext;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.mock.MockFactory;
-import org.apache.tuscany.core.mock.component.GenericSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponent;
-import org.apache.tuscany.core.mock.component.ModuleScopeSystemComponentImpl;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.core.runtime.RuntimeContextImpl;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.ConfiguredService;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.ExternalService;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.Service;
-import org.apache.tuscany.model.types.java.JavaServiceContract;
-
-/**
- * Tests bootstrapping a system module
- *
- * @version $Rev$ $Date$
- */
-public class SystemBootstrapTestCase extends TestCase {
- private List<RuntimeConfigurationBuilder> builders;
-
- private SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
-
- /**
- * Simulates booting a runtime process
- */
- public void testBoot() throws Exception {
- RuntimeContext runtimeContext = new RuntimeContextImpl(new NullMonitorFactory(), null, builders,null);
- runtimeContext.start();
-
- AggregateContext systemContext = runtimeContext.getSystemContext();
- Assert.assertNotNull(systemContext);
- Module systemModule = MockFactory.createSystemModule();
- // MockSystemAssemblyFactory.buildModule(systemModule, systemContext);
- systemContext.registerModelObject(systemModule);
-
- // create a test module
- Component moduleComponent = MockFactory.createAggregateComponent("module");
- runtimeContext.registerModelObject(moduleComponent);
- AggregateContextImpl moduleContext = (AggregateContextImpl) runtimeContext.getContext("module");
- Assert.assertNotNull(moduleContext);
- ExternalService es = MockFactory.createESSystemBinding("TestServiceES", "tuscany.system/TestService1EP");
- moduleContext.registerModelObject(es);
-
- // start the modules and test inter-module system wires
- systemContext.fireEvent(EventContext.MODULE_START, null);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
-
- Assert.assertNotNull(systemContext.locateInstance("TestService1EP"));
- GenericSystemComponent testService = (GenericSystemComponent) systemContext.locateInstance("TestService1");
- Assert.assertNotNull(testService);
- GenericSystemComponent testES = (GenericSystemComponent) moduleContext.locateInstance("TestServiceES");
- Assert.assertNotNull(testES);
- Assert.assertSame(testService, testES);
- }
-
- public void testRuntimeBoot() throws Exception {
- RuntimeContext runtime = new RuntimeContextImpl(new NullMonitorFactory(), null, builders,null);
- runtime.start();
- runtime.getRootContext();
-
- AggregateContext system = runtime.getSystemContext();
- system.registerModelObject(MockFactory.createSystemModule());
- system.registerModelObject(MockFactory.createSystemAggregateComponent("module2"));
- AggregateContext systemModule2 = (AggregateContext) system.getContext("module2");
- systemModule2.registerModelObject(MockFactory.createSystemChildModule());
-
- EntryPoint ep = MockFactory.createEPSystemBinding("TestService2EP", ModuleScopeSystemComponent.class, "ref");
- ep.getBindings().add(factory.createSystemBinding());
- Service service = factory.createService();
- service.setName("module2/TestService2EP");
- JavaServiceContract inter = factory.createJavaServiceContract();
- inter.setInterface(ModuleScopeSystemComponentImpl.class);
- service.setServiceContract(inter);
- ((ConfiguredService) ep.getConfiguredReference().getTargetConfiguredServices().get(0)).setService(service);
- system.registerModelObject(ep);
- system.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(system.locateInstance("TestService1"));
- Assert.assertNotNull(system.locateInstance("TestService2EP"));
-
- Assert.assertNotNull(((AutowireContext) system).resolveInstance(ModuleScopeSystemComponent.class));
- // create a test module
- Component moduleComponent = MockFactory.createAggregateComponent("test.module");
- runtime.registerModelObject(moduleComponent);
- AggregateContextImpl moduleContext = (AggregateContextImpl) runtime.getContext("test.module");
- Assert.assertNotNull(moduleContext);
- ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
- moduleContext.registerModelObject(es);
- moduleContext.fireEvent(EventContext.MODULE_START, null);
- Assert.assertNotNull(moduleContext.locateInstance("TestService2ES"));
-
- moduleContext.fireEvent(EventContext.MODULE_STOP, null);
- system.fireEvent(EventContext.MODULE_STOP, null);
- runtime.stop();
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- builders = MockFactory.createSystemBuilders();
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java
deleted file mode 100644
index 3c9aadac45..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/SystemObjectRegistrationTestCase.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *
- * Copyright 2005 BEA Systems Inc.
- * Copyright 2005 International Business Machines Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.core.system.context;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.core.runtime.RuntimeContextImpl;
-import org.apache.tuscany.core.context.SystemAggregateContext;
-import org.apache.tuscany.core.context.EventContext;
-import org.apache.tuscany.core.config.ConfigurationException;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SystemObjectRegistrationTestCase extends TestCase {
- private RuntimeContext runtime;
- private SystemAggregateContext systemContext;
-
- public void testRegistration() throws ConfigurationException {
- MockComponent instance = new MockComponent();
- systemContext.registerJavaObject("foo", instance);
- assertSame(instance, systemContext.locateInstance("foo"));
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- runtime = new RuntimeContextImpl();
- runtime.start();
- systemContext = runtime.getSystemContext();
- systemContext.fireEvent(EventContext.MODULE_START, null);
- }
-
- protected void tearDown() throws Exception {
- runtime.stop();
- super.tearDown();
- }
-
- private static class MockComponent {
- public String hello(String message) {
- return message;
- }
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java b/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java
deleted file mode 100644
index 6bdcd896a1..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/java/org/apache/tuscany/core/system/context/TestBuilder.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.tuscany.core.system.context;
-
-import org.apache.tuscany.core.builder.BuilderException;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.model.assembly.AssemblyModelObject;
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("MODULE")
-public class TestBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
-
- @Autowire
- private RuntimeContext runtime;
-
- private boolean invoked = false;
-
- public TestBuilder() {
- super();
- }
-
- @Init(eager = true)
- public void init() {
- runtime.addBuilder(this);
- }
-
- public void build(AssemblyModelObject object, AggregateContext context) throws BuilderException {
- invoked = true;
- }
-
- public boolean invoked() {
- return invoked;
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module b/tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module
deleted file mode 100644
index b261cbe6c0..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/resources/org/apache/tuscany/core/config/ModuleComponentLoaderTest1.module
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
- xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
- name="ModuleComponentLoaderTest1">
-
- <component name="HelloWorldServiceComponent">
- <implementation.java class="org.apache.tuscany.samples.helloworld.HelloWorldServiceComponentImpl"/>
- </component>
-</module>
diff --git a/tags/java-stable-20060304/sca/core/src/test/resources/system.fragment b/tags/java-stable-20060304/sca/core/src/test/resources/system.fragment
deleted file mode 100644
index 74d04561cd..0000000000
--- a/tags/java-stable-20060304/sca/core/src/test/resources/system.fragment
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<!--
- Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
- xmlns:system="http://org.apache.tuscany/xmlns/system/0.9"
- name="org.apache.tuscany.container.java">
-
-</moduleFragment>