summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/assembly-xml-osoa
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-25 23:40:38 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-25 23:40:38 +0000
commit1eafab3193550a62edf9a9c7c60c119796a9e7e8 (patch)
tree3b9da17022bb79565b4e24748ce8c34e87821cee /java/sca/modules/assembly-xml-osoa
parent6b71f86309fc1c20aaac34c205fe783664a48477 (diff)
Match the document using wildcards against the artifact URI
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@758464 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly-xml-osoa')
-rw-r--r--java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java38
-rw-r--r--java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java62
-rw-r--r--java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java52
3 files changed, 76 insertions, 76 deletions
diff --git a/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java b/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java
index 4262571a9a..938cc7750d 100644
--- a/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java
+++ b/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/BuildPolicyTestCase.java
@@ -6,15 +6,15 @@
* 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.
+ * under the License.
*/
package org.apache.tuscany.sca.assembly.xml.osoa;
@@ -56,13 +56,13 @@ import org.junit.Test;
/**
* Test reading SCA XML assembly documents.
- *
+ *
* @version $Rev$ $Date$
*/
-public class BuildPolicyTestCase {
+public class BuildPolicyTestCase {
private static URLArtifactProcessor<Object> documentProcessor;
private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
- private static ModelResolver resolver;
+ private static ModelResolver resolver;
private static CompositeBuilder compositeBuilder;
private static Composite composite;
private static Monitor monitor;
@@ -77,20 +77,20 @@ public class BuildPolicyTestCase {
List<Definitions> policyDefinitions = new ArrayList<Definitions>();
resolver = new DefaultModelResolver();
-
+
MonitorFactory monitorFactory = new DefaultMonitorFactory();
monitor = monitorFactory.createMonitor();
-
+
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
-
+
URLArtifactProcessorExtensionPoint documentProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
-
+
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
-
+
URL url = BuildPolicyTestCase.class.getResource("CalculatorComponent.constrainingType");
URI uri = URI.create("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
@@ -98,19 +98,19 @@ public class BuildPolicyTestCase {
resolver.addModel(constrainingType);
url = BuildPolicyTestCase.class.getResource("TestAllPolicyCalculator.composite");
- uri = URI.create("TestAllCalculator.constrainingType");
+ uri = URI.create("TestAllCalculator.composite");
composite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(composite);
-
+
url = BuildPolicyTestCase.class.getResource("another_test_definitions.xml");
uri = URI.create("another_test_definitions.xml");
Definitions definitions = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(definitions);
policyDefinitions.add(definitions);
-
+
documentProcessor.resolve(definitions, resolver);
documentProcessor.resolve(composite, resolver);
-
+
compositeBuilder.build(composite, null, monitor);
}
@@ -118,18 +118,18 @@ public class BuildPolicyTestCase {
@Ignore("The inheritance will be calculated differently in OASIS SCA")
public void testPolicyIntentInheritance() throws Exception {
String namespaceUri = "http://test";
-
+
PolicySubject policiedComposite = (PolicySubject)composite;
assertEquals(policiedComposite.getRequiredIntents().size(), 1);
assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
-
+
//1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4)
assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7);
- //1 from the operation defined in this service and 2 from the operation defined in the promoted service
+ //1 from the operation defined in this service and 2 from the operation defined in the promoted service
assertEquals(composite.getServices().get(0).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3"));
//bindings will have only 2 intents since duplications will be cut out
assertEquals(((PolicySubject)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
-
+
assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
assertEquals(((PolicySubject)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
diff --git a/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java b/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java
index e3f35d6f9b..94036c50cb 100644
--- a/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java
+++ b/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ReadDocumentTestCase.java
@@ -6,15 +6,15 @@
* 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.
+ * under the License.
*/
package org.apache.tuscany.sca.assembly.xml.osoa;
@@ -55,7 +55,7 @@ import org.xml.sax.XMLReader;
/**
* Test reading SCA XML assembly documents.
- *
+ *
* @version $Rev$ $Date$
*/
public class ReadDocumentTestCase {
@@ -64,24 +64,24 @@ public class ReadDocumentTestCase {
private static URLArtifactProcessor<Object> documentProcessor;
private static ModelResolver resolver;
private static XMLInputFactory inputFactory;
- private static StAXArtifactProcessor<Object> staxProcessor;
+ private static StAXArtifactProcessor<Object> staxProcessor;
@BeforeClass
public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
- documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
-
+ documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
+
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
inputFactory = XMLInputFactory.newInstance();
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
-
+
resolver = new DefaultModelResolver();
}
@Test
public void testValidateAssembly() throws Exception {
-
+
SchemaFactory schemaFactory;
try {
schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -94,19 +94,19 @@ public class ReadDocumentTestCase {
}
Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD));
ValidatorHandler handler = schema.newValidatorHandler();
-
+
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
URL url = getClass().getResource("Calculator.composite");
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setContentHandler(handler);
reader.parse(new InputSource(url.openStream()));
-
+
}
@Test
public void testValidateImplementation() throws Exception {
-
+
SchemaFactory schemaFactory;
try {
schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -119,7 +119,7 @@ public class ReadDocumentTestCase {
}
Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD));
ValidatorHandler handler = schema.newValidatorHandler();
-
+
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
URL url = getClass().getResource("JavaScriptReference.composite");
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
@@ -127,27 +127,27 @@ public class ReadDocumentTestCase {
reader.setContentHandler(handler);
reader.parse(new InputSource(url.openStream()));
}
-
+
@Test
- public void testReadImplementation() throws Exception {
-
+ public void testReadImplementation() throws Exception {
+
ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD).toString());
XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
factories.addFactory(validatingInputFactory);
-
+
CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null);
-
+
URL url = getClass().getResource("JavaScriptReference.composite");
URI uri = URI.create("JavaScriptReference.composite");
Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
assertNotNull(composite);
}
-
+
@Test
public void testValidateBinding() throws Exception {
-
+
SchemaFactory schemaFactory;
try {
schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -160,7 +160,7 @@ public class ReadDocumentTestCase {
}
Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD));
ValidatorHandler handler = schema.newValidatorHandler();
-
+
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
URL url = getClass().getResource("RMIBindingTest.composite");
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
@@ -168,26 +168,26 @@ public class ReadDocumentTestCase {
reader.setContentHandler(handler);
reader.parse(new InputSource(url.openStream()));
}
-
+
@Test
public void testReadBinding() throws Exception {
-
+
ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_10_XSD).toString());
XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas, null);
DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry());
factories.addFactory(validatingInputFactory);
CompositeDocumentProcessor compositeDocumentProcessor = new CompositeDocumentProcessor(factories , staxProcessor, null);
-
+
URL url = getClass().getResource("RMIBindingTest.composite");
URI uri = URI.create("RMIBindingTest.composite");
Composite composite = (Composite)compositeDocumentProcessor.read(null, uri, url);
assertNotNull(composite);
}
-
+
@Test
public void testResolveConstrainingType() throws Exception {
-
+
URL url = getClass().getResource("CalculatorComponent.constrainingType");
URI uri = URI.create("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
@@ -195,12 +195,12 @@ public class ReadDocumentTestCase {
resolver.addModel(constrainingType);
url = getClass().getResource("TestAllCalculator.composite");
- uri = URI.create("TestAllCalculator.constrainingType");
+ uri = URI.create("TestAllCalculator.composite");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(composite);
-
+
documentProcessor.resolve(composite, resolver);
-
+
assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
@@ -216,9 +216,9 @@ public class ReadDocumentTestCase {
url = getClass().getResource("TestAllCalculator.composite");
uri = URI.create("TestAllCalculator.composite");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
-
+
documentProcessor.resolve(composite, resolver);
-
+
assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
}
diff --git a/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java b/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java
index 2d2a703bcc..c242ce33fd 100644
--- a/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java
+++ b/java/sca/modules/assembly-xml-osoa/src/test/java/org/apache/tuscany/sca/assembly/xml/osoa/ResolvePolicyTestCase.java
@@ -6,18 +6,18 @@
* 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.
+ * under the License.
*/
-package org.apache.tuscany.sca.assembly.xml.osoa;
+package org.apache.tuscany.sca.assembly.xml.osoa;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -44,24 +44,24 @@ import org.junit.Test;
/**
* Test reading SCA XML assembly documents.
- *
+ *
* @version $Rev$ $Date$
*/
public class ResolvePolicyTestCase {
private static URLArtifactProcessor<Object> documentProcessor;
- private static ModelResolver resolver;
+ private static ModelResolver resolver;
private static URLArtifactProcessor<Definitions> policyDefinitionsProcessor;
@BeforeClass
public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
resolver = new DefaultModelResolver();
-
+
URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
-
+
// Create StAX processors
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
@@ -69,7 +69,7 @@ public class ResolvePolicyTestCase {
@Test
public void testResolveConstrainingType() throws Exception {
-
+
URL url = getClass().getResource("CalculatorComponent.constrainingType");
URI uri = URI.create("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
@@ -77,60 +77,60 @@ public class ResolvePolicyTestCase {
resolver.addModel(constrainingType);
url = getClass().getResource("TestAllCalculator.composite");
- uri = URI.create("TestAllCalculator.constrainingType");
+ uri = URI.create("TestAllCalculator.composite");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(composite);
-
+
url = getClass().getResource("test_definitions.xml");
uri = URI.create("test_definitions.xml");
Definitions scaDefns = (Definitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(scaDefns);
-
+
preResolvePolicyTests(composite);
documentProcessor.resolve(scaDefns, resolver);
documentProcessor.resolve(composite, resolver);
-
+
// Comment out the post resolving test
// postResolvePolicyTests(composite);
-
+
assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
-
+
private void preResolvePolicyTests(Composite composite) {
assertNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
assertTrue(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
-
+
assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertTrue(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
-
+
assertNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getComponents().get(0).getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
-
+
assertNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertTrue(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
}
-
+
private void postResolvePolicyTests(Composite composite) {
assertNotNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
assertFalse(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
-
+
assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getServices().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertFalse(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getServices().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
-
+
assertNotNull(composite.getComponents().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getComponents().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
@@ -140,15 +140,15 @@ public class ResolvePolicyTestCase {
assertNotNull(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getComponents().get(0).getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
-
+
assertNotNull(composite.getReferences().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getReferences().get(0).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getReferences().get(0).getCallback().getRequiredIntents().get(0).getDescription());
assertFalse(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNotNull(composite.getReferences().get(0).getCallback().getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
-
-
+
+
}
@Test
@@ -162,9 +162,9 @@ public class ResolvePolicyTestCase {
url = getClass().getResource("TestAllCalculator.composite");
uri = URI.create("TestAllCalculator.composite");
Composite composite = (Composite)documentProcessor.read(null, uri, url);
-
+
documentProcessor.resolve(composite, resolver);
-
+
assertEquals(composite.getComponents().get(2).getImplementation(), nestedComposite);
}