diff options
Diffstat (limited to 'branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org')
65 files changed, 0 insertions, 3671 deletions
diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java deleted file mode 100644 index 9b65af0ab1..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.implementation.java.context; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.ComponentService; -import org.apache.tuscany.sca.assembly.Contract; -import org.apache.tuscany.sca.assembly.Property; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.Service; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; - -/** - * @version $Rev$ $Date$ - */ -public class ModelHelper { - - public static Property getProperty(JavaImplementation type, String name) { - for (Property prop : type.getProperties()) { - if (prop.getName().equals(name)) { - return prop; - } - } - return null; - } - - public static Reference getReference(JavaImplementation type, String name) { - for (Reference ref : type.getReferences()) { - if (ref.getName().equals(name)) { - return ref; - } - } - return null; - } - - public static Service getService(JavaImplementation type, String name) { - for (Service svc : type.getServices()) { - if (svc.getName().equals(name)) { - return svc; - } - } - return null; - } - - public static boolean matches(Contract contract, Class<?> type) { - Interface interface1 = contract.getInterfaceContract().getInterface(); - if (interface1 instanceof JavaInterface) { - return type == ((JavaInterface)interface1).getJavaClass(); - } else { - return false; - } - } - - public static ComponentService createService(AssemblyFactory factory, - JavaInterfaceFactory javaFactory, Class<?> type) { - org.apache.tuscany.sca.assembly.ComponentService ref = factory.createComponentService(); - ref.setName(type.getSimpleName()); - JavaInterface i = javaFactory.createJavaInterface(); - i.setJavaClass(type); - JavaInterfaceContract ic = javaFactory.createJavaInterfaceContract(); - ic.setInterface(i); - ref.setInterfaceContract(ic); - return ref; - } - - public static Reference createReference(AssemblyFactory factory, - JavaInterfaceFactory javaFactory, String name, Class<?> type) { - org.apache.tuscany.sca.assembly.Reference ref = factory.createReference(); - ref.setName(name); - JavaInterface i = javaFactory.createJavaInterface(); - i.setJavaClass(type); - JavaInterfaceContract ic = javaFactory.createJavaInterfaceContract(); - ic.setInterface(i); - ref.setInterfaceContract(ic); - return ref; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java deleted file mode 100644 index ba8da101c6..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.context; - -import junit.framework.TestCase; - - -/** - * Tests wires that are configured with a multiplicity - * - * @version $Rev$ $Date$ - */ -public class MultiplicityTestCase extends TestCase { - - public void testMultiplicity() throws Exception { - // TODO implement - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java deleted file mode 100644 index c098062bc8..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.context; - -import static org.easymock.EasyMock.createMock; -import junit.framework.TestCase; - -import org.apache.tuscany.sca.implementation.java.injection.EventInvoker; -import org.apache.tuscany.sca.scope.TargetDestructionException; -import org.apache.tuscany.sca.scope.TargetInitializationException; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ReflectiveInstanceWrapperTestCase extends TestCase { - private ReflectiveInstanceWrapper<Object> wrapper; - private Object instance; - private EventInvoker<Object> initInvoker; - private EventInvoker<Object> destroyInvoker; - - public void testWithNoCallbacks() { - wrapper = new ReflectiveInstanceWrapper<Object>(instance, null, null); - try { - wrapper.start(); - } catch (TargetInitializationException e) { - fail(); - } - try { - wrapper.stop(); - } catch (TargetDestructionException e) { - fail(); - } - } - - public void testWithStartCallback() { - initInvoker.invokeEvent(instance); - EasyMock.replay(initInvoker); - wrapper = new ReflectiveInstanceWrapper<Object>(instance, initInvoker, null); - try { - wrapper.start(); - } catch (TargetInitializationException e) { - fail(); - } - EasyMock.verify(initInvoker); - } - - public void testWithStopCallback() { - destroyInvoker.invokeEvent(instance); - EasyMock.replay(destroyInvoker); - wrapper = new ReflectiveInstanceWrapper<Object>(instance, null, destroyInvoker); - try { - wrapper.stop(); - } catch (TargetDestructionException e) { - fail(); - } - EasyMock.verify(destroyInvoker); - } - - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - instance = new Object(); - initInvoker = createMock(EventInvoker.class); - destroyInvoker = createMock(EventInvoker.class); - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java deleted file mode 100644 index 29dcfa8169..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import static org.easymock.EasyMock.createMock; - -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class CallbackWireObjectFactoryTestCase extends TestCase { - - @SuppressWarnings({"unchecked"}) - public void testCreateInstance() throws Exception { - ProxyFactory service = createMock(ProxyFactory.class); - Foo foo = new Foo() { - }; - EasyMock.expect(service.createCallbackProxy(EasyMock.eq(Foo.class), EasyMock.isA(List.class))).andReturn(foo); - EasyMock.replay(service); - List<RuntimeWire> wires = new ArrayList<RuntimeWire>(); - CallbackWireObjectFactory factory = new CallbackWireObjectFactory(Foo.class, service, wires); - assertEquals(foo, factory.getInstance()); - EasyMock.verify(service); - } - - private interface Foo { - - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java deleted file mode 100644 index cef5cd4788..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import java.lang.reflect.Field; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class FieldInjectorTestCase extends TestCase { - - protected Field protectedField; - - public void testIllegalAccess() throws Exception { - FieldInjector<Foo> injector = new FieldInjector<Foo>(protectedField, new SingletonObjectFactory<String>("foo")); - Foo foo = new Foo(); - injector.inject(foo); - assertEquals("foo", foo.hidden); - } - - - protected void setUp() throws Exception { - super.setUp(); - protectedField = Foo.class.getDeclaredField("hidden"); - } - - private class Foo { - private String hidden; - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java deleted file mode 100644 index 69d2696944..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import javax.naming.Context; -import javax.naming.NamingException; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.factory.ObjectCreationException; -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class JNDIObjectFactoryTestCase extends TestCase { - - public void testGetInstance() throws Exception { - Context ctx = EasyMock.createMock(Context.class); - EasyMock.expect(ctx.lookup(EasyMock.eq("foo"))).andReturn(new Foo()); - EasyMock.replay(ctx); - JNDIObjectFactory<Foo> factory = new JNDIObjectFactory<Foo>(ctx, "foo"); - assertTrue(factory.getInstance() instanceof Foo); // must do an instanceof b/c of type erasure - EasyMock.verify(ctx); - } - - public void testGetInstanceError() throws Exception { - Context ctx = EasyMock.createMock(Context.class); - EasyMock.expect(ctx.lookup(EasyMock.eq("foo"))).andThrow(new NamingException()); - EasyMock.replay(ctx); - JNDIObjectFactory<Foo> factory = new JNDIObjectFactory<Foo>(ctx, "foo"); - try { - factory.getInstance(); - fail(); - } catch (ObjectCreationException e) { - //expected - } - EasyMock.verify(ctx); - } - - - private class Foo { - - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java deleted file mode 100644 index 47fb224c1e..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import java.lang.reflect.Method; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class MethodEventInvokerTestCase extends TestCase { - private Method privateMethod; - private Method exceptionMethod; - - public void testIllegalAccess() throws Exception { - MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(privateMethod); - try { - injector.invokeEvent(new Foo()); - fail(); - } catch (AssertionError e) { - // expected - } - } - - public void testException() throws Exception { - MethodEventInvoker<MethodEventInvokerTestCase.Foo> injector = new MethodEventInvoker<Foo>(exceptionMethod); - try { - injector.invokeEvent(new Foo()); - fail(); - } catch (RuntimeException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - privateMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("hidden"); - exceptionMethod = MethodEventInvokerTestCase.Foo.class.getDeclaredMethod("exception"); - - } - - private class Foo { - - public void foo() { - } - - private void hidden() { - } - - public void exception() { - throw new RuntimeException(); - } - - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java deleted file mode 100644 index f2b8b97e5a..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import java.lang.reflect.Method; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.factory.ObjectCreationException; -import org.apache.tuscany.sca.factory.ObjectFactory; - -/** - * @version $Rev$ $Date$ - */ -public class MethodInjectorTestCase extends TestCase { - private Method fooMethod; - private Method privateMethod; - private Method exceptionMethod; - - public void testIllegalArgument() throws Exception { - ObjectFactory<Object> factory = new SingletonObjectFactory<Object>(new Object()); - MethodInjector<Foo> injector = new MethodInjector<Foo>(fooMethod, factory); - try { - injector.inject(new Foo()); - fail(); - } catch (ObjectCreationException e) { - // expected - } - } - - public void testException() throws Exception { - ObjectFactory<Object> factory = new SingletonObjectFactory<Object>("foo"); - MethodInjector<Foo> injector = new MethodInjector<Foo>(exceptionMethod, factory); - try { - injector.inject(new Foo()); - fail(); - } catch (RuntimeException e) { - // expected - } - } - - protected void setUp() throws Exception { - super.setUp(); - fooMethod = Foo.class.getMethod("foo", String.class); - privateMethod = Foo.class.getDeclaredMethod("hidden", String.class); - exceptionMethod = Foo.class.getDeclaredMethod("exception", String.class); - - } - - private class Foo { - - public void foo(String bar) { - } - - private void hidden(String bar) { - } - - public void exception(String bar) { - throw new RuntimeException(); - } - - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java deleted file mode 100644 index 6bf0658284..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.factory.ObjectFactory; - -/** - * @version $Rev$ $Date$ - */ -public class PojoObjectFactoryTestCase extends TestCase { - - private Constructor<Foo> ctor; - - public void testConstructorInjection() throws Exception { - List<ObjectFactory> initializers = new ArrayList<ObjectFactory>(); - initializers.add(new SingletonObjectFactory<String>("foo")); - PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor, initializers); - Foo foo = factory.getInstance(); - assertEquals("foo", foo.foo); - } - - /** - * Verifies null parameters can be passed to a constructor. This is valid when a reference is optional during - * constructor injection - */ - public void testConstructorInjectionOptionalParam() throws Exception { - List<ObjectFactory> initializers = new ArrayList<ObjectFactory>(); - initializers.add(null); - PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor, initializers); - Foo foo = factory.getInstance(); - assertNull(foo.foo); - } - - public void testConstructorInitializerInjection() throws Exception { - PojoObjectFactory<Foo> factory = new PojoObjectFactory<Foo>(ctor); - factory.setInitializerFactory(0, new SingletonObjectFactory<String>("foo")); - Foo foo = factory.getInstance(); - assertEquals("foo", foo.foo); - } - - protected void setUp() throws Exception { - super.setUp(); - ctor = Foo.class.getConstructor(String.class); - } - - private static class Foo { - - private String foo; - - public Foo(String foo) { - this.foo = foo; - } - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java deleted file mode 100644 index d8b981e952..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class RequestContextObjectFactoryTestCase extends TestCase { - - public void testInstanceCreate() { - RequestContextObjectFactory factory = new RequestContextObjectFactory(); - assertNotNull(factory.getInstance()); - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java deleted file mode 100644 index ed7a0e7d03..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import junit.framework.TestCase; - -import org.easymock.EasyMock; - -/** - * @version $Rev$ $Date$ - */ -public class ResourceObjectFactoryTestCase extends TestCase { - - public void testResolveFromHostByType() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn("foo"); - EasyMock.replay(host); - ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host); - assertEquals("foo", factory.getInstance()); - EasyMock.verify(host); - } - - public void testResolveFromHostByName() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class), - EasyMock.eq("sca://localhost/bar"))).andReturn("foo"); - EasyMock.replay(host); - ResourceObjectFactory<String> factory = - new ResourceObjectFactory<String>(String.class, "sca://localhost/bar", false, host); - assertEquals("foo", factory.getInstance()); - EasyMock.verify(host); - } - - - public void testResolveFromParentThenResolveFromHostNotFound() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(host); - ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, true, host); - assertNull(factory.getInstance()); - EasyMock.verify(host); - } - - public void testResolveByTypeNotFound() throws Exception { -// ResourceHost host = EasyMock.createMock(ResourceHost.class); -// EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null); -// EasyMock.replay(host); -// -// RuntimeWire wire = EasyMock.createMock(RuntimeWire.class); -// EasyMock.expect(wire.getTargetInstance()).andReturn(null); -// EasyMock.replay(wire); -// -// ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, false, host); -// try { -// factory.getInstance(); -// fail(); -// } catch (ResourceNotFoundException e) { -// //expected -// } -// EasyMock.verify(host); - } - - public void testResolveByTypeNotFoundOptional() throws Exception { - ResourceHost host = EasyMock.createMock(ResourceHost.class); - EasyMock.expect(host.resolveResource(EasyMock.eq(String.class))).andReturn(null); - EasyMock.replay(host); - ResourceObjectFactory<String> factory = new ResourceObjectFactory<String>(String.class, true, host); - assertNull(factory.getInstance()); - EasyMock.verify(host); - } - - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java deleted file mode 100644 index 40ad1b1e95..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.injection; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class SingletonObjectFactoryTestCase extends TestCase { - - public void testSingleton() throws Exception { - Object o = new Object(); - SingletonObjectFactory<Object> factory = new SingletonObjectFactory<Object>(o); - assertEquals(o, factory.getInstance()); - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java deleted file mode 100644 index 738775b9a3..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.integration; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.core.scope.ConversationalScopeContainer; -import org.apache.tuscany.sca.core.store.MemoryStore; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.scope.ScopeContainer; -import org.apache.tuscany.sca.store.StoreMonitor; -import org.easymock.EasyMock; - -/** - * Provides helper methods for setting up a partial runtime for conversational test cases. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractConversationTestCase extends TestCase { - protected ScopeContainer container; - protected MemoryStore store; - protected RuntimeComponent component; - - protected void createRuntime() { - store = new MemoryStore(EasyMock.createNiceMock(StoreMonitor.class)); - component = EasyMock.createMock(RuntimeComponent.class); - container = new ConversationalScopeContainer(store, component); - } - - protected void initializeRuntime() { - store.init(); - container.start(); - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME deleted file mode 100644 index 47fa0f0bc5..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.core.integration.conversation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URI; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler; -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.Scope; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.InstanceWrapper; -import org.apache.tuscany.spi.component.TargetNotFoundException; -import org.apache.tuscany.spi.wire.InvocationChain; -import org.apache.tuscany.spi.wire.Wire; -import org.easymock.EasyMock; -import org.osoa.sca.annotations.Conversational; -import org.osoa.sca.annotations.EndsConversation; - -/** - * Verifies conversational resources are cleaned up if the maximum idle time is exceeded - * - * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $ - */ -public abstract class ConversationIdleExpireTestCase extends AbstractConversationTestCase { - protected AtomicComponent target; - private JDKInvocationHandler handler; - private FooImpl targetInstance; - private Method operation1; - private Method operation2; - private final Object mutex = new Object(); - - public void testConversationExpire() throws Throwable { - workContext.setIdentifier(Scope.CONVERSATION, "12345A"); - // start the conversation - handler.invoke(operation1, null); - // verify the instance was persisted - assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); - synchronized (mutex) { - mutex.wait(100); - } - // verify the instance was expired - assertNull(store.readRecord(target, "12345A")); - // continue the conversation - should throw an error - try { - handler.invoke(operation2, null); - fail(); - } catch (TargetNotFoundException e) { - // expected - } - } - - - protected void setUp() throws Exception { - super.setUp(); - createRuntime(); - store.setReaperInterval(10); - initializeRuntime(); - - targetInstance = EasyMock.createMock(FooImpl.class); - targetInstance.operation1(); - targetInstance.operation2(); - targetInstance.end(); - EasyMock.replay(targetInstance); - target = createTarget(); - - Wire wire = MockFactory.createWire("foo", Foo.class); - for (InvocationChain chain : wire.getInvocationChains().values()) { - chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false)); - } - handler = new JDKInvocationHandler(Foo.class, wire, workContext); - operation1 = Foo.class.getMethod("operation1"); - operation2 = Foo.class.getMethod("operation2"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - container.stop(); - store.destroy(); - } - - private JavaAtomicComponent createTarget() throws Exception { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName(new URI("target")); - configuration.setMaxIdleTime(50); - configuration.setInstanceFactory(new MockPojoFactory(FooImpl.class.getConstructor())); - configuration.setImplementationClass(FooImpl.class); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(container); - component.start(); - return component; - } - - private class MockPojoFactory extends PojoObjectFactory<FooImpl> { - public MockPojoFactory(Constructor<FooImpl> ctr) { - super(ctr); - } - - public FooImpl getInstance() throws ObjectCreationException { - return targetInstance; - } - } - - @Conversational - public static interface Foo { - - void operation1(); - - void operation2(); - - @EndsConversation - void end(); - - } - - public static class FooImpl implements Foo { - - public void operation1() { - } - - public void operation2() { - } - - @EndsConversation - public void end() { - } - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME deleted file mode 100644 index 36e221a1e9..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.core.integration.conversation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URI; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler; -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.wire.InvocationChain; -import org.apache.tuscany.spi.wire.Wire; -import org.easymock.EasyMock; -import org.osoa.sca.annotations.Conversational; -import org.osoa.sca.annotations.EndsConversation; - -/** - * Verifies conversational resources are cleaned up if the maximum age is exceeded - * - * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $ - */ -public abstract class ConversationMaxAgeExpireTestCase extends AbstractConversationTestCase { - protected AtomicComponent target; - private JDKInvocationHandler handler; - private FooImpl targetInstance; - private Method operation1; - private Method operation2; - private final Object mutex = new Object(); - - public void testConversationExpire() throws Throwable { -/* - workContext.setIdentifier(org.apache.tuscany.spi.model.Scope.CONVERSATION, "12345A"); - // start the conversation - handler.invoke(operation1, null); - // verify the instance was persisted - assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); - synchronized (mutex) { - mutex.wait(100); - } - // verify the instance was expired - assertNull(store.readRecord(target, "12345A")); - // continue the conversation - should throw an error - try { - handler.invoke(operation2, null); - fail(); - } catch (TargetNotFoundException e) { - // expected - } -*/ - } - - - protected void setUp() throws Exception { - super.setUp(); - createRuntime(); - store.setReaperInterval(10); - initializeRuntime(); - - targetInstance = EasyMock.createMock(FooImpl.class); - targetInstance.operation1(); - targetInstance.operation2(); - targetInstance.end(); - EasyMock.replay(targetInstance); - target = createTarget(); - // create source component mock - JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class); - EasyMock.expect(source.getUri()).andReturn(URI.create("source")).atLeastOnce(); - EasyMock.replay(source); - - Wire wire = MockFactory.createWire("foo", Foo.class); - for (InvocationChain chain : wire.getInvocationChains().values()) { - chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false)); - } - handler = new JDKInvocationHandler(Foo.class, wire, workContext); - operation1 = Foo.class.getMethod("operation1"); - operation2 = Foo.class.getMethod("operation2"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - container.stop(); - store.destroy(); - } - - private AtomicComponent createTarget() throws Exception { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName(new URI("target")); - configuration.setMaxAge(50); - Constructor<FooImpl> ctor = FooImpl.class.getConstructor(); - configuration.setInstanceFactory(new MockPojoFactory(ctor)); - configuration.setImplementationClass(FooImpl.class); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(container); - component.start(); - return component; - } - - private class MockPojoFactory extends PojoObjectFactory<FooImpl> { - public MockPojoFactory(Constructor<FooImpl> ctr) { - super(ctr); - } - - public FooImpl getInstance() throws ObjectCreationException { - return targetInstance; - } - } - - @Conversational - public static interface Foo { - - void operation1(); - - void operation2(); - - @EndsConversation - void end(); - - } - - public static class FooImpl implements Foo { - - public void operation1() { - } - - public void operation2() { - } - - @EndsConversation - public void end() { - } - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME deleted file mode 100644 index 1872eea709..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.core.integration.conversation; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URI; - -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler; -import org.apache.tuscany.spi.ObjectCreationException; -import org.apache.tuscany.spi.Scope; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.InstanceWrapper; -import org.apache.tuscany.spi.wire.InvocationChain; -import org.apache.tuscany.spi.wire.Wire; -import org.easymock.EasyMock; -import org.osoa.sca.annotations.Conversational; -import org.osoa.sca.annotations.EndsConversation; - -/** - * Verifies start, continue and end conversation invocations are processed properly. Checks that a target instance is - * properly instantiated and persisted in the store. Additionally verifies that invocations are dispatched to a target - * instance, and that start, continue, and end operations are performed correctly. Finally, verfies that the target - * instance is removed from the store when the conversation ends. - * - * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $ - */ -public abstract class ConversationStartStopEndTestCase extends AbstractConversationTestCase { - protected AtomicComponent target; - private FooImpl targetInstance; - private JDKInvocationHandler handler; - private Method operation1; - private Method operation2; - private Method endOperation; - - public void testConversationStartContinueEnd() throws Throwable { - workContext.setIdentifier(Scope.CONVERSATION, "12345A"); - // start the conversation - handler.invoke(operation1, null); - // verify the instance was persisted - assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); - // continue the conversation - handler.invoke(operation2, null); - // verify the instance was persisted - assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); - // end the conversation - handler.invoke(endOperation, null); - workContext.clearIdentifier(Scope.CONVERSATION); - EasyMock.verify(targetInstance); - // verify the store has removed the instance - assertNull(store.readRecord(target, "12345A")); - } - - - protected void setUp() throws Exception { - super.setUp(); - createRuntime(); - initializeRuntime(); - targetInstance = EasyMock.createMock(FooImpl.class); - targetInstance.operation1(); - targetInstance.operation2(); - targetInstance.end(); - EasyMock.replay(targetInstance); - // create target component mock - target = createAtomicComponent(); - Wire wire = MockFactory.createWire("foo", Foo.class); - for (InvocationChain chain : wire.getInvocationChains().values()) { - chain.setTargetInvoker(target.createTargetInvoker("foo", chain.getOperation(), false)); - } - handler = new JDKInvocationHandler(Foo.class, wire, workContext); - operation1 = Foo.class.getMethod("operation1"); - operation2 = Foo.class.getMethod("operation2"); - endOperation = Foo.class.getMethod("end"); - } - - protected void tearDown() throws Exception { - super.tearDown(); - container.stop(); - store.destroy(); - } - - private JavaAtomicComponent createAtomicComponent() throws Exception { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setName(new URI("target")); - configuration.setInstanceFactory(new MockPojoFactory(FooImpl.class.getConstructor())); - configuration.setImplementationClass(FooImpl.class); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(container); - component.start(); - return component; - } - - private class MockPojoFactory extends PojoObjectFactory<FooImpl> { - public MockPojoFactory(Constructor<FooImpl> ctr) { - super(ctr); - } - - public FooImpl getInstance() throws ObjectCreationException { - return targetInstance; - } - } - - @Conversational - public static interface Foo { - - void operation1(); - - void operation2(); - - @EndsConversation - void end(); - - } - - public static class FooImpl implements Foo { - - public void operation1() { - } - - public void operation2() { - } - - @EndsConversation - public void end() { - } - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME deleted file mode 100644 index 17a832b117..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.core.integration.wire; - -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.HashMap; -import java.util.Map; -import java.net.URI; - -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; - -import junit.framework.TestCase; -import org.apache.tuscany.core.component.scope.CompositeScopeContainer; -import org.apache.tuscany.core.integration.mock.MockFactory; -import org.apache.tuscany.core.mock.component.Source; -import org.apache.tuscany.core.mock.component.SourceImpl; -import org.apache.tuscany.core.mock.component.Target; -import org.apache.tuscany.core.mock.component.TargetImpl; - -/** - * @version $$Rev: 526399 $$ $$Date: 2007-04-07 01:14:49 -0700 (Sat, 07 Apr 2007) $$ - */ -public class ReferenceInjectionTestCase extends TestCase { - private Map<String, Member> members; - - public void testProxiedReferenceInjection() throws Exception { - ScopeContainer scope = new CompositeScopeContainer(null); - scope.start(); - URI groupId = URI.create("composite"); - scope.startContext(groupId, groupId); - Map<String, AtomicComponent> components = MockFactory.createWiredComponents("source", - SourceImpl.class, - scope, - members, - "target", - Target.class, - TargetImpl.class, - scope); - AtomicComponent sourceComponent = components.get("source"); - Source source = (Source) sourceComponent.getTargetInstance(); - Target target = source.getTarget(); - assertTrue(Proxy.isProxyClass(target.getClass())); - - assertNotNull(target); - scope.stop(); - } - - protected void setUp() throws Exception { - super.setUp(); - members = new HashMap<String, Member>(); - Method m = SourceImpl.class.getMethod("setTarget", Target.class); - members.put("target", m); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java deleted file mode 100644 index 65681550c0..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.OneWay; - -/** - * @version $Rev$ $Date$ - */ -public interface AsyncTarget { - @OneWay - void invoke(); - - int getCount(); -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java deleted file mode 100644 index 319d965960..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Context; - -public class BadContextPojo { - - @Context - String context; - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java deleted file mode 100644 index 1a93254f2b..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.ComponentName; - -public class BadNamePojo { - @ComponentName - private int name; -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java deleted file mode 100644 index 716a70b007..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * @version $Rev$ $Date$ - */ -public interface BasicInterface { - String returnsProperty(); - - BasicInterface returnsReference(); - - int returnsInt(); -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java deleted file mode 100644 index 5f3dc8e5fb..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Reference; - -/** - * @version $Rev$ $Date$ - */ -public class BasicInterfaceImpl implements BasicInterface { - - @Property - public String publicProperty; - - @Reference (required = false) - public BasicInterface publicReference; - - @Property - protected String protectedProperty; - - @Reference (required = false) - protected BasicInterface protectedReference; - - private String privateProperty; - - private BasicInterface privateReference; - - @Property - public void setPrivateProperty(String privateProperty) { - this.privateProperty = privateProperty; - } - - @Reference (required = false) - public void setPrivateReference(BasicInterface privateReference) { - this.privateReference = privateReference; - } - - public String returnsProperty() { - return privateProperty; - } - - public BasicInterface returnsReference() { - return privateReference; - } - - public int returnsInt() { - return 0; - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java deleted file mode 100644 index 1014dd3e1f..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("COMPOSITE") -public interface CompositeScopeComponent { - - //public boolean isInit(); -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java deleted file mode 100644 index 2b654111f3..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Scope; - - -/** - * @version $Rev$ $Date$ - */ -@Scope("COMPOSITE") -public class CompositeScopeComponentImpl implements - CompositeScopeComponent { - - private String foo; - - public void setFoo(String foo) { - this.foo = foo; - } - - public String getFoo() { - return foo; - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java deleted file mode 100644 index 7c5751578a..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Destroy; - -public class CompositeScopeDestroyOnlyComponent extends CompositeScopeComponentImpl { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java deleted file mode 100644 index 4e08b7157b..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Destroy; - -public class CompositeScopeInitDestroyComponent extends CompositeScopeInitOnlyComponent { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - if (destroyed) { - throw new AssertionError("Destroy called more than once"); - } - destroyed = true; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java deleted file mode 100644 index a9c8bf1566..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Init; - -public class CompositeScopeInitOnlyComponent extends CompositeScopeComponentImpl { - - private boolean initialized; - // this value tests to ensure introspection can find the init() method even - // if a field is named the same. Ultimately, this should be in the introspection tests - private boolean init; - - public boolean isInitialized() { - return initialized; - } - - @Init - public void init() { - if (initialized) { - throw new AssertionError("Init called more than once"); - } - initialized = true; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java deleted file mode 100644 index 39e8c4ca11..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java +++ /dev/null @@ -1,29 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.mock;
-
-import org.osoa.sca.annotations.Scope;
-
-/**
- * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $
- */
-@Scope("CONVERSATION")
-public interface ConversationalScopeComponent {
-
-}
diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java deleted file mode 100644 index caf5b292f6..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.mock;
-
-import org.osoa.sca.annotations.Scope;
-
-/**
- * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $
- */
-@Scope("CONVERSATION")
-public class ConversationalScopeComponentImpl implements ConversationalScopeComponent {
-
-}
diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java deleted file mode 100644 index 9fe019010d..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,37 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.mock;
-
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("CONVERSATION")
-public class ConversationalScopeDestroyOnlyComponent extends ConversationalScopeComponentImpl {
-
- boolean destroyed;
-
- public boolean isDestroyed() {
- return destroyed;
- }
-
- @Destroy
- public void destroy() {
- destroyed = true;
- }
-}
diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java deleted file mode 100644 index 77f9855fe0..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.mock;
-
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("CONVERSATION")
-public class ConversationalScopeInitDestroyComponent
- extends ConversationalScopeInitOnlyComponent {
-
- private boolean destroyed;
-
- public boolean isDestroyed() {
- return destroyed;
- }
-
- @Destroy
- public void destroy() {
- destroyed = true;
- }
-}
diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java deleted file mode 100644 index d45d1a3def..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.mock;
-
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Scope;
-
-@Scope("CONVERSATION")
-public class ConversationalScopeInitOnlyComponent
- extends ConversationalScopeComponentImpl {
-
- private boolean initialized;
-
- public boolean isInitialized() {
- return initialized;
- }
-
- @Init
- public void init() {
- initialized = true;
- }
-}
diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME deleted file mode 100644 index 56bccd8f09..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.core.integration.mock; - -import java.lang.reflect.Member; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.assembly.Contract; -import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory; -import org.apache.tuscany.core.component.WorkContextImpl; -import org.apache.tuscany.core.implementation.PojoConfiguration; -import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; -import org.apache.tuscany.core.injection.PojoObjectFactory; -import org.apache.tuscany.core.wire.InvocationChainImpl; -import org.apache.tuscany.core.wire.InvokerInterceptor; -import org.apache.tuscany.core.wire.WireImpl; -import org.apache.tuscany.core.wire.jdk.JDKProxyService; -import org.apache.tuscany.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.interfacedef.Operation; -import org.apache.tuscany.interfacedef.java.introspection.JavaInterfaceProcessorRegistry; -import org.apache.tuscany.interfacedef.java.introspection.impl.JavaInterfaceProcessorRegistryImpl; -import org.apache.tuscany.spi.component.AtomicComponent; -import org.apache.tuscany.spi.component.ScopeContainer; -import org.apache.tuscany.spi.wire.Interceptor; -import org.apache.tuscany.spi.wire.InvocationChain; -import org.apache.tuscany.spi.wire.ProxyService; -import org.apache.tuscany.spi.wire.Wire; - -/** - * @version $$Rev: 526852 $$ $$Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $$ - */ -public final class MockFactory { - - private static final ProxyService PROXY_SERVICE = new JDKProxyService(new WorkContextImpl()); - private static final JavaInterfaceProcessorRegistry REGISTRY = new JavaInterfaceProcessorRegistryImpl(); - - private MockFactory() { - } - - /** - * Wires two components together where the reference interface is the same as target service - */ - public static Map<String, AtomicComponent> createWiredComponents(String sourceName, - Class<?> sourceClass, - ScopeContainer sourceScope, - Map<String, Member> members, - String targetName, - Class<?> targetService, - Class<?> targetClass, - ScopeContainer targetScope) throws Exception { - return createWiredComponents(sourceName, - sourceClass, - targetService, - sourceScope, - null, - members, - targetName, - targetClass, - targetScope - ); - - } - - @SuppressWarnings("unchecked") - public static Map<String, AtomicComponent> createWiredComponents(String sourceName, Class<?> sourceClass, - Class<?> sourceReferenceClass, - ScopeContainer sourceScope, - Interceptor sourceHeadInterceptor, - Map<String, Member> members, - String targetName, - Class<?> targetClass, - ScopeContainer targetScope - ) - throws Exception { - - JavaAtomicComponent targetComponent = - createJavaComponent(targetName, targetScope, targetClass); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor())); - configuration.setProxyService(PROXY_SERVICE); - for (Map.Entry<String, Member> entry : members.entrySet()) { - configuration.addReferenceSite(entry.getKey(), entry.getValue()); - } - configuration.setWorkContext(new WorkContextImpl()); - configuration.setName(new URI(sourceName)); - configuration.setGroupId(URI.create("composite")); - JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration); - sourceComponent.setScopeContainer(sourceScope); - Wire wire = createWire(targetName, sourceReferenceClass, sourceHeadInterceptor); - for (InvocationChain chain : wire.getInvocationChains().values()) { - chain.setTargetInvoker(targetComponent.createTargetInvoker(targetName, chain.getOperation(), false)); - } - sourceComponent.attachWire(wire); - targetScope.register(targetComponent, configuration.getGroupId()); - sourceScope.register(sourceComponent, configuration.getGroupId()); - Map<String, AtomicComponent> components = new HashMap<String, AtomicComponent>(); - components.put(sourceName, sourceComponent); - components.put(targetName, targetComponent); - return components; - } - - - /** - * Wires two components using a multiplicity reference - */ - @SuppressWarnings("unchecked") - public static Map<String, AtomicComponent> createWiredMultiplicity(String sourceName, Class<?> sourceClass, - Class<?> sourceReferenceClass, - ScopeContainer sourceScope, - String targetName, Class<?> targetService, - Class<?> targetClass, - Map<String, Member> members, - ScopeContainer targetScope) throws Exception { - JavaAtomicComponent targetComponent = - createJavaComponent(targetName, targetScope, targetClass); - String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1); - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor())); - configuration.setProxyService(PROXY_SERVICE); - for (Map.Entry<String, Member> entry : members.entrySet()) { - configuration.addReferenceSite(entry.getKey(), entry.getValue()); - } - configuration.setWorkContext(new WorkContextImpl()); - configuration.setName(new URI(sourceName)); - configuration.setGroupId(URI.create("composite")); - - JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration); - sourceComponent.setScopeContainer(sourceScope); - Wire wire = createWire(targetName, sourceReferenceClass, null); - wire.setTargetUri(URI.create(targetName + "#" + serviceName)); - for (InvocationChain chain : wire.getInvocationChains().values()) { - chain.setTargetInvoker(targetComponent.createTargetInvoker("target", chain.getOperation(), false)); - } - List<Wire> wires = new ArrayList<Wire>(); - wires.add(wire); - sourceComponent.attachWires(wires); - targetScope.register(targetComponent, configuration.getGroupId()); - sourceScope.register(sourceComponent, configuration.getGroupId()); - - Map<String, AtomicComponent> components = new HashMap<String, AtomicComponent>(); - components.put(sourceName, sourceComponent); - components.put(targetName, targetComponent); - return components; - } - - public static <T> Wire createWire(String serviceName, Class<T> interfaze) - throws InvalidInterfaceException { - return createWire(serviceName, interfaze, null); - } - - public static <T> Wire createWire(String serviceName, Class<T> interfaze, Interceptor interceptor) - throws InvalidInterfaceException { - Wire wire = new WireImpl(); - Contract contract = new DefaultAssemblyFactory().createComponentService(); - REGISTRY.introspect(contract, interfaze); - wire.setSourceContract(contract); - wire.setSourceUri(URI.create("#" + serviceName)); - createChains(interfaze, interceptor, wire); - return wire; - } - - @SuppressWarnings("unchecked") - private static <T> JavaAtomicComponent createJavaComponent(String name, ScopeContainer scope, Class<T> clazz) - throws NoSuchMethodException, URISyntaxException { - PojoConfiguration configuration = new PojoConfiguration(); - configuration.setImplementationClass(clazz); - configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor())); - configuration.setProxyService(PROXY_SERVICE); - configuration.setWorkContext(new WorkContextImpl()); - configuration.setName(new URI(name)); - configuration.setGroupId(URI.create("composite")); - JavaAtomicComponent component = new JavaAtomicComponent(configuration); - component.setScopeContainer(scope); - return component; - } - - private static void createChains(Class<?> interfaze, Interceptor interceptor, Wire wire) - throws InvalidInterfaceException { - - Contract contract = new DefaultAssemblyFactory().createComponentService(); - REGISTRY.introspect(contract, interfaze); - for (Operation method : contract.getInterface().getOperations()) { - InvocationChain chain = new InvocationChainImpl(method); - if (interceptor != null) { - chain.addInterceptor(interceptor); - } - // add tail interceptor - chain.addInterceptor(new InvokerInterceptor()); - wire.addInvocationChain(method, chain); - } - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java deleted file mode 100644 index 23822bec74..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.implementation.java.invocation.TargetInvoker; -import org.apache.tuscany.sca.interfacedef.ConversationSequence; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Message; -import org.osoa.sca.ServiceRuntimeException; - -/** - * Caches component instances that do not need to be resolved for every wire, e.g. an wire originating from a lesser - * scope intended for a target with a wider scope - * - * @version $Rev$ $Date$ - */ -public class MockStaticInvoker implements TargetInvoker { - - private Object instance; - private Method operation; - private boolean cacheable; - - - public MockStaticInvoker(Method operation, Object instance) { - this.operation = operation; - this.instance = instance; - } - - public boolean isCacheable() { - return cacheable; - } - - public void setCacheable(boolean cacheable) { - this.cacheable = cacheable; - } - - public Object invokeTarget(final Object payload, final ConversationSequence sequence) throws InvocationTargetException { - try { - if (payload != null && !payload.getClass().isArray()) { - return operation.invoke(instance, payload); - } else { - return operation.invoke(instance, (Object[]) payload); - } - } catch (IllegalAccessException e) { - throw new ServiceRuntimeException(e); - } - } - - public Message invoke(Message msg) { - try { - Object resp = invokeTarget(msg.getBody(), null); - msg.setBody(resp); - } catch (InvocationTargetException e) { - msg.setFaultBody(e.getCause()); - } catch (Throwable e) { - msg.setFaultBody(e); - } - return msg; - } - - public void setNext(Interceptor next) { - throw new IllegalStateException("This interceptor must be the last interceptor in an interceptor chain"); - } - - public Object clone() throws CloneNotSupportedException { - try { - MockStaticInvoker invoker = (MockStaticInvoker) super.clone(); - invoker.instance = this.instance; - invoker.operation = this.operation; - return invoker; - } catch (CloneNotSupportedException e) { - return null; // will not happen - } - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java deleted file mode 100644 index 1e2f89cdf6..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; - -public class MockSyncInterceptor implements Interceptor { - - private int count; - - private Invoker next; - - public MockSyncInterceptor() { - } - - public Message invoke(Message msg) { - ++count; - return next.invoke(msg); - } - - public int getCount() { - return count; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public Invoker getNext() { - return next; - } - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java deleted file mode 100644 index 1d337de93f..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -public class OrderException extends Exception { - - public OrderException() { - super(); - } - - public OrderException(String message) { - super(message); - } - - public OrderException(String message, Throwable cause) { - super(message, cause); - } - - public OrderException(Throwable cause) { - super(cause); - } - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java deleted file mode 100644 index 09b58497fe..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * @version $$Rev$$ $$Date$$ - */ -public interface OrderedDependentPojo extends OrderedInitPojo { - - OrderedInitPojo getPojo(); - - void setPojo(OrderedInitPojo pojo); -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java deleted file mode 100644 index 0fc5a88925..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * @version $$Rev$$ $$Date$$ - */ -public class OrderedDependentPojoImpl extends OrderedInitPojoImpl implements OrderedDependentPojo { - - private OrderedInitPojo pojo; - - public OrderedInitPojo getPojo() { - return pojo; - } - - public void setPojo(OrderedInitPojo pojo) { - this.pojo = pojo; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java deleted file mode 100644 index 0907bf3e8b..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.EagerInit; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -@Scope("COMPOSITE") -@EagerInit -public class OrderedEagerInitPojo { - - private static final Object LOCK = new Object(); - private static int numberInstantied; - private int initOrder; - - @Init - public void init() { - synchronized (LOCK) { - ++numberInstantied; - initOrder = numberInstantied; - } - } - - @Destroy - public void destroy() throws OrderException { - synchronized (LOCK) { - if (initOrder != numberInstantied) { - throw new OrderException("Instance shutdown done out of order"); - } - --numberInstantied; - } - } - - public int getNumberInstantiated() { - return numberInstantied; - } - - public int getInitOrder() { - return initOrder; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java deleted file mode 100644 index 0c4f65e904..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * @version $$Rev$$ $$Date$$ - */ -public interface OrderedInitPojo { - int getNumberInstantiated(); - - int getInitOrder(); -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java deleted file mode 100644 index e67a1b807b..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -@Scope("COMPOSITE") -public class OrderedInitPojoImpl implements OrderedInitPojo { - - private static final Object LOCK = new Object(); - private static int numberInstantied; - private int initOrder; - - public OrderedInitPojoImpl() { - } - - @Init - public void init() { - synchronized (LOCK) { - ++numberInstantied; - initOrder = numberInstantied; - } - } - - @Destroy - public void destroy() throws OrderException { - synchronized (LOCK) { - if (initOrder != numberInstantied) { - throw new OrderException("Instance shutdown done out of order"); - } - --numberInstantied; - } - } - - public int getNumberInstantiated() { - return numberInstantied; - } - - public int getInitOrder() { - return initOrder; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java deleted file mode 100644 index 61802beaea..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * Implementations are used in wiring tests - * - * @version $Rev$ $Date$ - */ -public interface OtherTarget { - - String getString(); - - void setString(String val); -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java deleted file mode 100644 index 3b8c4842f1..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * A target used for testing wires with a different source and target interface - * - * @version $Rev$ $Date$ - */ -public class OtherTargetImpl implements OtherTarget { - - private String theString; - - public String getString() { - return theString; - } - - public void setString(String val) { - theString = val; - } - - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java deleted file mode 100644 index b10b1e7648..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("REQUEST") -public interface RequestScopeComponent { - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java deleted file mode 100644 index f504e284ab..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Scope; - -@Scope("REQUEST") -public class RequestScopeDestroyOnlyComponent extends SessionScopeComponentImpl { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java deleted file mode 100644 index 5a0f15a54f..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Scope; - -@Scope("REQUEST") -public class RequestScopeInitDestroyComponent extends SessionScopeInitOnlyComponent { - - boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java deleted file mode 100644 index b72cf2f1a3..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -@Scope("REQUEST") -public class RequestScopeInitOnlyComponent extends SessionScopeComponentImpl { - - private boolean initialized; - - public boolean isInitialized() { - return initialized; - } - - @Init - public void init() { - initialized = true; - } - - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java deleted file mode 100644 index 7dcfd4acda..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("SESSION") -public interface SessionScopeComponent { - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java deleted file mode 100644 index bb0da51475..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("SESSION") -public class SessionScopeComponentImpl implements - SessionScopeComponent { - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java deleted file mode 100644 index 5dc7d82a8d..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Destroy; - -public class SessionScopeInitDestroyComponent extends SessionScopeInitOnlyComponent { - - private boolean destroyed; - - public boolean isDestroyed() { - return destroyed; - } - - @Destroy - public void destroy() { - destroyed = true; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java deleted file mode 100644 index 9a212c927f..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Init; - -public class SessionScopeInitOnlyComponent extends SessionScopeComponentImpl { - - private boolean initialized; - - public boolean isInitialized() { - return initialized; - } - - @Init - public void init() { - initialized = true; - } - - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java deleted file mode 100644 index d8b6be1de0..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -public interface SimpleTarget { - - String hello(String message) throws Exception; - - String goodbye(String message) throws Exception; - - String echo(String message) throws Exception; - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java deleted file mode 100644 index 27cb9a7617..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -public class SimpleTargetImpl implements SimpleTarget { - - public SimpleTargetImpl() { - super(); - } - - public String hello(String message) throws Exception { - return message; - } - - public String goodbye(String message) throws Exception { - return message; - } - - public String echo(String message) throws Exception { - return message; - } - - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java deleted file mode 100644 index 630809bcad..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import java.util.List; - -/** - * Implementations are used in wiring tests - * - * @version $Rev$ $Date$ - */ -public interface Source { - - Target getTarget(); - - List<Target> getTargets(); - - List<Target> getTargetsThroughField(); - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java deleted file mode 100644 index bd1abf6577..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import java.util.List; - -/** - * Mock system component implementation used in wiring tests - * - * @version $Rev$ $Date$ - */ -public class SourceImpl implements Source { - - private Target target; - private List<Target> targets; - private List<Target> targetsThroughField; - private Target[] targetsArray; - - public void setTarget(Target target) { - this.target = target; - } - - public Target getTarget() { - return target; - } - - public List<Target> getTargets() { - return targets; - } - - public void setTargets(List<Target> targets) { - this.targets = targets; - } - - public List<Target> getTargetsThroughField() { - return targetsThroughField; - } - - public Target[] getArrayOfTargets() { - return targetsArray; - } - - public void setArrayOfTargets(Target[] targets) { - targetsArray = targets; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java deleted file mode 100644 index 7eb9172f28..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("STATELESS") -public interface StatelessComponent { - -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java deleted file mode 100644 index b1e0d33b63..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * @version $Rev$ $Date$ - */ -public class StatelessComponentImpl implements - StatelessComponent { - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java deleted file mode 100644 index fd175bdbc5..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * Implementations are used in wiring tests - * - * @version $Rev$ $Date$ - */ -public interface Target { - - String getString(); - - void setString(String val); -} - diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java deleted file mode 100644 index 5f5a11028f..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.mock; - -/** - * Mock system component implementation used in wiring tests - * - * @version $Rev$ $Date$ - */ -public class TargetImpl implements Target { - - private String theString; - - public String getString() { - return theString; - } - - public void setString(String val) { - theString = val; - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java deleted file mode 100644 index 7598b4f968..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.monitor; - -import java.io.PrintWriter; -import java.io.StringWriter; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class ExceptionFormatterTestCase extends TestCase { - private ExceptionFormatterImpl formatter = new ExceptionFormatterImpl(); - - public void testTuscanyExceptionFormat() throws Exception { - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - Exception e = new Exception("somemessage") { - }; - formatter.write(pw, e); - assertTrue(writer.toString().indexOf("somemessage") >= 0); - } - - public void testTuscanyRuntimeExceptionFormat() throws Exception { - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - RuntimeException e = new RuntimeException("somemessage") { - }; - formatter.write(pw, e); - assertTrue(writer.toString().indexOf("somemessage") >= 0); - } - - public void testNormalExceptionFormat() throws Exception { - StringWriter writer = new StringWriter(); - PrintWriter pw = new PrintWriter(writer); - Exception e = new Exception(); - formatter.write(pw, e); // just verify there are no errors since no formatting needs to be doen - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java deleted file mode 100644 index 2f7ed80030..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.monitor; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import junit.framework.TestCase; - -import org.apache.tuscany.api.annotation.LogLevel; - -/** - * Test case for the JavaLoggingMonitorFactory. - * - * @version $Rev$ $Date$ - */ -public class JavaLoggingTestCase extends TestCase { - private static final Logger LOGGER = Logger.getLogger(Monitor.class.getName()); - private static final MockHandler HANDLER = new MockHandler(); - - private MonitorFactory factory; - - /** - * Smoke test to ensure the LOGGER is working. - */ - public void testLogger() { - LOGGER.info("test"); - assertEquals(1, HANDLER.logs.size()); - } - - /** - * Test that no record is logged. - */ - public void testUnloggedEvent() { - Monitor mon = factory.getMonitor(Monitor.class); - mon.eventNotToLog(); - assertEquals(0, HANDLER.logs.size()); - } - - /** - * Test the correct record is written for an event with no arguments. - */ - public void testEventWithNoArgs() { - Monitor mon = factory.getMonitor(Monitor.class); - mon.eventWithNoArgs(); - assertEquals(1, HANDLER.logs.size()); - LogRecord record = HANDLER.logs.get(0); - assertEquals(Level.INFO, record.getLevel()); - assertEquals(LOGGER.getName(), record.getLoggerName()); - assertEquals(Monitor.class.getName() + "#eventWithNoArgs", record.getMessage()); - } - - /** - * Test the correct record is written for an event defined by annotation. - */ - public void testEventWithAnnotation() { - Monitor mon = factory.getMonitor(Monitor.class); - mon.eventWithAnnotation(); - assertEquals(1, HANDLER.logs.size()); - LogRecord record = HANDLER.logs.get(0); - assertEquals(Level.INFO, record.getLevel()); - assertEquals(LOGGER.getName(), record.getLoggerName()); - assertEquals(Monitor.class.getName() + "#eventWithAnnotation", record.getMessage()); - } - - /** - * Test the argument is logged. - */ - public void testEventWithOneArg() { - Monitor mon = factory.getMonitor(Monitor.class); - mon.eventWithOneArg("ARG"); - assertEquals(1, HANDLER.logs.size()); - LogRecord record = HANDLER.logs.get(0); - assertEquals(Monitor.class.getName() + "#eventWithOneArg", record.getMessage()); - } - - protected void setUp() throws Exception { - super.setUp(); - LOGGER.setUseParentHandlers(false); - LOGGER.addHandler(HANDLER); - HANDLER.flush(); - - String sourceClass = Monitor.class.getName(); - Properties levels = new Properties(); - levels.setProperty(sourceClass + "#eventWithNoArgs", "INFO"); - levels.setProperty(sourceClass + "#eventWithOneArg", "INFO"); - levels.setProperty(sourceClass + "#eventWithThrowable", "WARNING"); - factory = new JavaLoggingMonitorFactory(levels, Level.FINE, "TestMessages"); - } - - protected void tearDown() throws Exception { - LOGGER.removeHandler(HANDLER); - HANDLER.flush(); - super.tearDown(); - } - - /** - * Mock log HANDLER to capture records. - */ - public static class MockHandler extends Handler { - List<LogRecord> logs = new ArrayList<LogRecord>(); - - public void publish(LogRecord record) { - logs.add(record); - } - - public void flush() { - logs.clear(); - } - - public void close() throws SecurityException { - } - } - - @SuppressWarnings({"JavaDoc"}) - public static interface Monitor { - void eventNotToLog(); - - @LogLevel("INFO") - void eventWithNoArgs(); - - @LogLevel("INFO") - void eventWithOneArg(String msg); - - @LogLevel("WARNING") - void eventWithThrowable(Exception e); - - @LogLevel("INFO") - void eventWithAnnotation(); - } -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java deleted file mode 100644 index 40cf2e27cf..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.util; - - -public class Bean1 extends SuperBean { - - public static final int ALL_BEAN1_FIELDS = 6 + ALL_SUPER_FIELDS; - public static final int ALL_BEAN1_PUBLIC_PROTECTED_FIELDS = 5 + ALL_SUPER_PUBLIC_PROTECTED_FIELDS; - public static final int ALL_BEAN1_METHODS = 4 + ALL_SUPER_METHODS - 1; - public String field3; - protected String field2; - private String field1; - - public void setMethod1(String param) { - } - - public void setMethod1(int param) { - } - - public void override(String param) throws Exception { - } - - - public void noOverride(String param) throws Exception { - } - - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java deleted file mode 100644 index a00b9e7109..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.util; - -import java.util.List; - -import junit.framework.AssertionFailedError; - -public class Bean2 { - - private List methodList; - private List fieldList; - - public List getMethodList() { - return methodList; - } - - public void setMethodList(List list) { - methodList = list; - } - - public List getfieldList() { - return fieldList; - } - - public void setfieldList(List list) { - throw new AssertionFailedError("setter inadvertantly called"); - } - - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java deleted file mode 100644 index 1c8f1caa93..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.util; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper; -import org.apache.tuscany.sca.implementation.java.mock.Target; - -public class JavaIntrospectionHelperTestCase extends TestCase { - - private List testNoGenericsList; - private List<String> testList; - private Map<String, Bean1> testMap; - private Target[] testArray; - private String[] testStringArray; - - public JavaIntrospectionHelperTestCase() { - super(); - } - - public JavaIntrospectionHelperTestCase(String arg0) { - super(arg0); - } - - public void testBean1AllPublicProtectedFields() throws Exception { - Set<Field> beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class); - assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS - } - - public void testGetSuperAllMethods() throws Exception { - Set<Method> superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class); - assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size()); - } - - public void testGetBean1AllMethods() throws Exception { - Set<Method> beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); - assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size()); - } - - public void testOverrideMethod() throws Exception { - Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); - boolean invoked = false; - for (Method method : beanFields) { - if (method.getName().equals("override")) { - method.invoke(new Bean1(), "foo"); - invoked = true; - } - } - if (!invoked) { - throw new Exception("Override never invoked"); - } - } - - public void testNoOverrideMethod() throws Exception { - Set<Method> beanFields = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); - boolean found = false; - for (Method method : beanFields) { - if (method.getName().equals("noOverride") && method.getParameterTypes().length == 0) { - found = true; - } - } - if (!found) { - throw new Exception("No override not found"); - } - } - - public void testDefaultConstructor() throws Exception { - Constructor ctr = JavaIntrospectionHelper.getDefaultConstructor(Bean2.class); - assertEquals(ctr, Bean2.class.getConstructor()); - assertTrue(Bean2.class == ctr.newInstance((Object[]) null).getClass()); - } - - - public void testGetAllInterfaces() { - Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class); - assertEquals(2, interfaces.size()); - assertTrue(interfaces.contains(W.class)); - assertTrue(interfaces.contains(W2.class)); - } - - - public void testGetAllInterfacesObject() { - Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class); - assertEquals(0, interfaces.size()); - } - - public void testGetAllInterfacesNoInterfaces() { - Set<Class> interfaces = JavaIntrospectionHelper.getAllInterfaces(NoInterface.class); - assertEquals(0, interfaces.size()); - } - - /** - * Tests generics introspection capabilities - */ - public void testGenerics() throws Exception { - - List classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testList").getGenericType()); - assertEquals(1, classes.size()); - assertEquals(String.class, classes.get(0)); - - classes = - JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testNoGenericsList").getGenericType()); - assertEquals(0, classes.size()); - - classes = JavaIntrospectionHelper.getGenerics(getClass().getDeclaredField("testMap").getGenericType()); - assertEquals(2, classes.size()); - assertEquals(String.class, classes.get(0)); - assertEquals(Bean1.class, classes.get(1)); - - classes = JavaIntrospectionHelper - .getGenerics(getClass().getDeclaredMethod("fooMethod", Map.class).getGenericParameterTypes()[0]); - assertEquals(2, classes.size()); - assertEquals(String.class, classes.get(0)); - assertEquals(Bean1.class, classes.get(1)); - - classes = JavaIntrospectionHelper - .getGenerics(getClass().getDeclaredMethod("fooMethod", List.class).getGenericParameterTypes()[0]); - assertEquals(1, classes.size()); - assertEquals(String.class, classes.get(0)); - - } - - private void fooMethod(List<String> foo) { - - } - - private void fooMethod(Map<String, Bean1> foo) { - - } - - public void setTestArray(Target[] array) { - } - - private interface W { - - } - - private interface W2 { - - } - - private class X implements W { - - } - - private class Y extends X implements W, W2 { - - } - - private class Z extends Y { - - } - - private class NoInterface { - - } - -} diff --git a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java b/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java deleted file mode 100644 index 408cedb8be..0000000000 --- a/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.implementation.java.util; - -/** - * @version $Rev$ $Date$ - */ -public class SuperBean { - - public static final int ALL_SUPER_FIELDS = 6; - public static final int ALL_SUPER_PUBLIC_PROTECTED_FIELDS = 5; - public static final int ALL_SUPER_METHODS = 4; - public String superField2; - - protected String superField3; - - private String superField1; - - public void setSuperMethod1(String param) { - } - - public void setSuperMethod1(int param) { - } - - public void override(String param) throws Exception { - throw new Exception("Override not handled"); - } - - public void noOverride() throws Exception { - } - -} |