summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/contribution-namespace
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-04-22 21:51:38 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-04-22 21:51:38 +0000
commitb354c03aecb7f30bfd65f0ec02a81ab915ba4966 (patch)
tree569564504b982d2a5bfb3ab3052c0c5130fcae28 /branches/sca-java-1.x/modules/contribution-namespace
parentbaa5887866a52cd40be16707d9741cbbad9d7263 (diff)
Add "Extensible" support for the ContributionMetaData/Contribution/Import/Export models (TUSCANY-2983)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@767683 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/contribution-namespace')
-rw-r--r--branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java23
-rw-r--r--branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java72
-rw-r--r--branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java25
-rw-r--r--branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java68
-rw-r--r--branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java26
-rw-r--r--branches/sca-java-1.x/modules/contribution-namespace/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java27
6 files changed, 144 insertions, 97 deletions
diff --git a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
index 8991585d32..99af328964 100644
--- a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
+++ b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
@@ -6,35 +6,36 @@
* 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;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an export for the contribution
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceExportImpl implements NamespaceExport {
- private String namespace;
+public class NamespaceExportImpl extends ExtensibleImpl implements NamespaceExport {
+ private String namespace;
private ModelResolver modelResolver;
-
+
protected NamespaceExportImpl() {
super();
}
-
+
public String getNamespace() {
return namespace;
}
@@ -42,13 +43,13 @@ public class NamespaceExportImpl implements NamespaceExport {
public void setNamespace(String namespace) {
this.namespace = namespace;
}
-
+
public ModelResolver getModelResolver() {
return modelResolver;
}
-
+
public void setModelResolver(ModelResolver modelResolver) {
this.modelResolver = modelResolver;
}
-
+
}
diff --git a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
index a316818b0f..2ed444506c 100644
--- a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
+++ b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.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;
@@ -27,11 +27,14 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.tuscany.sca.assembly.ExtensionFactory;
import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
@@ -42,26 +45,35 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* Artifact processor for Namespace export
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceExportProcessor implements StAXArtifactProcessor<NamespaceExport> {
+public class NamespaceExportProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<NamespaceExport> {
private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
private static final QName EXPORT = new QName(SCA10_NS, "export");
private static final String NAMESPACE = "namespace";
-
+
private final NamespaceImportExportFactory factory;
private final Monitor monitor;
-
- public NamespaceExportProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+ private final ExtensionFactory extensionFactory;
+ private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
+
+ public NamespaceExportProcessor(ModelFactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor,
+ Monitor monitor) {
this.factory = modelFactories.getFactory(NamespaceImportExportFactory.class);
+ this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
this.monitor = monitor;
}
-
+
/**
* Report a warning.
- *
+ *
* @param problems
* @param message
* @param model
@@ -72,10 +84,10 @@ public class NamespaceExportProcessor implements StAXArtifactProcessor<Namespace
monitor.problem(problem);
}
}
-
+
/**
* Report a exception.
- *
+ *
* @param problems
* @param message
* @param model
@@ -90,43 +102,47 @@ public class NamespaceExportProcessor implements StAXArtifactProcessor<Namespace
public QName getArtifactType() {
return EXPORT;
}
-
+
public Class<NamespaceExport> getModelType() {
return NamespaceExport.class;
}
-
+
/**
* Process <export namespace=""/>
*/
public NamespaceExport read(XMLStreamReader reader) throws ContributionReadException {
NamespaceExport namespaceExport = this.factory.createNamespaceExport();
QName element = null;
-
+
try {
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
element = reader.getName();
-
+
// Read <export>
if (EXPORT.equals(element)) {
String ns = reader.getAttributeValue(null, NAMESPACE);
if (ns == null) {
error("AttributeNameSpaceMissing", reader);
//throw new ContributionReadException("Attribute 'namespace' is missing");
- } else
+ } else {
namespaceExport.setNamespace(ns);
- }
-
+ }
+ readExtendedAttributes(reader, namespaceExport, attributeProcessor, extensionFactory);
+ } else {
+ readExtendedElement(reader, namespaceExport, extensionProcessor);
+ }
+
break;
case XMLStreamConstants.END_ELEMENT:
if (EXPORT.equals(reader.getName())) {
return namespaceExport;
}
- break;
+ break;
}
-
+
// Read the next element
if (reader.hasNext()) {
reader.next();
@@ -137,24 +153,28 @@ public class NamespaceExportProcessor implements StAXArtifactProcessor<Namespace
ContributionReadException ex = new ContributionReadException(e);
error("XMLStreamException", reader, ex);
}
-
+
return namespaceExport;
}
public void write(NamespaceExport namespaceExport, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
-
+
// Write <export>
writer.writeStartElement(EXPORT.getNamespaceURI(), EXPORT.getLocalPart());
-
+
if (namespaceExport.getNamespace() != null) {
writer.writeAttribute(NAMESPACE, namespaceExport.getNamespace());
}
-
+
+ writeExtendedAttributes(writer, namespaceExport, attributeProcessor);
+
+ writeExtendedElements(writer, namespaceExport, extensionProcessor);
+
writer.writeEndElement();
}
public void resolve(NamespaceExport namespaceExport, ModelResolver resolver) throws ContributionResolveException {
-
+
if (namespaceExport.getNamespace() != null)
// Initialize the export's resolver
namespaceExport.setModelResolver(new NamespaceExportModelResolver(resolver));
diff --git a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
index 6d2a31f702..35e2d539d4 100644
--- a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
+++ b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
@@ -6,19 +6,20 @@
* 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;
+import org.apache.tuscany.sca.assembly.impl.ExtensibleImpl;
import org.apache.tuscany.sca.contribution.Export;
import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
@@ -26,26 +27,26 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
/**
* The representation of an import for the contribution
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceImportImpl implements NamespaceImport {
+public class NamespaceImportImpl extends ExtensibleImpl implements NamespaceImport {
private ModelResolver modelResolver;
/**
* The namespace to be imported
*/
- private String namespace;
+ private String namespace;
/**
* Optional location URI pointing to a Contribution that exports the namespace
*/
private String location;
-
+
protected NamespaceImportImpl() {
super();
}
-
+
public String getLocation() {
return location;
}
@@ -61,16 +62,16 @@ public class NamespaceImportImpl implements NamespaceImport {
public void setNamespace(String namespace) {
this.namespace = namespace;
}
-
+
public ModelResolver getModelResolver() {
return modelResolver;
}
-
+
public void setModelResolver(ModelResolver modelResolver) {
this.modelResolver = modelResolver;
}
-
+
/**
* Match a NamespaceImport to a given NamespaceExport based on :
* location is not provided
@@ -84,7 +85,7 @@ public class NamespaceImportImpl implements NamespaceImport {
}
return false;
}
-
+
@Override
public String toString() {
return String.valueOf(namespace);
diff --git a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
index a364823256..97fa65b7c2 100644
--- a/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
+++ b/branches/sca-java-1.x/modules/contribution-namespace/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.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;
@@ -27,11 +27,14 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
+import org.apache.tuscany.sca.assembly.ExtensionFactory;
import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.contribution.service.ContributionReadException;
import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
@@ -42,28 +45,37 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* Artifact processor for Namespace import
- *
+ *
* @version $Rev$ $Date$
*/
-public class NamespaceImportProcessor implements StAXArtifactProcessor<NamespaceImport> {
+public class NamespaceImportProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<NamespaceImport> {
private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
-
+
private static final QName IMPORT = new QName(SCA10_NS, "import");
private static final String NAMESPACE = "namespace";
private static final String LOCATION = "location";
-
+
private final NamespaceImportExportFactory factory;
+ private final ExtensionFactory extensionFactory;
+ private final StAXArtifactProcessor<Object> extensionProcessor;
+ private final StAXAttributeProcessor<Object> attributeProcessor;
private final Monitor monitor;
-
- public NamespaceImportProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+
+ public NamespaceImportProcessor(ModelFactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> attributeProcessor,
+ Monitor monitor) {
this.factory = modelFactories.getFactory(NamespaceImportExportFactory.class);
this.monitor = monitor;
+ this.extensionFactory = modelFactories.getFactory(ExtensionFactory.class);
+ this.extensionProcessor = extensionProcessor;
+ this.attributeProcessor = attributeProcessor;
}
-
+
/**
* Report a warning.
- *
+ *
* @param problems
* @param message
* @param model
@@ -74,10 +86,10 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac
monitor.problem(problem);
}
}
-
+
/**
* Report a exception.
- *
+ *
* @param problems
* @param message
* @param model
@@ -88,11 +100,11 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac
monitor.problem(problem);
}
}
-
+
public QName getArtifactType() {
return IMPORT;
}
-
+
public Class<NamespaceImport> getModelType() {
return NamespaceImport.class;
}
@@ -103,36 +115,40 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac
public NamespaceImport read(XMLStreamReader reader) throws ContributionReadException {
NamespaceImport namespaceImport = this.factory.createNamespaceImport();
QName element;
-
+
try {
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
element = reader.getName();
-
+
// Read <import>
if (IMPORT.equals(element)) {
String ns = reader.getAttributeValue(null, NAMESPACE);
if (ns == null) {
error("AttributeNameSpaceMissing", reader);
//throw new ContributionReadException("Attribute 'namespace' is missing");
- } else
+ } else {
namespaceImport.setNamespace(ns);
-
+ }
+
String location = reader.getAttributeValue(null, LOCATION);
if (location != null) {
namespaceImport.setLocation(location);
}
+ readExtendedAttributes(reader, namespaceImport, attributeProcessor, extensionFactory);
+ } else {
+ readExtendedElement(reader, namespaceImport, extensionProcessor);
}
break;
case XMLStreamConstants.END_ELEMENT:
if (IMPORT.equals(reader.getName())) {
return namespaceImport;
}
- break;
+ break;
}
-
+
// Read the next element
if (reader.hasNext()) {
reader.next();
@@ -143,22 +159,24 @@ public class NamespaceImportProcessor implements StAXArtifactProcessor<Namespac
ContributionReadException ex = new ContributionReadException(e);
error("XMLStreamException", reader, ex);
}
-
+
return namespaceImport;
}
public void write(NamespaceImport namespaceImport, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
-
+
// Write <import>
writer.writeStartElement(IMPORT.getNamespaceURI(), IMPORT.getLocalPart());
-
+
if (namespaceImport.getNamespace() != null) {
writer.writeAttribute(NAMESPACE, namespaceImport.getNamespace());
}
if (namespaceImport.getLocation() != null) {
writer.writeAttribute(LOCATION, namespaceImport.getLocation());
}
-
+
+ writeExtendedAttributes(writer, namespaceImport, attributeProcessor);
+ writeExtendedElements(writer, namespaceImport, extensionProcessor);
writer.writeEndElement();
}
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());
- }
+ }
}