From cbca5042b962fc23f91d4b0adf10e56068870c7a Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 14 Sep 2009 10:30:56 +0000 Subject: Tests for the scdl module, read in a composite or contribution and verifies the models are created correctly. Also verifies the dependencies required to run are as expected and the runtime modules arent required git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@814566 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/itest/scdl/pom.xml | 59 ++++++++++++++++ .../sca/itest/scdl/ContributionTestCase.java | 70 +++++++++++++++++++ .../tuscany/sca/itest/scdl/SCDLTestCase.java | 81 ++++++++++++++++++++++ .../itest/scdl/ValidateDependenciesTestCase.java | 74 ++++++++++++++++++++ .../itest/scdl/src/test/resources/test.composite | 51 ++++++++++++++ 5 files changed, 335 insertions(+) create mode 100644 java/sca/itest/scdl/pom.xml create mode 100644 java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java create mode 100644 java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java create mode 100644 java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java create mode 100644 java/sca/itest/scdl/src/test/resources/test.composite (limited to 'java/sca') diff --git a/java/sca/itest/scdl/pom.xml b/java/sca/itest/scdl/pom.xml new file mode 100644 index 0000000000..2ed073493f --- /dev/null +++ b/java/sca/itest/scdl/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-SNAPSHOT + ../pom.xml + + + itest-scdl + Apache Tuscany SCA iTest SCDL + + + + org.apache.tuscany.sca + tuscany-scdl + 2.0-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + compile + + copy-dependencies + + + + + + + + diff --git a/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java new file mode 100644 index 0000000000..22370f4e39 --- /dev/null +++ b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java @@ -0,0 +1,70 @@ +/* + * 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.itest.scdl; + +import java.util.List; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.implementation.java.JavaImplementation; +import org.apache.tuscany.sca.scdl.SCDLUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Test case for reading and writing SCDL + */ +public class ContributionTestCase { + + @Test + public void testRead() throws Exception { + Contribution contribution = SCDLUtils.readContribution("../../samples/calculator/target/sample-calculator.jar"); + + // Ferkle around in the contribution verifying it looks as expected + Assert.assertNotNull(contribution); + List deployables = contribution.getDeployables(); + Assert.assertEquals(1, deployables.size()); + Composite calculatorComposte = deployables.get(0); + Assert.assertEquals("Calculator", calculatorComposte.getName().getLocalPart()); + Assert.assertEquals(5, calculatorComposte.getComponents().size()); + Component calcComp = calculatorComposte.getComponent("CalculatorServiceComponent"); + Assert.assertNotNull(calcComp); + Assert.assertEquals(4, calcComp.getReferences().size()); + Reference ref = calcComp.getReference("addService"); + Assert.assertEquals("AddServiceComponent", ref.getTargets().get(0).getName()); + Implementation impl = calcComp.getImplementation(); + Assert.assertTrue(impl instanceof JavaImplementation); + Assert.assertEquals("calculator.CalculatorServiceImpl", ((JavaImplementation)impl).getJavaClass().getName()); + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } +} diff --git a/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java new file mode 100644 index 0000000000..a21de6f819 --- /dev/null +++ b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java @@ -0,0 +1,81 @@ +/* + * 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.itest.scdl; + +import java.io.InputStream; + +import javax.xml.stream.XMLStreamException; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.binding.jms.JMSBinding; +import org.apache.tuscany.sca.binding.jsonp.JSONPBinding; +import org.apache.tuscany.sca.binding.rmi.RMIBinding; +import org.apache.tuscany.sca.contribution.processor.ContributionReadException; +import org.apache.tuscany.sca.scdl.SCDLUtils; +import org.junit.Test; + +/** + * Test case for reading and writing a composite + */ +public class SCDLTestCase { + + @Test + public void testRead() throws ContributionReadException, XMLStreamException { + InputStream r = getClass().getClassLoader().getResourceAsStream("test.composite"); + Composite composite = SCDLUtils.readComposite(r); + Assert.assertNotNull(composite); + + Component JavaComp = composite.getComponent("JavaComponent"); + Assert.assertNotNull(JavaComp); + + Component bpelComp = composite.getComponent("BPELComponent"); + Assert.assertNotNull(bpelComp); + + Service jsonpService = composite.getService("JSONPService"); + Assert.assertNotNull(jsonpService); + Assert.assertEquals(1, jsonpService.getBindings().size()); + JSONPBinding jsonpBinding = jsonpService.getBinding(JSONPBinding.class); + Assert.assertNotNull(jsonpBinding); + + Service jmsService = composite.getService("JMSService"); + Assert.assertNotNull(jmsService); + Assert.assertEquals(1, jmsService.getBindings().size()); + JMSBinding jmsBinding = jmsService.getBinding(JMSBinding.class); + Assert.assertNotNull(jmsBinding); + + Service rmiService = composite.getService("RMIService"); + Assert.assertNotNull(rmiService); + Assert.assertEquals(1, rmiService.getBindings().size()); + RMIBinding rmiBinding = rmiService.getBinding(RMIBinding.class); + Assert.assertNotNull(rmiBinding); + +// TODO: WS binding drags in entire runtime +// Service wsService = composite.getService("WSService"); +// Assert.assertNotNull(wsService); +// Assert.assertEquals(1, wsService.getBindings().size()); +// WSBinding wsBinding = wsService.getBinding(WSBinding.class); +// Assert.assertNotNull(wsBinding); + } + +} diff --git a/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java new file mode 100644 index 0000000000..773248e3fc --- /dev/null +++ b/java/sca/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java @@ -0,0 +1,74 @@ +/* + * 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.itest.scdl; + +import java.io.File; + +import junit.framework.Assert; + +import org.junit.Test; + +/** + * Test case for verifying only SCDL jars are needed + * + * Uses maven-dependency-plugin config in the pom.xml + * + * Current required jars are: + * geronimo-stax-api_1.0_spec-1.0.1.jar + * jsr181-api-1.0-MR1.jar + * junit-4.5.jar + * tuscany-assembly-2.0-SNAPSHOT.jar + * tuscany-assembly-xml-2.0-SNAPSHOT.jar + * tuscany-assembly-xsd-2.0-SNAPSHOT.jar + * tuscany-binding-jms-2.0-SNAPSHOT.jar + * tuscany-binding-jsonp-2.0-SNAPSHOT.jar + * tuscany-binding-rmi-2.0-SNAPSHOT.jar + * tuscany-common-java-2.0-SNAPSHOT.jar + * tuscany-common-xml-2.0-SNAPSHOT.jar + * tuscany-contribution-2.0-SNAPSHOT.jar + * tuscany-definitions-xml-2.0-SNAPSHOT.jar + * tuscany-extensibility-2.0-SNAPSHOT.jar + * tuscany-implementation-bpel-2.0-SNAPSHOT.jar + * tuscany-implementation-java-2.0-SNAPSHOT.jar + * tuscany-interface-java-2.0-SNAPSHOT.jar + * tuscany-interface-wsdl-2.0-SNAPSHOT.jar + * tuscany-monitor-2.0-SNAPSHOT.jar + * tuscany-policy-xml-2.0-SNAPSHOT.jar + * tuscany-sca-api-2.0-SNAPSHOT.jar + * tuscany-scdl-2.0-SNAPSHOT.jar + * tuscany-xsd-2.0-SNAPSHOT.jar + * wsdl4j-1.6.2.jar + * wstx-asl-3.2.4.jar + * XmlSchema-1.4.2.jar + * + * TODO: WS binding drags in all runtime + */ +public class ValidateDependenciesTestCase { + + @Test + public void countDependencies() { + + File dependenciesDir = new File("target/dependency"); + Assert.assertTrue(dependenciesDir.exists()); + + File[] dependencyFiles = dependenciesDir.listFiles(); + Assert.assertEquals(26, dependencyFiles.length); + } +} diff --git a/java/sca/itest/scdl/src/test/resources/test.composite b/java/sca/itest/scdl/src/test/resources/test.composite new file mode 100644 index 0000000000..aa11c0d092 --- /dev/null +++ b/java/sca/itest/scdl/src/test/resources/test.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3