From a40e527938d76ba71f211da7e327adb50384ba69 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:26:33 +0000 Subject: Moving 1.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835157 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/itest/callableref/AComponent.java | 39 ++++++ .../sca/itest/callableref/AComponentImpl.java | 114 ++++++++++++++++ .../tuscany/sca/itest/callableref/BComponent.java | 30 +++++ .../sca/itest/callableref/BComponentImpl.java | 38 ++++++ .../tuscany/sca/itest/callableref/CComponent.java | 27 ++++ .../sca/itest/callableref/CComponentImpl.java | 30 +++++ .../tuscany/sca/itest/callableref/DComponent.java | 30 +++++ .../sca/itest/callableref/DComponentImpl.java | 65 +++++++++ .../ConversationalService.java | 68 ++++++++++ .../ConversationalServiceImpl.java | 111 ++++++++++++++++ .../tuscany/sca/itest/callablerefreturn/Alpha.java | 27 ++++ .../sca/itest/callablerefreturn/AlphaImpl.java | 86 ++++++++++++ .../tuscany/sca/itest/callablerefreturn/Beta.java | 28 ++++ .../sca/itest/callablerefreturn/BetaImpl.java | 44 +++++++ .../tuscany/sca/itest/callablerefreturn/Gamma.java | 35 +++++ .../sca/itest/callablerefreturn/GammaImpl.java | 47 +++++++ .../CallableReferenceConversationalTest.composite | 29 +++++ .../CallableReferenceReturnTest.composite | 39 ++++++ .../main/resources/CallableReferenceTest.composite | 45 +++++++ .../src/main/resources/nodeA/CompositeA.composite | 46 +++++++ .../resources/nodeA/META-INF/sca-contribution.xml | 22 ++++ .../src/main/resources/nodeB/CompositeB.composite | 43 ++++++ .../resources/nodeB/META-INF/sca-contribution.xml | 22 ++++ .../CallableReferenceConversationalTestCase.java | 109 ++++++++++++++++ .../CallableReferenceRemoteTestCase.java | 145 +++++++++++++++++++++ .../CallableReferenceReturnTestCase.java | 48 +++++++ .../callableref/CallableReferenceTestCase.java | 83 ++++++++++++ 27 files changed, 1450 insertions(+) create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Alpha.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/AlphaImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Beta.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/BetaImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Gamma.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/GammaImpl.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceReturnTest.composite create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceTest.composite create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.java create mode 100644 sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java (limited to 'sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src') diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java new file mode 100644 index 0000000000..5934f16851 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java @@ -0,0 +1,39 @@ +/* + * 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.callableref; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface AComponent { + String foo(); + + String fooB(); + String fooB1(); + + String fooC(); + String fooC1(); + + String fooStringD(); + String fooD(); + + String fooBC(); + + String invokeDReference(); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java new file mode 100644 index 0000000000..7c2fd092dc --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java @@ -0,0 +1,114 @@ +/* + * 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.callableref; + +import java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; + +import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(AComponent.class) +public class AComponentImpl implements AComponent { + + @Context + protected ComponentContext componentContext; + + @Reference(name = "bReference") + protected BComponent b; + + @Reference + protected CComponent cReference; + + @Reference + protected ServiceReference cServiceReference; + + @Reference(required=false) + protected DComponent dReference; + + protected DComponent dReference1; + + @Reference(name = "dReference1") + public void setDReference(DComponent dReference) { + this.dReference1 = dReference; + } + + public String foo() { + return "AComponent"; + } + + public String fooB() { + return b.foo(); + } + + public String fooB1() { + CallableReference bRef = componentContext.cast(b); + return bRef.getService().foo(); + } + + public String fooC() { + return cReference.foo(); + } + + public String fooC1() { + return cServiceReference.getService().foo(); + } + + public String fooBC() { + CallableReference cReference = componentContext.getServiceReference(CComponent.class, "cReference"); + return b.fooC(cReference); + } + + public String fooD() { + CallableReference aReference = componentContext.createSelfReference(AComponent.class); + return dReference1.foo(aReference); + } + + /** + * A test case to work out what needs to be done in a transformer to get the + * CallableReference across the wire. Left here for interest in case anyone + * is looking for how to get at the innards of CallableReferences + */ + public String fooStringD() { + CallableReference aReference = componentContext.createSelfReference(AComponent.class); + ByteArrayOutputStream bos = null; + + try { + bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(aReference); + } catch (Exception ex) { + System.out.println(ex.toString()); + return null; + } + + String aReferenceString = Base64Binary.encode(bos.toByteArray()); + return dReference1.fooString(aReferenceString); + } + + public String invokeDReference() { + return dReference.foo(null); + } + +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java new file mode 100644 index 0000000000..ade672b0ab --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.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.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface BComponent { + + String foo(); + + String fooC(CallableReference cComponent); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java new file mode 100644 index 0000000000..518e77d3a8 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.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.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Service; + +@Service(BComponent.class) +public class BComponentImpl implements BComponent { + + public BComponentImpl() { + } + + public String foo() { + return "BComponent"; + } + + public String fooC(CallableReference cReference) { + return "B" + cReference.getService().foo(); + } + +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java new file mode 100644 index 0000000000..fdf80cc1c8 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.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.callableref; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface CComponent { + + String foo(); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java new file mode 100644 index 0000000000..cc8ec8f000 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.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.callableref; + +import org.osoa.sca.annotations.Service; + +@Service(CComponent.class) +public class CComponentImpl implements CComponent { + + public String foo() { + return "CComponent"; + } + +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java new file mode 100644 index 0000000000..48b697df31 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.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.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface DComponent { + + String foo(CallableReference aReference); + + String fooString(String aReferenceString); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java new file mode 100644 index 0000000000..27ad48b9fe --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java @@ -0,0 +1,65 @@ +/* + * 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.callableref; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; +import org.osoa.sca.CallableReference; +import org.osoa.sca.RequestContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Service; + +@Service(DComponent.class) +public class DComponentImpl implements DComponent { + + @Context + protected RequestContext requestContext; + + public String foo(CallableReference aReference) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(aReference); + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); + Object obj = ois.readObject(); + aReference = (CallableReference) obj; + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Invoking service: " + requestContext.getServiceName()); + return "D" + aReference.getService().foo(); + } + + public String fooString(String aReferenceString) { + CallableReference aReference = null; + try { + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64Binary.decode(aReferenceString))); + Object obj = ois.readObject(); + aReference = (CallableReference) obj; + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Invoking service: " + requestContext.getServiceName()); + return "D" + aReference.getService().foo(); + } +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java new file mode 100644 index 0000000000..abcedfa6e1 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalService.java @@ -0,0 +1,68 @@ +/* + * 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.callablerefconversational; + +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Conversational; + +/** + * Simple conversational Service that is used to testing the method + * ComponentContext.createSelfReference() + * + * @version $Date$ $Revision$ + */ +@Conversational +public interface ConversationalService { + /** + * Default value for the user data + */ + String DEFAULT_USER_DATA = "NOT SET"; + + /** + * Retrieves the conversation ID for this Service + * + * @return The conversation ID for this Service + */ + Object getConversationID(); + + /** + * Creates a self reference to this Service + * + * @return A self reference to this Service + */ + ServiceReference createSelfRef(); + + /** + * Sets some user data on the instance + * + * @param a_Data Some data + * + * @See {@link #getUserData()} + */ + void setUserData(String a_Data); + + /** + * Gets some user data on the instance + * + * @return Some data + * + * @See {@link #setUserData(String)} + */ + String getUserData(); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java new file mode 100644 index 0000000000..f2e0ce7582 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefconversational/ConversationalServiceImpl.java @@ -0,0 +1,111 @@ +/* + * 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.callablerefconversational; + +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Simple conversational Service that is used to testing the method + * ComponentContext.createSelfReference() + * + * @version $Date$ $Revision$ + */ +@Service(ConversationalService.class) +@Scope("CONVERSATION") +public class ConversationalServiceImpl implements ConversationalService { + + /** + * The Conversation ID + */ + private Object m_ConversationID; + + /** + * Reference to the ComponentContext. + */ + @Context + protected ComponentContext m_Ctx; + + /** + * Some user data + */ + private String m_UserData = DEFAULT_USER_DATA; + + /** + * Constructor + */ + public ConversationalServiceImpl() { + System.out.println("New instance of " + this + " created"); + } + + /** + * Used to inject the Conversation ID + * + * @param a_ConversationID the Conversation ID + */ + @ConversationID + public void setConversationID(Object a_ConversationID) { + m_ConversationID = a_ConversationID; + System.out.println("Converstation ID set on " + this + " to " + a_ConversationID); + } + + /** + * Retrieves the conversation ID for this Service + * + * @return The conversation ID for this Service + */ + public Object getConversationID() { + return m_ConversationID; + } + + /** + * Creates a self reference to this Service + * + * @return A self reference to this Service + */ + public ServiceReference createSelfRef() { + return m_Ctx.createSelfReference(ConversationalService.class); + } + + /** + * Sets some user data on the instance + * + * @param a_Data Some data + * + * @See {@link #getUserData()} + */ + public void setUserData(String a_Data) { + m_UserData = a_Data; + } + + /** + * Gets some user data on the instance + * + * @return Some data + * + * @See {@link #setUserData(String)} + */ + public String getUserData() { + return m_UserData; + } +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Alpha.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Alpha.java new file mode 100644 index 0000000000..ab21421c4d --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Alpha.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.callablerefreturn; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Alpha +{ + boolean run(); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/AlphaImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/AlphaImpl.java new file mode 100644 index 0000000000..5b5984b164 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/AlphaImpl.java @@ -0,0 +1,86 @@ +/* + * 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.callablerefreturn; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.Conversation; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class AlphaImpl implements Alpha { + @Reference + public Beta beta; + + @Context + protected ComponentContext componentContext; + + public boolean run() { + CallableReference gammaRef = null; + try { + Object conversationId1 = null; + Object conversationId2 = null; + + // it is expected that this call returns a reference to Gamma that + // reuses the established Conversation + gammaRef = beta.getRef(); + + // no Conversation exists + Conversation con = gammaRef.getConversation(); + if (con == null) { + System.out.println("Alpha: Conversation to gamma is null"); + } else { + System.out + .println("Alpha: Conversation to gamma exists. conversationId=" + + con.getConversationID()); + conversationId1 = con.getConversationID(); + } + + // this call should reuse a Conversation, but as none exists it + // creates a new conversation + gammaRef.getService().doSomething(); + con = gammaRef.getConversation(); + if (con == null) { + System.out.println("Alpha: Conversation to gamma is null"); + } else { + System.out + .println("Alpha: Conversation to gamma exists. conversationId=" + + con.getConversationID()); + conversationId2 = con.getConversationID(); + } + + if ((conversationId1 == null) || (conversationId2 == null)) { + return false; + } + + boolean testPassed = conversationId1.equals(conversationId2); + return testPassed; + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + if (gammaRef != null) { + gammaRef.getService().stop(); + } + } + } + +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Beta.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Beta.java new file mode 100644 index 0000000000..223c467f47 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Beta.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.itest.callablerefreturn; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface Beta +{ + CallableReference getRef(); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/BetaImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/BetaImpl.java new file mode 100644 index 0000000000..ed4e66bec3 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/BetaImpl.java @@ -0,0 +1,44 @@ +/* + * 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.callablerefreturn; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.ServiceReference; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class BetaImpl implements Beta +{ + @Context + protected ComponentContext componentContext; + + @Reference + public Gamma gamma; + + public CallableReference getRef() + { + ServiceReference gammaRef = componentContext.getServiceReference(Gamma.class, "gamma"); + gammaRef.getService().start(); + return gammaRef; + } + +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Gamma.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Gamma.java new file mode 100644 index 0000000000..e32051373f --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/Gamma.java @@ -0,0 +1,35 @@ +/* + * 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.callablerefreturn; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Conversational +public interface Gamma +{ + void start(); + + void doSomething(); + + @EndsConversation + void stop(); +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/GammaImpl.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/GammaImpl.java new file mode 100644 index 0000000000..adf5a1c1ce --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callablerefreturn/GammaImpl.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.callablerefreturn; + +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; + +@Scope("CONVERSATION") +public class GammaImpl implements Gamma +{ + @ConversationID + protected String conversationId; + + + public void start() + { + System.out.println("Gamma:start(), conversationId=" + conversationId); + } + + + public void doSomething() + { + System.out.println("Gamma:doSomething(), conversationId=" + conversationId); + } + + + public void stop() + { + System.out.println("Gamma:stop(), conversationId=" + conversationId); + } +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite new file mode 100644 index 0000000000..0bf8f7ef1e --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceConversationalTest.composite @@ -0,0 +1,29 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceReturnTest.composite b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceReturnTest.composite new file mode 100644 index 0000000000..5b3add1e61 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceReturnTest.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceTest.composite b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceTest.composite new file mode 100644 index 0000000000..49b75f56e4 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/CallableReferenceTest.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite new file mode 100644 index 0000000000..9216f44191 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..95021f72a4 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeA/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite new file mode 100644 index 0000000000..42d739564c --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..2edda61601 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/main/resources/nodeB/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java new file mode 100644 index 0000000000..a9cbb5d0a1 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceConversationalTestCase.java @@ -0,0 +1,109 @@ +/* + * 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.callableref; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.itest.callablerefconversational.ConversationalService; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.osoa.sca.ServiceReference; + +/** + * Simple test case that creates a ServiceReference to a Conversational Component + * using ComponentContext.createSelfReference() + *

+ * This test case is for TUSCANY-2208 + * + * @version $Date$ $Revision$ + */ +public class CallableReferenceConversationalTestCase { + private static SCADomain domain; + private static ConversationalService acomponent; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CallableReferenceConversationalTest.composite"); + Assert.assertNotNull(domain); + acomponent = domain.getService(ConversationalService.class, "ConversationalComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + if (domain != null) { + domain.close(); + } + } + + /** + * This is a dummy test so that this Unit Test has a test so it will build. + * Once TUSCANY-2208 is fixed, this dummy test method can be removed + */ + @Test + public void dummyTestRemoveWhenTuscany2208IsFixed() { + } + + /** + * Tests creating Self References and validate them with Conversation IDs + */ + // Disabled until TUSCANY-2208 is fixed + // @Test + public void testCreateSelfRefUsingConvID() { + Assert.assertNotNull(acomponent); + + final Object origConvID = acomponent.getConversationID(); + Assert.assertNotNull(origConvID); + final ServiceReference ref = acomponent.createSelfRef(); + Assert.assertNotNull(ref); + + final ConversationalService resolvedRef = ref.getService(); + Assert.assertNotNull(resolvedRef); + final Object newConvID = resolvedRef.getConversationID(); + Assert.assertNotNull(newConvID); + + Assert.assertEquals(origConvID, newConvID); + } + + /** + * Tests creating Self References and validate them with user specified data + */ + // Disabled until TUSCANY-2208 is fixed + // @Test + public void testCreateSelfRefUsingUserData() { + Assert.assertNotNull(acomponent); + + final String origUserData = acomponent.getUserData(); + Assert.assertEquals(ConversationalService.DEFAULT_USER_DATA, origUserData); + + final String userData = "Some new user data set at " + System.currentTimeMillis(); + acomponent.setUserData(userData); + + final ServiceReference ref = acomponent.createSelfRef(); + Assert.assertNotNull(ref); + + final ConversationalService resolvedRef = ref.getService(); + Assert.assertNotNull(resolvedRef); + final String newUserData = resolvedRef.getUserData(); + Assert.assertNotNull(newUserData); + + Assert.assertEquals(userData, newUserData); + } +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java new file mode 100644 index 0000000000..ba9020811c --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java @@ -0,0 +1,145 @@ +/* + * 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.callableref; + + +import static junit.framework.Assert.assertEquals; + +import java.io.File; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * Runs a distributed domain in a single VM by using and in memory + * implementation of the distributed domain + */ +public class CallableReferenceRemoteTestCase { + + private static SCANode nodeA; + private static SCANode nodeB; + + private static AComponent acomponent; + + @BeforeClass + public static void init() throws Exception { + + try { + + System.out.println("Setting up nodes"); + + SCANodeFactory nodeFactory = SCANodeFactory.newInstance(); + nodeA = nodeFactory.createSCANode(new File("src/main/resources/nodeA/CompositeA.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/nodeA").toURL().toString())); + + + nodeB = nodeFactory.createSCANode(new File("src/main/resources/nodeB/CompositeB.composite").toURL().toString(), + new SCAContribution("TestContribution", + new File("src/main/resources/nodeB").toURL().toString())); + + + nodeA.start(); + nodeB.start(); + + acomponent = ((SCAClient)nodeA).getService(AComponent.class, "AComponent/AComponent"); + + } catch (Throwable ex) { + System.out.println(ex.toString()); + // Print detailed cause information. + ex.printStackTrace(); + StringBuffer sb = new StringBuffer(); + Throwable cause = ex.getCause(); + while ( cause != null ) { + sb.append( " " ); + System.out.println( sb.toString() + "Cause: " + cause ); + if (cause instanceof java.lang.reflect.InvocationTargetException) + System.out.println( sb.toString() + "Target Exception: " + ((java.lang.reflect.InvocationTargetException)cause).getTargetException() ); + cause = cause.getCause(); + } + } + } + + @AfterClass + public static void destroy() throws Exception { + // stop the nodes and hence the domains they contain + nodeA.stop(); + nodeB.stop(); + } + + //@Test + public void testKeepServerRunning1() throws Exception { + System.out.println("press enter to continue"); + System.in.read(); + } + + @Test + public void testBReference() { + assertEquals("BComponent", acomponent.fooB()); + } + + @Test + public void testBCast() { + assertEquals("BComponent", acomponent.fooB1()); + } + + @Test + public void testCReference() { + assertEquals("CComponent", acomponent.fooC()); + } + + @Test + public void testCServiceReference() { + assertEquals("CComponent", acomponent.fooC1()); + } + + @Test + public void testDReferenceString() { + assertEquals("DAComponent", acomponent.fooStringD()); + } + + @Test + public void testDReference() { + assertEquals("DAComponent", acomponent.fooD()); + } + + + @Test + public void testBCReference() { + assertEquals("BCComponent", acomponent.fooBC()); + } + + @Test + public void testRequiredFalseReference() { + try { + acomponent.invokeDReference(); + } catch (Exception e) { + Assert.assertTrue(true); + } + } + +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.java new file mode 100644 index 0000000000..f2d8fe5d64 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceReturnTestCase.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.callableref; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.itest.callablerefreturn.Alpha; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +public class CallableReferenceReturnTestCase { + private static SCADomain domain; + private static Alpha alpha; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CallableReferenceReturnTest.composite"); + alpha = domain.getService(Alpha.class, "Alpha"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } + + @Test + public void testCallableReferenceReturn() { + Assert.assertTrue(alpha.run()); + } + +} diff --git a/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java new file mode 100644 index 0000000000..d785a6a397 --- /dev/null +++ b/sca-java-1.x/tags/1.5.1-RC1/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.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.callableref; + +import static junit.framework.Assert.assertEquals; +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class CallableReferenceTestCase { + private static SCADomain domain; + private static AComponent acomponent; + + @BeforeClass + public static void init() throws Exception { + domain = SCADomain.newInstance("CallableReferenceTest.composite"); + acomponent = domain.getService(AComponent.class, "AComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + domain.close(); + } + + @Test + public void testBReference() { + assertEquals("BComponent", acomponent.fooB()); + } + + @Test + public void testBCast() { + assertEquals("BComponent", acomponent.fooB1()); + } + + @Test + public void testCReference() { + assertEquals("CComponent", acomponent.fooC()); + } + + @Test + public void testCServiceReference() { + assertEquals("CComponent", acomponent.fooC1()); + } + + @Test + public void testDReference() { + assertEquals("DAComponent", acomponent.fooD()); + } + + @Test + public void testBCReference() { + assertEquals("BCComponent", acomponent.fooBC()); + } + + @Test + public void testRequiredFalseReference() { + try { + acomponent.invokeDReference(); + } catch (Exception e) { + Assert.assertTrue(true); + } + } + +} -- cgit v1.2.3