You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/12/04 10:53:00 UTC

svn commit: r482119 - in /incubator/tuscany/java/sca/kernel/core/src: main/java/org/apache/tuscany/core/builder/ test/java/org/apache/tuscany/core/builder/

Author: jmarino
Date: Mon Dec  4 01:52:59 2006
New Revision: 482119

URL: http://svn.apache.org/viewvc?view=rev&rev=482119
Log:
clean up exception handling for reference targets that are not found

Added:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ReferenceTargetNotFoundException.java   (with props)
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

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=482119&r1=482118&r2=482119
==============================================================================
--- 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 Mon Dec  4 01:52:59 2006
@@ -418,6 +418,11 @@
             }
             boolean optimizable = isOptimizable(source.getScope(), target.getScope());
             connect(sourceWire, targetWire, optimizable);
+        } else if (target == null) {
+            String name = sourceWire.getReferenceName();
+            ReferenceTargetNotFoundException e = new ReferenceTargetNotFoundException(name);
+            e.setIdentifier(targetName.getQualifiedName());
+            throw e;
         } else {
             String name = sourceWire.getReferenceName();
             BuilderConfigException e = new BuilderConfigException("Invalid target type for reference " + name);

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ReferenceTargetNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ReferenceTargetNotFoundException.java?view=auto&rev=482119
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ReferenceTargetNotFoundException.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ReferenceTargetNotFoundException.java Mon Dec  4 01:52:59 2006
@@ -0,0 +1,43 @@
+/*
+ * 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.builder;
+
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+
+/**
+ * Indicates the target service of a reference was not found
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTargetNotFoundException extends BuilderConfigException {
+    public ReferenceTargetNotFoundException() {
+    }
+
+    public ReferenceTargetNotFoundException(String message) {
+        super(message);
+    }
+
+    public ReferenceTargetNotFoundException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ReferenceTargetNotFoundException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ReferenceTargetNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ReferenceTargetNotFoundException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=482119&r1=482118&r2=482119
==============================================================================
--- 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 Mon Dec  4 01:52:59 2006
@@ -301,6 +301,42 @@
         EasyMock.verify(chain);
     }
 
+    public void testConnectTargetNotFound() {
+        CompositeComponent parent = EasyMock.createMock(CompositeComponent.class);
+        EasyMock.expect(parent.getName()).andReturn("parent");
+        parent.getChild(EasyMock.isA(String.class));
+        EasyMock.expectLastCall().andReturn(null);
+        EasyMock.replay(parent);
+        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
+        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
+        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
+        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(null).anyTimes();
+        EasyMock.expect(outboundWire.getReferenceName()).andReturn("nothtere");
+        outboundWire.getTargetCallbackInvocationChains();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
+        EasyMock.replay(outboundWire);
+        Map<String, List<OutboundWire>> outboundWires = new HashMap<String, List<OutboundWire>>();
+        List<OutboundWire> list = new ArrayList<OutboundWire>();
+        list.add(outboundWire);
+        outboundWires.put("fooService", list);
+
+        // create the source
+        AtomicComponent source = EasyMock.createMock(AtomicComponent.class);
+        EasyMock.expect(source.getOutboundWires()).andReturn(outboundWires);
+        EasyMock.expect(source.isSystem()).andReturn(false);
+        EasyMock.expect(source.getName()).andReturn("foo");
+        EasyMock.expect(source.getParent()).andReturn(parent);
+        EasyMock.replay(source);
+        try {
+            connector.connect(source);
+            fail();
+        } catch (ReferenceTargetNotFoundException e) {
+            // expected
+        }
+
+        EasyMock.verify(source);
+    }
+
     public void testOutboundToInboundOptimization() {
         InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
         EasyMock.expect(inboundWire.getContainer()).andReturn(null);



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