diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:40 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 23:09:40 +0000 |
commit | f9be2165328dc76f562938566057e89c0723fe08 (patch) | |
tree | 4b32774b0050ed2d0aeb05f9f22844d41cf13023 /sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes | |
parent | a7c1a39d8c3c4ef4d5878dbff726085082a17e8a (diff) |
Moving 2.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835137 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes')
26 files changed, 1576 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/pom.xml new file mode 100644 index 0000000000..13b0dd0ab2 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/pom.xml @@ -0,0 +1,44 @@ +<?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-M4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>itest-nodes-helloworld-client</artifactId> + <name>Apache Tuscany SCA iTest Nodes Helloworld Client</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>itest-nodes-helloworld-iface</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>2.0-M4-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + </dependencies> +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java new file mode 100644 index 0000000000..bf8a588928 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java @@ -0,0 +1,43 @@ +/* + * 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.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +@EagerInit +@Scope("COMPOSITE") +public class HelloworldImpl implements Helloworld { + + @Reference + public Helloworld service; + + @Init + public void initialize(){ + System.out.println(">>>>>> " + sayHello("init")); + } + + public String sayHello(String name) { + return "Hi " + service.sayHello(name); + } + +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b4ba94220c --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ +<?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. +--> +<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + xmlns:itest="http://itest"> + <deployable composite="itest:HelloworldClient"/> +</contribution>
\ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite new file mode 100644 index 0000000000..9d5e9ae59a --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite @@ -0,0 +1,29 @@ +<?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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + targetNamespace="http://itest" + name="HelloworldClient"> + + <component name="HelloworldClient"> + <implementation.java class="itest.nodes.HelloworldImpl"/> + <reference name="service" target="HelloworldService"/> + </component> + +</composite> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/pom.xml new file mode 100644 index 0000000000..b8c8205eb2 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/pom.xml @@ -0,0 +1,39 @@ +<?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-M4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>itest-nodes-helloworld-iface</artifactId> + <name>Apache Tuscany SCA iTest Nodes Helloworld IFaces</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>2.0-M4-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + </dependencies> +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java new file mode 100644 index 0000000000..76f8d4400d --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/src/main/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/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/pom.xml new file mode 100644 index 0000000000..a8fe3ff7b3 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/pom.xml @@ -0,0 +1,49 @@ +<?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-M4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>itest-nodes-helloworld-service</artifactId> + <name>Apache Tuscany SCA iTest Nodes Helloworld Service</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>itest-nodes-helloworld-iface</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>2.0-M4-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-api</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java new file mode 100644 index 0000000000..81f7e1747d --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.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.nodes; + +public class HelloworldImpl implements Helloworld { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c65718909d --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ +<?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. +--> +<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + xmlns:itest="http://itest"> + <deployable composite="itest:HelloworldService"/> +</contribution>
\ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite new file mode 100644 index 0000000000..6b2d15b7a6 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite @@ -0,0 +1,28 @@ +<?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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" + targetNamespace="http://itest" + name="HelloworldService"> + + <component name="HelloworldService"> + <implementation.java class="itest.nodes.HelloworldImpl"/> + </component> + +</composite> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/one-node-test/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/one-node-test/pom.xml new file mode 100644 index 0000000000..0eb49a19fe --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/one-node-test/pom.xml @@ -0,0 +1,48 @@ +<?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-M4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>itest-nodes-one-node-test</artifactId> + <name>Apache Tuscany SCA iTest Nodes One Node Test</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>itest-nodes-helloworld-iface</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java new file mode 100644 index 0000000000..6d49b718ef --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java @@ -0,0 +1,87 @@ +/* + * 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 java.io.File; + +import itest.nodes.Helloworld; + +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; + +/** + * This shows how to test the Calculator service component. + */ +public class OneNodeTestCase{ + + private static Node node; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled", "false"); + NodeFactory factory = NodeFactory.newInstance(); + node = factory.createNode( + new Contribution("service", getJar("../helloworld-service/target")), + new Contribution("client", getJar("../helloworld-client/target"))); + node.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 { + + // Ideally this would use the SCAClient API but leaving that tillwe have the basics working + + Helloworld service = node.getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + + Helloworld client = node.getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (node != null) { + node.stop(); + } + } +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/pom.xml new file mode 100644 index 0000000000..0ef109c44e --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/pom.xml @@ -0,0 +1,45 @@ +<?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-M4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <packaging>pom</packaging> + <artifactId>itest-nodes</artifactId> + <name>Apache Tuscany SCA iTest Nodes</name> + + <build> + <defaultGoal>install</defaultGoal> + </build> + + <modules> + <module>helloworld-iface</module> + <module>helloworld-service</module> + <module>helloworld-client</module> + <module>one-node-test</module> + <module>two-nodes-test</module> + <module>two-nodes-two-vms-test</module> + </modules> + +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/pom.xml new file mode 100644 index 0000000000..f5c6d11cda --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/pom.xml @@ -0,0 +1,58 @@ +<?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-M4-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-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-client-impl</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-ws-axis2</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java new file mode 100644 index 0000000000..5f9453a5d6 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java @@ -0,0 +1,92 @@ +/* + * 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 javax.xml.namespace.QName; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.apache.tuscany.sca.node.configuration.NodeConfiguration; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.oasisopen.sca.client.SCAClient; + +/** + * This shows how to test the Calculator service component. + */ +public class ClientNode { + private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; + private static Node clientNode; + private static TestCaseRunner runner; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + runner = new TestCaseRunner(ServiceNode.class); + runner.beforeClass(); + System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled", + "false"); + NodeFactory factory = NodeFactory.newInstance(); + NodeConfiguration conf = + factory.createNodeConfiguration().setURI("clientNode"). + addBinding(new QName(SCA11_NS, "binding.sca"), "http://localhost:8085/sca https://localhost:9085/sca") + .addBinding(new QName(SCA11_NS, "binding.ws"), "http://localhost:8086/ws") + .addContribution("client", new File("../helloworld-client/target/classes").toURI().toString()); + clientNode = factory.createNode(conf).start(); + Thread.sleep(1000); + } + + @Test + public void testCalculator() throws Exception { + + Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + } + + @Test + @Ignore("SCAClient needs to leverage the EndpointRegistry to invoke services that are not hosted on the local node") + public void testCalculatorClientAPI() throws Exception { + Helloworld service = SCAClient.getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + + Helloworld client = SCAClient.getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (clientNode != null) { + clientNode.stop(); + } + if (runner != null) { + runner.afterClass(); + } + } +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java new file mode 100644 index 0000000000..b413825106 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java @@ -0,0 +1,58 @@ +/* + * 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 java.io.File; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.apache.tuscany.sca.node.configuration.NodeConfiguration; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** + * This shows how to test the Calculator service component. + */ +public class ServiceNode { + private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; + private static Node serviceNode; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled", + "false"); + NodeFactory factory = NodeFactory.newInstance(); + NodeConfiguration conf = + factory.createNodeConfiguration().setURI("serviceNode") + .addBinding(new QName(SCA11_NS, "binding.sca"), "http://localhost:8087/sca") + .addBinding(new QName(SCA11_NS, "binding.ws"), "http://localhost:8088/ws") + .addContribution("service", new File("../helloworld-service/target/classes").toURI().toString()); + serviceNode = factory.createNode(conf).start(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (serviceNode != null) { + serviceNode.stop(); + } + } +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java new file mode 100644 index 0000000000..4a41ae8133 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java @@ -0,0 +1,102 @@ +/*
+ * 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 static org.junit.Assert.fail;
+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.Test;
+
+/**
+ * Tests using two nodes and stopping and restarting a service node.
+ */
+public class StopStartNodesTestCase {
+
+ private static Node serviceNode;
+ private static Node clientNode;
+
+ @Test
+ public void testCalculator() throws Exception {
+ 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();
+
+ 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"));
+
+ serviceNode.stop();
+
+ client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ try {
+ client.sayHello("Petra");
+ fail();
+ } catch (Exception e) {
+ // expected
+ // TODO: better exception than NPE
+ }
+
+ serviceNode = factory.createNode(new Contribution("service", getJar("../helloworld-service/target")));
+ serviceNode.start();
+
+ client = clientNode.getService(Helloworld.class, "HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ /**
+ * 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);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ if (clientNode != null) {
+ clientNode.stop();
+ }
+ }
+}
diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java new file mode 100644 index 0000000000..7dfa6e66cc --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java @@ -0,0 +1,292 @@ +/* + * 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 java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.security.AccessController; +import java.security.PrivilegedAction; + +/** + * A helper class that can be used to run an SCA JUnit test case. The test case will run in an isolated class loader. + * + * @version $Rev$ $Date$ + */ +public class TestCaseRunner { + + private ClassLoader classLoader; + private Class<?> testSuiteClass; + private Object testSuite; + private Class<?> testResultClass; + private Class<?> testCaseClass; + private Object testCase; + + private Class<?> beforeAnnotation; + private Class<?> beforeClassAnnotation; + private Class<?> afterAnnotation; + private Class<?> afterClassAnnotation; + private Class<?> junit4AdapterClass; + private Class<?> junit3TestCaseClass; + + /** + * Constructs a new TestCase runner. + * + * @param testClass + */ + public TestCaseRunner(Class<?> testClass) { + try { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + classLoader = testClass.getClassLoader(); + if (classLoader instanceof URLClassLoader) { + URL[] urls = ((URLClassLoader)classLoader).getURLs(); + classLoader = new URLClassLoader(urls, classLoader.getParent()); + } else if (classLoader == tccl || classLoader.getParent() == tccl) { + classLoader = new URLClassLoader(new URL[0], classLoader); + } else { + classLoader = tccl; + } + + try { + // Thread.currentThread().setContextClassLoader(classLoader); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finalClassLoader = classLoader; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finalClassLoader); + return null; + } + }); + + testCaseClass = Class.forName(testClass.getName(), true, classLoader); + testCase = testCaseClass.newInstance(); + ClassLoader testClassLoader = testCaseClass.getClassLoader(); + + junit3TestCaseClass = Class.forName("junit.framework.TestCase", true, testClassLoader); + + testSuiteClass = Class.forName("junit.framework.TestSuite", true, testClassLoader); + Constructor<?> testSuiteConstructor = testSuiteClass.getConstructor(Class.class); + testSuite = testSuiteConstructor.newInstance(testCaseClass); + + testResultClass = Class.forName("junit.framework.TestResult", true, testClassLoader); + + try { + beforeAnnotation = Class.forName("org.junit.Before", true, testClassLoader); + afterAnnotation = Class.forName("org.junit.After", true, testClassLoader); + beforeClassAnnotation = Class.forName("org.junit.BeforeClass", true, testClassLoader); + afterClassAnnotation = Class.forName("org.junit.AfterClass", true, testClassLoader); + junit4AdapterClass = Class.forName("junit.framework.JUnit4TestAdapter", true, testClassLoader); + } catch (Exception e) { + // Unexpected + throw new AssertionError(e); + } + } catch (Throwable e) { + e.printStackTrace(); + } finally { + // Thread.currentThread().setContextClassLoader(tccl); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finaltccl = tccl; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finaltccl); + return null; + } + }); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Run the test case + */ + public void run() { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + try { + // Thread.currentThread().setContextClassLoader(classLoader); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finalClassLoader = classLoader; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finalClassLoader); + return null; + } + }); + + if (junit3TestCaseClass.isAssignableFrom(testCaseClass)) { + Object testResult = testResultClass.newInstance(); + Method runMethod = testSuiteClass.getMethod("run", testResultClass); + runMethod.invoke(testSuite, testResult); + } else { + Object junit4Adapter = junit4AdapterClass.getConstructor(Class.class).newInstance(testCaseClass); + Object testResult = testResultClass.newInstance(); + Method runMethod = junit4AdapterClass.getMethod("run", testResultClass); + runMethod.invoke(junit4Adapter, testResult); + } + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + // Thread.currentThread().setContextClassLoader(tccl); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finaltccl = tccl; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finaltccl); + return null; + } + }); + } + } + + /** + * Invoke the setUp method + */ + public void setUp() { + execute("setUp"); + } + + /** + * Invoke the before methods + */ + public void before() { + execute(beforeAnnotation); + } + + /** + * Invoke the beforeClass methods + */ + public void beforeClass() { + execute(beforeClassAnnotation); + } + + /** + * Invoke the tearDown method + */ + public void tearDown() { + execute("tearDown"); + } + + /** + * Invoke the after methods + */ + public void after() { + execute(afterAnnotation); + } + + /** + * Invoke the afterClass methods + */ + public void afterClass() { + execute(afterClassAnnotation); + } + + /** + * Invoke the specified test method. + */ + public void run(String methodName) { + execute(methodName); + } + + /** + * Invoke the methods annotated with the specified annotation. + */ + private void execute(Class<?> annotationClass) { + if (annotationClass == null) { + throw new RuntimeException(new NoSuchMethodException()); + } + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + try { + // Thread.currentThread().setContextClassLoader(classLoader); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finalClassLoader = classLoader; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finalClassLoader); + return null; + } + }); + + for (Method method : testCaseClass.getDeclaredMethods()) { + for (Annotation annotation : method.getAnnotations()) { + if (annotation.annotationType() == annotationClass) { + method.invoke(testCase); + } + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + // Thread.currentThread().setContextClassLoader(tccl); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finaltccl = tccl; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finaltccl); + return null; + } + }); + } + } + + /** + * Invoke the specified method + */ + private void execute(String methodName) { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + try { + // Thread.currentThread().setContextClassLoader(classLoader); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finalClassLoader = classLoader; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finalClassLoader); + return null; + } + }); + Method setUpMethod = testCaseClass.getDeclaredMethod(methodName); + setUpMethod.setAccessible(true); + setUpMethod.invoke(testCase); + } catch (Exception e) { + throw new RuntimeException(e); + } finally { + // Thread.currentThread().setContextClassLoader(tccl); + // Allow privileged access to set class loader. Requires RuntimePermission + // setContextClassLoader in security policy. + final ClassLoader finaltccl = tccl; + AccessController.doPrivileged(new PrivilegedAction<Object>() { + public Object run() { + Thread.currentThread().setContextClassLoader(finaltccl); + return null; + } + }); + } + } + +} + diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java new file mode 100644 index 0000000000..769aad1940 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java @@ -0,0 +1,105 @@ +/* + * 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.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.apache.tuscany.sca.node.configuration.NodeConfiguration; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.oasisopen.sca.client.SCAClient; + +/** + * 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(); + NodeConfiguration configuration1 = + factory.createNodeConfiguration().setURI("serviceNode") + .addContribution("service", getJar("../helloworld-service/target")); + serviceNode = factory.createNode(configuration1).start(); + + NodeConfiguration configuration2 = + factory.createNodeConfiguration().setURI("clientNode") + .addContribution("client", getJar("../helloworld-client/target")); + clientNode = factory.createNode(configuration2).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 { + Helloworld service = SCAClient.getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + + Helloworld client = SCAClient.getService(Helloworld.class, "HelloworldClient"); + 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(); + } + } +} diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/build.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/build.xml new file mode 100644 index 0000000000..933aec2636 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/build.xml @@ -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. +--> +<project name="itest-samples" default="run"> + + <target name="run"> + + <parallel> + + <daemons> + <ant antfile="server.xml"/> + </daemons> + + <sequential> + <sleep seconds="4"/> + <ant antfile="client.xml"/> + </sequential> + + </parallel> + + </target> + +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client-config.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client-config.xml new file mode 100644 index 0000000000..c2aa76ef37 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client-config.xml @@ -0,0 +1,38 @@ +<?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. +--> +<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" + xmlns="http://tuscany.apache.org/xmlns/sca/1.1" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + uri="http://sample/nodes/TestNode1" + domain="http://domain1"> + + <!-- Configure the base URIs for a given binding --> + <!-- Each base URI is for a protocol supported by the binding --> + <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/> + <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/> + + <!-- Configure a list of contributions --> + <contribution uri="iface" location="../helloworld-iface/target/itest-nodes-helloworld-iface-2.0-M4-SNAPSHOT.jar"/> + <contribution uri="client" location="../helloworld-client/target/itest-nodes-helloworld-client-2.0-M4-SNAPSHOT.jar"> + <!-- doesn't pick up the deployable composite properly without this?--> + <deploymentComposite location="helloworld-client.composite"/> + </contribution> + +</node>
\ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client.xml new file mode 100644 index 0000000000..bb65805144 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client.xml @@ -0,0 +1,33 @@ +<!-- + * 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 name="server" default="run"> + + <!--echo>${runtime_classpath}</echo--> + + <target name="run"> + <java classpath="${runtime_classpath}" classname="org.apache.tuscany.sca.node.launcher.NodeMain" fork="true"> + <!--jvmarg value="-Djava.util.logging.config.file=../logging.properties"/--> + <arg value="-ttl"/> + <arg value="0"/> + <arg value="-node"/> + <arg value="./client-config.xml"/> + </java> + </target> + +</project>
\ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/pom.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/pom.xml new file mode 100644 index 0000000000..34eadae505 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/pom.xml @@ -0,0 +1,117 @@ +<?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-M4-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>itest-nodes-two-nodes-two-vms-test</artifactId> + <name>Apache Tuscany SCA iTest Nodes Two Nodes Two VMs Test</name> + + <dependencies> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-endpoint-tribes</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>itest-nodes-helloworld-iface</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-impl</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-node-launcher</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca-client-impl</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-sca-axis2-runtime</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-jetty</artifactId> + <version>2.0-M4-SNAPSHOT</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.3</version> + + <dependencies> + <dependency> + <groupId>ant</groupId> + <artifactId>ant-trax</artifactId> + <version>1.6.5</version> + </dependency> + <!-- this JDk dependency is a workaround for Maven bug - http://jira.codehaus.org/browse/MNG-1323 --> + <dependency> + <groupId>sun.jdk</groupId> + <artifactId>tools</artifactId> + <version>1.6</version> + <scope>system</scope> + <systemPath>${java.home}/../lib/tools.jar</systemPath> + </dependency> + </dependencies> + + <executions> + <execution> + <id>run-samples</id> + <phase>verify</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks> + <property name="tuscany.version" value="${version}" /> + <property name="runtime_classpath" refid="maven.runtime.classpath"/> + <ant antfile="./build.xml" target="run"/> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server-config.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server-config.xml new file mode 100644 index 0000000000..14a48f507a --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server-config.xml @@ -0,0 +1,38 @@ +<?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. +--> +<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" + xmlns="http://tuscany.apache.org/xmlns/sca/1.1" + xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" + uri="http://sample/nodes/TestNode1" + domain="http://domain1"> + + <!-- Configure the base URIs for a given binding --> + <!-- Each base URI is for a protocol supported by the binding --> + <binding name="sca:binding.sca" baseURIs="http://localhost:8081/sca https://localhost:8081/sca"/> + <binding name="sca:binding.ws" baseURIs="http://localhost:8082/ws https://localhost:8082/ws"/> + + <!-- Configure a list of contributions --> + <contribution uri="iface" location="../helloworld-iface/target/classes"/> + <contribution uri="service" location="../helloworld-service/target/classes"> + <!-- doesn't pick up the deployable composite properly without this?--> + <deploymentComposite location="helloworld-service.composite"/> + </contribution> + +</node>
\ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server.xml b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server.xml new file mode 100644 index 0000000000..7b6d206b7f --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server.xml @@ -0,0 +1,33 @@ +<!-- + * 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 name="server" default="run"> + + <!--echo>${runtime_classpath}</echo--> + + <target name="run"> + <java classpath="${runtime_classpath}" classname="org.apache.tuscany.sca.node.launcher.NodeMain" fork="true"> + <!--jvmarg value="-Djava.util.logging.config.file=../logging.properties"/--> + <!--arg value="-ttl"/> + <arg value="0"/--> + <arg value="-node"/> + <arg value="./server-config.xml"/> + </java> + </target> + +</project>
\ No newline at end of file diff --git a/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java new file mode 100644 index 0000000000..b27d16a562 --- /dev/null +++ b/sca-java-2.x/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java @@ -0,0 +1,57 @@ +/* + * 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 java.io.File; + +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; + +/** + * This shows how to test the Calculator service component. + */ +public class TwoNodesTestCase { + + private static Node serviceNode; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + NodeFactory factory = NodeFactory.newInstance(); + + serviceNode = factory.createNode(new File("server-config.xml").toURI().toURL()); + serviceNode.start(); + + } + + @Test + public void testNothing() throws Exception { + + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (serviceNode != null) { + serviceNode.stop(); + } + } +} |