tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adrianocrest...@apache.org
Subject svn commit: r653133 [30/33] - in /incubator/tuscany/sandbox/mobile-android: android-jdk-classes/ android-jdk-classes/src/ android-jdk-classes/src/javax/ android-jdk-classes/src/javax/xml/ android-jdk-classes/src/javax/xml/namespace/ android-jdk-classes...
Date Sat, 03 May 2008 20:52:58 GMT
Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,165 @@
+/*
+ * 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.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper.getAllInterfaces;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Processes an {@link org.osoa.sca.annotations.Service} annotation and updates
+ * the component type with corresponding {@link Service}s. Also processes
+ * related {@link org.osoa.sca.annotations.Callback} annotations.
+ * 
+ * @version $Rev: 639634 $ $Date: 2008-03-21 05:33:46 -0800 (Fri, 21 Mar 2008) $
+ */
+public class ServiceProcessor extends BaseJavaClassVisitor {
+    private JavaInterfaceFactory javaFactory;
+    
+    public ServiceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
+        super(assemblyFactory);
+        this.javaFactory = javaFactory;
+    }
+
+    @Override
+    public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+        org.osoa.sca.annotations.Service annotation = clazz.getAnnotation(org.osoa.sca.annotations.Service.class);
+        if (annotation == null) {
+            // scan interfaces for remotable
+            Set<Class> interfaces = getAllInterfaces(clazz);
+            for (Class<?> interfaze : interfaces) {
+                if (interfaze.isAnnotationPresent(Remotable.class) || interfaze.isAnnotationPresent(Callback.class)) {
+                    Service service;
+                    try {
+                        service = createService(interfaze);
+                    } catch (InvalidInterfaceException e) {
+                        throw new IntrospectionException(e);
+                    }
+                    type.getServices().add(service);
+                }
+            }
+            return;
+        }
+        Class<?>[] interfaces = annotation.interfaces();
+        if (interfaces.length == 0) {
+            Class<?> interfaze = annotation.value();
+            if (Void.class.equals(interfaze)) {
+                throw new IllegalServiceDefinitionException("No interfaces specified");
+            } else {
+                interfaces = new Class<?>[1];
+                interfaces[0] = interfaze;
+            }
+        }
+        for (Class<?> interfaze : interfaces) {
+            try {
+                Service service = createService(interfaze);
+                type.getServices().add(service);
+            } catch (InvalidInterfaceException e) {
+                throw new IntrospectionException(e);
+            }
+        }
+    }
+
+    @Override
+    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+
+        Callback annotation = method.getAnnotation(Callback.class);
+        if (annotation == null) {
+            return;
+        }
+        if (method.getParameterTypes().length != 1) {
+            throw new IllegalCallbackReferenceException("Setter must have one parameter", method);
+        }
+        JavaElementImpl element = new JavaElementImpl(method, 0);
+        createCallback(type, element);
+    }
+
+    @Override
+    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+
+        Callback annotation = field.getAnnotation(Callback.class);
+        if (annotation == null) {
+            return;
+        }
+        JavaElementImpl element = new JavaElementImpl(field);
+        createCallback(type, element);
+    }
+
+    /**
+     * @param type
+     * @param element
+     * @throws IllegalCallbackReferenceException
+     */
+    private void createCallback(JavaImplementation type, JavaElementImpl element)
+        throws IllegalCallbackReferenceException {
+        Service callbackService = null;
+        Class<?> callbackClass = element.getType();
+        Type genericType = element.getGenericType();
+        Class<?> baseType = callbackClass;
+        if(CallableReference.class.isAssignableFrom(baseType)) {
+            // @Callback protected CallableReference<MyCallback> callback;
+            // The base type will be MyCallback
+            baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
+        }        
+        for (Service service : type.getServices()) {
+            JavaInterface javaInterface = (JavaInterface)service.getInterfaceContract().getCallbackInterface();
+            if (javaInterface != null && baseType == javaInterface.getJavaClass()) {
+                callbackService = service;
+            }
+        }
+        if (callbackService == null) {
+            throw new IllegalCallbackReferenceException("Callback type does not match a service callback interface");
+        }
+        type.getCallbackMembers().put(baseType.getName(), element);
+    }
+
+    public Service createService(Class<?> interfaze) throws InvalidInterfaceException {
+        Service service = assemblyFactory.createService();
+        JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+        service.setInterfaceContract(interfaceContract);
+
+        // create a relative URI
+        service.setName(interfaze.getSimpleName());
+
+        JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+        service.getInterfaceContract().setInterface(callInterface);
+        if (callInterface.getCallbackClass() != null) {
+            JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+            service.getInterfaceContract().setCallbackInterface(callbackInterface);
+        }
+        return service;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,35 @@
+/*
+ * 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.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when a service interface cannot be determined based on a heuristic evaluation of an implementation
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class ServiceTypeNotFoundException extends IntrospectionException {
+    private static final long serialVersionUID = -5124437274726947007L;
+
+    public ServiceTypeNotFoundException(String message) {
+        super(message);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java Sat May  3 13:52:41 2008
@@ -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.introspect.impl;
+
+/**
+ * Thrown when a method or field marked with {@link org.osoa.sca.annotations.Context} takes an unknown type
+ *
+ * @version $Rev: 563019 $ $Date: 2007-08-05 20:43:59 -0700 (Sun, 05 Aug 2007) $
+ */
+public class UnknownContextTypeException extends IllegalContextException {
+    private static final long serialVersionUID = 8125863714365422419L;
+
+    public UnknownContextTypeException(String message) {
+        super(message);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory Sat May  3 13:52:41 2008
@@ -0,0 +1,18 @@
+# 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.
+
+org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java Sat May  3 13:52:41 2008
@@ -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.introspect.impl;
+
+import java.lang.reflect.Constructor;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaParameterImpl;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+
+
+/**
+ * Base class to simulate the processor sequences
+ * 
+ * @version $Rev: 564364 $ $Date: 2007-08-09 13:14:52 -0700 (Thu, 09 Aug 2007) $
+ */
+public class AbstractProcessorTest extends TestCase {
+    protected AssemblyFactory factory;
+    protected JavaInterfaceFactory javaFactory;
+    protected ConstructorProcessor constructorProcessor;
+    private ReferenceProcessor referenceProcessor;
+    private PropertyProcessor propertyProcessor;
+    private ResourceProcessor resourceProcessor;
+
+
+    protected AbstractProcessorTest() {
+        factory = new DefaultAssemblyFactory();
+        javaFactory = new DefaultJavaInterfaceFactory();
+        referenceProcessor = new ReferenceProcessor(factory, javaFactory);
+        propertyProcessor = new PropertyProcessor(factory);
+        resourceProcessor = new ResourceProcessor(factory);
+        constructorProcessor = new ConstructorProcessor(factory);
+        referenceProcessor = new ReferenceProcessor(factory, javaFactory);
+        propertyProcessor = new PropertyProcessor(factory);
+    }
+
+    protected <T> void visitConstructor(Constructor<T> constructor,
+                                        JavaImplementation type) throws IntrospectionException {
+        constructorProcessor.visitConstructor(constructor, type);
+        JavaConstructorImpl<?> definition = type.getConstructor();
+        if (definition == null) {
+            definition = new JavaConstructorImpl<T>(constructor);
+            type.getConstructors().put(constructor, definition);
+        }
+        JavaParameterImpl[] parameters = definition.getParameters();
+        for (int i = 0; i < parameters.length; i++) {
+            referenceProcessor.visitConstructorParameter(parameters[i], type);
+            propertyProcessor.visitConstructorParameter(parameters[i], type);
+            resourceProcessor.visitConstructorParameter(parameters[i], type);
+            // monitorProcessor.visitConstructorParameter(parameters[i], type);
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessorTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,169 @@
+/*
+ * 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.introspect.impl;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+
+import java.lang.annotation.Retention;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+
+
+/**
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class AbstractPropertyProcessorTestCase extends TestCase {
+
+    private JavaClassVisitor extension;
+    private JavaImplementationFactory javaImplementationFactory;
+
+    public void testVisitMethod() throws Exception {
+        Method method = Foo.class.getMethod("setBar", String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        extension.visitMethod(method, type);
+        Property prop = getProperty(type, "test");
+        assertNotNull(prop);
+    }
+
+    public void testVisitNoParamsMethod() throws Exception {
+        Method method = Foo.class.getMethod("setNoParamsBar");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            extension.visitMethod(method, type);
+            fail();
+        } catch (IllegalPropertyException e) {
+            // expected
+        }
+    }
+
+    public void testVisitNonVoidMethod() throws Exception {
+        Method method = Foo.class.getMethod("setBadBar", String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            extension.visitMethod(method, type);
+            fail();
+        } catch (IllegalPropertyException e) {
+            // expected
+        }
+    }
+
+    public void testDuplicateMethod() throws Exception {
+        Method method = Foo.class.getMethod("setBar", String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        extension.visitMethod(method, type);
+        try {
+            extension.visitMethod(method, type);
+            fail();
+        } catch (DuplicatePropertyException e) {
+            // expected
+        }
+    }
+
+    public void testVisitField() throws Exception {
+        Field field = Foo.class.getDeclaredField("d");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        extension.visitField(field, type);
+        Property prop = getProperty(type, "test");
+        assertNotNull(prop);
+    }
+
+    public void testVisitConstructor() throws Exception {
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        JavaConstructorImpl<Foo> def = new JavaConstructorImpl<Foo>(ctor);
+        JavaParameterImpl parameter = def.getParameters()[0];
+        extension.visitConstructorParameter(parameter, type);
+        assertEquals("test", def.getParameters()[0].getName());
+        assertNotNull(getProperty(type, "test"));
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected void setUp() throws Exception {
+        super.setUp();
+        extension = new TestProcessor();
+        javaImplementationFactory = new DefaultJavaImplementationFactory();
+    }
+
+    @Retention(RUNTIME)
+    private @interface Bar {
+
+    }
+
+    private class TestProcessor extends AbstractPropertyProcessor<Bar> {
+
+        public TestProcessor() {
+            super(new DefaultAssemblyFactory(), Bar.class);
+        }
+
+        @Override
+        @SuppressWarnings("unchecked")
+        protected void initProperty(Property property, Bar annotation) {
+            // property.setDefaultValueFactory(EasyMock.createMock(ObjectFactory.class));
+            property.setName("test");
+        }
+
+        @Override
+        protected String getName(Bar annotation) {
+            return "test";
+        }
+    }
+
+    private static class Foo {
+
+        @Bar
+        protected String d;
+
+        public Foo(String a, @Bar
+        String b) {
+        }
+
+        public Foo(@Bar
+        String d) {
+            this.d = d;
+        }
+
+        @Bar
+        public void setBar(String d) {
+            this.d = d;
+        }
+
+        @Bar
+        public void setNoParamsBar() {
+        }
+
+        @Bar
+        public String setBadBar(String d) {
+            return null;
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,71 @@
+/*
+ * 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.introspect.impl;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.osoa.sca.annotations.AllowsPassByReference;
+
+/**
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class AllowsPassByReferenceProcessorTestCase extends TestCase {
+
+    JavaImplementation type;
+    AllowsPassByReferenceProcessor processor;
+    private JavaImplementationFactory javaImplementationFactory;
+
+    public void testClassAnnotation() throws Exception {
+        processor.visitClass(Foo.class, type);
+        assertEquals(true, type.isAllowsPassByReference());
+
+        processor.visitClass(Bar.class, type);
+        assertEquals(false, type.isAllowsPassByReference());
+
+        Method m1 = Bar.class.getMethod("m1", new Class[] {});
+        processor.visitMethod(m1, type);
+        assertTrue(type.isAllowsPassByReference(m1));
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        javaImplementationFactory = new DefaultJavaImplementationFactory();
+        type = javaImplementationFactory.createJavaImplementation();
+        processor = new AllowsPassByReferenceProcessor(new DefaultAssemblyFactory());
+    }
+
+    @AllowsPassByReference
+    private class Foo {
+    }
+
+    // no annotation
+    private class Bar {
+        @AllowsPassByReference
+        public void m1() {
+
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,192 @@
+/*
+ * 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.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getReference;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaParameterImpl;
+import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * @version $Rev: 564364 $ $Date: 2007-08-09 13:14:52 -0700 (Thu, 09 Aug 2007) $
+ */
+public class ConstructorProcessorTestCase extends TestCase {
+    private ConstructorProcessor processor = new ConstructorProcessor(new DefaultAssemblyFactory());
+    
+    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+    public void testDuplicateConstructor() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            processor.visitClass(BadFoo.class, type);
+            fail();
+        } catch (DuplicateConstructorException e) {
+            // expected
+        }
+    }
+
+    public void testConstructorAnnotation() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class);
+        processor.visitConstructor(ctor1, type);
+        assertEquals("foo", type.getConstructor().getParameters()[0].getName());
+    }
+
+    public void testNoAnnotation() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<NoAnnotation> ctor1 = NoAnnotation.class.getConstructor();
+        processor.visitConstructor(ctor1, type);
+        assertNull(type.getConstructor());
+    }
+
+    public void testBadAnnotation() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadAnnotation> ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class);
+        try {
+            processor.visitConstructor(ctor1, type);
+            fail();
+        } catch (InvalidConstructorException e) {
+            // expected
+        }
+    }
+
+    public void testMixedParameters() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Mixed> ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class);
+        processor.visitConstructor(ctor1, type);
+
+        AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+        JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory();
+        ReferenceProcessor referenceProcessor = new ReferenceProcessor(assemblyFactory, javaFactory);
+        PropertyProcessor propertyProcessor = new PropertyProcessor(assemblyFactory);
+        JavaParameterImpl[] parameters = type.getConstructor().getParameters();
+        for (int i = 0; i < parameters.length; i++) {
+            referenceProcessor.visitConstructorParameter(parameters[i], type);
+            propertyProcessor.visitConstructorParameter(parameters[i], type);
+        }
+
+        assertEquals("_ref0", parameters[0].getName());
+        assertEquals("foo", parameters[1].getName());
+        assertEquals("bar", parameters[2].getName());
+    }
+
+    private static class BadFoo {
+
+        @org.osoa.sca.annotations.Constructor("foo")
+        public BadFoo(String foo) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor( {"foo", "bar"})
+        public BadFoo(String foo, String bar) {
+
+        }
+    }
+
+    private static class Foo {
+        @org.osoa.sca.annotations.Constructor("foo")
+        public Foo(String foo) {
+
+        }
+    }
+
+    private static class NoAnnotation {
+        public NoAnnotation() {
+        }
+    }
+
+    private static class BadAnnotation {
+        @org.osoa.sca.annotations.Constructor("foo")
+        public BadAnnotation(String foo, Foo ref) {
+        }
+    }
+
+    public static final class Mixed {
+        @org.osoa.sca.annotations.Constructor
+        public Mixed(@Reference
+        String param1, @Property(name = "foo")
+        String param2, @Reference(name = "bar")
+        String param3) {
+        }
+    }
+
+    public static final class Multiple {
+        @org.osoa.sca.annotations.Constructor
+        public Multiple(@Reference
+        Collection<String> param1, @Property(name = "foo")
+        String[] param2, @Reference(name = "bar", required = true)
+        List<String> param3, @Property(name = "abc")
+        Set<String> param4, @Reference(name = "xyz")
+        String[] param5) {
+        }
+    }
+
+    public void testMultiplicity() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Multiple> ctor1 = Multiple.class.getConstructor(Collection.class,
+                                                                    String[].class,
+                                                                    List.class,
+                                                                    Set.class,
+                                                                    String[].class);
+        processor.visitConstructor(ctor1, type);
+        AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+        JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory();
+        ReferenceProcessor referenceProcessor = new ReferenceProcessor(assemblyFactory, javaFactory);
+        PropertyProcessor propertyProcessor = new PropertyProcessor(assemblyFactory);
+        JavaParameterImpl[] parameters = type.getConstructor().getParameters();
+        for (int i = 0; i < parameters.length; i++) {
+            referenceProcessor.visitConstructorParameter(parameters[i], type);
+            propertyProcessor.visitConstructorParameter(parameters[i], type);
+        }
+
+        org.apache.tuscany.sca.assembly.Reference ref0 = getReference(type, "_ref0");
+        assertNotNull(ref0);
+        assertEquals(Multiplicity.ONE_N, ref0.getMultiplicity());
+        org.apache.tuscany.sca.assembly.Reference ref1 = getReference(type, "bar");
+        assertNotNull(ref1);
+        assertEquals(Multiplicity.ONE_N, ref1.getMultiplicity());
+        org.apache.tuscany.sca.assembly.Reference ref2 = getReference(type, "xyz");
+        assertNotNull(ref2);
+        assertEquals(Multiplicity.ONE_N, ref2.getMultiplicity());
+        org.apache.tuscany.sca.assembly.Property prop1 = getProperty(type, "foo");
+        assertNotNull(prop1);
+        assertTrue(prop1.isMany());
+        org.apache.tuscany.sca.assembly.Property prop2 = getProperty(type, "abc");
+        assertNotNull(prop2);
+        assertTrue(prop2.isMany());
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,157 @@
+/*
+ * 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.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getProperty;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class ConstructorPropertyTestCase extends AbstractProcessorTest {
+    
+    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+    public void testProperty() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+        visitConstructor(ctor, type);
+        org.apache.tuscany.sca.assembly.Property property = getProperty(type, "myProp");
+        assertTrue(property.isMustSupply());
+        assertEquals("myProp", property.getName());
+    }
+
+    public void testTwoPropertiesSameType() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+        visitConstructor(ctor, type);
+        assertNotNull(getProperty(type, "myProp1"));
+        assertNotNull(getProperty(type, "myProp2"));
+    }
+
+    public void testDuplicateProperty() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (DuplicatePropertyException e) {
+            // expected
+        }
+    }
+
+    public void testNoName() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidPropertyException e) {
+            // expected
+        }
+    }
+
+    public void testNamesOnConstructor() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+        visitConstructor(ctor, type);
+        assertNotNull(getProperty(type, "myProp"));
+    }
+
+    public void testInvalidNumberOfNames() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidConstructorException e) {
+            // expected
+        }
+    }
+
+    public void testNoMatchingNames() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidConstructorException e) {
+            // expected
+        }
+    }
+
+//    public void testMultiplicityRequired() throws Exception {
+    // TODO multiplicity
+//    }
+
+    private static class Foo {
+
+        @org.osoa.sca.annotations.Constructor()
+        public Foo(@Property(name = "myProp", required = true)String prop) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor("myProp")
+        public Foo(@Property Integer prop) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor()
+        public Foo(@Property(name = "myProp1")String prop1, @Property(name = "myProp2")String prop2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor()
+        public Foo(@Property List prop) {
+
+        }
+    }
+
+    private static class BadFoo {
+
+        @org.osoa.sca.annotations.Constructor()
+        public BadFoo(@Property(name = "myProp")String prop1, @Property(name = "myProp")String prop2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor()
+        public BadFoo(@Property String prop) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor("myProp")
+        public BadFoo(@Property Integer prop, @Property Integer prop2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"})
+        public BadFoo(@Property List ref, @Property(name = "myOtherRef")List ref2) {
+
+        }
+
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,167 @@
+/*
+ * 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.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.ModelHelper.getReference;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class ConstructorReferenceTestCase extends AbstractProcessorTest {
+    
+    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+    public void testReference() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+        visitConstructor(ctor, type);
+        org.apache.tuscany.sca.assembly.Reference reference = getReference(type, "myRef");
+        assertEquals(Multiplicity.ONE_ONE, reference.getMultiplicity());
+        assertEquals("myRef", reference.getName());
+    }
+
+    public void testTwoReferencesSameType() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+        visitConstructor(ctor, type);
+        assertNotNull(getReference(type, "myRef1"));
+        assertNotNull(getReference(type, "myRef2"));
+    }
+
+    public void testDuplicateProperty() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (DuplicateReferenceException e) {
+            // expected
+        }
+    }
+
+    public void testNoName() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<NoNameFoo> ctor = NoNameFoo.class.getConstructor(String.class);
+        visitConstructor(ctor, type);
+        assertNotNull(getReference(type, "_ref0"));
+    }
+
+    public void testNamesOnConstructor() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+        visitConstructor(ctor, type);
+        assertNotNull(getReference(type, "myRef"));
+    }
+
+    public void testInvalidNumberOfNames() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidConstructorException e) {
+            // expected
+        }
+    }
+
+    public void testNoMatchingNames() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidConstructorException e) {
+            // expected
+        }
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+//    public void testMultiplicityRequired() throws Exception {
+    // TODO multiplicity
+//    }
+
+    private static class Foo {
+
+        @org.osoa.sca.annotations.Constructor()
+        public Foo(@Reference(name = "myRef", required = true)String prop) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor()
+        public Foo(@Reference(name = "myRef1")String prop1, @Reference(name = "myRef2")String prop2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor("myRef")
+        public Foo(@Reference Integer prop) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor()
+        public Foo(@Reference List prop) {
+
+        }
+    }
+
+    private static class NoNameFoo {
+
+        @org.osoa.sca.annotations.Constructor
+        public NoNameFoo(@Reference String prop) {
+
+        }
+    }
+
+    private static class BadFoo {
+
+        @org.osoa.sca.annotations.Constructor
+        public BadFoo(@Reference(name = "myRef")String prop1, @Reference(name = "myRef")String prop2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor
+        public BadFoo(@Reference String prop) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor("myRef")
+        public BadFoo(@Reference Integer ref, @Reference Integer ref2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor({"myRef", "myRef2"})
+        public BadFoo(@Reference List ref, @Reference(name = "myOtherRef")List ref2) {
+
+        }
+
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java Sat May  3 13:52:41 2008
@@ -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.introspect.impl;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+
+/**
+ * @version $Rev: 563019 $ $Date: 2007-08-05 20:43:59 -0700 (Sun, 05 Aug 2007) $
+ */
+public class ConstructorResourceTestCase extends AbstractProcessorTest {
+    
+    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+    public void testResource() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+        visitConstructor(ctor, type);
+        org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl resource = type.getResources().get("myResource");
+        assertFalse(resource.isOptional());
+    }
+
+    public void testTwoResourcesSameType() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
+        visitConstructor(ctor, type);
+        assertNotNull(type.getResources().get("myResource1"));
+        assertNotNull(type.getResources().get("myResource2"));
+    }
+
+    public void testDuplicateResource() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (DuplicateResourceException e) {
+            // expected
+        }
+    }
+
+    public void testNoName() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<ConstructorResourceTestCase.BadFoo> ctor =
+            ConstructorResourceTestCase.BadFoo.class.getConstructor(String.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidResourceException e) {
+            // expected
+        }
+    }
+
+    public void testNamesOnConstructor() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
+        visitConstructor(ctor, type);
+        assertNotNull(type.getResources().get("myResource"));
+    }
+
+    public void testInvalidNumberOfNames() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<ConstructorResourceTestCase.BadFoo> ctor =
+            ConstructorResourceTestCase.BadFoo.class.getConstructor(Integer.class, Integer.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidConstructorException e) {
+            // expected
+        }
+    }
+
+    public void testNoMatchingNames() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Constructor<ConstructorResourceTestCase.BadFoo> ctor =
+            ConstructorResourceTestCase.BadFoo.class.getConstructor(List.class, List.class);
+        try {
+            visitConstructor(ctor, type);
+            fail();
+        } catch (InvalidConstructorException e) {
+            // expected
+        }
+    }
+
+    private static class Foo {
+
+        @org.osoa.sca.annotations.Constructor
+        public Foo(@Resource(name = "myResource") String resource) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor("myResource")
+        public Foo(@Resource Integer resource) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor
+        public Foo(@Resource(name = "myResource1") String res1, @Resource(name = "myResource2") String res2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor
+        public Foo(@Resource List res) {
+
+        }
+    }
+
+    private static class BadFoo {
+
+        @org.osoa.sca.annotations.Constructor
+        public BadFoo(@Resource(name = "myResource") String res1, @Resource(name = "myResource") String res2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor
+        public BadFoo(@Resource String res) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor("myProp")
+        public BadFoo(@Resource Integer res, @Resource Integer res2) {
+
+        }
+
+        @org.osoa.sca.annotations.Constructor({"myRes", "myRes2"})
+        public BadFoo(@Resource List res, @Resource(name = "myOtherRes") List res2) {
+
+        }
+
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,201 @@
+/*
+ * 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.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+
+/**
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class ContextProcessorTestCase extends TestCase {
+    private ContextProcessor processor;
+    private ComponentNameProcessor nameProcessor;
+    private JavaImplementationFactory javaImplementationFactory;
+
+    public void testComponentContextMethod() throws Exception {
+        Method method = Foo.class.getMethod("setContext", ComponentContext.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitMethod(method, type);
+        assertNotNull(type.getResources().get("context"));
+    }
+
+    public void testComponentContextField() throws Exception {
+        Field field = Foo.class.getDeclaredField("context");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitField(field, type);
+        assertNotNull(type.getResources().get("context"));
+    }
+
+    public void testRequestContextMethod() throws Exception {
+        Method method = Foo.class.getMethod("setRequestContext", RequestContext.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitMethod(method, type);
+        assertNotNull(type.getResources().get("requestContext"));
+    }
+
+    public void testRequestContextField() throws Exception {
+        Field field = Foo.class.getDeclaredField("requestContext");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitField(field, type);
+        assertNotNull(type.getResources().get("requestContext"));
+    }
+
+    public void testComponentNameMethod() throws Exception {
+        Method method = Foo.class.getMethod("setName", String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        nameProcessor.visitMethod(method, type);
+        assertNotNull(type.getResources().get("name"));
+    }
+
+    public void testComponentNameField() throws Exception {
+        Field field = Foo.class.getDeclaredField("name");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        nameProcessor.visitField(field, type);
+        assertNotNull(type.getResources().get("name"));
+    }
+
+    public void testInvalidParamType() throws Exception {
+        Method method = Foo.class.getMethod("setContext", String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            processor.visitMethod(method, type);
+            fail();
+        } catch (UnknownContextTypeException e) {
+            // expected
+        }
+    }
+
+    public void testInvalidParamTypeField() throws Exception {
+        Field field = Foo.class.getDeclaredField("badContext");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            processor.visitField(field, type);
+            fail();
+        } catch (UnknownContextTypeException e) {
+            // expected
+        }
+    }
+
+
+    public void testInvalidParamNum() throws Exception {
+        Method method = Foo.class.getMethod("setContext", ComponentContext.class, String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            processor.visitMethod(method, type);
+            fail();
+        } catch (IllegalContextException e) {
+            // expected
+        }
+    }
+
+    public void testInvalidNoParams() throws Exception {
+        Method method = Foo.class.getMethod("setContext");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            processor.visitMethod(method, type);
+            fail();
+        } catch (IllegalContextException e) {
+            // expected
+        }
+    }
+
+    public void testNoContext() throws Exception {
+        Method method = Foo.class.getMethod("noContext", ComponentContext.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitMethod(method, type);
+        assertEquals(0, type.getResources().size());
+    }
+
+    public void testNoContextField() throws Exception {
+        Field field = Foo.class.getDeclaredField("noContext");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitField(field, type);
+        assertEquals(0, type.getResources().size());
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        javaImplementationFactory = new DefaultJavaImplementationFactory();
+        processor = new ContextProcessor(new DefaultAssemblyFactory());
+        nameProcessor = new ComponentNameProcessor(new DefaultAssemblyFactory());
+    }
+
+    private class Foo {
+        @Context
+        protected ComponentContext context;
+
+        @ComponentName
+        protected String name;
+
+        @Context
+        protected Object badContext;
+
+        protected ComponentContext noContext;
+
+        @Context
+        protected RequestContext requestContext;
+
+        @Context
+        public void setContext(ComponentContext context) {
+
+        }
+
+        @ComponentName
+        public void setName(String name) {
+
+        }
+
+        @Context
+        public void setContext(String context) {
+
+        }
+
+        @Context
+        public void setContext(ComponentContext context, String string) {
+
+        }
+
+        @Context
+        public void setContext() {
+
+        }
+
+        public void noContext(ComponentContext context) {
+
+        }
+
+        @Context
+        public void setRequestContext(RequestContext requestContext) {
+            this.requestContext = requestContext;
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,92 @@
+/*
+ * 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.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.osoa.sca.annotations.ConversationID;
+
+/**
+ * Test the ConversationIDProcessor
+ */
+public class ConversationIDProcessorTestCase extends TestCase {
+    private ConversationIDProcessor processor;
+    private JavaImplementationFactory javaImplementationFactory;
+
+    public void testConversationIDMethod() throws Exception {
+        Method method = Foo.class.getMethod("setConversationID", String.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitMethod(method, type);
+        assertNotNull(type.getResources().get("conversationID"));
+    }
+
+    public void testConversationIDField() throws Exception {
+        Field field = Foo.class.getDeclaredField("cid");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitField(field, type);
+        assertNotNull(type.getResources().get("cid"));
+    }
+
+    public void testConversationIDMethodNotString() throws Exception {
+        Method method = Foo.class.getMethod("setConversationID", Long.class);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitMethod(method, type);
+        assertNotNull(type.getResources().get("conversationID"));
+    }
+
+    public void testConversationIDFieldNotString() throws Exception {
+        Field field = Foo.class.getDeclaredField("longCID");
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitField(field, type);
+        assertNotNull(type.getResources().get("longCID"));
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        javaImplementationFactory = new DefaultJavaImplementationFactory();
+        processor = new ConversationIDProcessor(new DefaultAssemblyFactory());
+    }
+
+    private class Foo {
+
+        @ConversationID
+        protected String cid;
+
+        @ConversationID
+        public void setConversationID(String cid) {
+
+        }
+
+        @ConversationID
+        protected Long longCID;
+
+        @ConversationID
+        public void setConversationID(Long cid) {
+
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,144 @@
+/*
+ * 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.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.osoa.sca.annotations.ConversationAttributes;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev: 620333 $ $Date: 2008-02-10 13:31:04 -0800 (Sun, 10 Feb 2008) $
+ */
+public class ConversationProcessorTestCase extends TestCase {
+    private ConversationProcessor processor = new ConversationProcessor(new DefaultAssemblyFactory());
+    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+    public void testMaxIdleTime() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitClass(FooMaxIdle.class, type);
+        assertEquals(10000L, type.getMaxIdleTime());
+        assertEquals(-1, type.getMaxAge());
+    }
+
+    public void testMaxAge() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitClass(FooMaxAge.class, type);
+        assertEquals(10000L, type.getMaxAge());
+        assertEquals(-1, type.getMaxIdleTime());
+    }
+
+    public void testImplicitScope() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitClass(ImplicitFooScope.class, type);
+        assertEquals(org.apache.tuscany.sca.implementation.java.impl.JavaScopeImpl.CONVERSATION, type.getJavaScope());
+    }
+
+    /* TUSCANY-1999 - apply conversation properties to all scopes
+    public void testBadFooScope() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        try {
+            processor.visitClass(BadFooScope.class, type);
+            fail();
+        } catch (InvalidConversationalImplementation e) {
+            // expected
+        }
+    }
+    */
+
+    public void testBadFooBoth() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitClass(BadFooBoth.class, type);
+        assertEquals(10000L, type.getMaxAge());
+        assertEquals(10000L, type.getMaxIdleTime());
+    }
+
+    public void testJustConversation() throws Exception {
+        // TODO do we want these semantics
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        processor.visitClass(FooJustConversation.class, type);
+        assertEquals(org.apache.tuscany.sca.implementation.java.impl.JavaScopeImpl.CONVERSATION, type.getJavaScope());
+        assertEquals(-1, type.getMaxAge());
+        assertEquals(-1, type.getMaxIdleTime());
+    }
+
+    public void testSetConversationIDField() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Field field = FooWithConversationIDField.class.getDeclaredField("conversationID");
+        processor.visitField(field, type);
+        assertNotNull(type.getConversationIDMembers());
+        assertEquals(field, type.getConversationIDMembers().get(0));
+    }
+
+    public void testSetConversationIDMethod() throws Exception {
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Method method = FooWithConversationIDMethod.class.getDeclaredMethods()[0];
+        processor.visitMethod(method, type);
+        assertNotNull(type.getConversationIDMembers());
+        assertEquals(method, type.getConversationIDMembers().get(0));
+    }
+
+    @Scope("CONVERSATION")
+    @ConversationAttributes(maxIdleTime = "10 seconds")
+    private class FooMaxIdle {
+    }
+
+    @Scope("CONVERSATION")
+    @ConversationAttributes(maxAge = "10 seconds")
+    private class FooMaxAge {
+    }
+
+    @Scope("CONVERSATION")
+    @ConversationAttributes(maxAge = "10 seconds", maxIdleTime = "10 seconds")
+    private class BadFooBoth {
+    }
+
+    @ConversationAttributes(maxAge = "10 seconds")
+    private class ImplicitFooScope {
+    }
+
+    @Scope("STATELESS")
+    @ConversationAttributes(maxAge = "10 seconds")
+    private class BadFooScope {
+    }
+
+    @ConversationAttributes
+    private class FooJustConversation {
+    }
+
+    private class FooWithConversationIDField {
+        
+        @ConversationID
+        String conversationID;
+    }
+
+    private class FooWithConversationIDMethod {
+        @ConversationID
+        void setConversationID(String conversationID) {
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,117 @@
+/*
+ * 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.introspect.impl;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+
+/**
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class ConvertTimeMillisTestCase extends TestCase {
+    private MockProcessor registy;
+
+    public void testConvertSeconds() throws Exception {
+        assertEquals(10000L, registy.convertTimeMillis("10 seconds"));
+        assertEquals(10000L, registy.convertTimeMillis("10 SECONDS"));
+        try {
+            registy.convertTimeMillis("10seconds");
+            fail();
+        } catch (NumberFormatException e) {
+            // expected
+        }
+    }
+
+    public void testConvertMinutes() throws Exception {
+        assertEquals(600000L, registy.convertTimeMillis("10 minutes"));
+        assertEquals(600000L, registy.convertTimeMillis("10 MINUTES"));
+        try {
+            registy.convertTimeMillis("10minutes");
+            fail();
+        } catch (NumberFormatException e) {
+            // expected
+        }
+    }
+
+    public void testConvertHours() throws Exception {
+        assertEquals(36000000L, registy.convertTimeMillis("10 hours"));
+        assertEquals(36000000L, registy.convertTimeMillis("10 HOURS"));
+        try {
+            registy.convertTimeMillis("10hours");
+            fail();
+        } catch (NumberFormatException e) {
+            // expected
+        }
+    }
+
+    public void testConvertDays() throws Exception {
+        assertEquals(864000000L, registy.convertTimeMillis("10 days"));
+        assertEquals(864000000L, registy.convertTimeMillis("10 DAYS"));
+        try {
+            registy.convertTimeMillis("10days");
+            fail();
+        } catch (NumberFormatException e) {
+            // expected
+        }
+    }
+
+    public void testConvertYears() throws Exception {
+        assertEquals(315569260000L, registy.convertTimeMillis("10 years"));
+        assertEquals(315569260000L, registy.convertTimeMillis("10 YEARS"));
+        try {
+            registy.convertTimeMillis("10years");
+            fail();
+        } catch (NumberFormatException e) {
+            // expected
+        }
+    }
+
+    public void testConvertDefault() throws Exception {
+        assertEquals(10000L, registy.convertTimeMillis("10 "));
+        assertEquals(10000L, registy.convertTimeMillis("10"));
+    }
+
+    public void testInvalid() throws Exception {
+        try {
+            registy.convertTimeMillis("foo");
+            fail();
+        } catch (NumberFormatException e) {
+            // expected
+        }
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        registy = new MockProcessor();
+    }
+
+    private class MockProcessor extends ConversationProcessor {
+        
+        public MockProcessor() {
+            super(new DefaultAssemblyFactory());
+        }
+
+        @Override
+        protected long convertTimeMillis(String expr) throws NumberFormatException {
+            return super.convertTimeMillis(expr);
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java Sat May  3 13:52:41 2008
@@ -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.introspect.impl;
+
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.osoa.sca.annotations.Destroy;
+
+/**
+ * @version $Rev: 563019 $ $Date: 2007-08-05 20:43:59 -0700 (Sun, 05 Aug 2007) $
+ */
+public class DestroyProcessorTestCase extends TestCase {
+    
+    private AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+
+    public void testDestroy() throws Exception {
+        DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Method method = Foo.class.getMethod("destroy");
+        processor.visitMethod(method, type);
+        assertNotNull(type.getDestroyMethod());
+    }
+
+    public void testBadDestroy() throws Exception {
+        DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Method method = Bar.class.getMethod("badDestroy", String.class);
+        try {
+            processor.visitMethod(method, type);
+            fail();
+        } catch (IllegalDestructorException e) {
+            // expected
+        }
+    }
+
+    public void testTwoDestroy() throws Exception {
+        DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
+        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
+        Method method = Bar.class.getMethod("destroy");
+        Method method2 = Bar.class.getMethod("destroy2");
+        processor.visitMethod(method, type);
+        try {
+            processor.visitMethod(method2, type);
+            fail();
+        } catch (DuplicateDestructorException e) {
+            // expected
+        }
+    }
+
+
+    private class Foo {
+
+        @Destroy
+        public void destroy() {
+        }
+    }
+
+
+    private class Bar {
+
+        @Destroy
+        public void destroy() {
+        }
+
+        @Destroy
+        public void destroy2() {
+        }
+
+        @Destroy
+        public void badDestroy(String foo) {
+        }
+
+
+    }
+}



Mime
View raw message