summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration')
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java24
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java42
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java29
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java61
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java59
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java24
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java61
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java189
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java68
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java53
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.java68
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java99
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java261
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java73
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java61
-rw-r--r--tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java741
16 files changed, 0 insertions, 1913 deletions
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java
deleted file mode 100644
index 58180674b3..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProvider.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.container.java.integration;
-
-/**
- * @version $Rev$ $Date$
- */
-public interface GreetingProvider {
- String getGreeting(String name, String locale);
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java
deleted file mode 100644
index fef068c22e..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/GreetingProviderImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.container.java.integration;
-
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Service;
-
-/**
- * @version $Rev$ $Date$
- */
-@Service(GreetingProvider.class)
-public class GreetingProviderImpl implements GreetingProvider {
-
- public String greeting;
-
- @Property
- public void setGreeting(String greeting) {
- this.greeting = greeting;
- }
-
- public String getGreeting(String name, String locale) {
- if ("fr".equals(locale)) {
- return "Bonjour " + name;
- } else {
- return greeting + name;
- }
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java
deleted file mode 100644
index 9ff58f2d8d..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldImpl.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.container.java.integration;
-
-import org.osoa.sca.annotations.Service;
-
-/**
- * @version $Rev$ $Date$
- */
-@Service(HelloWorldService.class)
-public class HelloWorldImpl implements HelloWorldService {
- public String getGreetings(String name) {
- return "Hello " + name;
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
deleted file mode 100644
index aa5069c232..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.container.java.integration;
-
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Service;
-import org.apache.tuscany.core.sdo.helper.SDOHelper;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.DataFactory;
-
-/**
- * @version $Rev$ $Date$
- */
-@Service(HelloWorldService.class)
-public class HelloWorldMCImpl implements HelloWorldService {
-
- @Property
- public String locale;
-
- public String getBar() {
- return bar;
- }
-
- @Property(name= "bar", required=true)
- public void setXBar(String bar) {
- this.bar = bar;
- }
-
- public String bar;
-
- @Reference(name="greetingProvider")
- public void setGreetingProvider(GreetingProvider greetingProvider) {
- this.greetingProvider2 = greetingProvider;
- }
-
- public GreetingProvider greetingProvider2;
-
- @Reference(required=false)
- public GreetingProvider foo;
-
- public String getGreetings(String name) {
- return greetingProvider2.getGreeting(name, locale);
- }
-
-
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java
deleted file mode 100644
index 5a73abd45a..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldMCTestCase.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.container.java.integration;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.client.TuscanyRuntime;
-import org.osoa.sca.CurrentModuleContext;
-import org.osoa.sca.ModuleContext;
-
-/**
- * @version $Rev$ $Date$
- */
-public class HelloWorldMCTestCase extends TestCase {
- private ClassLoader oldCL;
-
- public void testHelloWorld() throws Exception {
- TuscanyRuntime tuscany = new TuscanyRuntime("test", "foo");
- tuscany.start();
- ModuleContext moduleContext = CurrentModuleContext.getContext();
- assertNotNull(moduleContext);
- assertEquals("foo", moduleContext.getURI());
- HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
- assertNotNull(helloworldService);
-
- String value = helloworldService .getGreetings("World");
- assertEquals("Hello World", value);
- tuscany.stop();
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- URL url = getClass().getResource("/helloworldmc/");
- ClassLoader cl = new URLClassLoader(new URL[]{url}, getClass().getClassLoader());
- oldCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(cl);
- }
-
- protected void tearDown() throws Exception {
- Thread.currentThread().setContextClassLoader(oldCL);
- super.tearDown();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java
deleted file mode 100644
index 3abb99d7e0..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldService.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.container.java.integration;
-
-/**
- * @version $Rev$ $Date$
- */
-public interface HelloWorldService {
- public String getGreetings(String name);
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java
deleted file mode 100644
index c714b416e4..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/HelloWorldTestCase.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation
- *
- * 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.container.java.integration;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import junit.framework.TestCase;
-import org.osoa.sca.CurrentModuleContext;
-import org.osoa.sca.ModuleContext;
-
-import org.apache.tuscany.core.client.TuscanyRuntime;
-
-/**
- * @version $Rev$ $Date$
- */
-public class HelloWorldTestCase extends TestCase {
- private ClassLoader oldCL;
-
- public void testHelloWorld() throws Exception {
- TuscanyRuntime tuscany = new TuscanyRuntime("test", null);
- tuscany.start();
- ModuleContext moduleContext = CurrentModuleContext.getContext();
- assertNotNull(moduleContext);
-
- HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
- assertNotNull(helloworldService);
-
- String value = helloworldService .getGreetings("World");
- assertEquals("Hello World", value);
-
- tuscany.stop();
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- URL url = getClass().getResource("/helloworld/");
- ClassLoader cl = new URLClassLoader(new URL[]{url}, getClass().getClassLoader());
- oldCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(cl);
- }
-
- protected void tearDown() throws Exception {
- Thread.currentThread().setContextClassLoader(oldCL);
- super.tearDown();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java
deleted file mode 100644
index f7cc2ed149..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaBuilderContextIntegrationTestCase.java
+++ /dev/null
@@ -1,189 +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.container.java.integration;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
-import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
-import org.apache.tuscany.container.java.builder.MockHandlerBuilder;
-import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
-import org.apache.tuscany.container.java.invocation.mock.MockHandler;
-import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.GenericComponent;
-import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry;
-import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
-import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
-import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
-import org.apache.tuscany.core.client.BootstrapHelper;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.event.ModuleStop;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.core.runtime.RuntimeContextImpl;
-import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
-import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
-import org.apache.tuscany.core.wire.service.WireFactoryService;
-
-/**
- * Verifies that the composite context implementation and java component builders construct references properly
- *
- * @version $Rev$ $Date$
- */
-public class JavaBuilderContextIntegrationTestCase extends TestCase {
- private ContextFactoryBuilderRegistry builderRegistry;
- private DefaultWireBuilder defaultWireBuilder;
- private NullMonitorFactory monitorFactory;
-
- public JavaBuilderContextIntegrationTestCase(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- monitorFactory = new NullMonitorFactory();
- builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
- defaultWireBuilder = new DefaultWireBuilder();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testRefWithSourceInterceptor() throws Exception {
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
- PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
- policyRegistry.registerSourceBuilder(interceptorBuilder);
- WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
- JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
-
- builderRegistry.register(javaBuilder);
-
- RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
- runtime.addBuilder(new JavaTargetWireBuilder());
- runtime.start();
- runtime.getRootContext().registerModelObject(
- MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModule());
- child.publish(new ModuleStart(this));
- GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- source.getGenericComponent().getString();
- Assert.assertEquals(1, mockInterceptor.getCount());
- source.getGenericComponent().getString();
- Assert.assertEquals(2, mockInterceptor.getCount());
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
- public void testRefWithSourceInterceptorHandler() throws Exception {
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
- MockHandler mockHandler = new MockHandler();
- MockHandlerBuilder handlerBuilder = new MockHandlerBuilder(mockHandler, true, true);
- PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
- policyRegistry.registerSourceBuilder(interceptorBuilder);
- policyRegistry.registerSourceBuilder(handlerBuilder);
- WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
- JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
-
- builderRegistry.register(javaBuilder);
- RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
- runtime.addBuilder(new JavaTargetWireBuilder());
- runtime.start();
- runtime.getRootContext().registerModelObject(
- MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModule());
- child.publish(new ModuleStart(this));
- GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- source.getGenericComponent().getString();
- Assert.assertEquals(1, mockInterceptor.getCount());
- Assert.assertEquals(1, mockHandler.getCount());
- source.getGenericComponent().getString();
- Assert.assertEquals(2, mockInterceptor.getCount());
- Assert.assertEquals(2, mockHandler.getCount());
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
- public void testRefWithTargetInterceptorHandler() throws Exception {
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- MockHandler mockHandler = new MockHandler();
- MockHandlerBuilder handlerBuilder = new MockHandlerBuilder(mockHandler, false, true);
- PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
- policyRegistry.registerSourceBuilder(interceptorBuilder);
- policyRegistry.registerSourceBuilder(handlerBuilder);
- WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
- JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
-
- builderRegistry.register(javaBuilder);
-
- RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
- runtime.addBuilder(new JavaTargetWireBuilder());
- runtime.start();
- runtime.getRootContext().registerModelObject(
- MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModule());
- child.publish(new ModuleStart(this));
- GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- source.getGenericComponent().getString();
- Assert.assertEquals(1, mockInterceptor.getCount());
- Assert.assertEquals(1, mockHandler.getCount());
- source.getGenericComponent().getString();
- Assert.assertEquals(2, mockInterceptor.getCount());
- Assert.assertEquals(2, mockHandler.getCount());
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
- public void testRefWithTargetInterceptor() throws Exception {
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- PolicyBuilderRegistry policyRegistry = new DefaultPolicyBuilderRegistry();
- policyRegistry.registerSourceBuilder(interceptorBuilder);
- WireFactoryService wireFactory = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
- JavaContextFactoryBuilder javaBuilder = new JavaContextFactoryBuilder(wireFactory);
-
- builderRegistry.register(javaBuilder);
-
- RuntimeContext runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, defaultWireBuilder);
- runtime.addBuilder(new JavaTargetWireBuilder());
-
- runtime.start();
- runtime.getRootContext().registerModelObject(
- MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModule());
- child.publish(new ModuleStart(this));
- GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- source.getGenericComponent().getString();
- Assert.assertEquals(1, mockInterceptor.getCount());
- source.getGenericComponent().getString();
- Assert.assertEquals(2, mockInterceptor.getCount());
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.java
deleted file mode 100644
index a5ec39480f..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaIntegrationTestCase.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.container.java.integration;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.common.monitor.MonitorFactory;
-import org.apache.tuscany.common.monitor.impl.NullMonitorFactory;
-import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
-import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
-import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry;
-import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
-import org.apache.tuscany.core.client.BootstrapHelper;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.core.runtime.RuntimeContextImpl;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.ModuleComponent;
-
-/**
- * Integration test that verifies container.java can be used to host components.
- *
- * @version $Rev$ $Date$
- */
-public class JavaIntegrationTestCase extends TestCase {
- private JavaAssemblyFactory factory;
- private RuntimeContext runtime;
-
- public void testModuleWithOneComponent() throws Exception {
- Module module = factory.createModule();
- ModuleComponent moduleComponent = factory.createModuleComponent();
- moduleComponent.setImplementation(module);
-
-// runtime.registerModelObject(moduleComponent);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // Create a factory for model objects
- factory = new JavaAssemblyFactoryImpl();
-
- // Create and bootstrap an empty Tuscany runtime
- MonitorFactory monitorFactory = new NullMonitorFactory();
- ContextFactoryBuilderRegistry builderRegistry = BootstrapHelper.bootstrapContextFactoryBuilders(monitorFactory);
- DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
- runtime = new RuntimeContextImpl(monitorFactory, builderRegistry, wireBuilder);
- runtime.start();
- }
-
- protected void tearDown() throws Exception {
- runtime.stop();
- super.tearDown();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java
deleted file mode 100644
index 6a9fca90c9..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/JavaRuntimeBootstrapTestCase.java
+++ /dev/null
@@ -1,53 +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.container.java.integration;
-
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.GenericComponent;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.Context;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * Ensures basic runtime with Java support boots properly
- *
- * @version $Rev$ $Date$
- */
-public class JavaRuntimeBootstrapTestCase extends TestCase {
-
- /**
- * Tests the runtime can be bootstrapped with Java builders and two module-scoped Java-based components can be wired
- */
- public void testRuntimeBoot() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD);
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule());
- testCtx.publish(new ModuleStart(this));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().getString();
- }
-
-}
-
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.java
deleted file mode 100644
index 8b7ed342c4..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/StartStopTestCase.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.container.java.integration;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.client.TuscanyRuntime;
-import org.osoa.sca.ModuleContext;
-import org.osoa.sca.CurrentModuleContext;
-
-/**
- * @version $Rev$ $Date$
- */
-public class StartStopTestCase extends TestCase {
- private ClassLoader oldCL;
-
- public void testHelloWorld() throws Exception {
- TuscanyRuntime tuscany = new TuscanyRuntime("test", null);
- tuscany.start();
- ModuleContext moduleContext = CurrentModuleContext.getContext();
- assertNotNull(moduleContext);
-
- HelloWorldService helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
- assertNotNull(helloworldService);
-
- String value = helloworldService .getGreetings("World");
- assertEquals("Hello World", value);
- tuscany.stop();
- tuscany = new TuscanyRuntime("test", null);
- tuscany.start();
- moduleContext = CurrentModuleContext.getContext();
- assertNotNull(moduleContext);
- helloworldService = (HelloWorldService) moduleContext.locateService("HelloWorld");
- assertNotNull(helloworldService);
- value = helloworldService .getGreetings("World");
- assertEquals("Hello World", value);
- tuscany.stop();
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- URL url = getClass().getResource("/helloworldmc/");
- ClassLoader cl = new URLClassLoader(new URL[]{url}, getClass().getClassLoader());
- oldCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(cl);
- }
-
- protected void tearDown() throws Exception {
- Thread.currentThread().setContextClassLoader(oldCL);
- super.tearDown();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java
deleted file mode 100644
index 17424669bc..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EPtoExternalServiceTestCase.java
+++ /dev/null
@@ -1,99 +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.container.java.integration.binding;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
-import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
-import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.EntryPointContext;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.event.ModuleStop;
-import org.apache.tuscany.core.context.event.RequestEnd;
-import org.apache.tuscany.core.context.event.RequestStart;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * @version $$Rev$$ $$Date$$
- */
-public class EPtoExternalServiceTestCase extends TestCase {
- private Method hello;
-
- /**
- * Tests wiring of an entry point directly to an external service
- */
- public void testEPtoESInvocation() throws Throwable {
- RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
- PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
- .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- registry.registerTargetBuilder(interceptorBuilder);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModuleWithEntryPointToExternalService());
- child.publish(new ModuleStart(this));
- Object id = new Object();
- child.publish(new RequestStart(this, id));
- EntryPointContext ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- InvocationHandler handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(0, mockInterceptor.getCount());
- Object response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("foo", response);
- Assert.assertEquals(1, mockInterceptor.getCount());
-
- ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- handler = (InvocationHandler) ctx.getHandler();
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("foo", response);
- child.publish(new RequestEnd(this, id));
-
- // second request
- Object id2 = new Object();
- child.publish(new RequestStart(this, id2));
- ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(2, mockInterceptor.getCount());
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("foo", response);
- Assert.assertEquals(3, mockInterceptor.getCount());
- child.publish(new RequestEnd(this, id2));
-
- child.publish(new ModuleStop(this));
- runtime.stop();
-
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- hello = HelloWorldService.class.getMethod("hello", String.class);
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
deleted file mode 100644
index f8ba1e2192..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/EntryPointToJavaTestCase.java
+++ /dev/null
@@ -1,261 +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.container.java.integration.binding;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
-import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
-import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.EntryPointContext;
-import org.apache.tuscany.core.context.event.HttpSessionBound;
-import org.apache.tuscany.core.context.event.HttpSessionEnd;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.event.ModuleStop;
-import org.apache.tuscany.core.context.event.RequestEnd;
-import org.apache.tuscany.core.context.event.RequestStart;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.model.assembly.Scope;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-/**
- * Tests basic entry point functionality with Java components
- *
- * @version $Rev$ $Date$
- */
-public class EntryPointToJavaTestCase extends TestCase {
-
- private Method hello;
-
- public void setUp() throws Exception {
- hello = HelloWorldService.class.getMethod("hello", String.class);
- }
-
- /**
- * Tests creation and wire of an entry point wired to a module-scoped service offered by a Java component
- */
- public void testEPtoJavaModuleScopeInvoke() throws Throwable {
- RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
- PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
- .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
-
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- registry.registerTargetBuilder(interceptorBuilder);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.MODULE));
- child.publish(new ModuleStart(this));
- Object id = new Object();
- child.publish(new RequestStart(this, id));
- EntryPointContext ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- InvocationHandler handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(0, mockInterceptor.getCount());
- Object response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(1, mockInterceptor.getCount());
- Object id2 = new Object();
- child.publish(new RequestStart(this, id2));
-
- // second request
- Object id3 = new Object();
- child.publish(new RequestStart(this, id3));
- ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(1, mockInterceptor.getCount());
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(2, mockInterceptor.getCount());
- HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
- Assert.assertEquals(2, service1.count());
- child.publish(new RequestEnd(this, id3));
-
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
- /**
- * Tests creation and wire of an entry point wired to a session-scoped service offered by a Java component
- */
- public void testEPtoJavaSessionScopeInvoke() throws Throwable {
- RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
- PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
- .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- registry.registerTargetBuilder(interceptorBuilder);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.SESSION));
- child.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- child.publish(new RequestStart(this, id));
- child.publish(new HttpSessionBound(this, session));
-
- EntryPointContext ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- InvocationHandler handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(0, mockInterceptor.getCount());
- Object response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(1, mockInterceptor.getCount());
- child.publish(new RequestEnd(this, id));
-
- Object id2 = new Object();
- child.publish(new RequestStart(this, id2));
- child.publish(new HttpSessionBound(this, session));
- EntryPointContext ctx2 = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx2);
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(2, mockInterceptor.getCount());
- HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
- Assert.assertEquals(2, service1.count());
- child.publish(new RequestEnd(this, id2));
- child.publish(new HttpSessionEnd(this, session));
-
- // second session
- Object session2 = new Object();
- child.publish(new RequestStart(this, new Object()));
- child.publish(new HttpSessionBound(this, session2));
-
- ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- Assert.assertEquals(2, mockInterceptor.getCount());
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(3, mockInterceptor.getCount());
- child.publish(new HttpSessionBound(this, session2));
-
- Object id3 = new Object();
- child.publish(new RequestStart(this, id3));
- child.publish(new HttpSessionBound(this, session2));
- ctx2 = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx2);
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(4, mockInterceptor.getCount());
- HelloWorldService service2 = (HelloWorldService) child.getContext("target").getInstance(null);
- Assert.assertEquals(2, service2.count());
- Assert.assertEquals(2, service1.count()); //ensure sessions not crossed
- child.publish(new RequestEnd(this, session2));
- child.publish(new HttpSessionBound(this, session2));
-
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
-
- /**
- * Tests creation and wire of an entry point wired to a module-scoped service offered by a Java component
- */
- public void testEPtoJavaStatelessInvoke() throws Throwable {
- RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
- PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
- .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- registry.registerTargetBuilder(interceptorBuilder);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.INSTANCE));
- child.publish(new ModuleStart(this));
- Object id = new Object();
- child.publish(new RequestStart(this, id));
- EntryPointContext ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- InvocationHandler handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(0, mockInterceptor.getCount());
- Object response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(1, mockInterceptor.getCount());
- child.publish(new RequestEnd(this, id));
-
- // second request
- Object id2 = new Object();
- child.publish(new RequestStart(this, id2));
- ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(1, mockInterceptor.getCount());
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(2, mockInterceptor.getCount());
- HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
- Assert.assertEquals(0, service1.count());
- child.publish(new RequestEnd(this, id));
-
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
- public void testEPtoJavaRequestInvoke() throws Throwable {
- RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
- PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
- .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- registry.registerTargetBuilder(interceptorBuilder);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModuleWithEntryPoint(Scope.REQUEST));
- child.publish(new ModuleStart(this));
- Object id = new Object();
- child.publish(new RequestStart(this, id));
- EntryPointContext ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- InvocationHandler handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(0, mockInterceptor.getCount());
- Object response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(1, mockInterceptor.getCount());
-
- ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- handler = (InvocationHandler) ctx.getHandler();
- response = handler.invoke(null, hello, new Object[]{"foo"});
- HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
- Assert.assertEquals(2, service1.count());
-
- child.publish(new RequestEnd(this, id));
-
- // second request
- Object id2 = new Object();
- child.publish(new RequestStart(this, id2));
- ctx = (EntryPointContext) child.getContext("source");
- Assert.assertNotNull(ctx);
- handler = (InvocationHandler) ctx.getHandler();
- Assert.assertEquals(2, mockInterceptor.getCount());
- response = handler.invoke(null, hello, new Object[]{"foo"});
- Assert.assertEquals("Hello foo", response);
- Assert.assertEquals(3, mockInterceptor.getCount());
- HelloWorldService service2 = (HelloWorldService) child.getContext("target").getInstance(null);
- Assert.assertEquals(1, service2.count());
- child.publish(new RequestEnd(this, id2));
-
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java
deleted file mode 100644
index 7357f973f7..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/ExternalServiceProxyInvokeTestCase.java
+++ /dev/null
@@ -1,73 +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.container.java.integration.binding;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
-import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
-import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.event.ModuleStop;
-import org.apache.tuscany.core.context.event.RequestEnd;
-import org.apache.tuscany.core.context.event.RequestStart;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-
-/**
- * @version $$Rev$$ $$Date$$
- */
-public class ExternalServiceProxyInvokeTestCase extends TestCase {
-
- /**
- * Tests that an external service can be invoked by locating a proxy to it as opposed to invoking it over a wire from another
- * source such as an entry point or external service.
- *
- * @throws Throwable
- */
- public void testProxyInvocation() throws Throwable {
- RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
- PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(MockFactory.SYSTEM_CHILD))
- .getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- registry.registerTargetBuilder(interceptorBuilder);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModuleWithEntryPointToExternalService());
- child.publish(new ModuleStart(this));
- Object id = new Object();
- child.publish(new RequestStart(this, id));
- HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
- Assert.assertEquals("foo", service1.hello("foo"));
-
- child.publish(new RequestEnd(this, id));
- child.publish(new ModuleStop(this));
- runtime.stop();
-
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java
deleted file mode 100644
index 90acb1c591..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/binding/JavaToExternalServiceTestCase.java
+++ /dev/null
@@ -1,61 +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.container.java.integration.binding;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.container.java.assembly.mock.HelloWorldService;
-import org.apache.tuscany.container.java.builder.MockInterceptorBuilder;
-import org.apache.tuscany.container.java.invocation.mock.MockSyncInterceptor;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.event.ModuleStop;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-
-/**
- * Tests basic Java to external service interaction
- *
- * @version $Rev$ $Date$
- */
-public class JavaToExternalServiceTestCase extends TestCase {
-
- /**
- * Tests an wire of an external service configured with the {@link org.apache.tuscany.container.java.mock.binding.foo.FooBinding}
- * from a Java component
- *
- * @throws Exception
- */
- public void testJavaToESInvoke() throws Exception {
- RuntimeContext runtime = MockFactory.registerFooBinding(MockFactory.createJavaRuntime());
- PolicyBuilderRegistry registry = (PolicyBuilderRegistry) ((CompositeContext) runtime.getSystemContext().getContext(
- MockFactory.SYSTEM_CHILD)).getContext(MockFactory.POLICY_BUILDER_REGISTRY).getInstance(null);
- MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
- MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
- registry.registerTargetBuilder(interceptorBuilder);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
- CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
- child.registerModelObject(MockFactory.createModuleWithExternalService());
- child.publish(new ModuleStart(this));
- HelloWorldService source = (HelloWorldService) child.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- Assert.assertEquals(0, mockInterceptor.getCount());
- Assert.assertEquals("foo", source.hello("foo"));
- Assert.assertEquals(1, mockInterceptor.getCount());
- child.publish(new ModuleStop(this));
- runtime.stop();
- }
-
-}
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java
deleted file mode 100644
index 89320f60e5..0000000000
--- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/integration/context/ScopeReferenceTestCase.java
+++ /dev/null
@@ -1,741 +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.container.java.integration.context;
-
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.GenericComponent;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.Context;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.event.RequestStart;
-import org.apache.tuscany.core.context.event.HttpSessionBound;
-import org.apache.tuscany.core.context.event.RequestEnd;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.model.assembly.Scope;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-/**
- * Tests scoping is properly handled for service references
- *
- * @version $Rev$ $Date$
- */
-public class ScopeReferenceTestCase extends TestCase {
-
- /**
- * Tests a module-to-module scoped wire is setup properly by the runtime
- */
- public void testModuleToModule() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule());
- testCtx.publish(new ModuleStart(this));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().getString();
- }
-
- /**
- * Tests a module-to-session scoped wire is setup properly by the runtime
- */
- public void testModuleToSession() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.SESSION));
- testCtx.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,id));
-
- //second session
- Object session2 = new Object();
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- testCtx.publish(new HttpSessionBound(this,session2));
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target2);
- Assert.assertTrue(!"foo".equals(target2.getString()));
-
- Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
- source.getGenericComponent().setString("bar");
- Assert.assertEquals("bar",target2.getString());
- Assert.assertEquals("bar",source.getGenericComponent().getString());
- //testCtx.fireEvent(EventContext.SESSION_NOTIFY,session);
-
- }
-
- /**
- * Tests a module-to-request scoped wire is setup properly by the runtime
- */
- public void testModuleToRequest() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.REQUEST));
- testCtx.publish(new ModuleStart(this));
-
- // first request
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,id));
-
- //second request
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target2);
- Assert.assertTrue(!"foo".equals(target2.getString()));
-
- Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
- source.getGenericComponent().setString("bar");
- Assert.assertEquals("bar",target2.getString());
- Assert.assertEquals("bar",source.getGenericComponent().getString());
-
- }
-
- /**
- * Tests a module-to-stateless scoped wire is setup properly by the runtime
- */
- public void testModuleToStateless() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.MODULE,Scope.INSTANCE));
- testCtx.publish(new ModuleStart(this));
-
- // first request
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertTrue(!"foo".equals(target.getString()));
- testCtx.publish(new RequestEnd(this,id));
-
- //second request
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target2);
- Assert.assertTrue(!"foo".equals(target2.getString()));
-
- Assert.assertTrue(!"foo".equals(source.getGenericComponent().getString()));
- source.getGenericComponent().setString("bar");
- Assert.assertTrue(!"bar".equals(target2.getString()));
- }
-
- /**
- * Tests a session-to-session scoped wire is setup properly by the runtime
- */
- public void testSessionToSession() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.SESSION));
- testCtx.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,id));
-
- //second session
- Object session2 = new Object();
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- testCtx.publish(new HttpSessionBound(this,session2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
-
- testCtx.publish(new RequestEnd(this,id2));
-
- }
-
-
- /**
- * Tests a session-to-module scoped wire is setup properly by the runtime
- */
- public void testSessionToModule() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.MODULE));
- testCtx.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,id));
-
- //second session
- Object session2 = new Object();
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- testCtx.publish(new HttpSessionBound(this,session2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals("foo",target2.getString());
- Assert.assertEquals("foo",source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
- Assert.assertEquals("baz",target.getString());
-
- testCtx.publish(new RequestEnd(this,session2));
-
- }
-
- /**
- * Tests a session-to-request scoped wire is setup properly by the runtime
- */
- public void testSessionToRequest() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.REQUEST));
- testCtx.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,session));
-
- //second session
- Object session2 = new Object();
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- testCtx.publish(new HttpSessionBound(this,session2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",target2.getString());
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
-
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,session));
-
- }
-
-
- /**
- * Tests a session-to-stateless scoped wire is setup properly by the runtime
- */
- public void testSessionToStateless() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.SESSION,Scope.INSTANCE));
- testCtx.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals(null,target.getString());
- testCtx.publish(new RequestEnd(this,session));
-
- //second session
- Object session2 = new Object();
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- testCtx.publish(new HttpSessionBound(this,session2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals(null,target2.getString()); //Note assumes no pooling
- Assert.assertEquals(null,source2.getGenericComponent().getString());
-
- Assert.assertEquals(null,target.getString()); //Note assumes no pooling
- testCtx.publish(new RequestEnd(this,session));
-
- }
-
- /**
- * Tests a request-to-request scoped wire is setup properly by the runtime
- */
- public void testRequestToRequest() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.REQUEST));
- testCtx.publish(new ModuleStart(this));
-
- // first request
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second request
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
- }
-
- /**
- * Tests a request-to-module scoped wire is setup properly by the runtime
- */
- public void testRequestToModule() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.MODULE));
- testCtx.publish(new ModuleStart(this));
-
- // first request
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second request
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals("foo",target2.getString());
- Assert.assertEquals("foo",source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
- Assert.assertEquals("baz",target.getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
- }
-
- /**
- * Tests a request-to-session scoped wire is setup properly by the runtime
- */
- public void testRequestToSession() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.SESSION));
- testCtx.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second request for session
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertEquals("foo",targetR2.getString());
- GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(sourceR2);
- Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second session
- Object session2 = new Object();
- Object id3 = new Object();
- testCtx.publish(new RequestStart(this,id3));
- testCtx.publish(new HttpSessionBound(this,session2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
-
- testCtx.publish(new RequestEnd(this,session2));
- Object id4 = new Object();
- testCtx.publish(new RequestStart(this,id4));
- testCtx.publish(new HttpSessionBound(this,session));
- testCtx.publish(new RequestEnd(this,session));
-
- }
-
-
- /**
- * Tests a request-to-stateless scoped wire is setup properly by the runtime
- */
- public void testRequestToStateless() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.REQUEST,Scope.INSTANCE));
- testCtx.publish(new ModuleStart(this));
-
- // first request
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals(null,target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second request
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- Assert.assertEquals(null,target2.getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
- }
-
-
- /**
- * Tests a stateless-to-stateless scoped wire is setup properly by the runtime
- */
- public void testStatelessToStateless() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.INSTANCE));
- testCtx.publish(new ModuleStart(this));
-
- // first request
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals(null,target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second request
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- Assert.assertEquals(null,target2.getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
- }
-
- /**
- * Tests a stateless-to-request scoped wire is setup properly by the runtime
- */
- public void testStatelessToRequest() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.REQUEST));
- testCtx.publish(new ModuleStart(this));
-
- // first request
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- GenericComponent targetR1 = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(targetR1);
- Assert.assertEquals("foo",target.getString());
-
- //second request
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
- }
-
- /**
- * Tests a stateless-to-session scoped wire is setup properly by the runtime
- */
- public void testStatelessToSession() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.SESSION));
- testCtx.publish(new ModuleStart(this));
-
- // first session
- Object session = new Object();
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second request for session
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- testCtx.publish(new HttpSessionBound(this,session));
- GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertEquals("foo",targetR2.getString());
- GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(sourceR2);
- Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second session
- Object session2 = new Object();
- Object id3 = new Object();
- testCtx.publish(new RequestStart(this,id3));
- testCtx.publish(new HttpSessionBound(this,session2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals(null,target2.getString());
- Assert.assertEquals(null,source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
-
- testCtx.publish(new RequestEnd(this,session2));
- Object id4 = new Object();
- testCtx.publish(new RequestStart(this,id4));
- testCtx.publish(new HttpSessionBound(this,session));
- testCtx.publish(new RequestEnd(this,session));
-
- }
-
-
- /**
- * Tests a stateless-to-module scoped wire is setup properly by the runtime
- */
- public void testStatelessToModule() throws Exception{
- RuntimeContext runtime = MockFactory.createJavaRuntime();
- Context ctx = runtime.getSystemContext().getContext("tuscany.system.child");
- Assert.assertNotNull(ctx);
- runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test"));
- CompositeContext testCtx = (CompositeContext) runtime.getRootContext().getContext("test");
- Assert.assertNotNull(testCtx);
- testCtx.registerModelObject(MockFactory.createModule(Scope.INSTANCE,Scope.MODULE));
- testCtx.publish(new ModuleStart(this));
-
- Object id = new Object();
- testCtx.publish(new RequestStart(this,id));
- GenericComponent source = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source);
- GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
- Assert.assertNotNull(target);
- source.getGenericComponent().setString("foo");
- Assert.assertEquals("foo",target.getString());
- testCtx.publish(new RequestEnd(this,new Object()));
-
- //second session
- Object id2 = new Object();
- testCtx.publish(new RequestStart(this,id2));
- GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
- Assert.assertNotNull(source2);
- GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
-
- Assert.assertNotNull(target2);
- Assert.assertEquals("foo",target2.getString());
- Assert.assertEquals("foo",source2.getGenericComponent().getString());
- source2.getGenericComponent().setString("baz");
- Assert.assertEquals("baz",source2.getGenericComponent().getString());
- Assert.assertEquals("baz",target2.getString());
-
- testCtx.publish(new RequestEnd(this,new Object()));
-
- }
-
-}
-