diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-22 09:11:51 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-22 09:11:51 +0000 |
commit | 0d7533759f027a0fafc5844210ddf4e35122c758 (patch) | |
tree | cd7e7bedbd53b9e04541ea6ba48a5b44a5460e6d /sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test | |
parent | 40e207beb6ed5c979bdedc71ebc735ba9295ecfe (diff) |
Create branch for next release
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@966547 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test')
14 files changed, 683 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/itest/nodes/Helloworld.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/itest/nodes/Helloworld.java new file mode 100644 index 0000000000..76f8d4400d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/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/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java new file mode 100644 index 0000000000..0a5d99ae7c --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java @@ -0,0 +1,84 @@ +/* + * 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.domain.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.After; +import org.junit.Ignore; +import org.junit.Test; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * This shows how to test the Calculator service component. + */ +@Ignore("TUSCANY-3391") +public class GetServiceTestCase{ + + private static DomainNode clientNode; + private static DomainNode serviceNode; + + @Test + public void testTwoNodesSameDomain() throws Exception { + serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"); + clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"); + + 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 testTwoNodesDifferentDomains() throws Exception { + serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"}); + Helloworld service = serviceNode.getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + + clientNode = new DomainNode("vm://barDomain", new String[] {"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"}); + Helloworld client = clientNode.getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + + try { + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + fail(); + } catch (ServiceRuntimeException e) { + // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException? + // expected + } + } + + @After + public void tearDownAfterClass() throws Exception { + if (clientNode != null) { + clientNode.stop(); + } + if (serviceNode != null) { + serviceNode.stop(); + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java new file mode 100644 index 0000000000..617876586b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.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 org.apache.tuscany.sca.domain.node; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import itest.nodes.Helloworld; + +import java.net.URI; + +import org.junit.After; +import org.junit.Ignore; +import org.junit.Test; +import org.oasisopen.sca.ServiceRuntimeException; +import org.oasisopen.sca.client.SCAClientFactory; + +/** + * This shows how to test the Calculator service component. + */ +@Ignore("TUSCANY-3391") +public class MultipleNodesPerJVMTestCase{ + + private static DomainNode clientNode; + private static DomainNode serviceNode; + + @Test + public void testTwoNodesSameDomain() throws Exception { + serviceNode = new DomainNode("target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"); + clientNode = new DomainNode("target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"); + + Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + + Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + } + + @Test + public void testTwoNodesDifferentDomains() throws Exception { + serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"}); + Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + + clientNode = new DomainNode("vm://barDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"}); + Helloworld client = SCAClientFactory.newInstance(URI.create("vm://barDomain")).getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + + try { + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + fail(); + } catch (ServiceRuntimeException e) { + // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException? + // expected + } + } + + @After + public void tearDownAfterClass() throws Exception { + if (clientNode != null) { + clientNode.stop(); + } + if (serviceNode != null) { + serviceNode.stop(); + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java new file mode 100644 index 0000000000..10803cd880 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.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 org.apache.tuscany.sca.domain.node; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import itest.nodes.Helloworld; + +import java.net.URI; + +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.NoSuchServiceException; +import org.oasisopen.sca.client.SCAClientFactory; + +/** + * This shows how to test the Calculator service component. + */ +@Ignore("TUSCANY-3391") +public class OneNodeTestCase{ + + private static DomainNode domain; + private static String serviceContributionUri; + + @Before + public 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 testService() throws Exception { + Helloworld service = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + } + + @Test + public void testClient() throws Exception { + Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + } + + @Test + public void testRemovingServiceContribution() throws Exception { + domain.removeContribution(serviceContributionUri); + try { + SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldService"); + // FIXME: should this be NoSuchServiceException or ServiceNotFoundException? + } catch (NoSuchServiceException e) { + // expected + } + + Helloworld client = SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + try { + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + fail(); + } catch (Exception e) { + // FIXME: this gives an NPE, would be better to be something like ServiceNotFoundException + // expected + } + } + + @Test + public void testStoppingDomainNode() throws Exception { + domain.stop(); + try { + SCAClientFactory.newInstance(URI.create("vm://defaultDomain")).getService(Helloworld.class, "HelloworldClient"); + fail(); + } catch (NoSuchDomainException e) { + // expected + } + } + + @After + public void tearDownAfterClass() throws Exception { + if (domain != null) { + domain.stop(); + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java new file mode 100644 index 0000000000..4a29822069 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java @@ -0,0 +1,82 @@ +/* + * 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.domain.node; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import itest.nodes.Helloworld; + +import java.net.URI; + +import org.junit.After; +import org.junit.Ignore; +import org.junit.Test; +import org.oasisopen.sca.client.SCAClientFactory; + +/** + * This shows how to test the Calculator service component. + */ +@Ignore("TUSCANY-3391") +public class StopStartNodesTestCase{ + + private static DomainNode clientNode; + private static DomainNode serviceNode; + + @Test + public void testTwoNodesSameDomain() throws Exception { + serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"}); + clientNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar"}); + + Helloworld service = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldService"); + assertNotNull(service); + assertEquals("Hello Petra", service.sayHello("Petra")); + + Helloworld client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + + serviceNode.stop(); + + client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + try { + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + fail(); + } catch (Exception e) { + // expected + } + + serviceNode = new DomainNode("vm://fooDomain", new String[]{"target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar"}); + client = SCAClientFactory.newInstance(URI.create("vm://fooDomain")).getService(Helloworld.class, "HelloworldClient"); + assertNotNull(client); + assertEquals("Hi Hello Petra", client.sayHello("Petra")); + } + + @After + public void tearDownAfterClass() throws Exception { + if (clientNode != null) { + clientNode.stop(); + } + if (serviceNode != null) { + serviceNode.stop(); + } + } +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java new file mode 100644 index 0000000000..450e5a8b3e --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/DeployerTestCase.java @@ -0,0 +1,77 @@ +/* + * 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.node2; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URI; +import java.util.List; + +import javax.xml.stream.XMLStreamException; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.deployment.Deployer; +import org.apache.tuscany.sca.monitor.Monitor; +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 DeployerTestCase { + + @Test + public void testInstalledContribution() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException { + NodeFactory nodeFactory = NodeFactory.newInstance(); + Node node = nodeFactory.createNode("myDomain"); + + Deployer deployer = nodeFactory.getDeployer(); + Monitor monitor = deployer.createMonitor(); + Contribution contribution = deployer.loadContribution(URI.create("foo"), new File("src/test/resources/sample-helloworld-nodeployable.jar").toURI().toURL(), monitor); + monitor.analyzeProblems(); + + node.installContribution(contribution, null, true); + List<String> ics = node.getInstalledContributions(); + Assert.assertEquals(1, ics.size()); + Assert.assertEquals("foo", ics.get(0)); + } + + @Test + public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException, MalformedURLException, XMLStreamException { + NodeFactory nodeFactory = NodeFactory.newInstance(); + Node node = nodeFactory.createNode("myDomain"); + + node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true); + + Deployer deployer = nodeFactory.getDeployer(); + Monitor monitor = deployer.createMonitor(); + Composite composite = deployer.loadXMLDocument(new File("src/test/resources/helloworld2.composite").toURI().toURL(), monitor); + monitor.analyzeProblems(); + composite.setURI("helloworld2.composite"); + node.addDeploymentComposite("foo", composite); + List<String> dcs = node.getDeployedCompostes("foo"); + Assert.assertEquals(1, dcs.size()); + Assert.assertEquals("helloworld2.composite", dcs.get(0)); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java new file mode 100644 index 0000000000..d82287926b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/org/apache/tuscany/sca/node2/NodeTestCase.java @@ -0,0 +1,143 @@ +/* + * 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.node2; + +import java.net.MalformedURLException; +import java.util.List; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.monitor.ValidationException; +import org.apache.tuscany.sca.node2.Node; +import org.apache.tuscany.sca.node2.NodeFactory; +import org.apache.tuscany.sca.node2.impl.NodeImpl; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.junit.Ignore; +import org.junit.Test; +import org.oasisopen.sca.NoSuchDomainException; +import org.oasisopen.sca.NoSuchServiceException; + +public class NodeTestCase { + + @Test + public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + node.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true); + +// Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); +// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + } + + @Ignore("TODO: fails with Sun JDK due to SCA properties issue") + @Test + public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + node.installContribution("store", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar", null, null, true); + node.installContribution("store-client", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar", null, null, true); + +// Helloworld helloworldService = node.getService(Helloworld.class, "HelloworldComponent"); +// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + } + + @Test + public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + node.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true); + +// SCAClientFactory scaClientFactory = node.getSCAClientFactory(); +// try { +// scaClientFactory.getService(Helloworld.class, "HelloworldComponent"); +// Assert.fail(); +// } catch (NoSuchServiceException e) { +// // expected as there is no deployables +// } + + node.addToDomainLevelComposite("helloworld" + "/helloworld.composite"); +// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent"); +// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + } + + @Test + public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + node.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar", null, null, true); + List<String> ics = node.getInstalledContributions(); + Assert.assertEquals(1, ics.size()); + Assert.assertEquals("foo", ics.get(0)); + } + + @Test + public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true); + List<String> dcs = node.getDeployedCompostes("foo"); + Assert.assertEquals(1, dcs.size()); + Assert.assertEquals("helloworld.composite", dcs.get(0)); + } + + @Test + public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, MalformedURLException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + node.installContribution("foo", "src/test/resources/sample-helloworld.jar", null, null, true); + node.removeFromDomainLevelComposite("foo/helloworld.composite"); + List<String> dcs = node.getDeployedCompostes("foo"); + Assert.assertEquals(0, dcs.size()); + } + + @Test + public void testInstallWithMetaData() throws ContributionReadException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + ((NodeImpl)node).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar", "src/test/resources/sca-contribution-generated.xml", null, true); + + List<String> dcs = node.getDeployedCompostes("helloworld"); + Assert.assertEquals(1, dcs.size()); + Assert.assertEquals("helloworld.composite", dcs.get(0)); + +// Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent"); +// Assert.assertEquals("Hello petra", helloworldService.sayHello("petra")); + } + + @Test + public void testURI() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException { + Node node = NodeFactory.newInstance().createNode("default"); + String uri = node.installContribution("src/test/resources/sample-helloworld.jar"); + Assert.assertEquals("sample-helloworld", uri); + } + + @Test + public void testStaticCreate() { + Node node = NodeFactory.createNode("helloworld.composite", "src/test/resources/sample-helloworld.jar"); + List<String> cs = node.getInstalledContributions(); + Assert.assertEquals(1, cs.size()); + List<String> dcs = node.getDeployedCompostes(cs.get(0)); + Assert.assertEquals(1, dcs.size()); + Assert.assertEquals("helloworld.composite", dcs.get(0)); + } + + @Test + public void testStaticCreateWithNullComposite() { + Node node = NodeFactory.createNode(null, "src/test/resources/sample-helloworld.jar"); + List<String> cs = node.getInstalledContributions(); + Assert.assertEquals(1, cs.size()); + List<String> dcs = node.getDeployedCompostes(cs.get(0)); + Assert.assertEquals(1, dcs.size()); + Assert.assertEquals("helloworld.composite", dcs.get(0)); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/sample/Helloworld.java b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/sample/Helloworld.java new file mode 100644 index 0000000000..ea65a1e58c --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/java/sample/Helloworld.java @@ -0,0 +1,24 @@ +/* + * 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 sample; + +public interface Helloworld { + String sayHello(String name); +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/helloworld2.composite b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/helloworld2.composite new file mode 100644 index 0000000000..8c7a789380 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/helloworld2.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/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://sample"
+ name="helloworld2">
+
+ <component name="Helloworld2Component">
+ <implementation.java class="sample.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar Binary files differnew file mode 100644 index 0000000000..3e9ae79a41 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar Binary files differnew file mode 100644 index 0000000000..40333cab75 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar Binary files differnew file mode 100644 index 0000000000..16dde03858 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sample-helloworld-nodeployable.jar diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sample-helloworld.jar b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sample-helloworld.jar Binary files differnew file mode 100644 index 0000000000..50e732d50b --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sample-helloworld.jar diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sca-contribution-generated.xml b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sca-contribution-generated.xml new file mode 100644 index 0000000000..8e20561dc3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta1/modules/domain-node/src/test/resources/sca-contribution-generated.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/200912" + xmlns:sample="http://sample"> + <deployable composite="sample:helloworld"/> +</contribution> |