diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:31 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:31 +0000 |
commit | a7c1a39d8c3c4ef4d5878dbff726085082a17e8a (patch) | |
tree | 54faa0e87eb8c8242a4a0baeb5f7b505a175d00f /sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test | |
parent | 4e13586bc791d71c41760cf4d0a5cc908973de3e (diff) |
Moving 2.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835136 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test')
2 files changed, 154 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test/pom.xml new file mode 100644 index 0000000000..d30358cfe2 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test/pom.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-M3-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-nodes-two-nodes-test</artifactId>
+ <name>Apache Tuscany SCA iTest Nodes Two Nodes Test</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-M3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-M3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M3-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java b/sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java new file mode 100644 index 0000000000..8352f70e17 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M3/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java @@ -0,0 +1,101 @@ +/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.io.File;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClient;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoNodesTestCase{
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled", "false");
+ NodeFactory factory = NodeFactory.newInstance();
+ serviceNode = factory.createNode(new Contribution("service", getJar("../helloworld-service/target")));
+ serviceNode.start();
+ clientNode = factory.createNode(new Contribution("client", getJar("../helloworld-client/target")));
+ clientNode.start();
+ }
+
+ /**
+ * Get the jar in the target folder without being dependent on the version name to
+ * make tuscany releases easier
+ */
+ private static String getJar(String targetDirectory) {
+ File f = new File(targetDirectory);
+ for (File file : f.listFiles()) {
+ if (file.getName().endsWith(".jar")) {
+ return file.toURI().toString();
+ }
+ }
+ throw new IllegalStateException("Can't find jar in: " + targetDirectory);
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testCalculatorClientAPI() throws Exception {
+ SCAClient scaClient = SCAClientFactory.newInstance();
+ Helloworld service = scaClient.getService(Helloworld.class, "HelloworldService", null);
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = scaClient.getService(Helloworld.class, "HelloworldClient", null);
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
|