You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2008/02/07 23:09:47 UTC

svn commit: r619662 - in /incubator/tuscany/java/sca/itest/contribution-import-export: export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/ import-composite/src/test/java/org/apache/tuscany/test/contribution/ import-java/src/test/ja...

Author: rfeng
Date: Thu Feb  7 14:09:45 2008
New Revision: 619662

URL: http://svn.apache.org/viewvc?rev=619662&view=rev
Log:
Support jar-based contribution for the itests

Modified:
    incubator/tuscany/java/sca/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java
    incubator/tuscany/java/sca/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java
    incubator/tuscany/java/sca/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java
    incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/pom.xml
    incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java

Modified: incubator/tuscany/java/sca/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java?rev=619662&r1=619661&r2=619662&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java Thu Feb  7 14:09:45 2008
@@ -20,8 +20,8 @@
 
 import hello.Hello;
 
-import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 
 import junit.framework.TestCase;
@@ -53,8 +53,11 @@
         ContributionService contributionService = domain.getContributionService();
 
         ModelResolver helloResolver = new ModelResolverImpl(cl);
-        File helloContrib = new File("./target/classes/");
-        URL helloURL = helloContrib.toURL();
+        
+        URL helloURL = getContributionURL(Hello.class);
+        
+        // File helloContrib = new File("./target/classes/");
+        // URL helloURL = helloContrib.toURL();
         Contribution consumerContribution =
             contributionService.contribute("http://import-export/hello", helloURL, helloResolver, false);
         Composite consumerComposite = consumerContribution.getDeployables().get(0);
@@ -64,6 +67,18 @@
         // Start Components from my composite
         domain.getCompositeActivator().activate(consumerComposite);
         domain.getCompositeActivator().start(consumerComposite);
