Author: jmarino
Date: Tue Jan  2 02:55:03 2007
New Revision: 491776

URL: http://svn.apache.org/viewvc?view=rev&rev=491776
Log:
more connector test cases

Added:
    
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/
    
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java
   (with props)
Modified:
    
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
    
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java

Modified: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java?view=diff&rev=491776&r1=491775&r2=491776
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/LocalReferenceWiringTestCase.java
 Tue Jan  2 02:55:03 2007
@@ -1,13 +1,25 @@
 package org.apache.tuscany.core.builder;
 
+import javax.xml.namespace.QName;
+
 import org.apache.tuscany.spi.component.CompositeComponent;
 import org.apache.tuscany.spi.component.Reference;
 import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.wire.InboundInvocationChain;
 import org.apache.tuscany.spi.wire.Interceptor;
 import org.apache.tuscany.spi.wire.Message;
 import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
 
+import org.apache.tuscany.core.implementation.composite.ServiceImpl;
+import org.apache.tuscany.core.mock.binding.MockServiceBinding;
+import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.InvokerInterceptor;
+import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+import org.apache.tuscany.core.wire.SynchronousBridgingInterceptor;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 
@@ -26,6 +38,7 @@
      * binding.
      */
     public void testConnectLocalReferenceBindingToCompositeService() throws 
Exception {
+        createLocalReferenceToServiceConfiguration();
         connector.connect(reference);
         InboundInvocationChain chain = 
referenceBinding.getInboundWire().getInvocationChains().get(operation);
         Interceptor interceptor = chain.getHeadInterceptor();
@@ -35,10 +48,22 @@
         assertEquals(RESPONSE, resp.getBody());
     }
 
+    public void 
testConnectLocalReferenceBindingToCompositeServiceNoMatchingBinding() throws 
Exception {
+        createLocalReferenceToInvalidServiceConfiguration();
+        try {
+            connector.connect(reference);
+            fail();
+        } catch (NoCompatibleBindingsException e) {
+            // expected
+        }
+    }
+
 
     protected void setUp() throws Exception {
         super.setUp();
+    }
 
+    private void createLocalReferenceToServiceConfiguration() throws Exception 
{
         CompositeComponent topComposite = 
EasyMock.createMock(CompositeComponent.class);
         topComposite.getChild(TARGET);
         EasyMock.expectLastCall().andStubAnswer(new IAnswer<Object>() {
@@ -55,5 +80,53 @@
         service = createLocalService(topComposite);
         reference = createLocalReference(parent);
     }
+
+    private void createLocalReferenceToInvalidServiceConfiguration() throws 
Exception {
+        CompositeComponent topComposite = 
EasyMock.createMock(CompositeComponent.class);
+        topComposite.getChild(TARGET);
+        EasyMock.expectLastCall().andStubAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                return service;
+            }
+        });
+        EasyMock.replay(topComposite);
+
+        CompositeComponent parent = 
EasyMock.createMock(CompositeComponent.class);
+        EasyMock.expect(parent.getParent()).andReturn(topComposite);
+        EasyMock.replay(parent);
+
+        service = createService(topComposite);
+        reference = createLocalReference(parent);
+    }
+
+    protected Service createService(CompositeComponent parent) throws 
WireConnectException {
+        QName qName = new QName("foo", "bar");
+        ServiceBinding serviceBinding = new MockServiceBinding();
+        InboundInvocationChain targetInboundChain = new 
InboundInvocationChainImpl(operation);
+        targetInboundChain.addInterceptor(new 
SynchronousBridgingInterceptor());
+        InboundWireImpl targetInboundWire = new InboundWireImpl();
+        targetInboundWire.setBindingType(qName);
+        targetInboundWire.setServiceContract(contract);
+        targetInboundWire.addInvocationChain(operation, targetInboundChain);
+        targetInboundWire.setContainer(serviceBinding);
+
+        OutboundInvocationChain targetOutboundChain = new 
OutboundInvocationChainImpl(operation);
+        // place an invoker interceptor on the end
+        targetOutboundChain.addInterceptor(new InvokerInterceptor());
+        OutboundWireImpl targetOutboundWire = new OutboundWireImpl();
+        targetOutboundWire.setServiceContract(contract);
+        targetOutboundWire.addInvocationChain(operation, targetOutboundChain);
+        targetOutboundWire.setContainer(serviceBinding);
+        targetOutboundWire.setBindingType(qName);
+
+        serviceBinding.setInboundWire(targetInboundWire);
+        serviceBinding.setOutboundWire(targetOutboundWire);
+        // manually connect the service chains
+        connector.connect(targetInboundChain, targetOutboundChain);
+        Service service = new ServiceImpl(TARGET, null, contract);
+        service.addServiceBinding(serviceBinding);
+        return service;
+    }
+
 
 }

