From cbd96cbf252e7e6989aba9a46a556573aa533606 Mon Sep 17 00:00:00 2001 From: slaws Date: Sun, 12 Oct 2008 12:25:49 +0000 Subject: Branch for 1.3.3 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@703809 13f79535-47bb-0310-9956-ffa450edef68 --- .../itest/callback-complex-type/pom.xml | 45 +++++++ .../tuscany/sca/test/CallBackCTypeCallBack.java | 33 +++++ .../tuscany/sca/test/CallBackCTypeClient.java | 28 ++++ .../tuscany/sca/test/CallBackCTypeClientImpl.java | 142 +++++++++++++++++++++ .../tuscany/sca/test/CallBackCTypeService.java | 36 ++++++ .../tuscany/sca/test/CallBackCTypeServiceImpl.java | 62 +++++++++ .../main/resources/CallBackCTypeClient.composite | 33 +++++ .../test/CallBackCTypeServiceImpl.componentType | 28 ++++ .../sca/test/CallBackCTypeTestCaseFIXME.java | 48 +++++++ 9 files changed, 455 insertions(+) create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/pom.xml create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType create mode 100644 branches/sca-java-1.3.3/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCaseFIXME.java (limited to 'branches/sca-java-1.3.3/itest/callback-complex-type') diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/pom.xml b/branches/sca-java-1.3.3/itest/callback-complex-type/pom.xml new file mode 100644 index 0000000000..8e61c8b82b --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.3.2-SNAPSHOT + ../pom.xml + + itest-callback-complex-type + Apache Tuscany SCA Callback Complex Type Integration Tests + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.3.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.3.2-SNAPSHOT + runtime + + + diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java new file mode 100644 index 0000000000..9fddb850ba --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.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.test; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +/** + * + */ +public interface CallBackCTypeCallBack { + + public void callBackMessage(String aString); + + public void callBackIncrement(String aString); + +} diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java new file mode 100644 index 0000000000..739983c277 --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java @@ -0,0 +1,28 @@ +/* + * 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.test; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CallBackCTypeClient { + + public void run(); + +} diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java new file mode 100644 index 0000000000..d2b03fcde7 --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java @@ -0,0 +1,142 @@ +/* + * 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.test; + +import junit.framework.Assert; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(CallBackCTypeClient.class) +public class CallBackCTypeClientImpl implements CallBackCTypeClient, CallBackCTypeCallBack { + + @Reference + protected CallBackCTypeService aCallBackService; + private static String returnMessage = null; + private static int callBackCount = 0; + private static Object monitor = new Object(); + + public CallBackCTypeClientImpl() { + } + + public void run() { + + // This test is the same as the Basic Callback except it uses a + // componentType side file. + // This test currently fails because the integration test environment + // does not properly copy + // the componentType files to the target folder. This is documented in + // Tuscany-967. + + // Test12a is the basic callback where the target calls back prior to + // returning to the client. + test12a(); + + // Test12b is where the target does not call back to the client. + test12b(); + + // Test12c is where the target calls back multiple times to the client. + test12c(); + + return; + } + + private void test12a() { + aCallBackService.knockKnock("Knock Knock"); + int count = 0; + + // + // If we can't get a response in 30 seconds consider this a failure + // + + synchronized (monitor) { + while (returnMessage == null && count++ < 30) { + try { + monitor.wait(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + Assert.assertEquals("CallBackBasicITest - test12a -", "Who's There", this.getReturnMessage()); + + } + + private void test12b() { + aCallBackService.noCallBack("No Reply Desired"); + Assert.assertEquals("CallBackBasicITest - test12b -", 1, 1); + return; + } + + private void test12c() { + aCallBackService.multiCallBack("Call me back 3 times"); + int count = 0; + + // + // If we can't get a response in 30 seconds consider this a failure + // + + synchronized (monitor) { + while (this.getCallBackCount() < 3 && count++ < 30) { + try { + monitor.wait(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + Assert.assertEquals("CallBackBasicITest - test12c -", 3, this.getCallBackCount()); + return; + } + + public String getReturnMessage() { + return returnMessage; + } + + public void setReturnMessage(String aReturnMessage) { + returnMessage = aReturnMessage; + } + + public int getCallBackCount() { + return callBackCount; + } + + public void incrementCallBackCount() { + callBackCount++; + } + + public void callBackMessage(String aString) { + System.out.println("Entering callback callBackMessage: " + aString); + synchronized (monitor) { + this.setReturnMessage(aString); + monitor.notify(); + } + } + + public void callBackIncrement(String aString) { + System.out.println("Entering callback increment: " + aString); + synchronized (monitor) { + this.incrementCallBackCount(); + monitor.notify(); + } + } + +} diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java new file mode 100644 index 0000000000..ffbf4f35fa --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java @@ -0,0 +1,36 @@ +/* + * 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.test; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +// @Callback(CallBackCTypeCallBack.class) +/** + * + */ +public interface CallBackCTypeService { + + public void knockKnock(String aString); + + public void noCallBack(String aString); + + public void multiCallBack(String aString); + +} diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java new file mode 100644 index 0000000000..dc31ed156b --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java @@ -0,0 +1,62 @@ +/* + * 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.test; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Service; + +@Service(CallBackCTypeService.class) +public class CallBackCTypeServiceImpl implements CallBackCTypeService { + + @Callback + protected CallBackCTypeCallBack callback; + + public CallBackCTypeServiceImpl() { + } + + public void knockKnock(String aString) { + + System.out.println("CallBackCTypeServiceImpl message received: " + aString); + callback.callBackMessage("Who's There"); + System.out.println("CallBackCTypeServiceImpl response sent"); + return; + + } + + public void multiCallBack(String aString) { + + System.out.println("CallBackCTypeServiceImpl message received: " + aString); + callback.callBackIncrement("Who's There 1"); + System.out.println("CallBackCTypeServiceImpl response sent"); + callback.callBackIncrement("Who's There 2"); + System.out.println("CallBackCTypeServiceImpl response sent"); + callback.callBackIncrement("Who's There 3"); + System.out.println("CallBackCTypeServiceImpl response sent"); + return; + + } + + public void noCallBack(String aString) { + + System.out.println("CallBackCTypeServiceImpl message received: " + aString); + System.out.println("CallBackCTypeServiceImpl No response desired"); + return; + + } +} diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite new file mode 100644 index 0000000000..3f48f16389 --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType new file mode 100644 index 0000000000..ff38134df5 --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.3.3/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCaseFIXME.java b/branches/sca-java-1.3.3/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCaseFIXME.java new file mode 100644 index 0000000000..33d1afaecd --- /dev/null +++ b/branches/sca-java-1.3.3/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCaseFIXME.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.test; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +//FIXME Fix this test case +public class CallBackCTypeTestCaseFIXME extends TestCase { + + private SCADomain domain; + private CallBackCTypeClient aCallBackClient; + + public void testCallBackBasic() { + aCallBackClient.run(); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CallBackCTypeClient.composite"); + + aCallBackClient = + domain.getService(CallBackCTypeClient.class, "CallBackCTypeClient"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} -- cgit v1.2.3