From 5963a2d3d6860fe57afc138f095bf2d2eb5a7b80 Mon Sep 17 00:00:00 2001 From: lresende Date: Mon, 7 Oct 2013 22:23:21 +0000 Subject: Official Tuscany 2.0.1 Release git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1530096 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/assembly/AssemblyFactoryTestCase.java | 170 --------- .../apache/tuscany/sca/assembly/TestBinding.java | 70 ---- .../tuscany/sca/assembly/TestImplementation.java | 61 --- .../apache/tuscany/sca/assembly/TestInterface.java | 42 --- .../sca/assembly/TestInterfaceContract.java | 41 -- .../apache/tuscany/sca/assembly/TestOperation.java | 30 -- .../impl/ContractCompatibilityTestCase.java | 411 --------------------- .../impl/InterfaceContractTestCase.java | 70 ---- .../tuscany/sca/policy/PolicyFactoryTestCase.java | 73 ---- 9 files changed, 968 deletions(-) delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java delete mode 100644 sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java') diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java deleted file mode 100644 index 20fd74d46e..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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.assembly; - -import javax.xml.namespace.QName; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test building of assembly model instances using the assembly factory. - * - * @version $Rev$ $Date$ - */ -public class AssemblyFactoryTestCase { - - private static AssemblyFactory assemblyFactory; - - @BeforeClass - public static void setUp() throws Exception { - assemblyFactory = new DefaultAssemblyFactory(); - } - - @Test - public void testCreateComponent() { - createComponent("AccountServiceComponent1"); - } - - @Test - public void testCreateComponentType() { - createComponentType(); - } - - @Test - public void testCreateComposite() { - createComposite(); - } - - /** - * Create a composite - */ - Composite createComposite() { - Composite c = assemblyFactory.createComposite(); - - Component c1 = createComponent("AccountServiceComponent1"); - c.getComponents().add(c1); - Component c2 = createComponent("AccountServiceComponent2"); - c.getComponents().add(c2); - - Wire w = assemblyFactory.createWire(); - w.setSource(c1.getReferences().get(0)); - w.setTarget(c2.getServices().get(0)); - c.getWires().add(w); - - CompositeService cs = assemblyFactory.createCompositeService(); - cs.setName("AccountService"); - cs.setPromotedService(c1.getServices().get(0)); - cs.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - c.getServices().add(cs); - cs.getBindings().add(new TestBinding(assemblyFactory)); - - CompositeReference cr = assemblyFactory.createCompositeReference(); - cr.setName("StockQuoteService"); - cr.getPromotedReferences().add(c2.getReferences().get(1)); - cr.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - c.getReferences().add(cr); - cr.getBindings().add(new TestBinding(assemblyFactory)); - - return c; - } - - /** - * Create a new component - */ - Component createComponent(String name) { - Component c = assemblyFactory.createComponent(); - c.setName(name); - - Implementation i = new TestImplementation(assemblyFactory); - c.setImplementation(i); - - ComponentProperty p = assemblyFactory.createComponentProperty(); - p.setName("currency"); - p.setValue("USD"); - p.setMustSupply(true); - p.setXSDType(new QName("", "")); - p.setProperty(i.getProperties().get(0)); - c.getProperties().add(p); - - ComponentReference ref1 = assemblyFactory.createComponentReference(); - ref1.setName("accountDataService"); - ref1.setMultiplicity(Multiplicity.ONE_ONE); - ref1.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - ref1.setReference(i.getReferences().get(0)); - c.getReferences().add(ref1); - ref1.getBindings().add(new TestBinding(assemblyFactory)); - - ComponentReference ref2 = assemblyFactory.createComponentReference(); - ref2.setName("stockQuoteService"); - ref2.setMultiplicity(Multiplicity.ONE_ONE); - ref2.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - ref2.setReference(i.getReferences().get(1)); - c.getReferences().add(ref2); - ref2.getBindings().add(new TestBinding(assemblyFactory)); - - ComponentService s = assemblyFactory.createComponentService(); - s.setName("AccountService"); - s.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - s.setService(i.getServices().get(0)); - c.getServices().add(s); - s.getBindings().add(new TestBinding(assemblyFactory)); - - return c; - } - - /** - * Create a new component type - * - * @return - */ - ComponentType createComponentType() { - ComponentType ctype = assemblyFactory.createComponentType(); - - Property p = assemblyFactory.createProperty(); - p.setName("currency"); - p.setValue("USD"); - p.setMustSupply(true); - p.setXSDType(new QName("", "")); - ctype.getProperties().add(p); - - Reference ref1 = assemblyFactory.createReference(); - ref1.setName("accountDataService"); - ref1.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - ref1.setMultiplicity(Multiplicity.ONE_ONE); - ctype.getReferences().add(ref1); - ref1.getBindings().add(new TestBinding(assemblyFactory)); - - Reference ref2 = assemblyFactory.createReference(); - ref2.setName("stockQuoteService"); - ref2.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - ref2.setMultiplicity(Multiplicity.ONE_ONE); - ctype.getReferences().add(ref2); - ref2.getBindings().add(new TestBinding(assemblyFactory)); - - Service s = assemblyFactory.createService(); - s.setName("AccountService"); - s.setInterfaceContract(new TestInterfaceContract(assemblyFactory)); - ctype.getServices().add(s); - s.getBindings().add(new TestBinding(assemblyFactory)); - - return ctype; - } - -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java deleted file mode 100644 index a09f7af06c..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.assembly; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.impl.BindingImpl; - -/** - * A test interface model. - * - * @version $Rev$ $Date$ - */ -public class TestBinding extends BindingImpl implements Binding { - private final static QName TYPE = new QName("http://test", "binding.test"); - - public TestBinding(AssemblyFactory factory) { - super(TYPE); - } - - public String getName() { - return null; - } - - public String getURI() { - return "http://test"; - } - - public boolean isUnresolved() { - return false; - } - - public WireFormat getRequestWireFormat() { - return null; - } - - public void setRequestWireFormat(WireFormat wireFormat) { - } - - public WireFormat getResponseWireFormat() { - return null; - } - - public void setResponseWireFormat(WireFormat wireFormat) { - } - - public OperationSelector getOperationSelector() { - return null; - } - - public void setOperationSelector(OperationSelector operationSelector) { - } - -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java deleted file mode 100644 index 6777c33ff1..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.assembly; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; - -/** - * A test component implementation model. - * - * @version $Rev$ $Date$ - */ -public class TestImplementation extends ImplementationImpl implements Implementation { - public TestImplementation(AssemblyFactory factory) { - super(new QName("http://test", "implementation.test")); - Property p = factory.createProperty(); - p.setName("currency"); - p.setValue("USD"); - p.setMustSupply(true); - p.setXSDType(new QName("", "")); - getProperties().add(p); - - Reference ref1 = factory.createReference(); - ref1.setName("accountDataService"); - ref1.setMultiplicity(Multiplicity.ONE_ONE); - getReferences().add(ref1); - ref1.getBindings().add(new TestBinding(factory)); - - Reference ref2 = factory.createReference(); - ref2.setName("stockQuoteService"); - ref2.setMultiplicity(Multiplicity.ONE_ONE); - ref2.setInterfaceContract(new TestInterfaceContract(factory)); - getReferences().add(ref2); - ref2.getBindings().add(new TestBinding(factory)); - - Service s = factory.createService(); - s.setName("AccountService"); - s.setInterfaceContract(new TestInterfaceContract(factory)); - getServices().add(s); - s.getBindings().add(new TestBinding(factory)); - - } - -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java deleted file mode 100644 index dbe0cb8225..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.assembly; - -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl; - -/** - * A test interface model. - * - * @version $Rev$ $Date$ - */ -public class TestInterface extends InterfaceImpl implements Interface { - - public TestInterface(AssemblyFactory factory) { - - setRemotable(true); - - Operation operation = new TestOperation(); - operation.setName("test"); - getOperations().add(operation); - - } - -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java deleted file mode 100644 index 24be8a3e7d..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.assembly; - -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl; - -/** - * A test interface contract model. - * - * @version $Rev$ $Date$ - */ -public class TestInterfaceContract extends InterfaceContractImpl implements InterfaceContract { - - public TestInterfaceContract(AssemblyFactory factory) { - - TestInterface testInterface = new TestInterface(factory); - setInterface(testInterface); - - TestInterface testCallbackInterface = new TestInterface(factory); - setCallbackInterface(testCallbackInterface); - - } - -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java deleted file mode 100644 index d94a7e93a3..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.assembly; - -import org.apache.tuscany.sca.interfacedef.impl.OperationImpl; - -/** - * A test operation model. - * - * @version $Rev$ $Date$ - */ -public class TestOperation extends OperationImpl { - -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java deleted file mode 100644 index 8d945038bf..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java +++ /dev/null @@ -1,411 +0,0 @@ -/* - * 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.interfacedef.impl; - -import static org.junit.Assert.fail; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.interfacedef.Compatibility; -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.junit.Before; -import org.junit.Test; - -/** - * TODO some tests commented out due to DataType.equals() needing to be strict - * - * @version $Rev$ $Date$ - */ -public class ContractCompatibilityTestCase { - - private InterfaceContractMapper mapper; - - @Before - public void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - mapper = utilities.getUtility(InterfaceContractMapper.class); - } - - @Test - public void testNoOperation() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - InterfaceContract target = new MockContract("FooContract"); - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - } - - @Test - public void testBasic() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - Operation opSource1 = newOperation("op1"); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - InterfaceContract target = new MockContract("FooContract"); - Operation opSource2 = newOperation("op1"); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opSource2); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - } - - @Test - public void testBasicIncompatibleOperationNames() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - Operation opSource1 = newOperation("op1"); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - InterfaceContract target = new MockContract("FooContract"); - Operation opSource2 = newOperation("op2"); - Map targetOperations = new HashMap(); - targetOperations.put("op2", opSource2); - target.getInterface().getOperations().addAll(targetOperations.values()); - try { - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - fail(); - } catch (IncompatibleInterfaceContractException e) { - // expected - } - } - - @Test - public void testInputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - List sourceInputTypes = new ArrayList(); - sourceInputTypes.add(new DataTypeImpl(Object.class, Object.class)); - DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); - Operation opSource1 = newOperation("op1"); - opSource1.setInputType(inputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - List targetInputTypes = new ArrayList(); - targetInputTypes.add(new DataTypeImpl(Object.class, Object.class)); - DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); - - Operation opTarget = newOperation("op1"); - opTarget.setInputType(targetInputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - } - - @Test - public void testIncompatibleInputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - List sourceInputTypes = new ArrayList(); - sourceInputTypes.add(new DataTypeImpl(Integer.class, Integer.class)); - DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); - Operation opSource1 = newOperation("op1"); - opSource1.setInputType(inputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - List targetInputTypes = new ArrayList(); - targetInputTypes.add(new DataTypeImpl(String.class, String.class)); - DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); - - Operation opTarget = newOperation("op1"); - opTarget.setInputType(targetInputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - try { - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - fail(); - } catch (IncompatibleInterfaceContractException e) { - // expected - } - } - - /** - * Verifies source input types can be super types of the target - */ - @Test - public void testSourceSuperTypeInputCompatibility() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // List sourceInputTypes = new ArrayList(); - // sourceInputTypes.add(new DataTypeImpl(Object.class, - // Object.class)); - // DataType> inputType = new - // DataTypeImpl>(String.class, sourceInputTypes); - // Operation opSource1 = newOperationImpl("op1", inputType, null, null, - // false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // List targetInputTypes = new ArrayList(); - // targetInputTypes.add(new DataTypeImpl(String.class, - // String.class)); - // DataType> targetInputType = - // new DataTypeImpl>(String.class, targetInputTypes); - // - // Operation opTarget = newOperationImpl("op1", targetInputType, null, - // null, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - @Test - public void testOutputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceStringType = new DataTypeImpl(String.class, String.class); - ArrayList sourceTypes = new ArrayList(); - sourceTypes.add(sourceStringType); - DataType sourceOutputType = new DataTypeImpl(Object[].class, sourceTypes); - Operation opSource1 = newOperation("op1"); - opSource1.setOutputType(sourceOutputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - DataType stringType = new DataTypeImpl(String.class, String.class); - ArrayList types = new ArrayList(); - types.add(stringType); - DataType targetOutputType = new DataTypeImpl(Object[].class, types); - Operation opTarget = newOperation("op1"); - opTarget.setOutputType(targetOutputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - } - - /** - * Verifies a return type that is a supertype of of the target is compatible - */ - @Test - public void testSupertypeOutputTypes() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // DataType sourceOutputType = new DataTypeImpl(Object.class, - // Object.class); - // Operation opSource1 = newOperationImpl("op1", null, - // sourceOutputType, null, false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // DataType targetOutputType = new DataTypeImpl(String.class, - // String.class); - // Operation opTarget = newOperationImpl("op1", null, targetOutputType, - // null, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - @Test - public void testIncompatibleOutputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceType = new DataTypeImpl(String.class, String.class); - ArrayList sourceTypes = new ArrayList(); - sourceTypes.add(sourceType); - DataType sourceOutputType = new DataTypeImpl(Object[].class, sourceTypes); - Operation opSource1 = newOperation("op1"); - opSource1.setOutputType(sourceOutputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - DataType targetType = new DataTypeImpl(Integer.class, Integer.class); - ArrayList targetTypes = new ArrayList(); - targetTypes.add(targetType); - DataType targetOutputType = new DataTypeImpl(Object[].class, targetTypes); - Operation opTarget = newOperation("op1"); - opTarget.setOutputType(targetOutputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - try { - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - fail(); - } catch (IncompatibleInterfaceContractException e) { - // expected - } - } - - @Test - public void testFaultTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceFaultType = new DataTypeImpl(String.class, String.class); - List sourceFaultTypes = new ArrayList(); - sourceFaultTypes.add(0, sourceFaultType); - Operation opSource1 = newOperation("op1"); - opSource1.setFaultTypes(sourceFaultTypes); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - DataType targetFaultType = new DataTypeImpl(String.class, String.class); - List targetFaultTypes = new ArrayList(); - targetFaultTypes.add(0, targetFaultType); - - Operation opTarget = newOperation("op1"); - opTarget.setFaultTypes(targetFaultTypes); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - } - - @Test - public void testSourceFaultTargetNoFaultCompatibility() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceFaultType = new DataTypeImpl(String.class, String.class); - List sourceFaultTypes = new ArrayList(); - sourceFaultTypes.add(0, sourceFaultType); - Operation opSource1 = newOperation("op1"); - opSource1.setFaultTypes(sourceFaultTypes); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - Operation opTarget = newOperation("op1"); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false); - } - - /** - * Verifies a source's fault which is a supertype of the target's fault are - * compatible - * - * @throws Exception - */ - @Test - public void testFaultSuperTypes() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // DataType sourceFaultType = new DataTypeImpl(Exception.class, - // Exception.class); - // List sourceFaultTypes = new ArrayList(); - // sourceFaultTypes.add(0, sourceFaultType); - // Operation opSource1 = newOperationImpl("op1", null, null, - // sourceFaultTypes, false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // DataType targetFaultType = new - // DataTypeImpl(TuscanyException.class, TuscanyException.class); - // List targetFaultTypes = new ArrayList(); - // targetFaultTypes.add(0, targetFaultType); - // - // Operation opTarget = newOperationImpl("op1", null, null, - // targetFaultTypes, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - /** - * Verifies a source's faults which are supertypes and a superset of the - * target's faults are compatible - */ - @Test - public void testFaultSuperTypesAndSuperset() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // DataType sourceFaultType = new DataTypeImpl(Exception.class, - // Exception.class); - // DataType sourceFaultType2 = new - // DataTypeImpl(RuntimeException.class, RuntimeException.class); - // List sourceFaultTypes = new ArrayList(); - // sourceFaultTypes.add(0, sourceFaultType); - // sourceFaultTypes.add(1, sourceFaultType2); - // Operation opSource1 = newOperationImpl("op1", null, null, - // sourceFaultTypes, false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // DataType targetFaultType = new - // DataTypeImpl(TuscanyException.class, TuscanyException.class); - // List targetFaultTypes = new ArrayList(); - // targetFaultTypes.add(0, targetFaultType); - // - // Operation opTarget = newOperationImpl("op1", null, null, - // targetFaultTypes, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - private static class MockInterface extends InterfaceImpl { - - } - - private class MockContract extends InterfaceContractImpl { - public MockContract() { - } - - public MockContract(String interfaceClass) { - Interface jInterface = new MockInterface(); - setInterface(jInterface); - } - } - - private static Operation newOperation(String name) { - Operation operation = new OperationImpl(); - operation.setName(name); - ArrayList outputTypes = new ArrayList(); - outputTypes.add(new DataTypeImpl(Object.class, Object.class)); - operation.setOutputType(new DataTypeImpl(Object[].class, outputTypes)); - return operation; - } -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java deleted file mode 100644 index d1faa5cf2b..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.interfacedef.impl; - - -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @version $Rev$ $Date$ - */ -public class InterfaceContractTestCase { - private InterfaceContract contract; - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - contract = new MockInterfaceContract(); - Interface i1 = new MockInterface(); - contract.setInterface(i1); - Operation op1 = newOperation("op1"); - i1.getOperations().add(op1); - Interface i2 = new MockInterface(); - contract.setCallbackInterface(i2); - Operation callbackOp1 = newOperation("callbackOp1"); - i2.getOperations().add(callbackOp1); - } - - @Test - public void testClone() throws Exception { - InterfaceContract copy = (InterfaceContract) contract.clone(); - Assert.assertNotNull(copy); - Assert.assertNotSame(copy.getCallbackInterface(), contract.getCallbackInterface()); - Assert.assertNotSame(copy.getInterface(), contract.getInterface()); - } - - private static class MockInterfaceContract extends InterfaceContractImpl implements InterfaceContract { - } - - private static class MockInterface extends InterfaceImpl implements Interface { - } - - private static Operation newOperation(String name) { - Operation operation = new OperationImpl(); - operation.setName(name); - return operation; - } -} diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java deleted file mode 100644 index 569366ad1b..0000000000 --- a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.policy; - -import static org.junit.Assert.assertEquals; - -import javax.xml.namespace.QName; - -import org.junit.Before; -import org.junit.Test; - -/** - * Test building of policy model instances using the policy factory. - * - * @version $Rev$ $Date$ - */ -public class PolicyFactoryTestCase { - - PolicyFactory factory; - - @Before - public void setUp() throws Exception { - factory = new DefaultPolicyFactory(); - } - - @Test - public void testCreateIntent() { - Intent intent = factory.createIntent(); - intent.setName(new QName("http://test", "reliability")); - assertEquals(intent.getName(), new QName("http://test", "reliability")); - } - - @Test - public void testCreatePolicySet() { - PolicySet policySet = factory.createPolicySet(); - policySet.setName(new QName("http://test", "reliability")); - assertEquals(policySet.getName(), new QName("http://test", "reliability")); - } - - @Test - public void testCreateExternalAttachment() { - ExternalAttachment attachment = factory.createExternalAttachment(); - attachment.setAttachTo("sca:component"); - - Intent intent = factory.createIntent(); - intent.setName(new QName("http://test", "reliability")); - attachment.getIntents().add(intent); - - PolicySet policySet = factory.createPolicySet(); - policySet.setName(new QName("http://test", "reliability")); - attachment.getPolicySets().add(policySet); - - assertEquals("sca:component", attachment.getAttachTo()); - assertEquals(intent, attachment.getIntents().get(0)); - assertEquals(policySet, attachment.getPolicySets().get(0)); - } -} -- cgit v1.2.3