Added: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java?view=auto&rev=491776
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java
 (added)
+++ 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java
 Tue Jan  2 02:55:03 2007
@@ -0,0 +1,85 @@
+/*
+ * 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.mock.binding;
+
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MockServiceBinding extends AbstractSCAObject implements 
ServiceBinding {
+    private InboundWire inboundWire;
+    private OutboundWire outboundWire;
+    private ServiceContract<?> bindingServiceContract;
+
+
+    public MockServiceBinding() {
+        super("foo", null);
+    }
+
+    public void setService(Service service) {
+    }
+
+    public ServiceContract<?> getBindingServiceContract() {
+        return bindingServiceContract;
+    }
+
+    public void setBindingServiceContract(ServiceContract<?> 
bindingServiceContract) {
+        this.bindingServiceContract = bindingServiceContract;
+    }
+
+    public InboundWire getInboundWire() {
+        return inboundWire;
+    }
+
+    public void setInboundWire(InboundWire inboundWire) {
+        this.inboundWire = inboundWire;
+    }
+
+    public OutboundWire getOutboundWire() {
+        return outboundWire;
+    }
+
+    public void setOutboundWire(OutboundWire outboundWire) {
+        this.outboundWire = outboundWire;
+    }
+
+    public TargetInvoker createTargetInvoker(ServiceContract contract, 
Operation operation)
+        throws TargetInvokerCreationException {
+        return null;
+    }
+
+    public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, 
Operation operation)
+        throws TargetInvokerCreationException {
+        return null;
+    }
+
+    public Scope getScope() {
+        return null;
+    }
+}

Propchange: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/binding/MockServiceBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java?view=diff&rev=491776&r1=491775&r2=491776
==============================================================================
--- 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireServiceExtensionTestCase.java
 Tue Jan  2 02:55:03 2007
@@ -29,7 +29,6 @@
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.Reference;
 import org.apache.tuscany.spi.component.ReferenceBinding;
-import org.apache.tuscany.spi.component.Service;
 import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.component.TargetInvokerCreationException;
 import org.apache.tuscany.spi.component.WorkContext;
@@ -57,6 +56,7 @@
 
 import junit.framework.TestCase;
 import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.mock.binding.MockServiceBinding;
 import org.easymock.EasyMock;
 
 /**
@@ -273,58 +273,6 @@
 
         public void setReference(Reference reference) {
 
-        }
-
-        public InboundWire getInboundWire() {
-            return inboundWire;
-        }
-
-        public void setInboundWire(InboundWire inboundWire) {
-            this.inboundWire = inboundWire;
-        }
-
-        public OutboundWire getOutboundWire() {
-            return outboundWire;
-        }
-
-        public void setOutboundWire(OutboundWire outboundWire) {
-            this.outboundWire = outboundWire;
-        }
-
-        public TargetInvoker createTargetInvoker(ServiceContract contract, 
Operation operation)
-            throws TargetInvokerCreationException {
-            return null;
-        }
-
-        public TargetInvoker createCallbackTargetInvoker(ServiceContract 
contract, Operation operation)
-            throws TargetInvokerCreationException {
-            return null;
-        }
-
-        public Scope getScope() {
-            return null;
-        }
-    }
-
-    private class MockServiceBinding extends AbstractSCAObject implements 
ServiceBinding {
-        private InboundWire inboundWire;
-        private OutboundWire outboundWire;
-        private ServiceContract<?> bindingServiceContract;
-
-
-        public MockServiceBinding() {
-            super("foo", null);
-        }
-
-        public void setService(Service service) {
-        }
-
-        public ServiceContract<?> getBindingServiceContract() {
-            return bindingServiceContract;
-        }
-
-        public void setBindingServiceContract(ServiceContract<?> 
bindingServiceContract) {
-            this.bindingServiceContract = bindingServiceContract;
         }
 
         public InboundWire getInboundWire() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to