You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/05/16 10:35:35 UTC

svn commit: r538477 - in /incubator/tuscany/java/sca/samples/implementation-crud-client: ./ src/ src/main/ src/main/java/ src/main/java/crud/ src/main/resources/ src/test/ src/test/java/ src/test/java/crud/

Author: slaws
Date: Wed May 16 01:35:33 2007
New Revision: 538477

URL: http://svn.apache.org/viewvc?view=rev&rev=538477
Log:
Move application level code from implementation-crud
TUSCANY-1287

Added:
    incubator/tuscany/java/sca/samples/implementation-crud-client/
    incubator/tuscany/java/sca/samples/implementation-crud-client/README   (with props)
    incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml   (with props)
    incubator/tuscany/java/sca/samples/implementation-crud-client/implementation-crud.png
      - copied unchanged from r538449, incubator/tuscany/java/sca/samples/implementation-crud/implementation-crud.png
    incubator/tuscany/java/sca/samples/implementation-crud-client/implementation-crud.svg
      - copied unchanged from r538449, incubator/tuscany/java/sca/samples/implementation-crud/implementation-crud.svg
    incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml   (with props)
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/CRUDClient.java   (with props)
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/resources/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/resources/crudclient.composite
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/
    incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/CRUDTestCase.java   (with props)

