summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authoredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2008-11-28 09:43:41 +0000
committeredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2008-11-28 09:43:41 +0000
commitcdf9b141765f5397bfd8927c8c8454fa8157ad65 (patch)
tree45c73b0dfbe065ac10758efd50166336b2996d84 /java
parent6a08f361c55de4d568ee2046b0af162bba9ef00e (diff)
New Folder for OASIS Specification conformance tests
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@721404 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/sca/stest/sampleTest/pom.xml91
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/ASM_0001_Client.java49
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/ASM_0002_Client.java57
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/ASM_0003_Client.java61
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/Service1.java17
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/TestInvocation.java17
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/service1Impl.java20
-rw-r--r--java/sca/stest/sampleTest/src/main/resources/Test_ASM_0001.composite40
-rw-r--r--java/sca/stest/sampleTest/src/main/resources/Test_ASM_0002.composite42
-rw-r--r--java/sca/stest/sampleTest/src/main/resources/Test_ASM_0003.composite59
-rw-r--r--java/sca/stest/sampleTest/src/main/resources/Test_ASM_0004.composite61
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTest.java122
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/BaseTest.java122
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/TestConfiguration.java30
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0002.java43
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0003.java44
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0004.java43
17 files changed, 918 insertions, 0 deletions
diff --git a/java/sca/stest/sampleTest/pom.xml b/java/sca/stest/sampleTest/pom.xml
new file mode 100644
index 0000000000..2e396d9ff7
--- /dev/null
+++ b/java/sca/stest/sampleTest/pom.xml
@@ -0,0 +1,91 @@
+<?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>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>stest-sampleTest</artifactId>
+ <name>Apache Tuscany SCA Specification Sample Testcase</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-node-api</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-node-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/java/sca/stest/sampleTest/src/main/java/test/ASM_0001_Client.java b/java/sca/stest/sampleTest/src/main/java/test/ASM_0001_Client.java
new file mode 100644
index 0000000000..5f35b31380
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/java/test/ASM_0001_Client.java
@@ -0,0 +1,49 @@
+package test;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Basic test initiation class
+ * @author MikeEdwards
+ *
+ */
+@Service(TestInvocation.class)
+public class ASM_0001_Client implements TestInvocation {
+
+ private String testName = "ASM_0001";
+
+ /**
+ * This method is offered as a service and is
+ * invoked by the test client to run the test
+ */
+ public String invokeTest( String input ) {
+ String response = null;
+
+ response = runTest( input );
+
+ return response;
+ } // end method invokeTest
+
+ /**
+ * This method actually runs the test - and is subclassed by classes that run other tests.
+ * @param input - an input string
+ * @return - a response string = "ASM_0001 inputString invoked ok";
+ *
+ */
+ public String runTest( String input ){
+ String response = null;
+
+ response = testName + " " + input + " invoked ok";
+
+ return response;
+ } // end method runTest
+
+ /**
+ * Sets the name of the test
+ * @param name - the test name
+ */
+ protected void setTestName( String name ) {
+ testName = name;
+ }
+
+} //
diff --git a/java/sca/stest/sampleTest/src/main/java/test/ASM_0002_Client.java b/java/sca/stest/sampleTest/src/main/java/test/ASM_0002_Client.java
new file mode 100644
index 0000000000..1e10cc9024
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/java/test/ASM_0002_Client.java
@@ -0,0 +1,57 @@
+package test;
+
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * Test initiation class with a single reference of multiplicity 1..1
+ * @author MikeEdwards
+ *
+ */
+@Service(TestInvocation.class)
+public class ASM_0002_Client implements TestInvocation {
+
+ @Property
+ private String testName = "ASM_xxxx";
+
+ @Reference
+ public Service1 reference1;
+
+ /**
+ * This method is offered as a service and is
+ * invoked by the test client to run the test
+ */
+ public String invokeTest( String input ) {
+ String response = null;
+
+ response = runTest( input );
+
+ return response;
+ } // end method invokeTest
+
+ /**
+ * This method actually runs the test - and is subclassed by classes that run other tests.
+ * @param input - an input string
+ * @return - a response string = "ASM_0001 inputString invoked ok";
+ *
+ */
+ public String runTest( String input ){
+ String response = null;
+
+ String response1 = reference1.operation1(input);
+
+ response = testName + " " + input + " " + response1;
+
+ return response;
+ } // end method runTest
+
+ /**
+ * Sets the name of the test
+ * @param name - the test name
+ */
+ protected void setTestName( String name ) {
+ testName = name;
+ }
+
+} //
diff --git a/java/sca/stest/sampleTest/src/main/java/test/ASM_0003_Client.java b/java/sca/stest/sampleTest/src/main/java/test/ASM_0003_Client.java
new file mode 100644
index 0000000000..437ded8cea
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/java/test/ASM_0003_Client.java
@@ -0,0 +1,61 @@
+package test;
+
+import org.osoa.sca.annotations.Service;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Property;
+
+import java.util.List;
+
+/**
+ * Basic test initiation class
+ * @author MikeEdwards
+ *
+ */
+@Service(TestInvocation.class)
+public class ASM_0003_Client implements TestInvocation {
+
+ @Property
+ private String testName = "ASM_xxxx";
+
+ @Reference
+ public List<Service1> reference1;
+
+ /**
+ * This method is offered as a service and is
+ * invoked by the test client to run the test
+ */
+ public String invokeTest( String input ) {
+ String response = null;
+
+ response = runTest( input );
+
+ return response;
+ } // end method invokeTest
+
+ /**
+ * This method actually runs the test - and is subclassed by classes that run other tests.
+ * @param input - an input string
+ * @return - a response string = "ASM_0001 inputString invoked ok";
+ *
+ */
+ public String runTest( String input ){
+ String response = "";
+
+ for( Service1 reference : reference1 ) {
+ response += reference.operation1(input);
+ } // end for
+
+ response = testName + " " + input + " " + response;
+
+ return response;
+ } // end method runTest
+
+ /**
+ * Sets the name of the test
+ * @param name - the test name
+ */
+ protected void setTestName( String name ) {
+ testName = name;
+ }
+
+} //
diff --git a/java/sca/stest/sampleTest/src/main/java/test/Service1.java b/java/sca/stest/sampleTest/src/main/java/test/Service1.java
new file mode 100644
index 0000000000..303a4f1cdd
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/java/test/Service1.java
@@ -0,0 +1,17 @@
+package test;
+
+/**
+ * A test service interface
+ * @author MikeEdwards
+ *
+ */
+public interface Service1 {
+
+ /**
+ * Method for invoking testcase service
+ * @param input - input parameter(s) as a String
+ * @return - output data as a String
+ */
+ public String operation1( String input );
+
+}
diff --git a/java/sca/stest/sampleTest/src/main/java/test/TestInvocation.java b/java/sca/stest/sampleTest/src/main/java/test/TestInvocation.java
new file mode 100644
index 0000000000..e33ab66bf6
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/java/test/TestInvocation.java
@@ -0,0 +1,17 @@
+package test;
+
+/**
+ * Basic interface to invoke testcases
+ * @author MikeEdwards
+ *
+ */
+public interface TestInvocation {
+
+ /**
+ * Method for invoking testcase
+ * @param input - input parameter(s) as a String
+ * @return - output data as a String
+ */
+ public String invokeTest( String input );
+
+}
diff --git a/java/sca/stest/sampleTest/src/main/java/test/service1Impl.java b/java/sca/stest/sampleTest/src/main/java/test/service1Impl.java
new file mode 100644
index 0000000000..98000e28f7
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/java/test/service1Impl.java
@@ -0,0 +1,20 @@
+package test;
+
+import org.osoa.sca.annotations.*;
+
+/**
+ * Simple Java component implementation for business interface Service1
+ * @author MikeEdwards
+ *
+ */
+@Service(Service1.class)
+public class service1Impl implements Service1 {
+
+ @Property
+ public String serviceName = "service1";
+
+ public String operation1(String input) {
+ return serviceName + " operation1 invoked";
+ }
+
+}
diff --git a/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0001.composite b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0001.composite
new file mode 100644
index 0000000000..ac9bb3ea00
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0001.composite
@@ -0,0 +1,40 @@
+<?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://oasis/tests"
+ xmlns:sample="http://oasis/tests"
+ name="TEST_ASM_0001">
+
+ <component name="TestClient">
+ <implementation.java class="test.ASM_0001_Client"/>
+ <service name="TestInvocation">
+ <interface.java interface="test.TestInvocation"/>
+ </service>
+ <!-- reference name="testRef1" target="TestComponent1/service1" / -->
+ </component>
+
+<!--
+ <component name="TestComponent1">
+ <implementation.java class="test.ASM_0001_Impl1"/>
+ <service name="service1"/>
+ </component>
+-->
+
+</composite>
diff --git a/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0002.composite b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0002.composite
new file mode 100644
index 0000000000..28e4b56ef3
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0002.composite
@@ -0,0 +1,42 @@
+<?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://oasis/tests"
+ xmlns:sample="http://oasis/tests"
+ name="TEST_ASM_0002">
+
+ <component name="TestClient">
+ <implementation.java class="test.ASM_0002_Client"/>
+ <service name="TestInvocation">
+ <interface.java interface="test.TestInvocation"/>
+ </service>
+ <reference name="reference1" target="TestComponent1/Service1" />
+ <property name="testName">ASM_0002</property>
+ </component>
+
+
+ <component name="TestComponent1">
+ <implementation.java class="test.service1Impl"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"></interface.java>
+ </service>
+ </component>
+
+</composite>
diff --git a/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0003.composite b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0003.composite
new file mode 100644
index 0000000000..577d4eb049
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0003.composite
@@ -0,0 +1,59 @@
+<?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://oasis/tests"
+ xmlns:sample="http://oasis/tests"
+ name="TEST_ASM_0003">
+
+ <component name="TestClient">
+ <implementation.java class="test.ASM_0003_Client"/>
+ <service name="TestInvocation">
+ <interface.java interface="test.TestInvocation"/>
+ </service>
+ <reference name="reference1" target="TestComponent1/Service1 TestComponent2/Service1 TestComponent3/Service1" />
+ <property name="testName">ASM_0003</property>
+ </component>
+
+
+ <component name="TestComponent1">
+ <implementation.java class="test.service1Impl"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"></interface.java>
+ </service>
+ <property name="serviceName">service1</property>
+ </component>
+
+ <component name="TestComponent2">
+ <implementation.java class="test.service1Impl"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"></interface.java>
+ </service>
+ <property name="serviceName">service2</property>
+ </component>
+
+ <component name="TestComponent3">
+ <implementation.java class="test.service1Impl"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"></interface.java>
+ </service>
+ <property name="serviceName">service3</property>
+ </component>
+
+</composite>
diff --git a/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0004.composite b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0004.composite
new file mode 100644
index 0000000000..c5cc0494a3
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0004.composite
@@ -0,0 +1,61 @@
+<?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.
+-->
+<!-- Test that verifies that a reference with multiplicity 1..1 which is provided
+ with multiple wire targets in the component configuration is marked as an error -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://oasis/tests"
+ xmlns:sample="http://oasis/tests"
+ name="TEST_ASM_0004">
+
+ <component name="TestClient">
+ <implementation.java class="test.ASM_0002_Client"/>
+ <service name="TestInvocation">
+ <interface.java interface="test.TestInvocation"/>
+ </service>
+ <reference name="reference1" target="TestComponent1/Service1 TestComponent2/Service1 TestComponent3/Service1" />
+ <property name="testName">ASM_0004</property>
+ </component>
+
+
+ <component name="TestComponent1">
+ <implementation.java class="test.service1Impl"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"></interface.java>
+ </service>
+ <property name="serviceName">service1</property>
+ </component>
+
+ <component name="TestComponent2">
+ <implementation.java class="test.service1Impl"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"></interface.java>
+ </service>
+ <property name="serviceName">service2</property>
+ </component>
+
+ <component name="TestComponent3">
+ <implementation.java class="test.service1Impl"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"></interface.java>
+ </service>
+ <property name="serviceName">service3</property>
+ </component>
+
+</composite>
diff --git a/java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTest.java b/java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTest.java
new file mode 100644
index 0000000000..cedf2e1992
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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 client;
+
+import static org.junit.Assert.*;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osoa.sca.annotations.Reference;
+
+import test.ASM_0001_Client;
+import test.TestInvocation;
+
+/**
+ * A generic test client based on JAX-WS APIs
+ */
+public class BaseJAXWSTest {
+
+ protected NodeLauncher launcher;
+ protected Node node;
+ protected TestConfiguration testConfiguration = getTestConfiguration();
+
+ public static void main(String[] args) throws Exception {
+ BaseJAXWSTest test = new BaseJAXWSTest();
+ test.setUp();
+ test.tearDown();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ startContribution();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ stopContribution();
+ }
+
+ @Test
+ public void testDummy() throws Exception {
+ // System.out.println("Test " + testName + " starting");
+ try {
+ String output = invokeTest( testConfiguration.getInput() );
+ assertEquals( output, testConfiguration.getExpectedOutput() );
+ } catch (Exception e) {
+ assertEquals( "exception", testConfiguration.getExpectedOutput() );
+ System.out.println( "Expected exception - detail: " + e.getMessage() );
+ }
+ System.out.println("Test " + testConfiguration.getTestName() + " completed successfully");
+ }
+
+ public String invokeTest( String input ) {
+
+ TestInvocation service = (TestInvocation) getService( testConfiguration.getServiceInterface(),
+ testConfiguration.getTestServiceName() );
+
+ return service.invokeTest( input );
+ } // end method invokeTest
+
+ protected <T> T getService( Class<T> interfaze, String serviceName ) {
+ T service = node.getService( interfaze, serviceName );
+ return service;
+ } // end getService
+
+ protected void startContribution() throws Exception {
+ // Tuscany specific code which starts the contribution holding the test
+ launcher = NodeLauncher.newInstance();
+ node = launcher.createNode(testConfiguration.getComposite(),
+ new Contribution(testConfiguration.getTestName(), getContributionURI()));
+ System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader());
+ node.start();
+ } // end method startContribution
+
+ protected void stopContribution() throws Exception {
+ if (node != null) {
+ node.stop();
+ node.destroy();
+ }
+ if (launcher != null) {
+ launcher.destroy();
+ }
+ } // end method stopContribution
+
+ protected String getContributionURI() {
+ String location = ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
+ return location;
+ }
+
+ protected TestConfiguration getTestConfiguration() {
+ TestConfiguration config = new TestConfiguration();
+ config.testName = "ASM_0001";
+ config.input = "request";
+ config.output = config.testName + " " + config.input + " invoked ok";
+ config.composite = "Test_ASM_0001.composite";
+ config.testServiceName = "TestClient";
+ config.testClass = ASM_0001_Client.class;
+ config.serviceInterface = TestInvocation.class;
+ return config;
+ }
+
+} // end class BaseTest
diff --git a/java/sca/stest/sampleTest/src/test/java/client/BaseTest.java b/java/sca/stest/sampleTest/src/test/java/client/BaseTest.java
new file mode 100644
index 0000000000..8c373beb61
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/test/java/client/BaseTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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 client;
+
+import static org.junit.Assert.*;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osoa.sca.annotations.Reference;
+
+import test.ASM_0001_Client;
+import test.TestInvocation;
+
+/**
+ * A generic test client based on Tuscany APIs
+ */
+public class BaseTest {
+
+ protected NodeLauncher launcher;
+ protected Node node;
+ protected TestConfiguration testConfiguration = getTestConfiguration();
+
+ public static void main(String[] args) throws Exception {
+ BaseTest test = new BaseTest();
+ test.setUp();
+ test.tearDown();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ startContribution();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ stopContribution();
+ }
+
+ @Test
+ public void testDummy() throws Exception {
+ // System.out.println("Test " + testName + " starting");
+ try {
+ String output = invokeTest( testConfiguration.getInput() );
+ assertEquals( output, testConfiguration.getExpectedOutput() );
+ } catch (Exception e) {
+ assertEquals( "exception", testConfiguration.getExpectedOutput() );
+ System.out.println( "Expected exception - detail: " + e.getMessage() );
+ }
+ System.out.println("Test " + testConfiguration.getTestName() + " completed successfully");
+ }
+
+ public String invokeTest( String input ) {
+
+ TestInvocation service = (TestInvocation) getService( testConfiguration.getServiceInterface(),
+ testConfiguration.getTestServiceName() );
+
+ return service.invokeTest( input );
+ } // end method invokeTest
+
+ protected <T> T getService( Class<T> interfaze, String serviceName ) {
+ T service = node.getService( interfaze, serviceName );
+ return service;
+ } // end getService
+
+ protected void startContribution() throws Exception {
+ // Tuscany specific code which starts the contribution holding the test
+ launcher = NodeLauncher.newInstance();
+ node = launcher.createNode(testConfiguration.getComposite(),
+ new Contribution(testConfiguration.getTestName(), getContributionURI()));
+ System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader());
+ node.start();
+ } // end method startContribution
+
+ protected void stopContribution() throws Exception {
+ if (node != null) {
+ node.stop();
+ node.destroy();
+ }
+ if (launcher != null) {
+ launcher.destroy();
+ }
+ } // end method stopContribution
+
+ protected String getContributionURI() {
+ String location = ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass());
+ return location;
+ }
+
+ protected TestConfiguration getTestConfiguration() {
+ TestConfiguration config = new TestConfiguration();
+ config.testName = "ASM_0001";
+ config.input = "request";
+ config.output = config.testName + " " + config.input + " invoked ok";
+ config.composite = "Test_ASM_0001.composite";
+ config.testServiceName = "TestClient";
+ config.testClass = ASM_0001_Client.class;
+ config.serviceInterface = TestInvocation.class;
+ return config;
+ }
+
+} // end class BaseTest
diff --git a/java/sca/stest/sampleTest/src/test/java/client/TestConfiguration.java b/java/sca/stest/sampleTest/src/test/java/client/TestConfiguration.java
new file mode 100644
index 0000000000..43df1366df
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/test/java/client/TestConfiguration.java
@@ -0,0 +1,30 @@
+package client;
+
+import test.ASM_0001_Client;
+import test.TestInvocation;
+
+/**
+ * A class to hold the metadata about the test
+ * @author MikeEdwards
+ *
+ */
+class TestConfiguration {
+
+ public String testName;
+ public String input;
+ public String output;
+ public String composite;
+ public String testServiceName;
+ public Class<?> testClass; //TODO - does the client need this??
+ public Class<?> serviceInterface;
+
+ public TestConfiguration() { }
+
+ public String getTestName() { return testName; }
+ public String getInput() { return input; }
+ public String getExpectedOutput() { return output; }
+ public String getComposite() { return composite; }
+ public String getTestServiceName() { return testServiceName; }
+ public Class<?> getTestClass() { return testClass; }
+ public Class<?> getServiceInterface() { return serviceInterface; }
+} \ No newline at end of file
diff --git a/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0002.java b/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0002.java
new file mode 100644
index 0000000000..10c1b78608
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0002.java
@@ -0,0 +1,43 @@
+/*
+ * 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 client;
+
+
+import test.ASM_0002_Client;
+import test.TestInvocation;
+
+/**
+ * A generic test client based on Tuscany APIs
+ */
+public class Test_ASM_0002 extends BaseTest {
+
+
+ protected TestConfiguration getTestConfiguration() {
+ TestConfiguration config = new TestConfiguration();
+ config.testName = "ASM_0002";
+ config.input = "request";
+ config.output = config.testName + " " + config.input + " service1 operation1 invoked";
+ config.composite = "Test_ASM_0002.composite";
+ config.testServiceName = "TestClient";
+ config.testClass = ASM_0002_Client.class;
+ config.serviceInterface = TestInvocation.class;
+ return config;
+ }
+
+} // end class Test_ASM_0002
diff --git a/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0003.java b/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0003.java
new file mode 100644
index 0000000000..e68c2acbbb
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0003.java
@@ -0,0 +1,44 @@
+/*
+ * 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 client;
+
+
+import test.ASM_0003_Client;
+import test.TestInvocation;
+
+/**
+ * A generic test client based on Tuscany APIs
+ */
+public class Test_ASM_0003 extends BaseTest {
+
+
+ protected TestConfiguration getTestConfiguration() {
+ TestConfiguration config = new TestConfiguration();
+ config.testName = "ASM_0003";
+ config.input = "request";
+ config.output = config.testName + " " + config.input + " service1 operation1 invoked" +
+ "service2 operation1 invoked" + "service3 operation1 invoked";
+ config.composite = "Test_ASM_0003.composite";
+ config.testServiceName = "TestClient";
+ config.testClass = ASM_0003_Client.class;
+ config.serviceInterface = TestInvocation.class;
+ return config;
+ }
+
+} // end class Test_ASM_0003
diff --git a/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0004.java b/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0004.java
new file mode 100644
index 0000000000..78a9cac2ab
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/test/java/client/Test_ASM_0004.java
@@ -0,0 +1,43 @@
+/*
+ * 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 client;
+
+
+import test.ASM_0002_Client;
+import test.TestInvocation;
+
+/**
+ * A generic test client based on Tuscany APIs
+ */
+public class Test_ASM_0004 extends BaseTest {
+
+
+ protected TestConfiguration getTestConfiguration() {
+ TestConfiguration config = new TestConfiguration();
+ config.testName = "ASM_0004";
+ config.input = "request";
+ config.output = "exception";
+ config.composite = "Test_ASM_0004.composite";
+ config.testServiceName = "TestClient";
+ config.testClass = ASM_0002_Client.class;
+ config.serviceInterface = TestInvocation.class;
+ return config;
+ }
+
+} // end class Test_ASM_0003