From 5559ef5edbf8d3616f7a4b497b2a459b0ee4082b Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:07:07 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835122 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca-java-1.0/itest/callablereferences/pom.xml | 81 +++++++++++++ .../tuscany/sca/itest/callableref/AComponent.java | 35 ++++++ .../sca/itest/callableref/AComponentImpl.java | 88 +++++++++++++++ .../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 | 28 +++++ .../sca/itest/callableref/DComponentImpl.java | 52 +++++++++ .../main/resources/CallableReferenceTest.composite | 45 ++++++++ .../src/main/resources/nodeA/CompositeA.composite | 47 ++++++++ .../resources/nodeA/META-INF/sca-contribution.xml | 22 ++++ .../src/main/resources/nodeB/CompositeB.composite | 34 ++++++ .../resources/nodeB/META-INF/sca-contribution.xml | 22 ++++ .../CallableReferenceRemoteTestCase.java | 125 +++++++++++++++++++++ .../callableref/CallableReferenceTestCase.java | 83 ++++++++++++++ 16 files changed, 787 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/CallableReferenceTest.composite create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java (limited to 'sca-java-1.x/branches/sca-java-1.0/itest/callablereferences') diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/pom.xml b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/pom.xml new file mode 100644 index 0000000000..f4202c1120 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.0-incubating-SNAPSHOT + ../pom.xml + + itest-callablereferences + Apache Tuscany SCA Callable References Integration Tests + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.0-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.0-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.0-incubating-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-domain-impl + 1.0-incubating-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.0-incubating-SNAPSHOT + test + + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.0-incubating-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2 + 1.0-incubating-SNAPSHOT + test + + + diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.java new file mode 100644 index 0000000000..fa63d975a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponent.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.callableref; + +public interface AComponent { + String foo(); + + String fooB(); + String fooB1(); + + String fooC(); + String fooC1(); + + String fooD(); + + String fooBC(); + + DComponent getDReference(); +} diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java new file mode 100644 index 0000000000..af3e624dc7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/AComponentImpl.java @@ -0,0 +1,88 @@ +/* + * 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.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); + } + + public DComponent getDReference() { + return dReference; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponent.java b/sca-java-1.x/branches/sca-java-1.0/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/branches/sca-java-1.0/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/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/BComponentImpl.java b/sca-java-1.x/branches/sca-java-1.0/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/branches/sca-java-1.0/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/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponent.java b/sca-java-1.x/branches/sca-java-1.0/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/branches/sca-java-1.0/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/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/CComponentImpl.java b/sca-java-1.x/branches/sca-java-1.0/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/branches/sca-java-1.0/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/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.java new file mode 100644 index 0000000000..3b25d351ae --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponent.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.callableref; + +import org.osoa.sca.CallableReference; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface DComponent { + + String foo(CallableReference aReference); +} diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java new file mode 100644 index 0000000000..1ab1973476 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/java/org/apache/tuscany/sca/itest/callableref/DComponentImpl.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.itest.callableref; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +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(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/CallableReferenceTest.composite b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/CallableReferenceTest.composite new file mode 100644 index 0000000000..49b75f56e4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/CallableReferenceTest.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite new file mode 100644 index 0000000000..eb456b99f2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeA/CompositeA.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeA/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-1.0/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/branches/sca-java-1.0/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/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite new file mode 100644 index 0000000000..2849400be4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeB/CompositeB.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/main/resources/nodeB/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-1.0/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/branches/sca-java-1.0/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/branches/sca-java-1.0/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java new file mode 100644 index 0000000000..3b4ac60668 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceRemoteTestCase.java @@ -0,0 +1,125 @@ +/* + * 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.domain.SCADomain; +import org.apache.tuscany.sca.node.impl.SCANodeImpl; +import org.apache.tuscany.sca.node.impl.SCANodeUtil; +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 String DEFAULT_DOMAIN_URL = "http://localhost:8877"; + + private static SCADomain domain; + private static SCADomain domainNodeA; + private static SCADomain domainNodeB; + + private static AComponent acomponent; + + @BeforeClass + public static void init() throws Exception { + + try { + System.out.println("Setting up distributed registry"); + domain = SCADomain.newInstance("domain.composite"); + + System.out.println("Setting up distributed nodes"); + + // create the node that runs the + // calculator component + domainNodeA = SCADomain.newInstance(DEFAULT_DOMAIN_URL, "nodeA", null, "nodeA/CompositeA.composite"); + + // create the node that runs the + // add component + domainNodeB = SCADomain.newInstance(DEFAULT_DOMAIN_URL, "nodeB", null, "nodeB/CompositeB.composite"); + + + // get a reference to the calculator service from domainA + // which will be running this component + acomponent = domainNodeA.getService(AComponent.class, "AComponent/AComponent"); + } catch (Exception ex) { + System.out.println(ex.toString()); + } + } + + @AfterClass + public static void destroy() throws Exception { + // stop the nodes and hence the domains they contain + domainNodeA.close(); + domainNodeB.close(); + 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()); + } + + /* Commented it out as it's still failing + @Test + public void testDReference() { + assertEquals("DAComponent", acomponent.fooD()); + } + */ + + //@Test + public void testBCReference() { + assertEquals("BCComponent", acomponent.fooBC()); + } + + @Test + public void testRequiredFalseReference() { + try { + acomponent.getDReference().foo(null); + } catch (Exception e) { + Assert.assertTrue(true); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java b/sca-java-1.x/branches/sca-java-1.0/itest/callablereferences/src/test/java/org/apache/tuscany/sca/itest/callableref/CallableReferenceTestCase.java new file mode 100644 index 0000000000..2b7750b443 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.0/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.getDReference().foo(null); + } catch (Exception e) { + Assert.assertTrue(true); + } + } + +} -- cgit v1.2.3