summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context')
-rw-r--r--tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java81
-rw-r--r--tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java59
-rw-r--r--tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java58
-rw-r--r--tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.java73
-rw-r--r--tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java95
-rw-r--r--tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java77
6 files changed, 0 insertions, 443 deletions
diff --git a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java b/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java
deleted file mode 100644
index ed91b9cb9b..0000000000
--- a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/DifferentInterfaceWireTestCase.java
+++ /dev/null
@@ -1,81 +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.context;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
-import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
-import org.apache.tuscany.container.java.mock.MockConfigContext;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.OtherTarget;
-import org.apache.tuscany.container.java.mock.components.Source;
-import org.apache.tuscany.container.java.mock.components.Target;
-import org.apache.tuscany.core.builder.ContextFactoryBuilder;
-import org.apache.tuscany.core.builder.WireBuilder;
-import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.AtomicContext;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
-import org.apache.tuscany.core.wire.service.WireFactoryService;
-import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Tests wires that have different interfaces on the source and target side
- *
- * @version $Rev$ $Date$
- */
-public class DifferentInterfaceWireTestCase extends TestCase {
-
- public void testMultiplicity() throws Exception {
-
- CompositeContext context = createContext();
- context.start();
- context.registerModelObject(MockFactory.createModuleWithWiredComponentsOfDifferentInterface(Scope.MODULE, Scope.MODULE));
- context.publish(new ModuleStart(this));
- Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
- Assert.assertNotNull(source);
- OtherTarget target = (OtherTarget) ((AtomicContext)context.getContext("target")).getTargetInstance();
- Assert.assertNotNull(target);
- // test setter injection
- List<Target> targets = source.getTargets();
- Assert.assertEquals(1, targets.size());
-
- // test field injection
- targets = source.getTargetsThroughField();
- Assert.assertEquals(1, targets.size());
- targets.get(0).setString("foo");
- Assert.assertEquals("foo",target.getString());
- }
-
- private CompositeContext createContext() {
- CompositeContextImpl context = new CompositeContextImpl();
- context.setName("system.context");
- List<ContextFactoryBuilder>builders = MockFactory.createSystemBuilders();
- WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
- builders.add(new JavaContextFactoryBuilder(wireService));
- List<WireBuilder> wireBuilders = new ArrayList<WireBuilder>();
- wireBuilders.add(new JavaTargetWireBuilder());
- context.setConfigurationContext(new MockConfigContext(builders,wireBuilders));
- return context;
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java b/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java
deleted file mode 100644
index c257a1f892..0000000000
--- a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextLifecycleTestCase.java
+++ /dev/null
@@ -1,59 +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.context;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
-import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Tests init and destroy lifecycle callbacks are handled properly
- *
- * @version $Rev$ $Date$
- */
-public class JavaAtomicContextLifecycleTestCase extends TestCase {
-
- public void testComponentNameSet() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
- ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
- context.start();
- ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
- Assert.assertNotNull(instance);
- Assert.assertEquals("TestServiceInit", instance.getName());
- context.stop();
- }
-
- public void testModuleContextSet() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
- ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
- context.start();
- ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
- Assert.assertNotNull(instance);
- Assert.assertEquals(mc, instance.getModuleContext());
- context.stop();
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java b/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java
deleted file mode 100644
index a79a04f5ab..0000000000
--- a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextMetadataInjectionTestCase.java
+++ /dev/null
@@ -1,58 +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.context;
-
-import junit.framework.TestCase;
-import junit.framework.Assert;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
-import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Tests SCA metadata such as <code>@ComponentName</code> and <code>@Context</code> are handled properly
- *
- * @version $Rev: 394173 $ $Date: 2006-04-14 11:54:59 -0700 (Fri, 14 Apr 2006) $
- */
-public class JavaAtomicContextMetadataInjectionTestCase extends TestCase {
-
- public void testComponentNameSet() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
- ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
- context.start();
- ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
- Assert.assertNotNull(instance);
- Assert.assertEquals("TestServiceInit", instance.getName());
- context.stop();
- }
-
- public void testModuleContextSet() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- JavaAtomicContext context = MockFactory.createPojoContext("TestServiceInit",
- ModuleScopeInitOnlyComponent.class, Scope.MODULE, mc);
- context.start();
- ModuleScopeInitOnlyComponent instance = (ModuleScopeInitOnlyComponent) context.getInstance(null);
- Assert.assertNotNull(instance);
- Assert.assertEquals(mc, instance.getModuleContext());
- context.stop();
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.java b/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.java
deleted file mode 100644
index 0a4527f405..0000000000
--- a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextNegativeMetadataTestCase.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.context;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.BadContextPojo;
-import org.apache.tuscany.container.java.mock.components.BadNamePojo;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Performs rudimentary negative testing by using malformed metadata on a POJO
- *
- * @version $Rev $Date
- */
-public class JavaAtomicContextNegativeMetadataTestCase extends TestCase {
-
- /**
- * Tests that a pojo with <code>@ComponentName</code> specified on a non-String type generates an error.
- * <p/>
- * <strong>NB:</strong> the test assumes an error with a message containing
- * "@ComponentName" is generated
- */
- public void testBadNameType() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- try {
- MockFactory.createPojoContext("BadNamePojo", BadNamePojo.class, Scope.MODULE, mc);
- } catch (NoSuchMethodException e) {
- if (e.getMessage().indexOf("@ComponentName") < 0) {
- throw e;
- }
- }
-
- }
-
- /**
- * Tests that a pojo with <code>@Context</code> specified on a non-ModuleContext type generates an error.
- * <p/>
- * <strong>NB:</strong> the test assumes an error with a message containing
- * "@Context" is generated
- */
- public void testContextType() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- try {
- MockFactory.createPojoContext("BadContextPojo", BadContextPojo.class, Scope.MODULE, mc);
- } catch (NoSuchMethodException e) {
- if (e.getMessage().indexOf("@Context") < 0) {
- throw e;
- }
- }
-
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java b/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java
deleted file mode 100644
index 96bff0cf2e..0000000000
--- a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/JavaAtomicContextScopeTestCase.java
+++ /dev/null
@@ -1,95 +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.context;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.container.java.assembly.JavaAssemblyFactory;
-import org.apache.tuscany.container.java.assembly.impl.JavaAssemblyFactoryImpl;
-import org.apache.tuscany.container.java.mock.components.GenericComponent;
-import org.apache.tuscany.container.java.mock.components.ModuleScopeComponentImpl;
-import org.apache.tuscany.container.java.mock.components.RequestScopeComponentImpl;
-import org.apache.tuscany.container.java.mock.components.SessionScopeComponentImpl;
-import org.apache.tuscany.container.java.mock.components.StatelessComponentImpl;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.core.injection.PojoObjectFactory;
-
-/**
- * Tests {@link JavaAtomicContext} to ensure it handles component scopes properly
- *
- * @version $Rev$ $Date$
- */
-public class JavaAtomicContextScopeTestCase extends TestCase {
-
- JavaAssemblyFactory factory = new JavaAssemblyFactoryImpl();
-
- public void testGetModuleInstance() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<ModuleScopeComponentImpl>(JavaIntrospectionHelper
- .getDefaultConstructor(ModuleScopeComponentImpl.class), null, null), false, null, null, false);
- GenericComponent service = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service);
- service.setString("foo");
- GenericComponent service2 = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service2);
- Assert.assertSame(service, service2);
- }
-
- public void testGetSessionInstance() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<SessionScopeComponentImpl>(JavaIntrospectionHelper
- .getDefaultConstructor(SessionScopeComponentImpl.class), null, null), false, null, null, false);
- GenericComponent service = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service);
- service.setString("foo");
- GenericComponent service2 = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service2);
- Assert.assertSame(service, service2);
- }
-
- public void testGetRequestInstance() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("mc");
- JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<RequestScopeComponentImpl>(JavaIntrospectionHelper
- .getDefaultConstructor(RequestScopeComponentImpl.class), null, null), false, null, null, false);
- GenericComponent service = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service);
- service.setString("foo");
- GenericComponent service2 = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service2);
- Assert.assertSame(service, service2);
- }
-
- public void testGetStatelessInstance() throws Exception {
- CompositeContext mc = new CompositeContextImpl();
- mc.setName("fooContext");
- JavaAtomicContext c = new JavaAtomicContext("foo", new PojoObjectFactory<StatelessComponentImpl>(JavaIntrospectionHelper
- .getDefaultConstructor(StatelessComponentImpl.class), null, null), false, null, null, true);
- GenericComponent service = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service);
- service.setString("foo");
- GenericComponent service2 = (GenericComponent) c.getInstance(null);
- Assert.assertNotNull(service2);
- Assert.assertTrue(!"foo".equals(service2.getString()));
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java b/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java
deleted file mode 100644
index a22a8dfce2..0000000000
--- a/tags/java-M1-20060522/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/MultiplicityTestCase.java
+++ /dev/null
@@ -1,77 +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.context;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.container.java.builder.JavaContextFactoryBuilder;
-import org.apache.tuscany.container.java.builder.JavaTargetWireBuilder;
-import org.apache.tuscany.container.java.mock.MockConfigContext;
-import org.apache.tuscany.container.java.mock.MockFactory;
-import org.apache.tuscany.container.java.mock.components.Source;
-import org.apache.tuscany.container.java.mock.components.Target;
-import org.apache.tuscany.core.builder.ContextFactoryBuilder;
-import org.apache.tuscany.core.builder.WireBuilder;
-import org.apache.tuscany.core.builder.system.DefaultPolicyBuilderRegistry;
-import org.apache.tuscany.core.context.CompositeContext;
-import org.apache.tuscany.core.context.AtomicContext;
-import org.apache.tuscany.core.context.event.ModuleStart;
-import org.apache.tuscany.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.core.wire.jdk.JDKWireFactoryFactory;
-import org.apache.tuscany.core.wire.service.WireFactoryService;
-import org.apache.tuscany.core.wire.service.DefaultWireFactoryService;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Tests wires that are configured with a multiplicity
- *
- * @version $Rev$ $Date$
- */
-public class MultiplicityTestCase extends TestCase {
-
- public void testMultiplicity() throws Exception {
- CompositeContext context = createContext();
- context.start();
- context.registerModelObject(MockFactory.createModuleWithWiredComponents(Scope.MODULE, Scope.MODULE));
- context.publish(new ModuleStart(this));
- Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
- Assert.assertNotNull(source);
- Target target = (Target) ((AtomicContext)context.getContext("target")).getTargetInstance();
- Assert.assertNotNull(target);
- // test setter injection
- List<Target> targets = source.getTargets();
- Assert.assertEquals(1, targets.size());
-
- // test field injection
- targets = source.getTargetsThroughField();
- Assert.assertEquals(1, targets.size());
- }
-
- private CompositeContext createContext() {
- CompositeContextImpl context = new CompositeContextImpl();
- context.setName("system.context");
- List<ContextFactoryBuilder>builders = MockFactory.createSystemBuilders();
- WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), new DefaultPolicyBuilderRegistry());
- builders.add(new JavaContextFactoryBuilder(wireService));
- List<WireBuilder> wireBuilders = new ArrayList<WireBuilder>();
- wireBuilders.add(new JavaTargetWireBuilder());
- context.setConfigurationContext(new MockConfigContext(builders,wireBuilders));
- return context;
- }
-}