summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/domain-node/src/test
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-07-29 08:46:16 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-07-29 08:46:16 +0000
commit84a39db4baae48c1afbe44e54754dd0988ca73b0 (patch)
tree7c4fb9b7d138ebc94ebf610e0b8295b47ff19513 /java/sca/modules/domain-node/src/test
parenta17725f068074bec886fbd6c47174ae7b590064c (diff)
Start of the node enhancements to support what was being discussed on the ML a couple of weeks ago http://apache.markmail.org/message/doxwldv2ddkmah5s. There's a runtime per node and a node locall for each domain being used, and you can add/remove contributions from a running node. Right now it just uses NodeFactory/Node under the covers, and ideally this function will be merged into the existing Node later
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@798811 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/domain-node/src/test')
-rw-r--r--java/sca/modules/domain-node/src/test/java/itest/nodes/Helloworld.java29
-rw-r--r--java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/node/OneNodeTestCase.java79
-rw-r--r--java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jarbin0 -> 4800 bytes
-rw-r--r--java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jarbin0 -> 4515 bytes
4 files changed, 108 insertions, 0 deletions
diff --git a/java/sca/modules/domain-node/src/test/java/itest/nodes/Helloworld.java b/java/sca/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
new file mode 100644
index 0000000000..ee15dfba12
--- /dev/null
+++ b/java/sca/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
@@ -0,0 +1,29 @@
+/*
+ * 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.nodes;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Helloworld {
+
+ String sayHello(String name);
+
+}
diff --git a/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/node/OneNodeTestCase.java b/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/node/OneNodeTestCase.java
new file mode 100644
index 0000000000..d36734875b
--- /dev/null
+++ b/java/sca/modules/domain-node/src/test/java/org/apache/tuscany/sca/node/OneNodeTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * 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.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import itest.nodes.Helloworld;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.client.SCAClient;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class OneNodeTestCase{
+
+ private static DomainNode domain;
+ private static String serviceContributionUri;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+
+ domain = new DomainNode();
+ serviceContributionUri = domain.addContribution("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ domain.addContribution("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ Helloworld service = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ // FIXME: this should give a service not found as the service contribution has been removed
+ // domain.removeContribution(serviceContributionUri);
+ // assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ domain.stop();
+ try {
+ SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ fail();
+ } catch (NoSuchDomainException e) {
+ // expected
+ }
+ }
+
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (domain != null && domain.isStarted()) {
+ domain.stop();
+ }
+ }
+}
diff --git a/java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar b/java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..0149416b15
--- /dev/null
+++ b/java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
Binary files differ
diff --git a/java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar b/java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..40333cab75
--- /dev/null
+++ b/java/sca/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
Binary files differ