summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/branches/2.0/testing/itest/interfaces
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2013-09-26 20:33:20 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2013-09-26 20:33:20 +0000
commite5b7380c874745c989d1816b8f552504f038e1bc (patch)
tree3084133139737c821ce5384bd27fc2258e795826 /sca-java-2.x/branches/2.0/testing/itest/interfaces
parent33b786453598495cde754c80f5a9397de68ff60e (diff)
2.0 branch for possible maintenance release
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1526672 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/pom.xml39
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/Helloworld.java25
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/HelloworldImpl.java27
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java30
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java47
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java83
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java37
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java49
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java48
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java33
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java64
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java82
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java38
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java54
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.composite28
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/remoteoverride/helloworld.composite33
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.composite40
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java136
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java52
-rw-r--r--sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/RemoteOverrideTestCase.java76
20 files changed, 1021 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/pom.xml b/sca-java-2.x/branches/2.0/testing/itest/interfaces/pom.xml
new file mode 100644
index 0000000000..95229c068a
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/pom.xml
@@ -0,0 +1,39 @@
+<?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-itest</artifactId>
+ <version>2.0</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-interfaces</artifactId>
+ <name>Apache Tuscany SCA iTest Interface</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-base-runtime-pom</artifactId>
+ <type>pom</type>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/Helloworld.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/Helloworld.java
new file mode 100644
index 0000000000..1129b16310
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/Helloworld.java
@@ -0,0 +1,25 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/HelloworldImpl.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/HelloworldImpl.java
new file mode 100644
index 0000000000..c21a305e40
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/HelloworldImpl.java
@@ -0,0 +1,27 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+public class HelloworldImpl implements Helloworld {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java
new file mode 100644
index 0000000000..f4131593d5
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+/**
+ * only for callBack
+ */
+public interface LocalCallbackInterface {
+
+ void callbackMethod(String str);
+
+ void modifyParameter(ParameterObject po);
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java
new file mode 100644
index 0000000000..3c7a398abd
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java
@@ -0,0 +1,47 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.OneWay;
+
+/*
+ * itest for interface: local,method-overloading
+ */
+public interface LocalClientComponent {
+
+ String foo1(ParameterObject po);
+
+ String foo2(String str) throws Exception;
+
+ String foo3(String str, int i);
+
+ String foo4(int i, String str) throws Exception;
+
+ void callback(String str);
+
+ void callModifyParameter();
+
+ @OneWay
+ void onewayMethod(String str);
+
+ String getCallbackValue();
+
+ String getOnewayValue();
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java
new file mode 100644
index 0000000000..fc88c4f119
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java
@@ -0,0 +1,83 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(LocalClientComponent.class)
+public class LocalClientComponentImpl implements LocalClientComponent, LocalCallbackInterface {
+
+ @Reference
+ protected LocalServiceComponent aCallBackService;
+ private static String callbackValue;
+ private static String onewayValue;
+
+ public String foo1(ParameterObject po) {
+ po.field1 = "AComponent";
+ return "AComponent";
+ }
+
+ public String foo2(String str) throws Exception {
+ return str + "AComponent";
+ }
+
+ public String foo3(String str, int i) {
+ return str + "AComponent" + i;
+ }
+
+ public String foo4(int i, String str) throws Exception {
+ return str + "AComponent" + i;
+ }
+
+ public void callback(String str) {
+ aCallBackService.callback(str);
+ }
+
+ public void callbackMethod(String str) {
+ callbackValue = str;
+ }
+
+ public void callModifyParameter() {
+ this.aCallBackService.modifyParameter();
+ }
+
+ public String getCallbackValue() {
+ return callbackValue;
+ }
+
+ public void onewayMethod(String str) {
+ onewayValue = str;
+ try {
+ Thread.sleep(200);
+ } catch (Exception e) {
+ //do nothing
+ }
+ }
+
+ public String getOnewayValue() {
+ return onewayValue;
+ }
+
+ public void modifyParameter(ParameterObject po) {
+ po.field1 = "AComponent";
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java
new file mode 100644
index 0000000000..05a9d09bdd
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java
@@ -0,0 +1,37 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+
+/**
+ * Local be-directional callBackService
+ */
+@Callback(LocalCallbackInterface.class)
+public interface LocalServiceComponent {
+
+ String foo(String str);
+
+ void callback(String str);
+
+ void modifyParameter();
+
+ ParameterObject getPO();
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java
new file mode 100644
index 0000000000..ab0b18191c
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(LocalServiceComponent.class)
+public class LocalServiceComponentImpl implements LocalServiceComponent {
+
+ @Callback
+ protected LocalCallbackInterface callback;
+
+ private static ParameterObject po;
+
+ public void callback(String str) {
+ callback.callbackMethod(str);
+ }
+
+ public void modifyParameter() {
+ po = new ParameterObject("CallBack");
+ callback.modifyParameter(po);
+ }
+
+ public String foo(String str) {
+ return str;
+ }
+
+ public ParameterObject getPO() {
+ return po;
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java
new file mode 100644
index 0000000000..724d94dffb
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import java.io.Serializable;
+
+public class ParameterObject implements Serializable {
+ private static final long serialVersionUID = 1L;
+ public String field1;
+
+ public ParameterObject() {
+ this.field1 = null;
+ }
+
+ public ParameterObject(String field1) {
+ this.field1 = field1;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof ParameterObject) {
+ ParameterObject other = (ParameterObject)o;
+ if (field1 != null) {
+ return field1.equals(other.field1);
+ }
+ }
+ return false;
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java
new file mode 100644
index 0000000000..be3fa4c15a
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java
@@ -0,0 +1,33 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * only for callBack
+ */
+@Remotable
+public interface RemoteCallbackInterface {
+
+ void callbackMethod(String str);
+
+ void modifyParameter(ParameterObject po);
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
new file mode 100644
index 0000000000..9f34dfd274
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/*
+ * different signatures
+ */
+
+@Remotable
+public interface RemoteClientComponent {
+
+ String foo1(ParameterObject po);
+
+ String foo3(ParameterObject po);
+
+ String foo2(int i, String str1) throws Exception;
+
+ void callback(String str);
+
+ void callModifyParameter();
+
+ String getCallbackValue();
+
+ void onewayMethod(String str);
+
+ String getOnewayValue();
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
new file mode 100644
index 0000000000..efeb6f91fe
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
@@ -0,0 +1,82 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.AllowsPassByReference;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(RemoteClientComponent.class)
+public class RemoteClientComponentImpl implements RemoteClientComponent, RemoteCallbackInterface {
+
+ @Reference
+ @AllowsPassByReference
+ protected RemoteServiceComponent aCallBackService;
+ private static String callbackValue;
+ private static String onewayValue;
+
+ public String foo1(ParameterObject po) {
+ po.field1 = "BComponent";
+ return "BComponent";
+ }
+
+ @AllowsPassByReference
+ public String foo3(ParameterObject po) {
+ po.field1 = "BComponent";
+ return "BComponent";
+ }
+
+ public String foo2(int i, String str) throws Exception {
+ return str + "BComponent" + i;
+ }
+
+ public void callback(String str) {
+ aCallBackService.callback(str);
+ }
+
+ public void callModifyParameter() {
+ this.aCallBackService.modifyParameter();
+ }
+
+ public void callbackMethod(String str) {
+ callbackValue = str;
+ }
+
+ public String getCallbackValue() {
+ return callbackValue;
+ }
+
+ public void onewayMethod(String str) {
+ onewayValue = str;
+ try {
+ Thread.sleep(200);
+ } catch (Exception e) {
+ //do nothing
+ }
+ }
+
+ public String getOnewayValue() {
+ return onewayValue;
+ }
+
+ public void modifyParameter(ParameterObject po) {
+ po.field1 = "BComponent";
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java
new file mode 100644
index 0000000000..b29b298ab6
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+@Callback(RemoteCallbackInterface.class)
+public interface RemoteServiceComponent {
+
+ String foo(String str);
+
+ void callback(String str);
+
+ void modifyParameter();
+
+ ParameterObject getPO();
+
+ String[] bar(int[][] intArray);
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java
new file mode 100644
index 0000000000..00a0f5645b
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import org.oasisopen.sca.annotation.Callback;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(RemoteServiceComponent.class)
+public class RemoteServiceComponentImpl implements RemoteServiceComponent {
+
+ @Callback
+ protected RemoteCallbackInterface callback;
+
+ private static ParameterObject po;
+
+ public void callback(String str) {
+ callback.callbackMethod(str);
+ }
+
+ public void modifyParameter() {
+ po = new ParameterObject("CallBack");
+ callback.modifyParameter(po);
+ }
+
+ public String foo(String str) {
+ return str;
+ }
+
+ public ParameterObject getPO() {
+ return po;
+ }
+
+ public String[] bar(int[][] intArray) {
+ return new String[] {"int"};
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.composite b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.composite
new file mode 100644
index 0000000000..da5700aa35
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/invalid/InvalidRemoteAttribute.composite
@@ -0,0 +1,28 @@
+<?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
+ * 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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="InvalidRemoteAttribute" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="RemoteServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.RemoteServiceComponentImpl" />
+ <service name="RemoteServiceComponent">
+ <interface.java interface="org.apache.tuscany.sca.itest.interfaces.RemoteServiceComponent" remotable="false"/>
+ </service>
+ </component>
+</composite> \ No newline at end of file
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/remoteoverride/helloworld.composite b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/remoteoverride/helloworld.composite
new file mode 100644
index 0000000000..cbeee0abd4
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/remoteoverride/helloworld.composite
@@ -0,0 +1,33 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.HelloworldImpl"/>
+ <service name="HelloworldImpl">
+ <interface.java interface="org.apache.tuscany.sca.itest.interfaces.Helloworld" remotable="true"/>
+ <binding.ws/>
+ </service>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.composite b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.composite
new file mode 100644
index 0000000000..e9267b75d3
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/main/resources/org/apache/tuscany/sca/itest/interfaces/valid/InterfacesTest.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
+ * 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://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:foo="http://foo" targetNamespace="http://foo"
+ name="InterfacesTest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <component name="LocalClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.LocalClientComponentImpl" />
+ <reference name="aCallBackService" target="LocalServiceComponent" />
+ </component>
+
+ <component name="RemoteClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.RemoteClientComponentImpl" />
+ <reference name="aCallBackService" target="RemoteServiceComponent" />
+ </component>
+
+ <component name="LocalServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.LocalServiceComponentImpl" />
+ </component>
+
+ <component name="RemoteServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.itest.interfaces.RemoteServiceComponentImpl" />
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
new file mode 100644
index 0000000000..1bc047092a
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
@@ -0,0 +1,136 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class InterfacesTestCase {
+ private static final String PKG = "org/apache/tuscany/sca/itest/interfaces/valid";
+ private static String ROOT = new File("target/classes/" + PKG).toURI().toString();
+
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ROOT;
+ node = NodeFactory.newInstance().createNode("InterfacesTest.composite", new Contribution("c1", location));
+ node.start();
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testLocalClient() {
+ LocalServiceComponent service = node.getService(LocalServiceComponent.class, "LocalServiceComponent");
+ LocalClientComponent local = node.getService(LocalClientComponent.class, "LocalClientComponent");
+
+ try {
+ ParameterObject po = new ParameterObject();
+ assertEquals("AComponent", local.foo1(po));
+ assertEquals("AComponent", po.field1);
+
+ assertEquals("AAComponent", local.foo2("A"));
+
+ assertEquals("AAComponent1", local.foo3("A", 1));
+ assertEquals("AAComponent1", local.foo4(1, "A"));
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ // test local callback
+ local.callback("CallBack");
+ Thread.sleep(100);
+ assertEquals("CallBack", local.getCallbackValue());
+
+ local.callModifyParameter();
+ Thread.sleep(100);
+ assertEquals("AComponent", service.getPO().field1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("CallBack failed");
+ }
+
+ try {
+ local.onewayMethod("OneWay");
+ Thread.sleep(100);
+ assertEquals("OneWay", local.getOnewayValue());
+ } catch (Exception e) {
+ fail("OneWay failed");
+ }
+ }
+
+ @Test
+ public void testRemoteClient() {
+ RemoteServiceComponent service = node.getService(RemoteServiceComponent.class, "RemoteServiceComponent");
+ RemoteClientComponent remote = node.getService(RemoteClientComponent.class, "RemoteClientComponent");
+
+ try {
+ // Test Pass By Value
+ ParameterObject po = new ParameterObject("NotBComponent");
+ assertEquals("BComponent", remote.foo1(po));
+ assertEquals("NotBComponent", po.field1);
+
+ assertEquals("BBComponent1", remote.foo2(1, "B"));
+
+// TODO: TUSCANY-3479, investigate Node/SCAClient pass by reference
+ // Test allowsPassByReference
+// assertEquals("BComponent", remote.foo3(po));
+// assertEquals("BComponent", po.field1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ try {
+ remote.callback("CallBack");
+ Thread.sleep(100);
+ assertEquals("CallBack", remote.getCallbackValue());
+
+ remote.callModifyParameter();
+ Thread.sleep(100);
+ assertEquals("CallBack", service.getPO().field1);
+ } catch (Exception e) {
+ fail("CallBack failed");
+ }
+
+ try {
+ remote.onewayMethod("OneWay");
+ Thread.sleep(100);
+ assertEquals("OneWay", remote.getOnewayValue());
+ } catch (Exception e) {
+ fail("OneWay failed");
+ }
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java
new file mode 100644
index 0000000000..5aa8be2f04
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.interfacedef.InvalidAnnotationException;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.Test;
+
+public class InvalidRemoteAttributeTestCase {
+ private static final String PKG = "org/apache/tuscany/sca/itest/interfaces/invalid";
+ private static String ROOT = new File("target/classes/" + PKG).toURI().toString();
+
+ @Test
+ public void testInvalidRemoteAttribute() throws Exception {
+ Node node = null;
+
+ try {
+ String location = ROOT;
+ node = NodeFactory.newInstance().createNode("InvalidRemoteAttribute.composite", new Contribution("c1", location));
+ node.start();
+ } catch (Exception e) {
+ if (! e.getCause().getClass().equals(InvalidAnnotationException.class)) {
+ throw e;
+ }
+ } finally {
+ if (node != null) {
+ node.stop();
+ }
+ }
+ }
+}
diff --git a/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/RemoteOverrideTestCase.java b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/RemoteOverrideTestCase.java
new file mode 100644
index 0000000000..ffadeb6dfb
--- /dev/null
+++ b/sca-java-2.x/branches/2.0/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/RemoteOverrideTestCase.java
@@ -0,0 +1,76 @@
+/*
+ * 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 org.apache.tuscany.sca.itest.interfaces;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+import org.junit.Assert;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchServiceException;
+
+public class RemoteOverrideTestCase {
+
+ @Test
+ public void testSayHello() throws NoSuchServiceException, IOException {
+
+ // Run the SCA composite in a Tuscany runtime
+ Node node = TuscanyRuntime.runComposite("helloworld.composite", "target/classes/org/apache/tuscany/sca/itest/interfaces/remoteoverride");
+ try {
+
+ // Get the Helloworld service proxy
+ Helloworld helloworld = node.getService(Helloworld.class, "HelloworldComponent");
+
+ // test that it works as expected
+ Assert.assertEquals("Hello Amelia", helloworld.sayHello("Amelia"));
+
+ // test that has exposed an HTTP endpoint that works as expected
+ // to keep this test simple just do ?wsdl on the endpoint
+ URL url = new URL("http://localhost:8085/HelloworldComponent/HelloworldImpl?wsdl");
+ Assert.assertTrue(read(url.openStream()).contains("address location="));
+
+ } finally {
+ // Stop the Tuscany runtime Node
+ node.stop();
+ }
+ }
+
+ private static String read(InputStream is) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ StringBuffer sb = new StringBuffer();
+ String str;
+ while ((str = reader.readLine()) != null) {
+ sb.append(str);
+ }
+ return sb.toString();
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+}