You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/10 11:30:01 UTC

svn commit: r527067 [2/2] - in /incubator/tuscany/java/sca/modules: ./ host-embedded/ host-embedded/src/test/resources/META-INF/services/ implementation-java-runtime/src/main/resources/META-INF/ implementation-java-runtime/src/main/resources/META-INF/s...

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java.FIXME Tue Apr 10 02:29:58 2007
@@ -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<FooImpl> {
+        public MockPojoFactory(Constructor<FooImpl> ctr) {
+            super(ctr);
+        }
+
+        public FooImpl getInstance() throws ObjectCreationException {
+            return targetInstance;
+        }
+    }
+
+    @Conversational
+    public static interface Foo {
+
+        void operation1();
+
+        void operation2();
+
+        @EndsConversation
+        void end();
+
+    }
+
+    public static class FooImpl implements Foo {
+
+        public void operation1() {
+        }
+
+        public void operation2() {
+        }
+
+        @EndsConversation
+        public void end() {
+        }
+    }
+}

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/mock/MockFactory.java.FIXME Tue Apr 10 02:29:58 2007
@@ -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<String, AtomicComponent> createWiredComponents(String sourceName,
+                                                                     Class<?> sourceClass,
+                                                                     ScopeContainer sourceScope,
+                                                                     Map<String, Member> members,
+                                                                     String targetName,
+                                                                     Class<?> targetService,
+                                                                     Class<?> targetClass,
+                                                                     ScopeContainer targetScope) throws Exception {
+        return createWiredComponents(sourceName,
+            sourceClass,
+            targetService,
+            sourceScope,
+            null,
+            members,
+            targetName,
+            targetClass,
+            targetScope
+        );
+
+    }
+
+    @SuppressWarnings("unchecked")
+    public static Map<String, AtomicComponent> createWiredComponents(String sourceName, Class<?> sourceClass,
+                                                                     Class<?> sourceReferenceClass,
+                                                                     ScopeContainer sourceScope,
+                                                                     Interceptor sourceHeadInterceptor,
+                                                                     Map<String, Member> members,
+                                                                     String targetName,
+                                                                     Class<?> targetClass,
+                                                                     ScopeContainer targetScope
+    )
+        throws Exception {
+
+        JavaAtomicComponent targetComponent =
+            createJavaComponent(targetName, targetScope, targetClass);
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
+        configuration.setProxyService(PROXY_SERVICE);
+        for (Map.Entry<String, Member> entry : members.entrySet()) {
+            configuration.addReferenceSite(entry.getKey(), entry.getValue());
+        }
+        configuration.setWorkContext(new WorkContextImpl());
+        configuration.setName(new URI(sourceName));
+        configuration.setGroupId(URI.create("composite"));
+        JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration);
+        sourceComponent.setScopeContainer(sourceScope);
+        Wire wire = createWire(targetName, sourceReferenceClass, sourceHeadInterceptor);
+        for (InvocationChain chain : wire.getInvocationChains().values()) {
+            chain.setTargetInvoker(targetComponent.createTargetInvoker(targetName, chain.getOperation(), false));
+        }
+        sourceComponent.attachWire(wire);
+        targetScope.register(targetComponent, configuration.getGroupId());
+        sourceScope.register(sourceComponent, configuration.getGroupId());
+        Map<String, AtomicComponent> components = new HashMap<String, AtomicComponent>();
+        components.put(sourceName, sourceComponent);
+        components.put(targetName, targetComponent);
+        return components;
+    }
+
+
+    /**
+     * Wires two components using a multiplicity reference
+     */
+    @SuppressWarnings("unchecked")
+    public static Map<String, AtomicComponent> createWiredMultiplicity(String sourceName, Class<?> sourceClass,
+                                                                       Class<?> sourceReferenceClass,
+                                                                       ScopeContainer sourceScope,
+                                                                       String targetName, Class<?> targetService,
+                                                                       Class<?> targetClass,
+                                                                       Map<String, Member> members,
+                                                                       ScopeContainer targetScope) throws Exception {
+        JavaAtomicComponent targetComponent =
+            createJavaComponent(targetName, targetScope, targetClass);
+        String serviceName = targetService.getName().substring(targetService.getName().lastIndexOf('.') + 1);
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setInstanceFactory(new PojoObjectFactory(sourceClass.getConstructor()));
+        configuration.setProxyService(PROXY_SERVICE);
+        for (Map.Entry<String, Member> entry : members.entrySet()) {
+            configuration.addReferenceSite(entry.getKey(), entry.getValue());
+        }
+        configuration.setWorkContext(new WorkContextImpl());
+        configuration.setName(new URI(sourceName));
+        configuration.setGroupId(URI.create("composite"));
+
+        JavaAtomicComponent sourceComponent = new JavaAtomicComponent(configuration);
+        sourceComponent.setScopeContainer(sourceScope);
+        Wire wire = createWire(targetName, sourceReferenceClass, null);
+        wire.setTargetUri(URI.create(targetName + "#" + serviceName));
+        for (InvocationChain chain : wire.getInvocationChains().values()) {
+            chain.setTargetInvoker(targetComponent.createTargetInvoker("target", chain.getOperation(), false));
+        }
+        List<Wire> wires = new ArrayList<Wire>();
+        wires.add(wire);
+        sourceComponent.attachWires(wires);
+        targetScope.register(targetComponent, configuration.getGroupId());
+        sourceScope.register(sourceComponent, configuration.getGroupId());
+
+        Map<String, AtomicComponent> components = new HashMap<String, AtomicComponent>();
+        components.put(sourceName, sourceComponent);
+        components.put(targetName, targetComponent);
+        return components;
+    }
+
+    public static <T> Wire createWire(String serviceName, Class<T> interfaze)
+        throws InvalidInterfaceException {
+        return createWire(serviceName, interfaze, null);
+    }
+
+    public static <T> Wire createWire(String serviceName, Class<T> interfaze, Interceptor interceptor)
+        throws InvalidInterfaceException {
+        Wire wire = new WireImpl();
+        Contract contract = new DefaultAssemblyFactory().createComponentService();
+        REGISTRY.introspect(contract, interfaze);
+        wire.setSourceContract(contract);
+        wire.setSourceUri(URI.create("#" + serviceName));
+        createChains(interfaze, interceptor, wire);
+        return wire;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static <T> JavaAtomicComponent createJavaComponent(String name, ScopeContainer scope, Class<T> clazz)
+        throws NoSuchMethodException, URISyntaxException {
+        PojoConfiguration configuration = new PojoConfiguration();
+        configuration.setImplementationClass(clazz);
+        configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor()));
+        configuration.setProxyService(PROXY_SERVICE);
+        configuration.setWorkContext(new WorkContextImpl());
+        configuration.setName(new URI(name));
+        configuration.setGroupId(URI.create("composite"));
+        JavaAtomicComponent component = new JavaAtomicComponent(configuration);
+        component.setScopeContainer(scope);
+        return component;
+    }
+
+    private static void createChains(Class<?> interfaze, Interceptor interceptor, Wire wire)
+        throws InvalidInterfaceException {
+
+        Contract contract = new DefaultAssemblyFactory().createComponentService();
+        REGISTRY.introspect(contract, interfaze);
+        for (Operation method : contract.getInterface().getOperations()) {
+            InvocationChain chain = new InvocationChainImpl(method);
+            if (interceptor != null) {
+                chain.addInterceptor(interceptor);
+            }
+            // add tail interceptor
+            chain.addInterceptor(new InvokerInterceptor());
+            wire.addInvocationChain(method, chain);
+        }
+    }
+
+}

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java.FIXME
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java.FIXME?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java.FIXME (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/integration/wire/ReferenceInjectionTestCase.java.FIXME Tue Apr 10 02:29:58 2007
@@ -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<String, Member> members;
+
+    public void testProxiedReferenceInjection() throws Exception {
+        ScopeContainer scope = new CompositeScopeContainer(null);
+        scope.start();
+        URI groupId = URI.create("composite");
+        scope.startContext(groupId, groupId);
+        Map<String, AtomicComponent> components = MockFactory.createWiredComponents("source",
+            SourceImpl.class,
+            scope,
+            members,
+            "target",
+            Target.class,
+            TargetImpl.class,
+            scope);
+        AtomicComponent sourceComponent = components.get("source");
+        Source source = (Source) sourceComponent.getTargetInstance();
+        Target target = source.getTarget();
+        assertTrue(Proxy.isProxyClass(target.getClass()));
+
+        assertNotNull(target);
+        scope.stop();
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        members = new HashMap<String, Member>();
+        Method m = SourceImpl.class.getMethod("setTarget", Target.class);
+        members.put("target", m);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+
+}

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -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.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;
+import org.apache.tuscany.host.MonitorFactory;
+
+/**
+ * Test case for the JavaLoggingMonitorFactory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaLoggingTestCaseFIXME extends TestCase {
+    private static final Logger LOGGER = Logger.getLogger(Monitor.class.getName());
+    private static final MockHandler HANDLER = new MockHandler();
+
+    private MonitorFactory factory;
+
+    /**
+     * Smoke test to ensure the LOGGER is working.
+     */
+    public void testLogger() {
+        LOGGER.info("test");
+        assertEquals(1, HANDLER.logs.size());
+    }
+
+    /**
+     * Test that no record is logged.
+     */
+    public void testUnloggedEvent() {
+        Monitor mon = factory.getMonitor(Monitor.class);
+        mon.eventNotToLog();
+        assertEquals(0, HANDLER.logs.size());
+    }
+
+    /**
+     * Test the correct record is written for an event with no arguments.
+     */
+    public void testEventWithNoArgs() {
+        Monitor mon = factory.getMonitor(Monitor.class);
+        mon.eventWithNoArgs();
+        assertEquals(1, HANDLER.logs.size());
+        LogRecord record = HANDLER.logs.get(0);
+        assertEquals(Level.INFO, record.getLevel());
+        assertEquals(LOGGER.getName(), record.getLoggerName());
+        assertEquals(Monitor.class.getName() + "#eventWithNoArgs", record.getMessage());
+    }
+
+    /**
+     * Test the correct record is written for an event defined by annotation.
+     */
+    public void testEventWithAnnotation() {
+        Monitor mon = factory.getMonitor(Monitor.class);
+        mon.eventWithAnnotation();
+        assertEquals(1, HANDLER.logs.size());
+        LogRecord record = HANDLER.logs.get(0);
+        assertEquals(Level.INFO, record.getLevel());
+        assertEquals(LOGGER.getName(), record.getLoggerName());
+        assertEquals(Monitor.class.getName() + "#eventWithAnnotation", record.getMessage());
+    }
+
+    /**
+     * Test the argument is logged.
+     */
+    public void testEventWithOneArg() {
+        Monitor mon = factory.getMonitor(Monitor.class);
+        mon.eventWithOneArg("ARG");
+        assertEquals(1, HANDLER.logs.size());
+        LogRecord record = HANDLER.logs.get(0);
+        assertEquals(Monitor.class.getName() + "#eventWithOneArg", record.getMessage());
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        LOGGER.setUseParentHandlers(false);
+        LOGGER.addHandler(HANDLER);
+        HANDLER.flush();
+
+        String sourceClass = Monitor.class.getName();
+        Properties levels = new Properties();
+        levels.setProperty(sourceClass + "#eventWithNoArgs", "INFO");
+        levels.setProperty(sourceClass + "#eventWithOneArg", "INFO");
+        levels.setProperty(sourceClass + "#eventWithThrowable", "WARNING");
+        factory = new JavaLoggingMonitorFactory(levels, Level.FINE, "TestMessages");
+    }
+
+    protected void tearDown() throws Exception {
+        LOGGER.removeHandler(HANDLER);
+        HANDLER.flush();
+        super.tearDown();
+    }
+
+    /**
+     * Mock log HANDLER to capture records.
+     */
+    public static class MockHandler extends Handler {
+        List<LogRecord> logs = new ArrayList<LogRecord>();
+
+        public void publish(LogRecord record) {
+            logs.add(record);
+        }
+
+        public void flush() {
+            logs.clear();
+        }
+
+        public void close() throws SecurityException {
+        }
+    }
+
+    @SuppressWarnings({"JavaDoc"})
+    public static interface Monitor {
+        void eventNotToLog();
+
+        @LogLevel("INFO")
+        void eventWithNoArgs();
+
+        @LogLevel("INFO")
+        void eventWithOneArg(String msg);
+
+        @LogLevel("WARNING")
+        void eventWithThrowable(Exception e);
+
+        @LogLevel("INFO")
+        void eventWithAnnotation();
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/monitor/JavaLoggingTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCaseFIXME.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCaseFIXME.java?view=auto&rev=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCaseFIXME.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCaseFIXME.java Tue Apr 10 02:29:58 2007
@@ -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.core.wire.jdk;
+
+import java.lang.reflect.Proxy;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.Contract;
+import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.core.wire.WireImpl;
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKProxyTestCaseFIXME extends TestCase {
+    private JDKProxyService proxyService;
+
+    public void testCreateProxy() {
+        URI uri = URI.create("#service");
+        Wire wire = new WireImpl();
+        wire.setSourceUri(uri);
+        Contract contract = new DefaultAssemblyFactory().createComponentReference();
+        wire.setSourceContract(contract);
+        TestInterface proxy = proxyService.createProxy(TestInterface.class, wire);
+        assertTrue(Proxy.isProxyClass(proxy.getClass()));
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        proxyService = new JDKProxyService();
+    }
+
+    public static interface TestInterface {
+        int primitives(int i);
+
+        String objects(String object);
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCaseFIXME.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java?view=diff&rev=527067&r1=527066&r2=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java Tue Apr 10 02:29:58 2007
@@ -27,12 +27,14 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.tuscany.assembly.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.impl.ServiceImpl;
 import org.apache.tuscany.assembly.xml.Constants;
 import org.apache.tuscany.implementation.java.JavaImplementation;
 import org.apache.tuscany.implementation.java.JavaImplementationFactory;
 import org.apache.tuscany.implementation.java.impl.DefaultJavaImplementationFactory;
 import org.apache.tuscany.implementation.java.impl.JavaImplementationDefinition;
 import org.apache.tuscany.implementation.java.introspection.IntrospectionRegistry;
+import org.apache.tuscany.implementation.java.introspection.impl.IntrospectionRegistryImpl;
 import org.apache.tuscany.services.spi.contribution.ArtifactResolver;
 import org.apache.tuscany.services.spi.contribution.ContributionReadException;
 import org.apache.tuscany.services.spi.contribution.ContributionResolveException;
@@ -48,6 +50,7 @@
 
     public JavaImplementationProcessor(JavaImplementationFactory javaFactory) {
         this.javaFactory = javaFactory;
+        this.introspectionRegistry = new IntrospectionRegistryImpl();
     }
 
     public JavaImplementationProcessor() {
@@ -94,7 +97,16 @@
         try {
             Class javaClass = Class.forName(javaImplementation.getName(), true, Thread.currentThread().getContextClassLoader());
             javaImplementation.setJavaClass(javaClass);
-            introspectionRegistry.introspect(javaImplementation.getJavaClass(), (JavaImplementationDefinition)javaImplementation);
+            
+            //FIXME JavaImplementationDefinition should not be mandatory 
+            if (javaImplementation instanceof JavaImplementationDefinition) {
+                introspectionRegistry.introspect(javaImplementation.getJavaClass(), (JavaImplementationDefinition)javaImplementation);
+                
+                //FIXME the introspector should always create at least one service
+                if (javaImplementation.getServices().isEmpty()) {
+                    javaImplementation.getServices().add(new ServiceImpl());
+                }
+            }
         } catch (Exception e) {
             throw new ContributionResolveException(e);
         }

Modified: incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/interfacedef/java/impl/JavaInterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/interfacedef/java/impl/JavaInterfaceImpl.java?view=diff&rev=527067&r1=527066&r2=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/interfacedef/java/impl/JavaInterfaceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/interfacedef/java/impl/JavaInterfaceImpl.java Tue Apr 10 02:29:58 2007
@@ -34,8 +34,10 @@
     public String getName() {
         if (isUnresolved()) {
             return className;
-        } else {
+        } else if (javaClass != null) {
             return javaClass.getName();
+        } else {
+            return null;
         }
     }
 

Modified: incubator/tuscany/java/sca/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/pom.xml?view=diff&rev=527067&r1=527066&r2=527067
==============================================================================
--- incubator/tuscany/java/sca/modules/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/pom.xml Tue Apr 10 02:29:58 2007
@@ -72,8 +72,8 @@
                 <module>interface-wsdl-xml</module>
                 <module>implementation-java</module>
                 <module>implementation-java-xml</module>
-                <!--
                 <module>implementation-java-runtime</module>
+                <!--
                 <module>implementation-script</module>
                 <module>implementation-spring</module>
                 -->



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org