tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r800887 - in /tuscany/java/sca/itest/builder/src: main/resources/scenario2/ main/resources/scenario2/META-INF/ test/java/org/apache/tuscany/sca/itest/builder/
Date Tue, 04 Aug 2009 17:43:02 GMT
Author: slaws
Date: Tue Aug  4 17:43:02 2009
New Revision: 800887

URL: http://svn.apache.org/viewvc?rev=800887&view=rev
Log:
Bring up the builder tests with the new builders. Includes simplification of results testing.
Only scenario 2 enabled. 

Modified:
    tuscany/java/sca/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml
    tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite
    tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite
    tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
    tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
    tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java

Modified: tuscany/java/sca/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml?rev=800887&r1=800886&r2=800887&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml
(original)
+++ tuscany/java/sca/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml
Tue Aug  4 17:43:02 2009
@@ -17,8 +17,7 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
-<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
-              targetNamespace="http://scenario2"
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               xmlns:ns2="http://scenario2">
     <deployable composite="ns2:CompositeA" />
 </contribution>

Modified: tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite?rev=800887&r1=800886&r2=800887&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite (original)
+++ tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2.composite Tue Aug
 4 17:43:02 2009
@@ -17,10 +17,10 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-        targetNamespace="http://scenario2"
-        xmlns:tns="http://scenario2"
-        name="CompositeA">
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+           targetNamespace="http://scenario2"
+           xmlns:tns="http://scenario2"
+           name="CompositeA">
 
     <service name="Service1" promote="ComponentB/Service2">
         <!-- bindings and/or interfaces may or may not be specified explicitly here -->

Modified: tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite?rev=800887&r1=800886&r2=800887&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite (original)
+++ tuscany/java/sca/itest/builder/src/main/resources/scenario2/scenario2a.composite Tue Aug
 4 17:43:02 2009
@@ -17,10 +17,10 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
-        targetNamespace="http://scenario2"
-        xmlns:tns="http://scenario2"
-        name="CompositeC">
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+           targetNamespace="http://scenario2"
+           xmlns:tns="http://scenario2"
+           name="CompositeC">
 
     <service name="Service2" promote="ComponentD/Service3">
         <!-- bindings and/or interfaces may or may not be specified explicitly here -->

Modified: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java?rev=800887&r1=800886&r2=800887&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
(original)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
Tue Aug  4 17:43:02 2009
@@ -28,6 +28,9 @@
 import org.apache.tuscany.sca.assembly.ComponentReference;
 import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Implementation;
 import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.Service;
 import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
@@ -54,6 +57,8 @@
     public void tearDown() throws Exception {
     }
 
+ /* OASIS doesn't take notice of top level composite services
+  * 
     // Scenario 1: <binding.ws> on outer composite service CompositeA/Service1
     @Ignore
     @Test
@@ -152,8 +157,10 @@
         
         Assert.assertEquals(expectedEndpoints, actualEndpoints);
     }
-/*
+*/
+
     // Scenario 2: <binding.ws> on outer component service ComponentB/Service2
+    @Test
     public void testScenario2() throws Exception {
         System.out.println("====>Running testScenario2");
         customBuilder = new CustomCompositeBuilder(false);
@@ -171,14 +178,29 @@
         TestUtils.checkProblems(customBuilder);
         checkScenario2and3Results("http://scenario2", true);
     }
-
+    
     private void checkScenario2and3Results(String namespace, boolean nonWiring) {
         Composite domainComposite = customBuilder.getDomainComposite();
+        
+        // Test that endpoint structure matches expected
+        String structure = TestUtils.printStructure(domainComposite, "");
+        System.out.println(structure);
+        
+        String expectedStructure = "Component URI - ComponentB\n" +
+        "  Component URI - ComponentB/ComponentD\n" +
+        "  Endpoint:  URI = ComponentB/ComponentD#service-binding(Service3/Service3) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n"
+
+        "  Endpoint:  URI = ComponentB/ComponentD#service-binding(Service3a/Service3a) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n"
+
+        "Endpoint:  URI = ComponentB#service-binding(Service3/Service2) org.apache.tuscany.sca.binding.ws.impl.WebServiceBindingImpl\n"
+
+        "Endpoint:  URI = ComponentB#service-binding(Service3a/Service2a) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n";
 
+        Assert.assertEquals(expectedStructure, structure);
+        
+        // Test that generated WSDL matches expected
         // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
         // No other services on ComponentB should have <binding.ws>
         Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
         WebServiceBinding wsBinding = null;
+    
         for (ComponentService service : componentB.getServices()) {
             WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
             if ("Service2".equals(service.getName())) {
@@ -187,91 +209,16 @@
                 assert wsb == null;
             }
         }
+       
         Definition def = wsBinding.getWSDLDocument();
+        TestUtils.writeWSDL(def);
+        
         javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/",
"Service3Service")); 
         Port port = svc.getPort("Service3Port");
