summaryrefslogtreecommitdiffstats
path: root/java/sca/stest
diff options
context:
space:
mode:
authoredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2009-01-09 10:40:11 +0000
committeredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2009-01-09 10:40:11 +0000
commitdee1b5dc073c5f472545a5749027f97ed3ac856e (patch)
tree79eb731b804931a5a8dbca8bdf4580f16297ec90 /java/sca/stest
parent7e2cc13ab517a95d77171b2bb096c845c436bdec (diff)
Added Test_ASM_0007
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@733002 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/ASM_0002_Client.java2
-rw-r--r--java/sca/stest/sampleTest/src/main/java/test/service1Impl2.java43
-rw-r--r--java/sca/stest/sampleTest/src/main/resources/TestComposite3.composite49
-rw-r--r--java/sca/stest/sampleTest/src/main/resources/Test_ASM_0007.composite60
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/ASM_0007_TestCase.java45
-rw-r--r--java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTestCase.java11
6 files changed, 208 insertions, 2 deletions
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
index 4ad8a375b3..2518c5aa76 100644
--- 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
@@ -48,7 +48,7 @@ public class ASM_0002_Client implements TestInvocation {
try {
response = runTest( input );
} catch( Exception e ) {
- throw new TestException("Test service got an exception during execution: " );
+ throw new TestException("Test service got an exception during execution: " + e.getClass().getName()+ " " + e.getMessage() );
} // end try
return response;
} // end method invokeTest
diff --git a/java/sca/stest/sampleTest/src/main/java/test/service1Impl2.java b/java/sca/stest/sampleTest/src/main/java/test/service1Impl2.java
new file mode 100644
index 0000000000..18793b5034
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/java/test/service1Impl2.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 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
+ public Service1 reference1 = null;
+
+ public String operation1(String input) {
+ String result = reference1.operation1(input);
+ return serviceName + " operation1 invoked" + " " + result;
+ }
+
+}
diff --git a/java/sca/stest/sampleTest/src/main/resources/TestComposite3.composite b/java/sca/stest/sampleTest/src/main/resources/TestComposite3.composite
new file mode 100644
index 0000000000..cc91e1eeea
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/resources/TestComposite3.composite
@@ -0,0 +1,49 @@
+<?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.
+-->
+<!-- An example of a composite which is invalid because it has two
+ composite level references with the same @name attribute -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://oasis/tests"
+ xmlns:sample="http://oasis/tests"
+ name="TestComposite3">
+
+ <service name="Service1" promote="TestComponent1/Service1">
+ <interface.java interface="test.Service1"/>
+ </service>
+
+ <property name="serviceName" type="string"/>
+
+ <component name="TestComponent1">
+ <implementation.java class="test.service1Impl2"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"/>
+ </service>
+ <property name="serviceName" source="$serviceName"/>
+ </component>
+
+ <reference name="Reference1" promote="TestComponent1/Reference">
+ <interface.java interface="test.Service1"/>
+ </reference>
+
+ <reference name="Reference1" promote="TestComponent1/Reference">
+ <interface.java interface="test.Service1"/>
+ </reference>
+
+</composite>
diff --git a/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0007.composite b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0007.composite
new file mode 100644
index 0000000000..7ab4d9db39
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/main/resources/Test_ASM_0007.composite
@@ -0,0 +1,60 @@
+<?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 the @name attribute of a <reference/> element of a
+ component is not equal to the @name attribute of any other
+ <reference/> element of the same component -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://oasis/tests"
+ xmlns:tns="http://oasis/tests"
+ xmlns:sample="http://oasis/tests"
+ name="TEST_ASM_0007">
+
+ <component name="TestClient">
+ <implementation.composite name="tns:TestClient_0002"/>
+ <service name="TestInvocation">
+ <interface.java interface="test.TestInvocation"/>
+ <binding.ws/>
+ </service>
+ <reference name="reference1" target="TestComponent1/Service1" />
+ <property name="testName">ASM_0005</property>
+ </component>
+
+ <component name="TestComponent1">
+ <implementation.composite name="tns:TestComposite3"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"/>
+ </service>
+ <property name="serviceName">service1</property>
+ <!-- Two references with the same name - the implementation also has
+ two references of the same name so that the component type
+ matches the configuration of the component -->
+ <reference name="Reference1" target="TestComponent2/Service1"/>
+ <reference name="Reference1" target="TestComponent2/Service1"/>
+ </component>
+
+ <component name="TestComponent2">
+ <implementation.composite name="tns:TestComposite1"/>
+ <service name="Service1">
+ <interface.java interface="test.Service1"/>
+ </service>
+ <property name="serviceName">service2</property>
+ </component>
+
+</composite>
diff --git a/java/sca/stest/sampleTest/src/test/java/client/ASM_0007_TestCase.java b/java/sca/stest/sampleTest/src/test/java/client/ASM_0007_TestCase.java
new file mode 100644
index 0000000000..44781eb87a
--- /dev/null
+++ b/java/sca/stest/sampleTest/src/test/java/client/ASM_0007_TestCase.java
@@ -0,0 +1,45 @@
+/*
+ * 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 testClient.TestInvocation;
+
+/**
+ * Client for ASM_0007_TestCase, which tests that the @name attribute of a <reference/>
+ * element of a component is not equal to the @name attribute of any other <reference/>
+ * element of the same component
+ */
+public class ASM_0007_TestCase extends BaseJAXWSTestCase {
+
+
+ protected TestConfiguration getTestConfiguration() {
+ TestConfiguration config = new TestConfiguration();
+ config.testName = "ASM_0007";
+ config.input = "request";
+ config.output = "exception";
+ config.composite = "Test_ASM_0007.composite";
+ config.testServiceName = "TestClient";
+ config.testClass = ASM_0002_Client.class;
+ config.serviceInterface = TestInvocation.class;
+ return config;
+ }
+
+} // end class Test_ASM_0003
diff --git a/java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTestCase.java b/java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTestCase.java
index 973bfec03e..5a350dc40f 100644
--- a/java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTestCase.java
+++ b/java/sca/stest/sampleTest/src/test/java/client/BaseJAXWSTestCase.java
@@ -36,6 +36,8 @@ import javax.xml.namespace.QName;
import test.ASM_0001_Client;
import testClient.TestInvocation;
+import testClient.TestException_Exception;
+import testClient.TestException;
/**
* A generic test client based on JAX-WS APIs
@@ -66,11 +68,18 @@ public class BaseJAXWSTestCase {
public void testDummy() throws Exception {
// System.out.println("Test " + testName + " starting");
try {
+ // Just requires input to proceed
+ // System.in.read();
+ //
String output = invokeTest( testConfiguration.getInput() );
assertEquals( testConfiguration.getExpectedOutput(), output );
+ } catch ( TestException_Exception e ) {
+ TestException exceptionContent = e.getFaultInfo();
+ System.out.println("Service fault received - detail: " + exceptionContent.getMessage() );
+ assertEquals( testConfiguration.getExpectedOutput(), "exception" );
} catch (Throwable e) {
e.printStackTrace();
- System.out.println( "Exception received - detail: " + e.getMessage() );
+ System.out.println( "Exception received - detail: " + e.getMessage() );
assertEquals( testConfiguration.getExpectedOutput(), "exception" );
}
System.out.println("Test " + testConfiguration.getTestName() + " completed successfully");