From 3c7c4a749baafcf375f4785a7668d3a25c9063e3 Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 13 Nov 2009 01:42:27 +0000 Subject: Moving 1.x trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835700 13f79535-47bb-0310-9956-ffa450edef68 --- .../trunk/samples/implementation-crud/README | 113 +++++++++++++++++ .../trunk/samples/implementation-crud/build.xml | 75 ++++++++++++ .../implementation-crud/implementation-crud.png | Bin 0 -> 4227 bytes .../implementation-crud/implementation-crud.svg | 135 +++++++++++++++++++++ .../trunk/samples/implementation-crud/pom.xml | 64 ++++++++++ .../src/main/java/crud/client/CRUDClient.java | 59 +++++++++ .../src/main/resources/crud.composite | 30 +++++ .../src/test/java/crud/client/CRUDTestCase.java | 61 ++++++++++ 8 files changed, 537 insertions(+) create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/README create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/build.xml create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.png create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.svg create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/pom.xml create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/src/main/resources/crud.composite create mode 100644 sca-java-1.x/trunk/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java (limited to 'sca-java-1.x/trunk/samples/implementation-crud') diff --git a/sca-java-1.x/trunk/samples/implementation-crud/README b/sca-java-1.x/trunk/samples/implementation-crud/README new file mode 100644 index 0000000000..50da631c04 --- /dev/null +++ b/sca-java-1.x/trunk/samples/implementation-crud/README @@ -0,0 +1,113 @@ +Implementation CRUD Sample Client +================================= +This sample demonstrates how to use the new implementation extension, +implementation-crud-extension. + +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 run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;..\implementation-crud-extension\target\sample-implementation-crud-extension.jar;target\sample-implementation-crud.jar crud.client.CRUDClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:../implementation-crud-extension/target/sample-implementation-crud-extension.jar:target/sample-implementation-crud.jar crud.client.CRUDClient + +This looks like a long command. The three things we add to the classpath are + +tuscany-sca-manifest.jar - all of the standard Tuscany SCA + runtime and extension classes +sample-implementation-crud-extension.jar - the new crud implementation + extension +sample-implementation-crud.jar - the application that uses the crud + implementation + +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-extension sample for details of this implementation type. + +implementation-crud/ + src/ + main/ + java/ + crud/ + client/ + CRUDClient.java - sample client + resources/ + crud.composite - the SCA assembly used by this sample + + test/ + java/ + crud/ + client/ + CRUDTestCase.java - sample JUnit test case for the sample client + + implementation-crud.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 +ant compile +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 +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running crud.client.CRUDTestCase +Starting CRUDServiceComponent +create(ABC) in tmp +retrieve(0) +update(0) +retrieve(0) +delete(0) +retrieve(0) +Stopping CRUDServiceComponent +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.641 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/trunk/samples/implementation-crud/build.xml b/sca-java-1.x/trunk/samples/implementation-crud/build.xml new file mode 100644 index 0000000000..10b26b5a94 --- /dev/null +++ b/sca-java-1.x/trunk/samples/implementation-crud/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.png b/sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.png new file mode 100644 index 0000000000..a292037e7a Binary files /dev/null and b/sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.png differ diff --git a/sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.svg b/sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.svg new file mode 100644 index 0000000000..dbb37be208 --- /dev/null +++ b/sca-java-1.x/trunk/samples/implementation-crud/implementation-crud.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + crud + + CRUDServiceComponent + CRUD + diff --git a/sca-java-1.x/trunk/samples/implementation-crud/pom.xml b/sca-java-1.x/trunk/samples/implementation-crud/pom.xml new file mode 100644 index 0000000000..c552472f21 --- /dev/null +++ b/sca-java-1.x/trunk/samples/implementation-crud/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6-SNAPSHOT + ../../pom.xml + + sample-implementation-crud + Apache Tuscany SCA Sample CRUD Implementation Extension Client + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + sample-implementation-crud-extension + 1.6-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/trunk/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java b/sca-java-1.x/trunk/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java new file mode 100644 index 0000000000..ea87cb3001 --- /dev/null +++ b/sca-java-1.x/trunk/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java @@ -0,0 +1,59 @@ +/* + * 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.client; + + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + +/** + * A sample client that shows how to create an SCA domain, get a service, and + * invoke service methods of a CRUD component. + * + * The CRUD component uses an implementation extension + * from module implementation-crud-extension. + * + * @version $Rev$ $Date$ + */ +public class CRUDClient { + + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("crud.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); + System.out.println("Result from delete: " + result); + + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/trunk/samples/implementation-crud/src/main/resources/crud.composite b/sca-java-1.x/trunk/samples/implementation-crud/src/main/resources/crud.composite new file mode 100644 index 0000000000..18745033bb --- /dev/null +++ b/sca-java-1.x/trunk/samples/implementation-crud/src/main/resources/crud.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/trunk/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java b/sca-java-1.x/trunk/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java new file mode 100644 index 0000000000..7e0476a8b1 --- /dev/null +++ b/sca-java-1.x/trunk/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java @@ -0,0 +1,61 @@ +/* + * 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.client; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + + +/** + * Tests the sample crud composite. + */ +public class CRUDTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("crud.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + CRUD crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent"); + + String id = crudService.create("ABC"); + Object result = crudService.retrieve(id); + assertEquals(result, "ABC"); + + crudService.update(id, "EFG"); + result = crudService.retrieve(id); + assertEquals(result, "EFG"); + + crudService.delete(id); + result = crudService.retrieve(id); + assertNull(result); + } +} -- cgit v1.2.3