From 62bd754d0a94844170a304b616fc7bc1b0cc6979 Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 29 Jan 2009 15:00:33 +0000 Subject: TUSCANY-2291, Separate the mixed callback error validation test from the other callback tests so that the error doesn't affect the rest of the tests git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@738875 13f79535-47bb-0310-9956-ffa450edef68 --- .../conversation/callback/mixed/CService.java | 38 ----------- .../callback/mixed/impl/BServiceImpl.java | 73 ---------------------- .../callback/mixed/impl/CServiceImpl.java | 49 --------------- .../src/main/resources/callback-mixed.composite | 40 ------------ .../conversation/callback/CallbackTestCase.java | 19 ------ .../java-api/conversation/callbackmixed/pom.xml | 46 ++++++++++++++ .../javaapi/conversation/callback/AService.java | 30 +++++++++ .../conversation/callback/AServiceCallback.java | 33 ++++++++++ .../javaapi/conversation/callback/BService.java | 40 ++++++++++++ .../conversation/callback/BServiceCallback.java | 33 ++++++++++ .../javaapi/conversation/callback/Utilities.java | 32 ++++++++++ .../conversation/callback/impl/AServiceImpl.java | 61 ++++++++++++++++++ .../conversation/callback/mixed/CService.java | 38 +++++++++++ .../callback/mixed/impl/BServiceImpl.java | 73 ++++++++++++++++++++++ .../callback/mixed/impl/CServiceImpl.java | 49 +++++++++++++++ .../src/main/resources/callback-mixed.composite | 38 +++++++++++ .../conversation/callback/CallbackTestCase.java | 73 ++++++++++++++++++++++ .../vtest/java-api/conversation/pom.xml | 1 + .../tuscany/sca/vtest/utilities/ServiceFinder.java | 5 +- 19 files changed, 551 insertions(+), 220 deletions(-) delete mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.java delete mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java delete mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.java delete mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/resources/callback-mixed.composite create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/pom.xml create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AService.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AServiceCallback.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BService.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BServiceCallback.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/Utilities.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/impl/AServiceImpl.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.java create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/resources/callback-mixed.composite create mode 100644 branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java (limited to 'branches/sca-java-1.x/vtest') diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.java b/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.java deleted file mode 100644 index 705e101a01..0000000000 --- a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.vtest.javaapi.conversation.callback.mixed; - -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BServiceCallback; -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Conversational; - -/** - * Simple Service - */ -@Conversational -@Callback(BServiceCallback.class) -public interface CService { - - public void setState(String someState); - - public String getState(); - - public void testCallBack(String string); - -} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java deleted file mode 100644 index c03b1aedc4..0000000000 --- a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.vtest.javaapi.conversation.callback.mixed.impl; - -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.AServiceCallback; -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BService; -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BServiceCallback; -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.mixed.CService; -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.Utilities; -import org.junit.Assert; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; - -@Service(BService.class) -@Scope("CONVERSATION") -public class BServiceImpl implements BService, BServiceCallback { - - String someState; - - @Callback - protected AServiceCallback callback; - - @Reference - protected ServiceReference c; - - public void setState(String someState) { - this.someState = someState; - } - - public String getState() { - return someState; - } - - public void callBack(String someState) { - System.out.println("B-callback called with this state => " + someState); - this.someState = someState; - } - - public void testCallBack(String someState) { - - c.getService().testCallBack(someState); - int count = 4; - while (this.someState == null && count > 0) { - Utilities.delayQuarterSecond(); - count--; - } - if (this.someState == null) - Assert.fail("Callback not received by this instance"); - - callback.callBack(someState); - } - -} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.java deleted file mode 100644 index 8e068c8be4..0000000000 --- a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.vtest.javaapi.conversation.callback.mixed.impl; - -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BServiceCallback; -import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.mixed.CService; -import org.osoa.sca.annotations.Callback; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; - -@Service(CService.class) -@Scope("CONVERSATION") -public class CServiceImpl implements CService { - - String someState; - - @Callback - protected BServiceCallback callback; - - public void setState(String someState) { - this.someState = someState; - } - - public String getState() { - return someState; - } - - public void testCallBack(String someState) { - callback.callBack(someState); - } - -} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/resources/callback-mixed.composite b/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/resources/callback-mixed.composite deleted file mode 100644 index d2d9956103..0000000000 --- a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/main/resources/callback-mixed.composite +++ /dev/null @@ -1,40 +0,0 @@ - - - - - diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java b/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java index dc681a4e7e..bd8f116c10 100644 --- a/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java @@ -173,25 +173,6 @@ public class CallbackTestCase { aService.testCallback(); } - /** - * Lines 534, 535 - *

