diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-19 13:58:04 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-19 13:58:04 +0000 |
commit | 0fe8f9530789d0d1310d2bac4eeb45313f9aa82d (patch) | |
tree | fcbfc609e8ab65c5512f161adb692f9b2712b82d /branches/sca-java-1.x/stest/sampleTest/src/main/java/test | |
parent | 8dd24acf4d472b50bd242aa167521f095d855caf (diff) |
copy stest framework from 2.x to consider potentially reusing in 1.x
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@735692 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/stest/sampleTest/src/main/java/test')
14 files changed, 684 insertions, 0 deletions
diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0001_Client.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0001_Client.java new file mode 100644 index 0000000000..0e4583ffc2 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0001_Client.java @@ -0,0 +1,69 @@ +/* + * 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 test; + +import org.osoa.sca.annotations.Service; + +import test.TestInvocation; + +/** + * 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 ) throws TestException { + 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/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0002_Client.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0002_Client.java new file mode 100644 index 0000000000..8a4a0c3fdc --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0002_Client.java @@ -0,0 +1,80 @@ +/* + * 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 test; + +import org.osoa.sca.annotations.Service; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Property; + +import test.TestInvocation; + +/** + * Test initiation class with a single reference of multiplicity 1..1 + * @author MikeEdwards + * + */ +@Service(TestInvocation.class) +public class ASM_0002_Client implements TestInvocation { + + @Property + public 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 ) throws TestException { + String response = null; + + try { + response = runTest( input ); + } catch( Exception e ) { + throw new TestException("Test service got an exception during execution: " + e.getClass().getName()+ " " + e.getMessage() ); + } // end try + 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/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0003_Client.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0003_Client.java new file mode 100644 index 0000000000..d4f3f7e5af --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/ASM_0003_Client.java @@ -0,0 +1,81 @@ +/* + * 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 test; + +import org.osoa.sca.annotations.Service; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Property; + +import test.TestInvocation; + +import java.util.List; + +/** + * Basic test initiation class + * @author MikeEdwards + * + */ +@Service(TestInvocation.class) +public class ASM_0003_Client implements TestInvocation { + + @Property + public 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 ) throws TestException { + 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/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service1.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service1.java new file mode 100644 index 0000000000..eeb3b31999 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service1.java @@ -0,0 +1,35 @@ +/* + * 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 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/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service1Superset.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service1Superset.java new file mode 100644 index 0000000000..487d748513 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service1Superset.java @@ -0,0 +1,42 @@ +/* + * 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 test; + +/** + * A superset of the basic test service interface + * @author MikeEdwards + * + */ +public interface Service1Superset { + + /** + * Method for invoking testcase service + * @param input - input parameter(s) as a String + * @return - output data as a String + */ + public String operation1( String input ); + + /** + * A second method for invoking a testcase service + * @param input - input parameter(s) as a String + * @return - output data as a String + */ + public String operation2( String input ); + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service2.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service2.java new file mode 100644 index 0000000000..3006a885b2 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/Service2.java @@ -0,0 +1,35 @@ +/* + * 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 test; + +/** + * A test service interface, designed to be incompatible with the Service1 interface + * @author MikeEdwards + * + */ +public interface Service2 { + + /** + * Method for invoking testcase service + * @param input - input parameter(s) as a String + * @return - output data as a String + */ + public int operation2( int input ); + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/TestException.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/TestException.java new file mode 100644 index 0000000000..d66a9c73bc --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/TestException.java @@ -0,0 +1,39 @@ +/* + * 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 test; + +/* + * Exception thrown by SCA Test services + */ +public class TestException extends Exception { + + /** + * Required serialVersionUID field + */ + private static final long serialVersionUID = -6978058912756564824L; + + public TestException() { super(); }; + + public TestException( String msg ) { super( msg ); }; + + public TestException( String msg, Throwable cause ) { super( msg, cause); }; + + public TestException( Throwable cause ) { super( cause ); }; + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/TestInvocation.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/TestInvocation.java new file mode 100644 index 0000000000..94bbe87ed0 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/TestInvocation.java @@ -0,0 +1,42 @@ +/* + * 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 test; + +import javax.jws.WebService; +import javax.jws.WebMethod; +import org.osoa.sca.annotations.Remotable; + +/** + * Basic interface to invoke testcases + * @author MikeEdwards + * + */ +@Remotable +public interface TestInvocation { + + /** + * Method for invoking testcase + * @param input - input parameter(s) as a String + * @return - output data as a String + * @throws - a TestException is thrown in cases where the test service fails internally + */ + @WebMethod + public String invokeTest( String input ) throws TestException ; + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl.java new file mode 100644 index 0000000000..b61fde92c9 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl.java @@ -0,0 +1,38 @@ +/* + * 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 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/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl2.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl2.java new file mode 100644 index 0000000000..abff52b606 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl2.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 test; + +import org.osoa.sca.annotations.*; + +/** + * Enhanced Java component implementation for business interface Service1, + * where the implementation also has a single reference using the Service1 + * interface and which gets called when operation1 is invoked + * @author MikeEdwards + * + */ +@Service(Service1.class) +public class service1Impl2 implements Service1 { + + @Property + public String serviceName = "service1"; + // Reference with an implied multiplicity of (1..1) since required=true is the default + @Reference + public Service1 reference1 = null; + + public String operation1(String input) { + String result = reference1.operation1(input); + return serviceName + " operation1 invoked" + " " + result; + } + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl3.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl3.java new file mode 100644 index 0000000000..b9f7d34638 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl3.java @@ -0,0 +1,49 @@ +/* + * 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 test; + +import org.osoa.sca.annotations.*; + +/** + * Enhanced Java component implementation for business interface Service1, + * where the implementation also has a single reference using the Service1 + * interface with mutiplicity 1..n all of which and which get called when + * operation1 is invoked + * @author MikeEdwards + * + */ +@Service(Service1.class) +public class service1Impl3 implements Service1 { + + @Property + public String serviceName = "service1"; + // Required = true + an array -> multiplicity 1..n + @Reference(required=true) + public Service1[] reference1 = null; + + public String operation1(String input) { + String result = ""; + // Call each of the references in the array, concatenating the results + for( int i=0 ; i < reference1.length; i++ ) { + result = result.concat( reference1[i].operation1(input) ); + } // end for + return serviceName + " operation1 invoked" + " " + result; + } + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl4.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl4.java new file mode 100644 index 0000000000..0c41f7e405 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1Impl4.java @@ -0,0 +1,50 @@ +/* + * 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 test; + +import org.osoa.sca.annotations.*; + +/** + * Enhanced Java component implementation for business interface Service1, + * where the implementation also has a single reference using the Service1 + * interface with multiplicity 0..n all of which and which get called when + * operation1 is invoked + * @author MikeEdwards + * + */ +@Service(Service1.class) +public class service1Impl4 implements Service1 { + + @Property + public String serviceName = "service1"; + // Required = false + an array -> multiplicity 0..n + @Reference(required=false) + public Service1[] reference1 = null; + + public String operation1(String input) { + String result = serviceName + " operation1 invoked"; + // Call each of the references in the array, concatenating the results + for( int i=0 ; i < reference1.length; i++ ) { + result = result.concat(" "); + result = result.concat( reference1[i].operation1(input) ); + } // end for + return result; + } + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1SupersetImpl.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1SupersetImpl.java new file mode 100644 index 0000000000..c75078f961 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service1SupersetImpl.java @@ -0,0 +1,42 @@ +/* + * 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 test; + +import org.osoa.sca.annotations.*; + +/** + * Simple Java component implementation for business interface Service1Superset + * @author MikeEdwards + * + */ +@Service(Service1Superset.class) +public class service1SupersetImpl implements Service1Superset { + + @Property + public String serviceName = "service1"; + + public String operation1(String input) { + return serviceName + " operation1 invoked"; + } + + public String operation2(String input) { + return serviceName + " operation2 invoked"; + } + +} diff --git a/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service2Impl.java b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service2Impl.java new file mode 100644 index 0000000000..44a2789125 --- /dev/null +++ b/branches/sca-java-1.x/stest/sampleTest/src/main/java/test/service2Impl.java @@ -0,0 +1,38 @@ +/* + * 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 test; + +import org.osoa.sca.annotations.*; + +/** + * Simple Java component implementation for business interface Service2 + * @author MikeEdwards + * + */ +@Service(Service2.class) +public class service2Impl implements Service2 { + + @Property + public String serviceName = "service1"; + + public int operation2(int input) { + return input+1; + } + +} |