From f860c2f35b2f94e379d2ff7d5c13f54cd4a3132a Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:42 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835119 13f79535-47bb-0310-9956-ffa450edef68 --- .../implementation/java/context/ModelHelper.java | 99 ++++++++++ .../java/context/MultiplicityTestCase.java | 34 ++++ .../context/ReflectiveInstanceWrapperTestCase.java | 83 ++++++++ .../CallbackWireObjectFactoryTestCase.java | 54 ++++++ .../java/injection/FieldInjectorTestCase.java | 48 +++++ .../java/injection/JNDIObjectFactoryTestCase.java | 61 ++++++ .../java/injection/MethodEventInvokerTestCase.java | 72 +++++++ .../java/injection/MethodInjectorTestCase.java | 79 ++++++++ .../java/injection/PojoObjectFactoryTestCase.java | 76 ++++++++ .../RequestContextObjectFactoryTestCase.java | 33 ++++ .../injection/ResourceObjectFactoryTestCase.java | 89 +++++++++ .../injection/SingletonObjectFactoryTestCase.java | 33 ++++ .../integration/AbstractConversationTestCase.java | 51 +++++ .../ConversationIdleExpireTestCase.java.FIXME | 149 ++++++++++++++ .../ConversationMaxAgeExpireTestCase.java.FIXME | 153 +++++++++++++++ .../ConversationStartStopEndTestCase.java.FIXME | 147 ++++++++++++++ .../ReferenceInjectionTestCase.java.FIXME | 79 ++++++++ .../sca/implementation/java/mock/AsyncTarget.java | 31 +++ .../implementation/java/mock/BadContextPojo.java | 28 +++ .../sca/implementation/java/mock/BadNamePojo.java | 26 +++ .../implementation/java/mock/BasicInterface.java | 30 +++ .../java/mock/BasicInterfaceImpl.java | 66 +++++++ .../java/mock/CompositeScopeComponent.java | 31 +++ .../java/mock/CompositeScopeComponentImpl.java | 40 ++++ .../mock/CompositeScopeDestroyOnlyComponent.java | 36 ++++ .../mock/CompositeScopeInitDestroyComponent.java | 39 ++++ .../java/mock/CompositeScopeInitOnlyComponent.java | 42 ++++ .../java/mock/ConversationalScopeComponent.java | 29 +++ .../mock/ConversationalScopeComponentImpl.java | 29 +++ .../ConversationalScopeDestroyOnlyComponent.java | 37 ++++ .../ConversationalScopeInitDestroyComponent.java | 38 ++++ .../mock/ConversationalScopeInitOnlyComponent.java | 38 ++++ .../java/mock/MockFactory.java.FIXME | 214 +++++++++++++++++++++ .../java/mock/MockStaticInvoker.java | 94 +++++++++ .../java/mock/MockSyncInterceptor.java | 52 +++++ .../implementation/java/mock/OrderException.java | 40 ++++ .../java/mock/OrderedDependentPojo.java | 29 +++ .../java/mock/OrderedDependentPojoImpl.java | 36 ++++ .../java/mock/OrderedEagerInitPojo.java | 60 ++++++ .../implementation/java/mock/OrderedInitPojo.java | 28 +++ .../java/mock/OrderedInitPojoImpl.java | 61 ++++++ .../sca/implementation/java/mock/OtherTarget.java | 31 +++ .../implementation/java/mock/OtherTargetImpl.java | 39 ++++ .../java/mock/RequestScopeComponent.java | 30 +++ .../mock/RequestScopeDestroyOnlyComponent.java | 38 ++++ .../mock/RequestScopeInitDestroyComponent.java | 38 ++++ .../java/mock/RequestScopeInitOnlyComponent.java | 39 ++++ .../java/mock/SessionScopeComponent.java | 30 +++ .../java/mock/SessionScopeComponentImpl.java | 30 +++ .../mock/SessionScopeInitDestroyComponent.java | 36 ++++ .../java/mock/SessionScopeInitOnlyComponent.java | 37 ++++ .../sca/implementation/java/mock/SimpleTarget.java | 30 +++ .../implementation/java/mock/SimpleTargetImpl.java | 41 ++++ .../sca/implementation/java/mock/Source.java | 37 ++++ .../sca/implementation/java/mock/SourceImpl.java | 63 ++++++ .../java/mock/StatelessComponent.java | 30 +++ .../java/mock/StatelessComponentImpl.java | 27 +++ .../sca/implementation/java/mock/Target.java | 32 +++ .../sca/implementation/java/mock/TargetImpl.java | 38 ++++ .../java/monitor/ExceptionFormatterTestCase.java | 57 ++++++ .../java/monitor/JavaLoggingTestCase.java | 152 +++++++++++++++ .../sca/implementation/java/util/Bean1.java | 45 +++++ .../sca/implementation/java/util/Bean2.java | 47 +++++ .../java/util/JavaIntrospectionHelperTestCase.java | 182 ++++++++++++++++++ .../sca/implementation/java/util/SuperBean.java | 48 +++++ 65 files changed, 3671 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java (limited to 'sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache') diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java new file mode 100644 index 0000000000..9b65af0ab1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ModelHelper.java @@ -0,0 +1,99 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java new file mode 100644 index 0000000000..ba8da101c6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java @@ -0,0 +1,34 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java new file mode 100644 index 0000000000..c098062bc8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java @@ -0,0 +1,83 @@ +/* + * 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 wrapper; + private Object instance; + private EventInvoker initInvoker; + private EventInvoker destroyInvoker; + + public void testWithNoCallbacks() { + wrapper = new ReflectiveInstanceWrapper(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(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(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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java new file mode 100644 index 0000000000..29dcfa8169 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java @@ -0,0 +1,54 @@ +/* + * 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 wires = new ArrayList(); + CallbackWireObjectFactory factory = new CallbackWireObjectFactory(Foo.class, service, wires); + assertEquals(foo, factory.getInstance()); + EasyMock.verify(service); + } + + private interface Foo { + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java new file mode 100644 index 0000000000..cef5cd4788 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java @@ -0,0 +1,48 @@ +/* + * 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 injector = new FieldInjector(protectedField, new SingletonObjectFactory("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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java new file mode 100644 index 0000000000..69d2696944 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JNDIObjectFactoryTestCase.java @@ -0,0 +1,61 @@ +/* + * 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 factory = new JNDIObjectFactory(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 factory = new JNDIObjectFactory(ctx, "foo"); + try { + factory.getInstance(); + fail(); + } catch (ObjectCreationException e) { + //expected + } + EasyMock.verify(ctx); + } + + + private class Foo { + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java new file mode 100644 index 0000000000..47fb224c1e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java @@ -0,0 +1,72 @@ +/* + * 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 injector = new MethodEventInvoker(privateMethod); + try { + injector.invokeEvent(new Foo()); + fail(); + } catch (AssertionError e) { + // expected + } + } + + public void testException() throws Exception { + MethodEventInvoker injector = new MethodEventInvoker(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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java new file mode 100644 index 0000000000..f2b8b97e5a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.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 factory = new SingletonObjectFactory(new Object()); + MethodInjector injector = new MethodInjector(fooMethod, factory); + try { + injector.inject(new Foo()); + fail(); + } catch (ObjectCreationException e) { + // expected + } + } + + public void testException() throws Exception { + ObjectFactory factory = new SingletonObjectFactory("foo"); + MethodInjector injector = new MethodInjector(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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java new file mode 100644 index 0000000000..6bf0658284 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/PojoObjectFactoryTestCase.java @@ -0,0 +1,76 @@ +/* + * 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 ctor; + + public void testConstructorInjection() throws Exception { + List initializers = new ArrayList(); + initializers.add(new SingletonObjectFactory("foo")); + PojoObjectFactory factory = new PojoObjectFactory(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 initializers = new ArrayList(); + initializers.add(null); + PojoObjectFactory factory = new PojoObjectFactory(ctor, initializers); + Foo foo = factory.getInstance(); + assertNull(foo.foo); + } + + public void testConstructorInitializerInjection() throws Exception { + PojoObjectFactory factory = new PojoObjectFactory(ctor); + factory.setInitializerFactory(0, new SingletonObjectFactory("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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java new file mode 100644 index 0000000000..d8b981e952 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java @@ -0,0 +1,33 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java new file mode 100644 index 0000000000..ed7a0e7d03 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java @@ -0,0 +1,89 @@ +/* + * 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 factory = new ResourceObjectFactory(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 factory = + new ResourceObjectFactory(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 factory = new ResourceObjectFactory(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 factory = new ResourceObjectFactory(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 factory = new ResourceObjectFactory(String.class, true, host); + assertNull(factory.getInstance()); + EasyMock.verify(host); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java new file mode 100644 index 0000000000..40ad1b1e95 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java @@ -0,0 +1,33 @@ +/* + * 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 factory = new SingletonObjectFactory(o); + assertEquals(o, factory.getInstance()); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java new file mode 100644 index 0000000000..738775b9a3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/AbstractConversationTestCase.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.implementation.java.integration; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.core.scope.ConversationalScopeContainer; +import org.apache.tuscany.sca.core.store.MemoryStore; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.scope.ScopeContainer; +import org.apache.tuscany.sca.store.StoreMonitor; +import org.easymock.EasyMock; + +/** + * Provides helper methods for setting up a partial runtime for conversational test cases. + * + * @version $Rev$ $Date$ + */ +public abstract class AbstractConversationTestCase extends TestCase { + protected ScopeContainer container; + protected MemoryStore store; + protected RuntimeComponent component; + + protected void createRuntime() { + store = new MemoryStore(EasyMock.createNiceMock(StoreMonitor.class)); + component = EasyMock.createMock(RuntimeComponent.class); + container = new ConversationalScopeContainer(store, component); + } + + protected void initializeRuntime() { + store.init(); + container.start(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME new file mode 100644 index 0000000000..47fa0f0bc5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationIdleExpireTestCase.java.FIXME @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.integration.conversation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.URI; + +import org.apache.tuscany.core.implementation.PojoConfiguration; +import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; +import org.apache.tuscany.core.injection.PojoObjectFactory; +import org.apache.tuscany.core.integration.mock.MockFactory; +import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler; +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.Scope; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.component.TargetNotFoundException; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; +import org.easymock.EasyMock; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; + +/** + * Verifies conversational resources are cleaned up if the maximum idle time is exceeded + * + * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $ + */ +public abstract class ConversationIdleExpireTestCase extends AbstractConversationTestCase { + protected AtomicComponent target; + private JDKInvocationHandler handler; + private FooImpl targetInstance; + private Method operation1; + private Method operation2; + private final Object mutex = new Object(); + + public void testConversationExpire() throws Throwable { + workContext.setIdentifier(Scope.CONVERSATION, "12345A"); + // start the conversation + handler.invoke(operation1, null); + // verify the instance was persisted + assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); + synchronized (mutex) { + mutex.wait(100); + } + // verify the instance was expired + assertNull(store.readRecord(target, "12345A")); + // continue the conversation - should throw an error + try { + handler.invoke(operation2, null); + fail(); + } catch (TargetNotFoundException e) { + // expected + } + } + + + protected void setUp() throws Exception { + super.setUp(); + createRuntime(); + store.setReaperInterval(10); + initializeRuntime(); + + targetInstance = EasyMock.createMock(FooImpl.class); + targetInstance.operation1(); + targetInstance.operation2(); + targetInstance.end(); + EasyMock.replay(targetInstance); + target = createTarget(); + + Wire wire = MockFactory.createWire("foo", Foo.class); + for (InvocationChain chain : wire.getInvocationChains().values()) { + chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false)); + } + handler = new JDKInvocationHandler(Foo.class, wire, workContext); + operation1 = Foo.class.getMethod("operation1"); + operation2 = Foo.class.getMethod("operation2"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + container.stop(); + store.destroy(); + } + + private JavaAtomicComponent createTarget() throws Exception { + PojoConfiguration configuration = new PojoConfiguration(); + configuration.setName(new URI("target")); + configuration.setMaxIdleTime(50); + configuration.setInstanceFactory(new MockPojoFactory(FooImpl.class.getConstructor())); + configuration.setImplementationClass(FooImpl.class); + JavaAtomicComponent component = new JavaAtomicComponent(configuration); + component.setScopeContainer(container); + component.start(); + return component; + } + + private class MockPojoFactory extends PojoObjectFactory { + public MockPojoFactory(Constructor ctr) { + super(ctr); + } + + public FooImpl getInstance() throws ObjectCreationException { + return targetInstance; + } + } + + @Conversational + public static interface Foo { + + void operation1(); + + void operation2(); + + @EndsConversation + void end(); + + } + + public static class FooImpl implements Foo { + + public void operation1() { + } + + public void operation2() { + } + + @EndsConversation + public void end() { + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME new file mode 100644 index 0000000000..36e221a1e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationMaxAgeExpireTestCase.java.FIXME @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.integration.conversation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.URI; + +import org.apache.tuscany.core.implementation.PojoConfiguration; +import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; +import org.apache.tuscany.core.injection.PojoObjectFactory; +import org.apache.tuscany.core.integration.mock.MockFactory; +import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler; +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; +import org.easymock.EasyMock; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; + +/** + * Verifies conversational resources are cleaned up if the maximum age is exceeded + * + * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $ + */ +public abstract class ConversationMaxAgeExpireTestCase extends AbstractConversationTestCase { + protected AtomicComponent target; + private JDKInvocationHandler handler; + private FooImpl targetInstance; + private Method operation1; + private Method operation2; + private final Object mutex = new Object(); + + public void testConversationExpire() throws Throwable { +/* + workContext.setIdentifier(org.apache.tuscany.spi.model.Scope.CONVERSATION, "12345A"); + // start the conversation + handler.invoke(operation1, null); + // verify the instance was persisted + assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); + synchronized (mutex) { + mutex.wait(100); + } + // verify the instance was expired + assertNull(store.readRecord(target, "12345A")); + // continue the conversation - should throw an error + try { + handler.invoke(operation2, null); + fail(); + } catch (TargetNotFoundException e) { + // expected + } +*/ + } + + + protected void setUp() throws Exception { + super.setUp(); + createRuntime(); + store.setReaperInterval(10); + initializeRuntime(); + + targetInstance = EasyMock.createMock(FooImpl.class); + targetInstance.operation1(); + targetInstance.operation2(); + targetInstance.end(); + EasyMock.replay(targetInstance); + target = createTarget(); + // create source component mock + JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class); + EasyMock.expect(source.getUri()).andReturn(URI.create("source")).atLeastOnce(); + EasyMock.replay(source); + + Wire wire = MockFactory.createWire("foo", Foo.class); + for (InvocationChain chain : wire.getInvocationChains().values()) { + chain.setTargetInvoker(target.createTargetInvoker("target", chain.getOperation(), false)); + } + handler = new JDKInvocationHandler(Foo.class, wire, workContext); + operation1 = Foo.class.getMethod("operation1"); + operation2 = Foo.class.getMethod("operation2"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + container.stop(); + store.destroy(); + } + + private AtomicComponent createTarget() throws Exception { + PojoConfiguration configuration = new PojoConfiguration(); + configuration.setName(new URI("target")); + configuration.setMaxAge(50); + Constructor 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 { + public MockPojoFactory(Constructor ctr) { + super(ctr); + } + + public FooImpl getInstance() throws ObjectCreationException { + return targetInstance; + } + } + + @Conversational + public static interface Foo { + + void operation1(); + + void operation2(); + + @EndsConversation + void end(); + + } + + public static class FooImpl implements Foo { + + public void operation1() { + } + + public void operation2() { + } + + @EndsConversation + public void end() { + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME new file mode 100644 index 0000000000..1872eea709 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ConversationStartStopEndTestCase.java.FIXME @@ -0,0 +1,147 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.integration.conversation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.URI; + +import org.apache.tuscany.core.implementation.PojoConfiguration; +import org.apache.tuscany.core.implementation.java.JavaAtomicComponent; +import org.apache.tuscany.core.injection.PojoObjectFactory; +import org.apache.tuscany.core.integration.mock.MockFactory; +import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler; +import org.apache.tuscany.spi.ObjectCreationException; +import org.apache.tuscany.spi.Scope; +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.InstanceWrapper; +import org.apache.tuscany.spi.wire.InvocationChain; +import org.apache.tuscany.spi.wire.Wire; +import org.easymock.EasyMock; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; + +/** + * Verifies start, continue and end conversation invocations are processed properly. Checks that a target instance is + * properly instantiated and persisted in the store. Additionally verifies that invocations are dispatched to a target + * instance, and that start, continue, and end operations are performed correctly. Finally, verfies that the target + * instance is removed from the store when the conversation ends. + * + * @version $Rev: 526852 $ $Date: 2007-04-09 10:47:45 -0700 (Mon, 09 Apr 2007) $ + */ +public abstract class ConversationStartStopEndTestCase extends AbstractConversationTestCase { + protected AtomicComponent target; + private FooImpl targetInstance; + private JDKInvocationHandler handler; + private Method operation1; + private Method operation2; + private Method endOperation; + + public void testConversationStartContinueEnd() throws Throwable { + workContext.setIdentifier(Scope.CONVERSATION, "12345A"); + // start the conversation + handler.invoke(operation1, null); + // verify the instance was persisted + assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); + // continue the conversation + handler.invoke(operation2, null); + // verify the instance was persisted + assertEquals(targetInstance, ((InstanceWrapper)store.readRecord(target, "12345A")).getInstance()); + // end the conversation + handler.invoke(endOperation, null); + workContext.clearIdentifier(Scope.CONVERSATION); + EasyMock.verify(targetInstance); + // verify the store has removed the instance + assertNull(store.readRecord(target, "12345A")); + } + + + protected void setUp() throws Exception { + super.setUp(); + createRuntime(); + initializeRuntime(); + targetInstance = EasyMock.createMock(FooImpl.class); + targetInstance.operation1(); + targetInstance.operation2(); + targetInstance.end(); + EasyMock.replay(targetInstance); + // create target component mock + target = createAtomicComponent(); + Wire wire = MockFactory.createWire("foo", Foo.class); + for (InvocationChain chain : wire.getInvocationChains().values()) { + chain.setTargetInvoker(target.createTargetInvoker("foo", chain.getOperation(), false)); + } + handler = new JDKInvocationHandler(Foo.class, wire, workContext); + operation1 = Foo.class.getMethod("operation1"); + operation2 = Foo.class.getMethod("operation2"); + endOperation = Foo.class.getMethod("end"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + container.stop(); + store.destroy(); + } + + private JavaAtomicComponent createAtomicComponent() throws Exception { + PojoConfiguration configuration = new PojoConfiguration(); + configuration.setName(new URI("target")); + configuration.setInstanceFactory(new MockPojoFactory(FooImpl.class.getConstructor())); + configuration.setImplementationClass(FooImpl.class); + JavaAtomicComponent component = new JavaAtomicComponent(configuration); + component.setScopeContainer(container); + component.start(); + return component; + } + + private class MockPojoFactory extends PojoObjectFactory { + public MockPojoFactory(Constructor ctr) { + super(ctr); + } + + public FooImpl getInstance() throws ObjectCreationException { + return targetInstance; + } + } + + @Conversational + public static interface Foo { + + void operation1(); + + void operation2(); + + @EndsConversation + void end(); + + } + + public static class FooImpl implements Foo { + + public void operation1() { + } + + public void operation2() { + } + + @EndsConversation + public void end() { + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME new file mode 100644 index 0000000000..17a832b117 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/integration/ReferenceInjectionTestCase.java.FIXME @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.core.integration.wire; + +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.HashMap; +import java.util.Map; +import java.net.URI; + +import org.apache.tuscany.spi.component.AtomicComponent; +import org.apache.tuscany.spi.component.ScopeContainer; + +import junit.framework.TestCase; +import org.apache.tuscany.core.component.scope.CompositeScopeContainer; +import org.apache.tuscany.core.integration.mock.MockFactory; +import org.apache.tuscany.core.mock.component.Source; +import org.apache.tuscany.core.mock.component.SourceImpl; +import org.apache.tuscany.core.mock.component.Target; +import org.apache.tuscany.core.mock.component.TargetImpl; + +/** + * @version $$Rev: 526399 $$ $$Date: 2007-04-07 01:14:49 -0700 (Sat, 07 Apr 2007) $$ + */ +public class ReferenceInjectionTestCase extends TestCase { + private Map members; + + public void testProxiedReferenceInjection() throws Exception { + ScopeContainer scope = new CompositeScopeContainer(null); + scope.start(); + URI groupId = URI.create("composite"); + scope.startContext(groupId, groupId); + Map 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(); + Method m = SourceImpl.class.getMethod("setTarget", Target.class); + members.put("target", m); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java new file mode 100644 index 0000000000..65681550c0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/AsyncTarget.java @@ -0,0 +1,31 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java new file mode 100644 index 0000000000..319d965960 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadContextPojo.java @@ -0,0 +1,28 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java new file mode 100644 index 0000000000..1a93254f2b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BadNamePojo.java @@ -0,0 +1,26 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java new file mode 100644 index 0000000000..716a70b007 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterface.java @@ -0,0 +1,30 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java new file mode 100644 index 0000000000..5f3dc8e5fb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/BasicInterfaceImpl.java @@ -0,0 +1,66 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java new file mode 100644 index 0000000000..1014dd3e1f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponent.java @@ -0,0 +1,31 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java new file mode 100644 index 0000000000..2b654111f3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeComponentImpl.java @@ -0,0 +1,40 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java new file mode 100644 index 0000000000..7c5751578a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeDestroyOnlyComponent.java @@ -0,0 +1,36 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java new file mode 100644 index 0000000000..4e08b7157b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitDestroyComponent.java @@ -0,0 +1,39 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java new file mode 100644 index 0000000000..a9c8bf1566 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/CompositeScopeInitOnlyComponent.java @@ -0,0 +1,42 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java new file mode 100644 index 0000000000..39e8c4ca11 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponent.java @@ -0,0 +1,29 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java new file mode 100644 index 0000000000..caf5b292f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeComponentImpl.java @@ -0,0 +1,29 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java new file mode 100644 index 0000000000..9fe019010d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeDestroyOnlyComponent.java @@ -0,0 +1,37 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java new file mode 100644 index 0000000000..77f9855fe0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitDestroyComponent.java @@ -0,0 +1,38 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java new file mode 100644 index 0000000000..d45d1a3def --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/ConversationalScopeInitOnlyComponent.java @@ -0,0 +1,38 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME new file mode 100644 index 0000000000..56bccd8f09 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockFactory.java.FIXME @@ -0,0 +1,214 @@ +/* + * 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 createWiredComponents(String sourceName, + Class sourceClass, + ScopeContainer sourceScope, + Map 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 createWiredComponents(String sourceName, Class sourceClass, + Class sourceReferenceClass, + ScopeContainer sourceScope, + Interceptor sourceHeadInterceptor, + Map 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 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 components = new HashMap(); + components.put(sourceName, sourceComponent); + components.put(targetName, targetComponent); + return components; + } + + + /** + * Wires two components using a multiplicity reference + */ + @SuppressWarnings("unchecked") + public static Map createWiredMultiplicity(String sourceName, Class sourceClass, + Class sourceReferenceClass, + ScopeContainer sourceScope, + String targetName, Class targetService, + Class targetClass, + Map 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 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 wires = new ArrayList(); + wires.add(wire); + sourceComponent.attachWires(wires); + targetScope.register(targetComponent, configuration.getGroupId()); + sourceScope.register(sourceComponent, configuration.getGroupId()); + + Map components = new HashMap(); + components.put(sourceName, sourceComponent); + components.put(targetName, targetComponent); + return components; + } + + public static Wire createWire(String serviceName, Class interfaze) + throws InvalidInterfaceException { + return createWire(serviceName, interfaze, null); + } + + public static Wire createWire(String serviceName, Class 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 JavaAtomicComponent createJavaComponent(String name, ScopeContainer scope, Class 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java new file mode 100644 index 0000000000..23822bec74 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockStaticInvoker.java @@ -0,0 +1,94 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java new file mode 100644 index 0000000000..1e2f89cdf6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/MockSyncInterceptor.java @@ -0,0 +1,52 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java new file mode 100644 index 0000000000..1d337de93f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderException.java @@ -0,0 +1,40 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java new file mode 100644 index 0000000000..09b58497fe --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojo.java @@ -0,0 +1,29 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java new file mode 100644 index 0000000000..0fc5a88925 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedDependentPojoImpl.java @@ -0,0 +1,36 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java new file mode 100644 index 0000000000..0907bf3e8b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedEagerInitPojo.java @@ -0,0 +1,60 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java new file mode 100644 index 0000000000..0c4f65e904 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojo.java @@ -0,0 +1,28 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java new file mode 100644 index 0000000000..e67a1b807b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OrderedInitPojoImpl.java @@ -0,0 +1,61 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java new file mode 100644 index 0000000000..61802beaea --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTarget.java @@ -0,0 +1,31 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java new file mode 100644 index 0000000000..3b8c4842f1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/OtherTargetImpl.java @@ -0,0 +1,39 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java new file mode 100644 index 0000000000..b10b1e7648 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeComponent.java @@ -0,0 +1,30 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java new file mode 100644 index 0000000000..f504e284ab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeDestroyOnlyComponent.java @@ -0,0 +1,38 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java new file mode 100644 index 0000000000..5a0f15a54f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitDestroyComponent.java @@ -0,0 +1,38 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java new file mode 100644 index 0000000000..b72cf2f1a3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/RequestScopeInitOnlyComponent.java @@ -0,0 +1,39 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java new file mode 100644 index 0000000000..7dcfd4acda --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponent.java @@ -0,0 +1,30 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java new file mode 100644 index 0000000000..bb0da51475 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeComponentImpl.java @@ -0,0 +1,30 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java new file mode 100644 index 0000000000..5dc7d82a8d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitDestroyComponent.java @@ -0,0 +1,36 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java new file mode 100644 index 0000000000..9a212c927f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SessionScopeInitOnlyComponent.java @@ -0,0 +1,37 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java new file mode 100644 index 0000000000..d8b6be1de0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTarget.java @@ -0,0 +1,30 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java new file mode 100644 index 0000000000..27cb9a7617 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SimpleTargetImpl.java @@ -0,0 +1,41 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java new file mode 100644 index 0000000000..630809bcad --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Source.java @@ -0,0 +1,37 @@ +/* + * 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 getTargets(); + + List getTargetsThroughField(); + +} + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java new file mode 100644 index 0000000000..bd1abf6577 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/SourceImpl.java @@ -0,0 +1,63 @@ +/* + * 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 targets; + private List targetsThroughField; + private Target[] targetsArray; + + public void setTarget(Target target) { + this.target = target; + } + + public Target getTarget() { + return target; + } + + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } + + public List getTargetsThroughField() { + return targetsThroughField; + } + + public Target[] getArrayOfTargets() { + return targetsArray; + } + + public void setArrayOfTargets(Target[] targets) { + targetsArray = targets; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java new file mode 100644 index 0000000000..7eb9172f28 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponent.java @@ -0,0 +1,30 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java new file mode 100644 index 0000000000..b1e0d33b63 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/StatelessComponentImpl.java @@ -0,0 +1,27 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java new file mode 100644 index 0000000000..fd175bdbc5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/Target.java @@ -0,0 +1,32 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java new file mode 100644 index 0000000000..5f5a11028f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/mock/TargetImpl.java @@ -0,0 +1,38 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java new file mode 100644 index 0000000000..7598b4f968 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/ExceptionFormatterTestCase.java @@ -0,0 +1,57 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java new file mode 100644 index 0000000000..2f7ed80030 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/monitor/JavaLoggingTestCase.java @@ -0,0 +1,152 @@ +/* + * 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 logs = new ArrayList(); + + 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java new file mode 100644 index 0000000000..40cf2e27cf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java @@ -0,0 +1,45 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java new file mode 100644 index 0000000000..a00b9e7109 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java @@ -0,0 +1,47 @@ +/* + * 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java new file mode 100644 index 0000000000..1c8f1caa93 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java @@ -0,0 +1,182 @@ +/* + * 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 testList; + private Map testMap; + private Target[] testArray; + private String[] testStringArray; + + public JavaIntrospectionHelperTestCase() { + super(); + } + + public JavaIntrospectionHelperTestCase(String arg0) { + super(arg0); + } + + public void testBean1AllPublicProtectedFields() throws Exception { + Set beanFields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(Bean1.class); + assertEquals(4, beanFields.size()); //Bean1.ALL_BEAN1_PUBLIC_PROTECTED_FIELDS + } + + public void testGetSuperAllMethods() throws Exception { + Set superBeanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(SuperBean.class); + assertEquals(SuperBean.ALL_SUPER_METHODS, superBeanMethods.size()); + } + + public void testGetBean1AllMethods() throws Exception { + Set beanMethods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(Bean1.class); + assertEquals(Bean1.ALL_BEAN1_METHODS, beanMethods.size()); + } + + public void testOverrideMethod() throws Exception { + Set 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 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 interfaces = JavaIntrospectionHelper.getAllInterfaces(Z.class); + assertEquals(2, interfaces.size()); + assertTrue(interfaces.contains(W.class)); + assertTrue(interfaces.contains(W2.class)); + } + + + public void testGetAllInterfacesObject() { + Set interfaces = JavaIntrospectionHelper.getAllInterfaces(Object.class); + assertEquals(0, interfaces.size()); + } + + public void testGetAllInterfacesNoInterfaces() { + Set 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 foo) { + + } + + private void fooMethod(Map 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/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java new file mode 100644 index 0000000000..408cedb8be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java @@ -0,0 +1,48 @@ +/* + * 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 { + } + +} -- cgit v1.2.3