tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r561957 - in /incubator/tuscany/java/sca/itest/recursive/src: main/resources/ main/resources/META-INF/ test/java/composite/
Date Wed, 01 Aug 2007 21:19:18 GMT
Author: lresende
Date: Wed Aug  1 14:19:12 2007
New Revision: 561957

URL: http://svn.apache.org/viewvc?view=rev&rev=561957
Log:
Testcase to exercise issue mentioned in TUSCANY-1347.

Added:
    incubator/tuscany/java/sca/itest/recursive/src/main/resources/META-INF/
    incubator/tuscany/java/sca/itest/recursive/src/main/resources/META-INF/sca-contribution.xml
    incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceEmbeddedSCADomainTestCase.java
    incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceSCADomainTestCase.java
Modified:
    incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite2.composite
    incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite3.composite

Modified: incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite2.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite2.composite?view=diff&rev=561957&r1=561956&r2=561957
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite2.composite (original)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite2.composite Wed
Aug  1 14:19:12 2007
@@ -17,8 +17,10 @@
     * specific language governing permissions and limitations
     * under the License.    
 -->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://sample" xmlns:sample="http://sample"
-    name="Composite2">
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           targetNamespace="http://sample"
+           xmlns:sample="http://sample"
+           name="Composite2">
 
     <component name="ComponentC">
         <implementation.java class="sample.ComponentCImpl" />

Modified: incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite3.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite3.composite?view=diff&rev=561957&r1=561956&r2=561957
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite3.composite (original)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/resources/Composite3.composite Wed
Aug  1 14:19:12 2007
@@ -17,8 +17,11 @@
     * specific language governing permissions and limitations
     * under the License.    
 -->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://sample" xmlns:sample="http://sample"
-    xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Composite3">
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+           targetNamespace="http://sample"
+           xmlns:sample="http://sample"
+           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+           name="Composite3">
 
     <component name="ComponentE">
         <implementation.java class="sample.ComponentEImpl" />

Added: incubator/tuscany/java/sca/itest/recursive/src/main/resources/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/main/resources/META-INF/sca-contribution.xml?view=auto&rev=561957
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/main/resources/META-INF/sca-contribution.xml
(added)
+++ incubator/tuscany/java/sca/itest/recursive/src/main/resources/META-INF/sca-contribution.xml
Wed Aug  1 14:19:12 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+              targetNamespace="http://sample"
+              xmlns:sample="http://sample">
+   <deployable composite="sample:OuterComposite"/>
+</contribution>
\ No newline at end of file

Added: incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceEmbeddedSCADomainTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceEmbeddedSCADomainTestCase.java?view=auto&rev=561957
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceEmbeddedSCADomainTestCase.java
(added)
+++ incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceEmbeddedSCADomainTestCase.java
Wed Aug  1 14:19:12 2007
@@ -0,0 +1,97 @@
+/*
+ * 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 composite;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.service.ContributionService;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+
+public class LocateServiceEmbeddedSCADomainTestCase extends TestCase{
+    private ClassLoader cl;
+    private EmbeddedSCADomain domain;
+
+    protected void setUp() throws Exception {
+        //Create a test embedded SCA domain
+        cl = getClass().getClassLoader();
+        domain = new EmbeddedSCADomain(cl, "http://localhost");
+
+        //Start the domain
+        domain.start();
+
+        // Contribute the SCA contribution
+        ContributionService contributionService = domain.getContributionService();
+
+        
+        File contribLocation = new File("./target/classes/");
+        URL contributionURL = contribLocation.toURL();
+        Contribution contribution = contributionService.contribute("http://contribution",
contributionURL, false);
+        for (Composite deployable : contribution.getDeployables() ) {
+            domain.getDomainCompositeHelper().addComposite(deployable);
+        }
+
+        //activate SCA Domain
+        domain.getDomainCompositeHelper().activateDomain();
+
+        //Start Components from my composite
+        domain.getDomainCompositeHelper().startComponent(domain.getDomainCompositeHelper().getComponent("SourceComponent"));
+    }
+
+    public void testValidLocateService() throws Exception {
+        Source source;
+        try {
+            source = domain.getService(Source.class, "SourceComponent");
+            assertNotNull(source);
+        } catch (Throwable t) {
+            fail("Could not locate service");
+        }
+    }
+
+    public void testInvalidLocateService() throws Exception {
+        Source source;
+        try {
+            source = domain.getService(Source.class, "SourceComponentXXX");
+            assertNull(source);
+            fail("Expected to generate org.osoa.sca.ServiceRuntimeException but did not when
invoking service with async");
+        } catch (org.osoa.sca.ServiceRuntimeException e) {
+            // expected.
+        }
+    }
+
+
+    public void tearDown() throws Exception {
+        ContributionService contributionService = domain.getContributionService();
+
+        // Remove the contribution from the in-memory repository
+        contributionService.remove("http://contribution");
+
+        //Stop Components from my composite
+        domain.getDomainCompositeHelper().stopComponent(domain.getDomainCompositeHelper().getComponent("SourceComponent"));
+
+        domain.stop();
+        domain.close();
+    }
+
+}

Added: incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceSCADomainTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceSCADomainTestCase.java?view=auto&rev=561957
==============================================================================
--- incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceSCADomainTestCase.java
(added)
+++ incubator/tuscany/java/sca/itest/recursive/src/test/java/composite/LocateServiceSCADomainTestCase.java
Wed Aug  1 14:19:12 2007
@@ -0,0 +1,60 @@
+/*
+ * 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 composite;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class LocateServiceSCADomainTestCase extends TestCase {
+
+    private SCADomain domain;
+    
+
+    protected void setUp() throws Exception {
+        domain = SCADomain.newInstance("OuterComposite.composite");
+    }
+    
+    protected void tearDown() throws Exception {
+        domain.close();
+    }
+
+    public void testValidLocateService() throws Exception {
+        Source source;
+        try {
+            source = domain.getService(Source.class, "SourceComponent");
+            assertNotNull(source);
+        } catch (Throwable t) {
+            fail("Could not locate service");
+        }
+    }
+
+    public void testInvalidLocateService() throws Exception {
+        Source source;
+        try {
+            source = domain.getService(Source.class, "SourceComponentXXX");
+            assertNull(source);
+            fail("Expected to generate org.osoa.sca.ServiceRuntimeException but did not when
invoking service with async");
+        } catch (org.osoa.sca.ServiceRuntimeException e) {
+            // expected.
+        }
+    }
+
+}



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


Mime
View raw message