tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r449155 - in /incubator/tuscany/java/sca/kernel: core/src/main/java/org/apache/tuscany/core/builder/ core/src/test/java/org/apache/tuscany/core/builder/ host-api/src/main/java/org/apache/tuscany/host/util/
Date Sat, 23 Sep 2006 04:30:29 GMT
Author: jmarino
Date: Fri Sep 22 21:30:29 2006
New Revision: 449155

URL: http://svn.apache.org/viewvc?view=rev&rev=449155
Log:
more unit tests; checkstyle cleanup

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
    incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?view=diff&rev=449155&r1=449154&r2=449155
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
Fri Sep 22 21:30:29 2006
@@ -65,10 +65,9 @@
     public ConnectorImpl() {
     }
 
-    @Constructor({"wireService", "postProcessorRegistry"})
-    public ConnectorImpl(@Autowire WireService wireService,
-                         @Autowire WirePostProcessorRegistry postProcessorRegistry) {
-        this.postProcessorRegistry = postProcessorRegistry;
+    @Constructor({"wireService", "processorRegistry"})
+    public ConnectorImpl(@Autowire WireService wireService, @Autowire WirePostProcessorRegistry
processorRegistry) {
+        this.postProcessorRegistry = processorRegistry;
         this.wireService = wireService;
     }
 
@@ -261,6 +260,13 @@
         }
     }
 