-        assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
-
-        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
-        if (!nonWiring) {
-            // Should create component service $promoted$ComponentB$slash$Service2 on innermost
component
-            //  ComponentD, with <binding.ws> and uri="/ComponentB/Service2"
-            wsBinding = null;
-            for (ComponentService service : componentD.getServices()) {
-                if ("$promoted$ComponentB$slash$Service2".equals(service.getName())) {
-                    wsBinding = service.getBinding(WebServiceBinding.class);
-                }
-            }
-            assert "/ComponentB/Service2".equals(wsBinding.getURI());
-
-            // Should create WSDL document for ComponentD/$promoted$ComponentB$slash$Service2
with endpoint uri="/ComponentB/Service2"
-            def = wsBinding.getWSDLDocument();
-            svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/",
"Service3Service")); 
-            port = svc.getPort("Service3Port");
-            assert "/ComponentB/Service2".equals(TestUtils.getPortAddress(port));
-        } else {
-            // Should not create component service $promoted$ComponentB$slash$Service2 on
innermost component ComponentD
-            for (ComponentService service : componentD.getServices()) {
-                assert !"$promoted$ComponentB$slash$Service2".equals(service.getName());
-            }
-        }
-
-        // Should add <binding.ws> to outer composite service CompositeA/Service1 
-        wsBinding = null;
-        for (Service service : domainComposite.getServices()) {
-            if ("Service1".equals(service.getName())) {
-                wsBinding = service.getBinding(WebServiceBinding.class);
-            }
-        }
-        assert wsBinding != null;
-        if (nonWiring) {
-            // Should not add a WSDL document to domain composite service Service1
-            assert wsBinding.getWSDLDocument() == null;
-        }
-
-        if (!nonWiring) {
-            // Should create component service $promoted$Service1 on innermost component
-            //  ComponentD, with <binding.ws> and uri="/Service1"
-            wsBinding = null;
-            for (ComponentService service : componentD.getServices()) {
-                if ("$promoted$Service1".equals(service.getName())) {
-                    wsBinding = service.getBinding(WebServiceBinding.class);
-                }
-            }
-            assert "/Service1".equals(wsBinding.getURI());
-
-            // Should create WSDL document for ComponentD/$promoted$Service1 with endpoint
uri="/Service1"
-            def = wsBinding.getWSDLDocument();
-            svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/",
"Service3Service")); 
-            port = svc.getPort("Service3Port");
-            assert "/Service1".equals(TestUtils.getPortAddress(port));
-        } else {
-            // Should not create component service $promoted$.Service1 on innermost component
ComponentD
-            for (ComponentService service : componentD.getServices()) {
-                assert !"$promoted$Service1".equals(service.getName());
-            }
-        }
-
-        // No services on ComponentD should have <binding.ws>, except for $promoted$Service1
-        // and $promoted$ComponentB$slash$Service2  
-        for (ComponentService service : componentD.getServices()) {
-            if (!"$promoted$Service1".equals(service.getName()) &&
-                !"$promoted$ComponentB$slash$Service2".equals(service.getName())) {
-                assert service.getBinding(WebServiceBinding.class) == null;
-            }
-        }
-
-        // No services on CompositeC should have <binding.ws>, except for Service2
in Scenario 3
-        Composite compositeC = TestUtils.getComposite(domainComposite, new QName(namespace,
"CompositeC"));
-        for (Service service : compositeC.getServices()) {
-            if ("http://scenario3".equals(namespace) && "Service2".equals(service.getName()))
{
-                assert service.getBinding(WebServiceBinding.class) != null;
-            } else {
-                assert service.getBinding(WebServiceBinding.class) == null;
-            }
-        }
+        Assert.assertEquals("/ComponentB/Service2",TestUtils.getPortAddress(port));
+     
     }
