diff options
Diffstat (limited to 'branches/sca-java-1.x/modules/contribution-namespace/src/test/java')
2 files changed, 30 insertions, 23 deletions
diff --git a/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java b/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java index 1f508d6a4a..5e213e3729 100644 --- a/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java +++ b/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.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.contribution.namespace.impl; @@ -41,17 +41,19 @@ import org.apache.tuscany.sca.monitor.impl.DefaultMonitorImpl; /** * Test NamespaceExportProcessorTestCase - * + * * @version $Rev$ $Date$ */ public class NamespaceExportProcessorTestCase extends TestCase { private static final String VALID_XML = - "<?xml version=\"1.0\" encoding=\"ASCII\"?>" - + "<export xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\" namespace=\"http://foo\"/>"; + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + + "<export xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\"" + + " ns:ext=\"extended\" namespace=\"http://foo\">" + + "<ns:foo/></export>"; private static final String INVALID_XML = - "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<export xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\"/>"; private XMLInputFactory inputFactory; @@ -64,11 +66,11 @@ public class NamespaceExportProcessorTestCase extends TestCase { inputFactory = XMLInputFactory.newInstance(); // Create a monitor UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl(); + MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl(); if (monitorFactory != null) { monitor = monitorFactory.createMonitor(); utilities.addUtility(monitorFactory); - } + } StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, monitor); } @@ -81,6 +83,8 @@ public class NamespaceExportProcessorTestCase extends TestCase { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML)); NamespaceExport namespaceExport = (NamespaceExport)staxProcessor.read(reader); assertEquals("http://foo", namespaceExport.getNamespace()); + assertEquals(1, namespaceExport.getAttributeExtensions().size()); + assertEquals(1, namespaceExport.getExtensions().size()); } /** @@ -96,8 +100,8 @@ public class NamespaceExportProcessorTestCase extends TestCase { assertTrue(true); }*/ staxProcessor.read(reader); - Problem problem = ((DefaultMonitorImpl)monitor).getLastLoggedProblem(); + Problem problem = ((DefaultMonitorImpl)monitor).getLastLoggedProblem(); assertNotNull(problem); assertEquals("AttributeNameSpaceMissing", problem.getMessageId()); - } + } } diff --git a/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java b/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java index 71ac33bf68..7e889ec3ea 100644 --- a/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java +++ b/branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.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.contribution.namespace.impl; @@ -32,7 +32,6 @@ import org.apache.tuscany.sca.contribution.namespace.NamespaceImport; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; @@ -44,17 +43,19 @@ import org.apache.tuscany.sca.monitor.impl.DefaultMonitorImpl; /** * Test NamespaceImportProcessorTestCase - * + * * @version $Rev$ $Date$ */ public class NamespaceImportProcessorTestCase extends TestCase { private static final String VALID_XML = - "<?xml version=\"1.0\" encoding=\"ASCII\"?>" - + "<import xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\" namespace=\"http://foo\" location=\"sca://contributions/001\"/>"; + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + + "<import xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\"" + + " ns:ext=\"extended\" namespace=\"http://foo\" location=\"sca://contributions/001\">" + + "<ns:foo/></import>"; private static final String INVALID_XML = - "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<import xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\" location=\"sca://contributions/001\"/>"; private XMLInputFactory inputFactory; @@ -67,7 +68,7 @@ public class NamespaceImportProcessorTestCase extends TestCase { inputFactory = XMLInputFactory.newInstance(); // Create a monitor UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl(); + MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl(); if (monitorFactory != null) { monitor = monitorFactory.createMonitor(); utilities.addUtility(monitorFactory); @@ -83,9 +84,11 @@ public class NamespaceImportProcessorTestCase extends TestCase { public void testLoad() throws Exception { XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML)); NamespaceImport namespaceImport = (NamespaceImport)staxProcessor.read(reader); - + assertEquals("http://foo", namespaceImport.getNamespace()); assertEquals("sca://contributions/001", namespaceImport.getLocation()); + assertEquals(1, namespaceImport.getAttributeExtensions().size()); + assertEquals(1, namespaceImport.getExtensions().size()); } /** @@ -101,8 +104,8 @@ public class NamespaceImportProcessorTestCase extends TestCase { assertTrue(true); }*/ staxProcessor.read(reader); - Problem problem = ((DefaultMonitorImpl)monitor).getLastLoggedProblem(); + Problem problem = ((DefaultMonitorImpl)monitor).getLastLoggedProblem(); assertNotNull(problem); assertEquals("AttributeNameSpaceMissing", problem.getMessageId()); - } + } } |