+    /**
+     * Connects a source to target chain
+     *
+     * @param sourceChain the source chain
+     * @param targetChain the target chain
+     * @param invoker     the invoker to place on the source chain for dispatching invocations
+     */
     void connect(OutboundInvocationChain sourceChain, InboundInvocationChain targetChain,
TargetInvoker invoker) {
         Interceptor headInterceptor = targetChain.getHeadInterceptor();
         if (headInterceptor == null) {

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java?view=diff&rev=449155&r1=449154&r2=449155
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
Fri Sep 22 21:30:29 2006
@@ -32,16 +32,13 @@
  */
 public class ConnectorImplTestCase extends TestCase {
 
-    private ConnectorImpl connector = new ConnectorImpl();
+    private ConnectorImpl connector;
+    private ServiceContract contract;
+    private Operation<Type> operation;
+    private Interceptor headInterceptor;
+    private Interceptor tailInterceptor;
 
     public void testConnectReferenceWires() {
-        // create the wire contract, operation
-        ServiceContract contract = new JavaServiceContract(String.class);
-        Operation<Type> operation = new Operation<Type>("bar", null, null, null);
-
-        // create source and target interceptors
-        Interceptor headInterceptor = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(headInterceptor);
 
         // create the inbound wire and chain
         InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
@@ -83,20 +80,9 @@
         EasyMock.verify(outboundWire);
         EasyMock.verify(inboundChain);
         EasyMock.verify(outboundChain);
-
     }
 
     public void testConnectServiceWires() {
-        // create the wire contract, operation
-        ServiceContract contract = new JavaServiceContract(String.class);
-        Operation<Type> operation = new Operation<Type>("bar", null, null, null);
-
-        // create source and target interceptors
-        Interceptor headInterceptor = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(headInterceptor);
-        Interceptor tailInterceptor = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(tailInterceptor);
-
         // create the inbound wire and chain for the target
         InboundInvocationChain targetChain = EasyMock.createMock(InboundInvocationChain.class);
         EasyMock.expect(targetChain.getOperation()).andReturn(operation).atLeastOnce();
@@ -185,15 +171,6 @@
      * Verifies connecting a wire from an atomic component to a target atomic component with
one synchronous operation
      */
     public void testConnectAtomicComponentToAtomicComponentSyncWire() throws Exception {
-        // create the wire contractm, operation
-        ServiceContract contract = new JavaServiceContract(String.class);
-        Operation<Type> operation = new Operation<Type>("bar", null, null, null);
-
-        // create source and target interceptors
-        Interceptor headInterceptor = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(headInterceptor);
-        Interceptor tailInterceptor = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(tailInterceptor);
 
         // create the inbound wire and chain
         InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
@@ -262,8 +239,6 @@
         EasyMock.replay(outboundWire);
 
         connector.connect(source);
-        EasyMock.verify(headInterceptor);
-        EasyMock.verify(tailInterceptor);
         EasyMock.verify(outboundWire);
         EasyMock.verify(targetWire);
         EasyMock.verify(outboundChain);
@@ -273,11 +248,6 @@
     }
 
     public void testConnectInboundAtomicComponentWires() {
-
-        // create the wire contractm, operation
-        ServiceContract contract = new JavaServiceContract(String.class);
-        Operation<Type> operation = new Operation<Type>("bar", null, null, null);
-
         // create the inbound wire and chain
         InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class);
         EasyMock.expect(chain.getOperation()).andReturn(operation).atLeastOnce();
@@ -310,7 +280,6 @@
         EasyMock.verify(source);
         EasyMock.verify(wire);
         EasyMock.verify(chain);
-
     }
 
     public void testOutboundToInboundOptimization() {
@@ -331,26 +300,21 @@
         connector.connect(outboundWire, inboundWire, true);
         EasyMock.verify(inboundWire);
         EasyMock.verify(outboundWire);
-
     }
 
     public void testOutboundToInboundChainConnect() {
-        Interceptor head = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(head);
-        Interceptor tail = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(tail);
 
         TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
         EasyMock.replay(invoker);
 
         InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
-        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(head);
+        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
         EasyMock.replay(inboundChain);
 
         OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        EasyMock.expect(outboundChain.getTailInterceptor()).andReturn(tail);
+        EasyMock.expect(outboundChain.getTailInterceptor()).andReturn(tailInterceptor);
         outboundChain.prepare();
-        outboundChain.setTargetInterceptor(head);
+        outboundChain.setTargetInterceptor(headInterceptor);
         outboundChain.setTargetInvoker(invoker);
         EasyMock.replay(outboundChain);
         connector.connect(outboundChain, inboundChain, invoker);
@@ -358,21 +322,78 @@
     }
 
     public void testInboundToOutboundChainConnect() {
-        Interceptor head = EasyMock.createMock(Interceptor.class);
-        EasyMock.replay(head);
-
         InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
         inboundChain.addInterceptor(EasyMock.isA(BridgingInterceptor.class));
         EasyMock.replay(inboundChain);
 
         OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
-        EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(head);
+        EasyMock.expect(outboundChain.getHeadInterceptor()).andReturn(headInterceptor);
         outboundChain.prepare();
-        outboundChain.setTargetInterceptor(head);
+        outboundChain.setTargetInterceptor(headInterceptor);
         EasyMock.replay(outboundChain);
         connector.connect(inboundChain, outboundChain);
         EasyMock.verify(inboundChain);
     }
 
+    public void testOutboundWireToInboundReferenceTarget() {
+        AtomicComponent component = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(component.getName()).andReturn("foo");
+        EasyMock.replay(component);
+        // create the inbound wire and chain
+        InboundInvocationChain inboundChain = EasyMock.createMock(InboundInvocationChain.class);
+        EasyMock.expect(inboundChain.getOperation()).andReturn(operation).atLeastOnce();
+        EasyMock.expect(inboundChain.getHeadInterceptor()).andReturn(headInterceptor);
+        EasyMock.replay(inboundChain);
+        Map<Operation<?>, InboundInvocationChain> inboundChains = new HashMap<Operation<?>,
InboundInvocationChain>();
+        inboundChains.put(operation, inboundChain);
+        InboundWire targetWire = EasyMock.createMock(InboundWire.class);
+        EasyMock.expect(targetWire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.expect(targetWire.getInvocationChains()).andReturn(inboundChains);
+        targetWire.getSourceCallbackInvocationChains("foo");
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        Reference target = EasyMock.createMock(Reference.class);
+        EasyMock.expect(target.createTargetInvoker(EasyMock.isA(ServiceContract.class), EasyMock.isA(Operation.class)))
+            .andReturn(null);
+        EasyMock.replay(target);
+
+        EasyMock.expect(targetWire.getContainer()).andReturn(target);
+        EasyMock.replay(targetWire);
+
+        // create the outbound wire and chain from the source component
+        OutboundInvocationChain outboundChain = EasyMock.createMock(OutboundInvocationChain.class);
+        EasyMock.expect(outboundChain.getTailInterceptor()).andReturn(tailInterceptor);
+        EasyMock.expect(outboundChain.getOperation()).andReturn(operation).atLeastOnce();
+        outboundChain.setTargetInterceptor(EasyMock.eq(headInterceptor));
+        outboundChain.setTargetInvoker(null);
+        outboundChain.prepare();
+        EasyMock.replay(outboundChain);
+        Map<Operation<?>, OutboundInvocationChain> outboundChains =
+            new HashMap<Operation<?>, OutboundInvocationChain>();
+        outboundChains.put(operation, outboundChain);
+        OutboundWire sourceWire = EasyMock.createMock(OutboundWire.class);
+        EasyMock.expect(sourceWire.getContainer()).andReturn(component);
+        EasyMock.expect(sourceWire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.expect(sourceWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
+        EasyMock.expect(sourceWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
+        sourceWire.getTargetCallbackInvocationChains();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        EasyMock.replay(sourceWire);
+
+        connector.connect(sourceWire, targetWire, false);
+        EasyMock.verify(inboundChain);
+        EasyMock.verify(targetWire);
+        EasyMock.verify(target);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        connector = new ConnectorImpl();
+        contract = new JavaServiceContract(String.class);
+        operation = new Operation<Type>("bar", null, null, null);
+        headInterceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(headInterceptor);
+        tailInterceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.replay(tailInterceptor);
+    }
 
 }

Modified: incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java?view=diff&rev=449155&r1=449154&r2=449155
==============================================================================
--- incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java
(original)
+++ incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/util/LaunchHelper.java
Fri Sep 22 21:30:29 2006
@@ -18,17 +18,22 @@
  */
 package org.apache.tuscany.host.util;
 
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.net.MalformedURLException;
 import java.io.File;
 import java.io.FilenameFilter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
 
 /**
  * @version $Rev$ $Date$
  */
 public final class LaunchHelper {
+
+    ///CLOVER:OFF
+    private LaunchHelper() {
+    }
+
     /**
      * Scan a directory for jar files to be added to the classpath.
      *
@@ -58,8 +63,8 @@
      * Set a JavaBean property on an object.
      *
      * @param instance the object whose property should be set
-     * @param name the name of the property
-     * @param value the value to set it to
+     * @param name     the name of the property
+     * @param value    the value to set it to
      */
     public static void setProperty(Object instance, String name, Object value) {
         Class<?> beanType = instance.getClass();
@@ -76,15 +81,13 @@
             throw new IllegalStateException(e.getCause());
         }
     }
-        ///CLOVER:OFF
-    private LaunchHelper() {
-    }
+
     /**
      * Invoke a method on an object.
      *
      * @param instance the object to invoke
-     * @param name the name of the method to invoke
-     * @param args arguments to call the method with
+     * @param name     the name of the method to invoke
+     * @param args     arguments to call the method with
      * @return the value returned by the method
      * @throws InvocationTargetException if the method throw an Exception
      */



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


Mime
View raw message