Added: incubator/tuscany/java/sca/samples/implementation-crud-client/README
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud-client/README?view=auto&rev=538477
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud-client/README (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud-client/README Wed May 16 01:35:33 2007
@@ -0,0 +1,106 @@
+Implementation CRUD Sample Client
+=================================
+This sample demonstrates how to use the new implementation extension, 
+implementation-crud
+
+The README in the samples directory (the directory above this) provides 
+general instructions about building and running samples. Take a look there 
+first. 
+
+If you just want to run it to see what happens, open a command prompt,
+navigate to this sample directory, and do
+
+ant 
+
+OR if you don't have ant, on Windows do
+
+java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-implementation-crud-client.jar crud.CRUDClient
+
+and on *nix do
+
+java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-implementation-crud-client.jar crud.CRUDClient
+
+
+Sample Overview
+---------------
+This sample contains a client application for a CRUD implementation type that
+shows how to create new implementation types. See the README for the
+mplementation-crud sample for details of this implementation type.
+
+implementation-crud-client/
+  src/
+    main/
+      java/
+        crud/
+          CRUDClient.java      - sample client
+      resources/
+        crudclient.composite   - the SCA assembly used by this sample
+          
+    test/
+      java/
+        crud/ 
+          CRUDTestCase.java    - sample JUnit test case for the sample client
+          
+  implementation-crudclient.png- a pictorial representation of the sample 
+                                 .composite file          
+  build.xml                    - the Ant build file
+  pom.xml                      - the Maven build file
+  
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+With the binary distribution the sample can be built and run using Ant as 
+follows
+
+cd implementation-crud-client
+ant
+ant run
+
+You should see the following output from the run target.
+
+run:
+     [java] Starting CRUDServiceComponent
+     [java] create(ABC) in tmp
+     [java] retrieve(0)
+     [java] Result from create: ABC
+     [java] update(0)
+     [java] retrieve(0)
+     [java] Result from update: EFG
+     [java] delete(0)
+     [java] retrieve(0)
+     [java] Result from delete: null
+     [java] Stopping CRUDServiceComponent
+
+
+Building And Running The Sample Using Maven 
+-------------------------------------------
+With either the binary or source distributions the sample can be built and
+run using Maven as follows. 
+
+cd implementation-crud-client
+mvn
+
+You should see the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running crudClient.CRUDTestCase
+Starting CRUDServiceComponent
+create(ABC) in tmp
+retrieve(0)
+Result from create: ABC
+update(0)
+retrieve(0)
+Result from update: EFG
+delete(0)
+retrieve(0)
+Result from delete: null
+Stopping CRUDServiceComponent
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.212 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+This shows that the Junit test cases have run successfully. 

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/README
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/README
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml?view=auto&rev=538477
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml Wed May 16 01:35:33 2007
@@ -0,0 +1,72 @@
+<!--
+ * 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.    
+-->
+<project name="implementation-crud-client" default="compile">
+    <property name="test.class" value="crud.CRUDClient" />
+	<property name="test.jar"   value="sample-implementation-crud-client.jar" />
+	
+    <target name="init">
+        <mkdir dir="target/classes"/>
+    </target>
+	
+    <target name="compile" depends="init">
+        <javac srcdir="src/main/java"
+               destdir="target/classes"
+               debug="on"
+               source="1.5"
+               target="1.5">
+            <classpath>
+                <pathelement location="../implementation-crud/target/sample-implementation-crud.jar"/>
+                <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+            </classpath>
+        </javac> 
+        <jar destfile="target/${test.jar}" basedir="target/classes">
+            <manifest>
+                <attribute name="Main-Class" value="${test.class}" /> 
+            </manifest>
+        </jar>      
+    </target>	
+	
+    <target name="run-classes" depends="compile">
+        <java classname="${test.class}"
+              fork="true">
+            <classpath>
+                <pathelement path="target/classes"/>
+                <pathelement location="../implementation-crud/target/sample-implementation-crud.jar"/>
+            	<pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+            </classpath>
+        </java>
+    </target>
+	
+    <target name="run" depends="compile">
+        <java classname="${test.class}"
+              fork="true">
+            <classpath>
+                <pathelement location="target/${test.jar}"/>
+                <pathelement location="../implementation-crud/target/sample-implementation-crud.jar"/>
+                <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
+            </classpath>
+        </java>    	
+    </target>	
+	
+    <target name="clean">
+        <delete quiet="true" includeemptydirs="true">
+            <fileset dir="target"/>
+        </delete>
+    </target>
+</project>

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/build.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml?view=auto&rev=538477
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml Wed May 16 01:35:33 2007
@@ -0,0 +1,64 @@
+<?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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-sca</artifactId>
+        <version>1.0-incubating-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <artifactId>sample-implementation-crud-client</artifactId>
+    <name>Apache Tuscany CRUD Implementation Extension Sample Client</name>
+
+    <repositories>
+       <repository>
+          <id>apache.incubator</id>
+          <url>http://people.apache.org/repo/m2-incubating-repository</url>
+       </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>sample-implementation-crud</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>        
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.2</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+       <finalName>${artifactId}</finalName>
+    </build>
+
+</project>

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/CRUDClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/CRUDClient.java?view=auto&rev=538477
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/CRUDClient.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/CRUDClient.java Wed May 16 01:35:33 2007
@@ -0,0 +1,53 @@
+/*
+ * 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 crud;
+
+import crud.CRUD;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CRUDClient {
+
+    public static void main(String[] args) throws Exception {
+
+        SCADomain scaDomain = SCADomain.newInstance("crudclient.composite");
+        CRUD crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent");
+        
+        String id = crudService.create("ABC");
+        Object result = crudService.retrieve(id);
+        System.out.println("Result from create: " + result);
+        crudService.update(id, "EFG");
+        result = crudService.retrieve(id);
+        System.out.println("Result from update: " + result);
+        crudService.delete(id);
+        result = crudService.retrieve(id);
+        if (result == null) {
+            System.out.println("Result from delete: null");
+        } else {
+            System.out.println("Result from delete: should be null but was " + result);
+        }
+        
+        scaDomain.close();
+
+    }
+
+}

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/CRUDClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/java/crud/CRUDClient.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/resources/crudclient.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/resources/crudclient.composite?view=auto&rev=538477
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/resources/crudclient.composite (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud-client/src/main/resources/crudclient.composite Wed May 16 01:35:33 2007
@@ -0,0 +1,30 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+	targetNamespace="http://sample/crud"
+	xmlns:sc="http://sample/crud"
+	xmlns:c="http://crud"
+	name="crud">
+
+    <component name="CRUDServiceComponent">
+        <c:implementation.crud directory="tmp" />
+    </component>
+
+</composite>

Added: incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/CRUDTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/CRUDTestCase.java?view=auto&rev=538477
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/CRUDTestCase.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/CRUDTestCase.java Wed May 16 01:35:33 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 crud;
+
+import crud.CRUDClient;
+import junit.framework.TestCase;
+
+public class CRUDTestCase extends TestCase {
+
+    public void test() throws Exception {
+        CRUDClient.main(null);
+    }
+}

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/CRUDTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/samples/implementation-crud-client/src/test/java/crud/CRUDTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



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