Return-Path: Delivered-To: apmail-ws-tuscany-commits-archive@locus.apache.org Received: (qmail 74543 invoked from network); 7 Feb 2008 22:10:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Feb 2008 22:10:13 -0000 Received: (qmail 72936 invoked by uid 500); 7 Feb 2008 22:10:06 -0000 Delivered-To: apmail-ws-tuscany-commits-archive@ws.apache.org Received: (qmail 72900 invoked by uid 500); 7 Feb 2008 22:10:06 -0000 Mailing-List: contact tuscany-commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tuscany-dev@ws.apache.org Delivered-To: mailing list tuscany-commits@ws.apache.org Received: (qmail 72890 invoked by uid 99); 7 Feb 2008 22:10:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Feb 2008 14:10:06 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Feb 2008 22:09:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 14C6E1A9832; Thu, 7 Feb 2008 14:09:48 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Thu, 07 Feb 2008 22:09:47 -0000 To: tuscany-commits@ws.apache.org From: rfeng@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080207220948.14C6E1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ itest-contribution-import-wsdl Apache Tuscany SCA Contribution WSDL Import Integration Tests - + + + org.apache.tuscany.sca + itest-contribution-export-wsdl + 1.2-incubating-SNAPSHOT + + org.apache.tuscany.sca tuscany-host-embedded 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