diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-08-17 11:39:29 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-08-17 11:39:29 +0000 |
commit | 6adb50f1e762044f947036c14304eedc31f0d9d0 (patch) | |
tree | 1a1aaa961b4386542cfe2940b3907201ec0f1f17 /sca-java-2.x/trunk/testing/itest/dynamic/src/test/java/sample | |
parent | 0311cb3720748d4481d1122db551ca084629e230 (diff) |
Change the dynamically added endpoint tests to use wsdl resource from a contribution and simplify the endpoint creation helper
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1374206 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest/dynamic/src/test/java/sample')
-rw-r--r-- | sca-java-2.x/trunk/testing/itest/dynamic/src/test/java/sample/HelloworldDynamicWSImpl.java | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/dynamic/src/test/java/sample/HelloworldDynamicWSImpl.java b/sca-java-2.x/trunk/testing/itest/dynamic/src/test/java/sample/HelloworldDynamicWSImpl.java index 03e2f06ad3..a68474b18d 100644 --- a/sca-java-2.x/trunk/testing/itest/dynamic/src/test/java/sample/HelloworldDynamicWSImpl.java +++ b/sca-java-2.x/trunk/testing/itest/dynamic/src/test/java/sample/HelloworldDynamicWSImpl.java @@ -18,15 +18,20 @@ */
package sample;
-import java.io.File;
import java.io.IOException;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.impl.NodeImpl;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.monitor.ValidationException;
import org.apache.tuscany.sca.runtime.DOMInvoker;
import org.apache.tuscany.sca.runtime.TuscanyComponentContext;
+import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.annotation.Context;
import org.oasisopen.sca.annotation.Init;
import org.xml.sax.SAXException;
@@ -37,31 +42,42 @@ import test.EndpointHelper; public class HelloworldDynamicWSImpl implements Helloworld {
@Context
- TuscanyComponentContext context;
+ private TuscanyComponentContext context;
+
private DOMHelper domHelper;
- private DOMInvoker domInvoker;
+ private Node node;
@Init
public void init() {
+ domHelper = DOMHelper.getInstance(context.getExtensionPointRegistry());
+ node = context.getNode();
+ }
+
+ public String sayHello(String name) {
try {
+
+ String curi = node.installContribution("src/test/resources/resources.zip");
+
+ Endpoint endpoint = EndpointHelper.createWSEndpoint("SomeEndpointName", new QName("http://sample/", "Helloworld"), "http://localhost:8080/testComponent/Helloworld", curi, node);
- domHelper = DOMHelper.getInstance(context.getExtensionPointRegistry());
- Node node = context.getNode();
- EndpointHelper.addWSEndpoint(node, "SomeEndpointName", new File("src/test/resources/helloworld.wsdl").toURI().toURL(), new QName("http://sample/", "Helloworld"), "http://localhost:8089/testComponent/Helloworld");
+ ((NodeImpl)node).getEndpointRegistry().addEndpoint(endpoint);
- domInvoker = node.getDOMInvoker("SomeEndpointName");
-
- } catch (Exception e) {
+ DOMInvoker domInvoker = node.getDOMInvoker("SomeEndpointName");
+
+ org.w3c.dom.Node arg = getRequestDOM(name);
+ org.w3c.dom.Node response = domInvoker.invoke("sayHello", arg);
+ return "Remote WS says: " + getResponseString(response);
+
+ } catch (ContributionReadException e) {
+ throw new RuntimeException(e);
+ } catch (ValidationException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchServiceException e) {
+ throw new RuntimeException(e);
+ } catch (InvalidInterfaceException e) {
throw new RuntimeException(e);
}
}
-
- public String sayHello(String name) {
- org.w3c.dom.Node arg = getRequestDOM(name);
- org.w3c.dom.Node response = domInvoker.invoke("sayHello", arg);
- return "Remote WS says: " + getResponseString(response);
-
- }
private String getResponseString(org.w3c.dom.Node responseDOM) {
String xml = domHelper.saveAsString(responseDOM);
|