You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2011/07/23 22:17:04 UTC

svn commit: r1150211 - in /tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps: ./ src/main/assembly/ src/main/assembly/resources/ src/main/assembly/resources/META-INF/ src/main/java/sample/ src/main/resources/ src/main/resources/MET...

Author: antelder
Date: Sat Jul 23 20:17:02 2011
New Revision: 1150211

URL: http://svn.apache.org/viewvc?rev=1150211&view=rev
Log:
Add a sample for a zip contribution using a nested jar

Added:
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/
      - copied from r1147543, tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld/
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/helloworld.composite
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/sca-contribution.xml
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/zip.xml
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/test/
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/test/java/sample/HelloworldTestCase.java
      - copied, changed from r1147543, tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld/src/test/java/sample/HelloworldTestCase.java
Removed:
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/resources/META-INF/
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/resources/helloworld.composite
Modified:
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/pom.xml
    tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/java/sample/HelloworldImpl.java

Modified: tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/pom.xml?rev=1150211&r1=1147543&r2=1150211&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/pom.xml Sat Jul 23 20:17:02 2011
@@ -27,15 +27,29 @@
       <version>2.0-SNAPSHOT</version>
       <relativePath>../../pom.xml</relativePath>
    </parent>
-   <artifactId>helloworld</artifactId>
+   <artifactId>helloworld-withdeps</artifactId>
    <version>2.0-SNAPSHOT</version>
 
-   <name>Apache Tuscany SCA Samples Helloworld</name>
+   <name>Apache Tuscany SCA Samples Helloworld With Dependencies</name>
 
    <properties>
       <tuscany.version>${project.version}</tuscany.version>
    </properties>
 
+   <!-- ASF repositories so sample can be built from SVN without building trunk-->
+   <repositories><repository>
+      <id>apache.snapshots</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+      <releases><enabled>false</enabled></releases>
+   </repository></repositories>
+   <pluginRepositories><pluginRepository>
+       <id>apache.snapshots</id>
+       <name>Apache Snapshot Repository</name>
+       <url>http://repository.apache.org/snapshots</url>
+       <releases><enabled>false</enabled></releases>
+   </pluginRepository></pluginRepositories>
+
    <dependencies>
 
       <dependency>
@@ -46,6 +60,12 @@
       </dependency>
 
       <dependency>
+         <groupId>org.apache.commons</groupId>
+         <artifactId>commons-lang3</artifactId>
+         <version>3.0</version>
+      </dependency>
+
+      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.8.1</version>
@@ -65,12 +85,34 @@
 
       <plugins>
 
+        <plugin>
+           <groupId>org.apache.maven.plugins</groupId>
+           <artifactId>maven-assembly-plugin</artifactId>
+           <version>2.2.1</version>
+           <executions>
+              <execution>
+                 <id>zip</id>
+                 <phase>package</phase>
+                 <goals>
+                    <goal>single</goal>
+                 </goals>
+                 <configuration>
+                    <appendAssemblyId>false</appendAssemblyId>
+                    <descriptors>
+                       <descriptor>src/main/assembly/zip.xml</descriptor>
+                    </descriptors>
+                 </configuration>
+              </execution>
+           </executions>
+        </plugin>
+
          <!-- to support running the composite with mvn tuscany:run -->
          <plugin>
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-maven-plugin</artifactId>
             <version>${tuscany.version}</version>
          </plugin>
+
       </plugins>
 
    </build>

Added: tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/helloworld.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/helloworld.composite?rev=1150211&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/helloworld.composite (added)
+++ tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/helloworld.composite Sat Jul 23 20:17:02 2011
@@ -0,0 +1,29 @@
+<?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.    
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+           targetNamespace="http://sample"
+           name="helloworld-withdeps">
+
+    <component name="HelloworldComponent">
+        <implementation.java class="sample.HelloworldImpl"/>
+    </component>
+
+</composite>

Added: tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/sca-contribution.xml?rev=1150211&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/sca-contribution.xml (added)
+++ tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/resources/META-INF/sca-contribution.xml Sat Jul 23 20:17:02 2011
@@ -0,0 +1,25 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+              xmlns:sample="http://sample">
+   
+   <deployable composite="sample:helloworld-withdeps" />
+
+</contribution>

Added: tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/zip.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/zip.xml?rev=1150211&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/zip.xml (added)
+++ tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/assembly/zip.xml Sat Jul 23 20:17:02 2011
@@ -0,0 +1,41 @@
+<?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.
+-->
+<assembly>
+    <id>zip</id>
+    <includeBaseDirectory>false</includeBaseDirectory>
+
+    <formats>
+        <format>zip</format>
+    </formats>
+
+    <fileSets>
+       <fileSet>
+          <directory>src/main/assembly/resources</directory>
+          <outputDirectory>.</outputDirectory>
+       </fileSet>
+    </fileSets>
+
+    <dependencySets>
+       <dependencySet>
+          <outputDirectory>lib</outputDirectory>
+       </dependencySet>
+    </dependencySets>
+
+</assembly>

Modified: tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/java/sample/HelloworldImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/java/sample/HelloworldImpl.java?rev=1150211&r1=1147543&r2=1150211&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/java/sample/HelloworldImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/main/java/sample/HelloworldImpl.java Sat Jul 23 20:17:02 2011
@@ -18,10 +18,12 @@
  */
 package sample;
 
+import org.apache.commons.lang3.text.WordUtils;
+
 public class HelloworldImpl implements Helloworld {
 
     public String sayHello(String name) {
-        return "Hello " + name;
+        return "Hello " + WordUtils.capitalize(name);
     }
 
 }

Copied: tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/test/java/sample/HelloworldTestCase.java (from r1147543, tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld/src/test/java/sample/HelloworldTestCase.java)
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/test/java/sample/HelloworldTestCase.java?p2=tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/test/java/sample/HelloworldTestCase.java&p1=tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld/src/test/java/sample/HelloworldTestCase.java&r1=1147543&r2=1150211&rev=1150211&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld/src/test/java/sample/HelloworldTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/getting-started/helloworld-withdeps/src/test/java/sample/HelloworldTestCase.java Sat Jul 23 20:17:02 2011
@@ -19,9 +19,6 @@
 package sample;
 
 import org.junit.Assert;
-
-import org.apache.tuscany.sca.Node;
-import org.apache.tuscany.sca.TuscanyRuntime;
 import org.junit.Test;
 import org.oasisopen.sca.NoSuchServiceException;
 
@@ -30,19 +27,23 @@ public class HelloworldTestCase {
     @Test
     public void testSayHello() throws NoSuchServiceException {
 
-        // Run the SCA composite in a Tuscany runtime
-        Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes");
-        try {
-            
-            // Get the Helloworld service proxy
-            Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
-            
-            // test that it works as expected
-            Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
-            
-        } finally {
-            // Stop the Tuscany runtime Node
-            node.stop();        
-        }
+//        // Run the SCA composite in a Tuscany runtime
+//        Node node = TuscanyRuntime.runComposite(null, "target/helloworld-withdeps-2.0-SNAPSHOT.zip");
+//        try {
+//            
+//            // Get the Helloworld service proxy
+//            Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
+//            
+//            // test that it works as expected
+//            Assert.assertEquals("Hello Amelia", helloworld.sayHello("amelia"));
+//            
+//        } finally {
+//            // Stop the Tuscany runtime Node
+//            node.stop();        
+//        }
+        Helloworld helloworld = new HelloworldImpl();
+
+        // Test that a lower case name does get capitalized
+        Assert.assertEquals("Hello Amelia", helloworld.sayHello("amelia"));
     }
 }