From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- branches/sca-java-0.90/itest/callback-api/pom.xml | 45 +++++++ .../tuscany/sca/test/CallBackApiCallBack.java | 33 +++++ .../apache/tuscany/sca/test/CallBackApiClient.java | 28 +++++ .../tuscany/sca/test/CallBackApiClientImpl.java | 135 +++++++++++++++++++++ .../tuscany/sca/test/CallBackApiService.java | 37 ++++++ .../tuscany/sca/test/CallBackApiServiceImpl.java | 78 ++++++++++++ .../src/main/resources/CallBackApiTest.composite | 33 +++++ .../apache/tuscany/sca/test/CallBackApiTest.java | 45 +++++++ 8 files changed, 434 insertions(+) create mode 100644 branches/sca-java-0.90/itest/callback-api/pom.xml create mode 100644 branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java create mode 100644 branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java create mode 100644 branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java create mode 100644 branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java create mode 100644 branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java create mode 100644 branches/sca-java-0.90/itest/callback-api/src/main/resources/CallBackApiTest.composite create mode 100644 branches/sca-java-0.90/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTest.java (limited to 'branches/sca-java-0.90/itest/callback-api') diff --git a/branches/sca-java-0.90/itest/callback-api/pom.xml b/branches/sca-java-0.90/itest/callback-api/pom.xml new file mode 100644 index 0000000000..92da2ac39c --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 0.90-incubating-SNAPSHOT + ../pom.xml + + tuscany-itest-callback-api + Apache Tuscany SCA Callback API Integration Tests + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.90-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.90-incubating-SNAPSHOT + runtime + + + diff --git a/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java new file mode 100644 index 0000000000..56e7ba7b3f --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.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 +/** + * @author lamodeo + */ +public interface CallBackApiCallBack { + + public void callBackMessage(String aString); + + public void callBackIncrement(String aString); + +} diff --git a/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java new file mode 100644 index 0000000000..3e7c840e15 --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.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 CallBackApiClient { + + public void run(); + +} diff --git a/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java new file mode 100644 index 0000000000..1c32783271 --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java @@ -0,0 +1,135 @@ +/* + * 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(CallBackApiClient.class) +public class CallBackApiClientImpl implements CallBackApiClient, CallBackApiCallBack { + + @Reference + protected CallBackApiService aCallBackService; + + private static String returnMessage = null; + private static int callBackCount = 0; + private static Object monitor = new Object(); + + public void run() { + + // This tests basic callback patterns. + + // Test3a is the basic callback where the target calls back prior to + // returning to the client. + test3a(); + + // Test3b is where the target does not call back to the client. + test3b(); + + // Test3c is where the target calls back multiple times to the client. + test3c(); + + return; + } + + private void test3a() { + aCallBackService.knockKnock("Knock Knock"); + int count = 0; + + // + // If we cant 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("CallBackApiITest - test3a", "Who's There", this.getReturnMessage()); + + } + + private void test3b() { + aCallBackService.noCallBack("No Reply Desired"); + Assert.assertEquals("CallBackApiITest - test3b", 1, 1); + return; + } + + private void test3c() { + aCallBackService.multiCallBack("Call me back 3 times"); + int count = 0; + + // + // If we cant 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("CallBackApiITest - test3c", 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-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java new file mode 100644 index 0000000000..51d9f24723 --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.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.test; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Callback(CallBackApiCallBack.class) +/** + * + */ +public interface CallBackApiService { + + public void knockKnock(String aString); + + public void noCallBack(String aString); + + public void multiCallBack(String aString); + +} diff --git a/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java new file mode 100644 index 0000000000..727047e42e --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java @@ -0,0 +1,78 @@ +/* + * 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.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Service; + +@Service(CallBackApiService.class) +public class CallBackApiServiceImpl implements CallBackApiService { + + @Context + protected ComponentContext componentContext; + + private CallBackApiCallBack callback; + + public void knockKnock(String aString) { + + System.out.println("CallBackApiServiceImpl message received: " + aString); + callback = this.getCallBackInterface(); + callback.callBackMessage("Who's There"); + System.out.println("CallBackApiServiceImpl response sent"); + return; + + } + + public void multiCallBack(String aString) { + + callback = this.getCallBackInterface(); + + System.out.println("CallBackApiServiceImpl message received: " + aString); + callback.callBackIncrement("Who's There 1"); + System.out.println("CallBackApiServiceImpl response sent"); + callback.callBackIncrement("Who's There 2"); + System.out.println("CallBackApiServiceImpl response sent"); + callback.callBackIncrement("Who's There 3"); + System.out.println("CallBackApiServiceImpl response sent"); + return; + + } + + public void noCallBack(String aString) { + + System.out.println("CallBackApiServiceImpl message received: " + aString); + + return; + + } + + private CallBackApiCallBack getCallBackInterface() { + System.out.println("CallBackApiServiceImpl getting request context"); + RequestContext rc = componentContext.getRequestContext(); + System.out.println("CallBackApiServiceImpl getting callback from request context"); + callback = (CallBackApiCallBack) ((ServiceReference) rc.getServiceReference()).getCallback(); + System.out.println("CallBackApiServiceImpl returning callback"); + return callback; + + } + +} diff --git a/branches/sca-java-0.90/itest/callback-api/src/main/resources/CallBackApiTest.composite b/branches/sca-java-0.90/itest/callback-api/src/main/resources/CallBackApiTest.composite new file mode 100644 index 0000000000..946c4862ee --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/src/main/resources/CallBackApiTest.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-0.90/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTest.java b/branches/sca-java-0.90/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTest.java new file mode 100644 index 0000000000..892c425e48 --- /dev/null +++ b/branches/sca-java-0.90/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTest.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 org.apache.tuscany.sca.test; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class CallBackApiTest extends TestCase { + + private SCADomain domain; + private CallBackApiClient aCallBackClient; + + public void testCallBackBasic() { + aCallBackClient.run(); + } + + protected void setUp() throws Exception { + domain = SCADomain.newInstance("CallBackApiTest.composite"); + + aCallBackClient = + domain.getService(CallBackApiClient.class, "CallBackApiClient"); + } + + protected void tearDown() throws Exception { + domain.close(); + } + +} -- cgit v1.2.3