You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/03/14 00:43:32 UTC
svn commit: r517938 - in
/incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly:
./ model/ model/AssemblyFactoryTestCase.java model/TestImplementation.java
Author: jsdelfino
Date: Tue Mar 13 16:43:31 2007
New Revision: 517938
URL: http://svn.apache.org/viewvc?view=rev&rev=517938
Log:
Added tests of the assembly factory
Added:
incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/
incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/
incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java (with props)
incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java (with props)
Added: incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java?view=auto&rev=517938
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java Tue Mar 13 16:43:31 2007
@@ -0,0 +1,212 @@
+/*
+ * 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.assembly.model;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.assembly.model.impl.AssemblyFactoryImpl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test building of assembly model instances using the assembly factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyFactoryTestCase {
+
+ AssemblyFactory factory;
+
+ @Before
+ public void setUpBefore() throws Exception {
+ factory = new AssemblyFactoryImpl();
+ }
+
+ @After
+ public void tearDownAfter() throws Exception {
+ factory = null;
+ }
+
+ @Test
+ public void testCreateComponent() {
+ createComponent("AccountServiceComponent1");
+ }
+
+ @Test
+ public void testCreateComponentType() {
+ createComponentType();
+ }
+
+ @Test
+ public void testCreateComposite() {
+ createComposite();
+ }
+
+ @Test
+ public void testCreateConstrainingType() {
+ createConstrainingType();
+ }
+
+ /**
+ * Create a composite
+ */
+ Composite createComposite() {
+ Composite c = factory.createComposite();
+
+ Component c1 = createComponent("AccountServiceComponent1");
+ c.getComponents().add(c1);
+ Component c2 = createComponent("AccountServiceComponent2");
+ c.getComponents().add(c2);
+
+ Wire w = factory.createWire();
+ w.setSource(c1.getReferences().get(0));
+ w.setTarget(c2.getServices().get(0));
+ c.getWires().add(w);
+
+ CompositeService cs = factory.createCompositeService();
+ cs.setName("AccountService");
+ cs.setPromotedService(c1.getServices().get(0));
+ c.getServices().add(cs);
+
+ CompositeReference cr = factory.createCompositeReference();
+ cr.setName("StockQuoteService");
+ cr.getPromotedReferences().add(c2.getReferences().get(1));
+ c.getReferences().add(cr);
+
+ return c;
+ }
+
+ /**
+ * Create a new component
+ */
+ Component createComponent(String name) {
+ Component c = factory.createComponent();
+
+ c.setName(name);
+
+ ConstrainingType constraint =factory.createConstrainingType();
+ c.setConstrainingType(constraint);
+
+ Implementation i = new TestImplementation(factory);
+ c.setImplementation(i);
+
+ ComponentProperty p = factory.createComponentProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ p.setProperty(i.getProperties().get(0));
+ c.getProperties().add(p);
+
+ {
+ ComponentReference r = factory.createComponentReference();
+ r.setName("accountDataService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ r.setReference(i.getReferences().get(0));
+ c.getReferences().add(r);
+ }
+
+ {
+ ComponentReference r = factory.createComponentReference();
+ r.setName("stockQuoteService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ r.setReference(i.getReferences().get(1));
+ c.getReferences().add(r);
+ }
+
+ ComponentService s = factory.createComponentService();
+ s.setName("AccountService");
+ s.setService(i.getServices().get(0));
+ c.getServices().add(s);
+
+ return c;
+ }
+
+ /**
+ * Create a new component type
+ * @return
+ */
+ ComponentType createComponentType() {
+ ComponentType ctype = factory.createComponentType();
+
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ {
+ Reference r = factory.createReference();
+ r.setName("accountDataService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ }
+
+ {
+ Reference r = factory.createReference();
+ r.setName("stockQuoteService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ }
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ ctype.getServices().add(s);
+
+ return ctype;
+ }
+
+ /**
+ * Create a new constraining type
+ * @return
+ */
+ ConstrainingType createConstrainingType() {
+ ConstrainingType ctype = factory.createConstrainingType();
+
+ AbstractProperty p = factory.createAbstractProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ {
+ AbstractReference r = factory.createAbstractReference();
+ r.setName("accountDataService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ }
+
+ {
+ AbstractReference r = factory.createAbstractReference();
+ r.setName("stockQuoteService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ }
+
+ AbstractService s = factory.createAbstractService();
+ s.setName("AccountService");
+ ctype.getServices().add(s);
+
+ return ctype;
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java?view=auto&rev=517938
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java Tue Mar 13 16:43:31 2007
@@ -0,0 +1,61 @@
+/*
+ * 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.assembly.model;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.assembly.model.impl.ComponentTypeImpl;
+
+/**
+ * A test component implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestImplementation extends ComponentTypeImpl implements Implementation {
+
+ public TestImplementation(AssemblyFactory factory) {
+
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ getProperties().add(p);
+
+ {
+ Reference r = factory.createReference();
+ r.setName("accountDataService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ getReferences().add(r);
+ }
+
+ {
+ Reference r = factory.createReference();
+ r.setName("stockQuoteService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ getReferences().add(r);
+ }
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ getServices().add(s);
+
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org