diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-09 14:24:17 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-09 14:24:17 +0000 |
commit | 4be6e6a0226c629fe14315e6269262bb102dfd3a (patch) | |
tree | 6ef533719acb2733645d2fa0482e94f8212229d1 /sca-java-2.x/trunk/testing/itest/interface-matching | |
parent | 5575ba3e47ff0c656c0a89ca2db04a54f39c1714 (diff) |
TUSCANY-3916 - Replace WSDL representation of interface contract with an internal representation for passing via the registry. Still not particularly happy with this but I have more confidence that it will work reliably when compared to serializing/deserializing WSDL. It would be preferable I think to represent the interface contract more generally as artifacts in the domain registry but that's for another day.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1167202 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest/interface-matching')
4 files changed, 145 insertions, 7 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponent.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponent.java index ecafb20c2e..a1c933716e 100644 --- a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponent.java +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponent.java @@ -18,6 +18,8 @@ */
package org.apache.tuscany.sca.itest.interfaces;
+import java.util.List;
+
import org.oasisopen.sca.annotation.Callback;
import org.oasisopen.sca.annotation.Remotable;
@@ -39,5 +41,12 @@ public interface ServiceMissmatchComponent { void modifyParameter();
ParameterObject getPO();
-
+
+ void inArray(String[] stringArray);
+
+ String[] outArray();
+
+ void inCollection(List<String> stringArray);
+
+ List<String> outCollection();
}
diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponentImpl.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponentImpl.java index 713cce6776..0e0966da79 100644 --- a/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponentImpl.java +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/main/java/org/apache/tuscany/sca/itest/interfaces/ServiceMissmatchComponentImpl.java @@ -18,6 +18,8 @@ */
package org.apache.tuscany.sca.itest.interfaces;
+import java.util.List;
+
import org.oasisopen.sca.annotation.Callback;
import org.oasisopen.sca.annotation.Service;
@@ -49,5 +51,18 @@ public class ServiceMissmatchComponentImpl implements ServiceMissmatchComponent public ParameterObject getPO() {
return po;
}
-
+
+ public void inArray(String[] stringArray) {
+ }
+
+ public String[] outArray() {
+ return null;
+ }
+
+ public void inCollection(List<String> stringArray) {
+ }
+
+ public List<String> outCollection() {
+ return null;
+ }
}
diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java index 86400b9487..0c54e5f8e7 100644 --- a/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InerfaceMissmatchTestCase.java @@ -148,13 +148,16 @@ public class InerfaceMissmatchTestCase { try {
local.foo1(po);
+ node1.stop();
+ node2.stop();
Assert.fail("Expected exception indicating that interfaces don't match");
} catch (ServiceRuntimeException ex){
+ node1.stop();
+ node2.stop();
Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
}
- node1.stop();
- node2.stop();
+
}
/**
@@ -190,13 +193,14 @@ public class InerfaceMissmatchTestCase { try {
local.foo1(po);
+ node1.stop();
+ node2.stop();
Assert.fail("Expected exception indicating that interfaces don't match");
} catch (ServiceRuntimeException ex){
+ node1.stop();
+ node2.stop();
Assert.assertTrue(ex.getMessage().startsWith("Unable to bind []"));
}
-
- node1.stop();
- node2.stop();
}
}
diff --git a/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfaceWriteTestCase.java b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfaceWriteTestCase.java new file mode 100644 index 0000000000..9f6c1edbb0 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/interface-matching/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfaceWriteTestCase.java @@ -0,0 +1,110 @@ +/*
+ * 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.itest.interfaces;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.net.URI;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import junit.framework.Assert;
+
+
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.xml.InterfaceContractProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
+import org.apache.tuscany.sca.interfacedef.util.Audit;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.junit.Test;
+
+public class InterfaceWriteTestCase {
+
+ /**
+ * Looks at writing and reading the Tuscany interface model
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testInterfaceWriteRead() throws Exception {
+ String [] contributions = {"./target/classes"};
+ NodeImpl node1 = (NodeImpl)NodeFactory.newInstance().createNode(URI.create("uri:default"),
+ "org/apache/tuscany/sca/itest/interfaces/missmatch/distributed/MissmatchDistributedService.composite",
+ contributions);
+ node1.start();
+
+ Component serviceComponent = node1.getDomainComposite().getComponents().get(0);
+ Service service = serviceComponent.getServices().get(0);
+
+ InterfaceContractProcessor processor = new InterfaceContractProcessor(node1.getExtensionPointRegistry());
+ ProcessorContext context = new ProcessorContext();
+
+ FactoryExtensionPoint modelFactories = node1.getExtensionPointRegistry().getExtensionPoint(FactoryExtensionPoint.class);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(bos);
+ processor.write(service.getInterfaceContract(), writer, context);
+ writer.close();
+
+ String xml = bos.toString();
+ System.out.println("Written ouput is:\n" + xml);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(xml.getBytes());
+ XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(bis);
+ InterfaceContract interfaceContract = processor.read(reader, context);
+
+ bos = new ByteArrayOutputStream();
+ writer = outputFactory.createXMLStreamWriter(bos);
+ processor.write(interfaceContract, writer, context);
+ writer.close();
+
+ System.out.println("Read ouput is:\n" + bos);
+
+ InterfaceContractMapper interfaceContractMapper = new InterfaceContractMapperImpl(node1.getExtensionPointRegistry());
+
+ Audit matchAudit = new Audit();
+ boolean match = false;
+ match = interfaceContractMapper.isCompatibleSubset(service.getInterfaceContract(),
+ interfaceContract,
+ matchAudit);
+
+ if (!match){
+ System.out.println(matchAudit.toString());
+ }
+
+ Assert.assertTrue(match);
+
+ node1.stop();
+ }
+
+}
|