-
+/*
     // Scenario 3: <binding.ws> on inner composite service CompositeC/Service2
     public void testScenario3() throws Exception {
         System.out.println("====>Running testScenario3");
@@ -514,9 +461,10 @@
         
         Assert.assertEquals(expectedEndpoints, actualEndpoints);        
     }
-*/
+
     
     // Scenario 6: <binding.ws> and <interface.wsdl> on outer component reference
ComponentB/reference2
+    @Ignore
     @Test
     public void testScenario6() throws Exception {
         System.out.println("====>Running testScenario6");
@@ -646,7 +594,7 @@
         
         Assert.assertEquals(expectedEndpoints, actualEndpoints);        
     }
-/*
+
     // Scenario 7: <binding.ws> and <interface.wsdl> on inner composite reference
CompositeC/reference2
     public void testScenario7() throws Exception {
         System.out.println("====>Running testScenario7");

Modified: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java?rev=800887&r1=800886&r2=800887&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
(original)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
Tue Aug  4 17:43:02 2009
@@ -49,7 +49,8 @@
     }
     
     public void loadContribution(String compositeURL, String sourceURI, String sourceURL)
throws Exception {
-        node = NodeFactory.newInstance().createNode(compositeURL, new Contribution(sourceURI,
sourceURL));
+        NodeFactory nodeFactory = NodeFactory.newInstance();
+        node = nodeFactory.createNode(compositeURL, new Contribution(sourceURI, sourceURL));
         node.start();
         
         // get some things out of the extension registry
@@ -87,7 +88,7 @@
      * @return the domain composite model object
      */
     public Composite getDomainComposite() {
-        return (Composite) domainComposite.getIncludes().get(0);
+        return (Composite) ((NodeImpl)node).getDomainComposite();
     }
     
     /**

Modified: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java?rev=800887&r1=800886&r2=800887&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
(original)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
Tue Aug  4 17:43:02 2009
@@ -71,13 +71,18 @@
 
     protected static String getPortAddress(Port port) {
         Object ext = port.getExtensibilityElements().get(0);
+        String returnAddress = null;
         if (ext instanceof SOAPAddress) {
-            return ((SOAPAddress)ext).getLocationURI();
+            returnAddress = ((SOAPAddress)ext).getLocationURI();
         }
         if (ext instanceof SOAP12Address) {
-            return ((SOAP12Address)ext).getLocationURI();
+            returnAddress = ((SOAP12Address)ext).getLocationURI();
         }
-        return null;
+        
+        returnAddress = returnAddress.substring(returnAddress.indexOf("//") + 2);
+        returnAddress = returnAddress.substring(returnAddress.indexOf("/"));
+        
+        return returnAddress;
     }
 
     protected static Component getComponent(Composite composite, String name) {
@@ -202,6 +207,40 @@
         }
     }
     
+    protected static void writeWSDL(Definition definition) {
+        try {
+            WSDLWriter writer =  WSDLFactory.newInstance().newWSDLWriter();
+            writer.writeWSDL(definition, System.out);
+        } catch (WSDLException e) {
+            // ignore
+        }
+    }
+    
+    protected static String printStructure(Composite composite, String indent){
+        String structure = "";
+        for (Component component : composite.getComponents()){
+            structure += indent + "Component URI - " + component.getURI() + "\n";
+            
+            // recurse for composite implementations
+            Implementation implementation = component.getImplementation();
+            if (implementation instanceof Composite) {
+                structure += printStructure((Composite)implementation, indent + "  ");
+            }
+            
+            for (Service service : component.getServices()){
+                for (Endpoint endpoint : service.getEndpoints()){
+                    structure += indent + endpoint + " " + endpoint.getBinding().getClass().getName()
+ "\n";
+                }
+            }
+            for (Reference reference : component.getReferences()){
+                for (EndpointReference endpointReference : reference.getEndpointReferences()){
+                    structure += indent + endpointReference + " " + endpointReference.getBinding().getClass().getName()
+ "\n";
+                }
+            }
+        }
+        return structure;
+    }    
+/*    
     protected static String printEndpoints(Composite composite){
         return printEndpoints(composite, "");
     }
@@ -272,5 +311,5 @@
         
         return buffer;
     }    
-
+*/
 }



Mime
View raw message