+    }
+
+    private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+        String flag = "/" + cls.getName().replace('.', '/') + ".class";
+        URL url = cls.getResource(flag);
+        String root = url.toExternalForm();
+        root = root.substring(0, root.length() - flag.length() + 1);
+        if (root.startsWith("jar:") && root.endsWith("!/")) {
+            root = root.substring(4, root.length() - 2);
+        }
+        url = new URL(root);
+        return url;
     }
 
     public void testHello() throws IOException {

Modified: incubator/tuscany/java/sca/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java?rev=619662&r1=619661&r2=619662&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java Thu Feb  7 14:09:45 2008
@@ -18,10 +18,11 @@
  */
 package org.apache.tuscany.test.contribution;
 
+import hello.Hello;
 import helloworld.HelloWorldService;
 
-import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.Socket;
 import java.net.URL;
 
@@ -53,8 +54,9 @@
         // Contribute the SCA contribution
         ContributionService contributionService = domain.getContributionService();
 
-        File compositeContribLocation = new File("../export-composite/target/classes");
-        URL compositeContribURL = compositeContribLocation.toURL();
+        // File compositeContribLocation = new File("../export-composite/target/classes");
+        // URL compositeContribURL = compositeContribLocation.toURL();
+        URL compositeContribURL = getContributionURL(Hello.class);
         compositeContribution =
             contributionService.contribute("http://import-export/export-composite", compositeContribURL, false);
         for (Composite deployable : compositeContribution.getDeployables()) {
@@ -62,8 +64,9 @@
             domain.buildComposite(deployable);
         }
 
-        File helloWorldContribLocation = new File("./target/classes/");
-        URL helloWorldContribURL = helloWorldContribLocation.toURL();
+//        File helloWorldContribLocation = new File("./target/classes/");
+//        URL helloWorldContribURL = helloWorldContribLocation.toURL();
+        URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
         helloWorldContribution =
             contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
         for (Composite deployable : helloWorldContribution.getDeployables()) {
@@ -76,6 +79,18 @@
             domain.getCompositeActivator().activate(deployable);
             domain.getCompositeActivator().start(deployable);
         }
+    }
+    
+    private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+        String flag = "/" + cls.getName().replace('.', '/') + ".class";
+        URL url = cls.getResource(flag);
+        String root = url.toExternalForm();
+        root = root.substring(0, root.length() - flag.length() + 1);
+        if (root.startsWith("jar:") && root.endsWith("!/")) {
+            root = root.substring(4, root.length() - 2);
+        }
+        url = new URL(root);
+        return url;
     }
 
     public void testPing() throws IOException {

Modified: incubator/tuscany/java/sca/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java?rev=619662&r1=619661&r2=619662&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java Thu Feb  7 14:09:45 2008
@@ -18,10 +18,11 @@
  */
 package org.apache.tuscany.sca.test.contribution;
 
+import helloworld.HelloWorldImpl;
 import helloworld.HelloWorldService;
 
-import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 
 import junit.framework.TestCase;
@@ -34,7 +35,7 @@
 /**
  * Tests that the helloworld server is available
  */
-public class HelloWorldServerTestCase extends TestCase{
+public class HelloWorldServerTestCase extends TestCase {
     private ClassLoader cl;
     private EmbeddedSCADomain domain;
     private Contribution helloWorldContribution;
@@ -52,43 +53,61 @@
         // Contribute the SCA contribution
         ContributionService contributionService = domain.getContributionService();
 
-        File javaContribLocation = new File("../export-java/target/classes");
-        URL javaContribURL = javaContribLocation.toURL();
+//        File javaContribLocation = new File("../export-java/target/classes");
+//        URL javaContribURL = javaContribLocation.toURL();
+        URL javaContribURL = getContributionURL(HelloWorldService.class);
         javaContribution = contributionService.contribute("http://import-export/export-java", javaContribURL, false);
-        for (Composite deployable : javaContribution.getDeployables() ) {
+        for (Composite deployable : javaContribution.getDeployables()) {
             domain.getDomainComposite().getIncludes().add(deployable);
             domain.buildComposite(deployable);
         }
 
-        File helloWorldContribLocation = new File("./target/classes/");
-        URL helloWorldContribURL = helloWorldContribLocation.toURL();
-        helloWorldContribution = contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
-        for (Composite deployable : helloWorldContribution.getDeployables() ) {
+//        File helloWorldContribLocation = new File("./target/classes/");
+//        URL helloWorldContribURL = helloWorldContribLocation.toURL();
+        URL helloWorldContribURL = getContributionURL(HelloWorldImpl.class);
+
+        helloWorldContribution =
+            contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
+        for (Composite deployable : helloWorldContribution.getDeployables()) {
             domain.getDomainComposite().getIncludes().add(deployable);
             domain.buildComposite(deployable);
         }
 
         // Start Components from my composite
-        for (Composite deployable : helloWorldContribution.getDeployables() ) {
+        for (Composite deployable : helloWorldContribution.getDeployables()) {
             domain.getCompositeActivator().activate(deployable);
             domain.getCompositeActivator().start(deployable);
         }
     }
+    
+    private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+        String flag = "/" + cls.getName().replace('.', '/') + ".class";
+        URL url = cls.getResource(flag);
+        String root = url.toExternalForm();
+        root = root.substring(0, root.length() - flag.length() + 1);
+        if (root.startsWith("jar:") && root.endsWith("!/")) {
+            root = root.substring(4, root.length() - 2);
+        }
+        url = new URL(root);
+        return url;
+    }
 
-	public void testPing() throws IOException {
-		HelloWorldService helloWorldService = domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
+    public void testPing() throws IOException {
+        HelloWorldService helloWorldService =
+            domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
         assertNotNull(helloWorldService);
         assertEquals("Hello test", helloWorldService.getGreetings("test"));
-	}
+    }
 
     public void testServiceCall() throws IOException {
-        HelloWorldService helloWorldService = domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
+        HelloWorldService helloWorldService =
+            domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
         assertNotNull(helloWorldService);
 
         assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
     }
 
-	@Override
+    @Override
     public void tearDown() throws Exception {
         ContributionService contributionService = domain.getContributionService();
 
@@ -97,7 +116,7 @@
         contributionService.remove("http://import-export/export-java");
 
         // Stop Components from my composite
-        for (Composite deployable : helloWorldContribution.getDeployables() ) {
+        for (Composite deployable : helloWorldContribution.getDeployables()) {
             domain.getCompositeActivator().stop(deployable);
             domain.getCompositeActivator().deactivate(deployable);
         }
@@ -105,6 +124,6 @@
         domain.stop();
 
         domain.close();
-	}
+    }
 
 }

Modified: incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/pom.xml?rev=619662&r1=619661&r2=619662&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/pom.xml (original)
+++ incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/pom.xml Thu Feb  7 14:09:45 2008
@@ -28,7 +28,13 @@
     <artifactId>itest-contribution-import-wsdl</artifactId>
     <name>Apache Tuscany SCA Contribution WSDL Import Integration Tests</name>
 
-<dependencies>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>itest-contribution-export-wsdl</artifactId>
+            <version>1.2-incubating-SNAPSHOT</version>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-host-embedded</artifactId>

Modified: incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java?rev=619662&r1=619661&r2=619662&view=diff
==============================================================================
--- incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java Thu Feb  7 14:09:45 2008
@@ -20,8 +20,8 @@
 
 import helloworld.HelloWorldService;
 
-import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.Socket;
 import java.net.URL;
 
@@ -35,7 +35,7 @@
 /**
  * Tests that the helloworld server is available
  */
-public class HelloWorldServerTestCase extends TestCase{
+public class HelloWorldServerTestCase extends TestCase {
     private ClassLoader cl;
     private EmbeddedSCADomain domain;
     private Contribution wsdlContribution;
@@ -53,35 +53,63 @@
         // Contribute the SCA contribution
         ContributionService contributionService = domain.getContributionService();
 
-        File wsdlContribLocation = new File("../export-wsdl/target/classes");
-        URL wsdlContribURL = wsdlContribLocation.toURL();
+        //        File wsdlContribLocation = new File("../export-wsdl/target/classes");
+        //        URL wsdlContribURL = wsdlContribLocation.toURL();
+        URL wsdlContribURL = getContributionURL(getClass().getClassLoader(), "helloworld.wsdl");
         wsdlContribution = contributionService.contribute("http://import-export/export-wsdl", wsdlContribURL, false);
-        for (Composite deployable : wsdlContribution.getDeployables() ) {
+        for (Composite deployable : wsdlContribution.getDeployables()) {
             domain.getDomainComposite().getIncludes().add(deployable);
             domain.buildComposite(deployable);
         }
 
-        File helloWorldContribLocation = new File("./target/classes/");
-        URL helloWorldContribURL = helloWorldContribLocation.toURL();
-        consumerContribution = contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
-        for (Composite deployable : consumerContribution.getDeployables() ) {
+        //        File helloWorldContribLocation = new File("./target/classes/");
+        //        URL helloWorldContribURL = helloWorldContribLocation.toURL();
+        URL helloWorldContribURL = getContributionURL(HelloWorldService.class);
+        consumerContribution =
+            contributionService.contribute("http://import-export/helloworld", helloWorldContribURL, false);
+        for (Composite deployable : consumerContribution.getDeployables()) {
             domain.getDomainComposite().getIncludes().add(deployable);
             domain.buildComposite(deployable);
         }
 
         // Start Components from my composite
-        for (Composite deployable : consumerContribution.getDeployables() ) {
+        for (Composite deployable : consumerContribution.getDeployables()) {
             domain.getCompositeActivator().activate(deployable);
             domain.getCompositeActivator().start(deployable);
         }
     }
 
-	public void testPing() throws IOException {
-		new Socket("127.0.0.1", 8085);
-	}
+    public void testPing() throws IOException {
+        new Socket("127.0.0.1", 8085);
+    }
+
+    private URL getContributionURL(Class<?> cls) throws MalformedURLException {
+        String flag = "/" + cls.getName().replace('.', '/') + ".class";
+        URL url = cls.getResource(flag);
+        String root = url.toExternalForm();
+        root = root.substring(0, root.length() - flag.length() + 1);
+        if (root.startsWith("jar:") && root.endsWith("!/")) {
+            root = root.substring(4, root.length() - 2);
+        }
+        url = new URL(root);
+        return url;
+    }
+
+    private URL getContributionURL(ClassLoader cl, String flag) throws MalformedURLException {
+        URL url = cl.getResource(flag);
+        String root = url.toExternalForm();
+        root = root.substring(0, root.length() - flag.length());
+        if (root.startsWith("jar:") && root.endsWith("!/")) {
+            root = root.substring(4, root.length() - 2);
+        }
+        url = new URL(root);
+        // System.out.println(url);
+        return url;
+    }
 
     public void testServiceCall() throws IOException {
-        HelloWorldService helloWorldService = domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
+        HelloWorldService helloWorldService =
+            domain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService");
         assertNotNull(helloWorldService);
 
         assertEquals("Hello Smith", helloWorldService.getGreetings("Smith"));
@@ -96,7 +124,7 @@
         contributionService.remove("http://import-export/export-wsdl");
 
         // Stop Components from my composite
-        for (Composite deployable : consumerContribution.getDeployables() ) {
+        for (Composite deployable : consumerContribution.getDeployables()) {
             domain.getCompositeActivator().stop(deployable);
             domain.getCompositeActivator().deactivate(deployable);
         }



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