From 9598850b3f833a1c7b0a10eac5f975454f468534 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 9 Jun 2011 08:30:25 +0000 Subject: Add an itest for stopping and starting a composite on a remote node git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1133709 13f79535-47bb-0310-9956-ffa450edef68 --- .../testing/itest/nodes/remote-stop-start/pom.xml | 71 ++++++++++++++++++++++ .../src/main/java/itest/HelloworldService.java | 28 +++++++++ .../src/main/java/itest/HelloworldServiceImpl.java | 38 ++++++++++++ .../main/java/itest/RemoteHelloworldService.java | 28 +++++++++ .../src/main/resources/Helloworld.composite | 29 +++++++++ .../main/resources/META-INF/sca-contribution.xml | 23 +++++++ .../java/test/scaclient/StopStartTestCase.java | 61 +++++++++++++++++++ 7 files changed, 278 insertions(+) create mode 100644 sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/pom.xml create mode 100644 sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldService.java create mode 100644 sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldServiceImpl.java create mode 100644 sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/RemoteHelloworldService.java create mode 100644 sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/Helloworld.composite create mode 100644 sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/test/java/test/scaclient/StopStartTestCase.java (limited to 'sca-java-2.x/trunk/testing/itest/nodes') diff --git a/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/pom.xml b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/pom.xml new file mode 100644 index 0000000000..1bb177e012 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-nodes + 2.0-SNAPSHOT + ../pom.xml + + itest-remote-stop-start + Apache Tuscany SCA iTest Remote Stop Start + + + + org.apache.tuscany.sca + tuscany-base-runtime + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-domain-hazelcast + 2.0-SNAPSHOT + + + + + + + org.apache.tuscany.sca + tuscany-maven-plugin + 2.0-SNAPSHOT + + uri:StartStopTestCase?bind=127.0.0.1:9876 + + + + process-test-classes + + start + + + + stop + prepare-package + + stop + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldService.java b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldService.java new file mode 100644 index 0000000000..f97d2c3a83 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldService.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 itest; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldServiceImpl.java b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldServiceImpl.java new file mode 100644 index 0000000000..4fd909af82 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/HelloworldServiceImpl.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 itest; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Scope; + +@EagerInit +@Scope("COMPOSITE") +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + + @Init + public void init() { + System.out.println("init: " + sayHello("world")); + } + +} diff --git a/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/RemoteHelloworldService.java b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/RemoteHelloworldService.java new file mode 100644 index 0000000000..d5b9dcf311 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/java/itest/RemoteHelloworldService.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 itest; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface RemoteHelloworldService { + + String sayHelloRemote(String name); + +} diff --git a/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/Helloworld.composite b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/Helloworld.composite new file mode 100644 index 0000000000..d37c93857d --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/Helloworld.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e178823296 --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/test/java/test/scaclient/StopStartTestCase.java b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/test/java/test/scaclient/StopStartTestCase.java new file mode 100644 index 0000000000..910f219bcc --- /dev/null +++ b/sca-java-2.x/trunk/testing/itest/nodes/remote-stop-start/src/test/java/test/scaclient/StopStartTestCase.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 test.scaclient; + +import itest.HelloworldService; + +import java.util.List; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.Node; +import org.apache.tuscany.sca.TuscanyRuntime; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.monitor.ValidationException; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.junit.Test; +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.NoSuchServiceException; + +public class StopStartTestCase { + + @Test + public void startStopInstall() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { + TuscanyRuntime runtime = TuscanyRuntime.newInstance(); + Node node1 = runtime.createNode("uri:StartStopTestCase?wka=127.0.0.1:9876"); + Assert.assertEquals("Hello Amelia", node1.getService(HelloworldService.class, "HelloworldComponent").sayHello("Amelia")); + + String curi = node1.getInstalledContributionURIs().get(0); + + node1.stopComposite(curi, "Helloworld.composite"); + try { + node1.getService(HelloworldService.class, "HelloworldComponent").sayHello("Amelia"); + Assert.fail(); + } catch (NoSuchServiceException e) { + // expected + } + + List nodes = node1.getNodeNames(); + nodes.remove(node1.getLocalNodeName()); + String remoteNode = nodes.get(0); + node1.startComposite(curi, "Helloworld.composite", remoteNode); + +// Assert.assertEquals("Hello Amelia", node1.getService(HelloworldService.class, "HelloworldComponent").sayHello("Amelia")); + } +} -- cgit v1.2.3