- * Callbacks may be used for both remotable and local services. Either both - * interfaces of a bidirectional service must be remotable, or both must be - * local. It is illegal to mix the two. - *

- * In this test configuration BServiceCallback is remotable and CService is - * not - */ - @Test(expected = ServiceRuntimeException.class) - @Ignore("TUSCANY-2291") - public void statefulMixedCallback() throws Exception { - System.out.println("Setting up for mixed local/remote callback tests"); - ServiceFinder.init("callback-mixed.composite"); - aService = ServiceFinder.getService(AService.class, "AComponent"); - aService.testCallback(); - } - /** * Lines 613-615 *

diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/pom.xml b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/pom.xml new file mode 100644 index 0000000000..a582913c54 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + java-api-annotations + 1.5-SNAPSHOT + ../pom.xml + + vtest-java-api-conversation-callback-mixed + Apache Tuscany SCA vTest Java APIs and Annotations Verification Tests - Conversation - Callback - Mixed + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.5-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.5-SNAPSHOT + runtime + + + + diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AService.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AService.java new file mode 100644 index 0000000000..e78736d4df --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AService.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.vtest.javaapi.conversation.callback; + +/** + * Simple Service + */ +public interface AService { + + public void testCallback(); + + public void testCallback2(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AServiceCallback.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AServiceCallback.java new file mode 100644 index 0000000000..0a90f9c99a --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/AServiceCallback.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.vtest.javaapi.conversation.callback; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +@Conversational +public interface AServiceCallback { + + public void callBack(String someState); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BService.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BService.java new file mode 100644 index 0000000000..0e61247294 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BService.java @@ -0,0 +1,40 @@ +/* + * 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.vtest.javaapi.conversation.callback; + +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.AServiceCallback; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +/** + * Simple Service + */ +@Remotable +@Conversational +@Callback(AServiceCallback.class) +public interface BService { + + public void setState(String someState); + + public String getState(); + + public void testCallBack(String string); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BServiceCallback.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BServiceCallback.java new file mode 100644 index 0000000000..e317a6e7e0 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/BServiceCallback.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.vtest.javaapi.conversation.callback; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +@Conversational +public interface BServiceCallback { + + public void callBack(String someState); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/Utilities.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/Utilities.java new file mode 100644 index 0000000000..15672f9ee0 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/Utilities.java @@ -0,0 +1,32 @@ +/* + * 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.vtest.javaapi.conversation.callback; + +public class Utilities { + + public static void delayQuarterSecond() { + try { + Thread.sleep(250);// millisecs + } catch (InterruptedException ex) { + throw new Error(ex); + } + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/impl/AServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/impl/AServiceImpl.java new file mode 100644 index 0000000000..1ace5858b2 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/impl/AServiceImpl.java @@ -0,0 +1,61 @@ +/* + * 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.vtest.javaapi.conversation.callback.impl; + +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.AService; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.AServiceCallback; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BService; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.Utilities; +import org.junit.Assert; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(AService.class) +@Scope("CONVERSATION") +public class AServiceImpl implements AService, AServiceCallback { + + @Reference + protected ServiceReference b; + + private String someState; + + public void callBack(String someState) { + System.out.println("A-callback called with this state => " + someState); + this.someState = someState; + } + + public void testCallback() { + b.getService().testCallBack("Some string"); + int count = 4; + while (someState == null && count > 0) { + Utilities.delayQuarterSecond(); + count--; + } + if (someState == null) + Assert.fail("Callback not received by this instance"); + } + + public void testCallback2() { + Assert.fail("Should not be called"); + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.java new file mode 100644 index 0000000000..705e101a01 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/CService.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.vtest.javaapi.conversation.callback.mixed; + +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BServiceCallback; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Conversational; + +/** + * Simple Service + */ +@Conversational +@Callback(BServiceCallback.class) +public interface CService { + + public void setState(String someState); + + public String getState(); + + public void testCallBack(String string); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java new file mode 100644 index 0000000000..c03b1aedc4 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/BServiceImpl.java @@ -0,0 +1,73 @@ +/* + * 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.vtest.javaapi.conversation.callback.mixed.impl; + +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.AServiceCallback; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BService; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BServiceCallback; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.mixed.CService; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.Utilities; +import org.junit.Assert; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(BService.class) +@Scope("CONVERSATION") +public class BServiceImpl implements BService, BServiceCallback { + + String someState; + + @Callback + protected AServiceCallback callback; + + @Reference + protected ServiceReference c; + + public void setState(String someState) { + this.someState = someState; + } + + public String getState() { + return someState; + } + + public void callBack(String someState) { + System.out.println("B-callback called with this state => " + someState); + this.someState = someState; + } + + public void testCallBack(String someState) { + + c.getService().testCallBack(someState); + int count = 4; + while (this.someState == null && count > 0) { + Utilities.delayQuarterSecond(); + count--; + } + if (this.someState == null) + Assert.fail("Callback not received by this instance"); + + callback.callBack(someState); + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.java new file mode 100644 index 0000000000..8e068c8be4 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/mixed/impl/CServiceImpl.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.vtest.javaapi.conversation.callback.mixed.impl; + +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.BServiceCallback; +import org.apache.tuscany.sca.vtest.javaapi.conversation.callback.mixed.CService; +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(CService.class) +@Scope("CONVERSATION") +public class CServiceImpl implements CService { + + String someState; + + @Callback + protected BServiceCallback callback; + + public void setState(String someState) { + this.someState = someState; + } + + public String getState() { + return someState; + } + + public void testCallBack(String someState) { + callback.callBack(someState); + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/resources/callback-mixed.composite b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/resources/callback-mixed.composite new file mode 100644 index 0000000000..ff6e0b63b2 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/main/resources/callback-mixed.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java new file mode 100644 index 0000000000..2bc5f6c910 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/conversation/callbackmixed/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java @@ -0,0 +1,73 @@ +/* + * 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.vtest.javaapi.conversation.callback; + +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.osoa.sca.ServiceRuntimeException; + +/** + * + */ +public class CallbackTestCase { + + protected static AService aService = null; + + @Before + public void init() throws Exception { + try { + System.out.println("Setting up"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @After + public void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + } + + /** + * Lines 534, 535 + *

+ * Callbacks may be used for both remotable and local services. Either both + * interfaces of a bidirectional service must be remotable, or both must be + * local. It is illegal to mix the two. + *

+ * In this test configuration BServiceCallback is remotable and CService is + * not + */ + @Test(expected = ServiceRuntimeException.class) + public void statefulMixedCallback() throws Exception { + System.out.println("Setting up for mixed local/remote callback tests"); + ServiceFinder.init("callback-mixed.composite"); + + // test an error was detected + + //aService = ServiceFinder.getService(AService.class, "AComponent"); + //aService.testCallback(); + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/conversation/pom.xml b/branches/sca-java-1.x/vtest/java-api/conversation/pom.xml index 12839204c3..5c8ee059cb 100644 --- a/branches/sca-java-1.x/vtest/java-api/conversation/pom.xml +++ b/branches/sca-java-1.x/vtest/java-api/conversation/pom.xml @@ -57,6 +57,7 @@ lifetime id callback + callbackmixed diff --git a/branches/sca-java-1.x/vtest/utilities/src/main/java/org/apache/tuscany/sca/vtest/utilities/ServiceFinder.java b/branches/sca-java-1.x/vtest/utilities/src/main/java/org/apache/tuscany/sca/vtest/utilities/ServiceFinder.java index 9b6792e51b..b1ba978d1c 100644 --- a/branches/sca-java-1.x/vtest/utilities/src/main/java/org/apache/tuscany/sca/vtest/utilities/ServiceFinder.java +++ b/branches/sca-java-1.x/vtest/utilities/src/main/java/org/apache/tuscany/sca/vtest/utilities/ServiceFinder.java @@ -53,7 +53,10 @@ public class ServiceFinder { } public static void cleanup() { - domain.close(); + if (domain != null){ + domain.close(); + } + domain = null; } -- cgit v1.2.3