diff options
Diffstat (limited to '')
3 files changed, 19 insertions, 18 deletions
diff --git a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java index ac9f4c6006..a09807d3f8 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java +++ b/branches/sca-java-1.x/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java @@ -882,8 +882,13 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement QName attributeName = reader.getAttributeName(a); if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) { if( ! elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) { - String attributeValue = (String) extensionAttributeProcessor.read(attributeName, reader); - Extension attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true); + Object attributeValue = extensionAttributeProcessor.read(attributeName, reader); + Extension attributeExtension; + if (attributeValue instanceof Extension) { + attributeExtension = (Extension) attributeValue; + } else { + attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true); + } estensibleElement.getAttributeExtensions().add(attributeExtension); } } @@ -903,7 +908,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement protected void writeExtendedAttributes(XMLStreamWriter writer, Extensible extensibleElement, StAXAttributeProcessor extensionAttributeProcessor) throws ContributionWriteException, XMLStreamException { for(Extension extension : extensibleElement.getAttributeExtensions()) { if(extension.isAttribute()) { - extensionAttributeProcessor.write(extension.getValue(), writer); + extensionAttributeProcessor.write(extension, writer); } } } diff --git a/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java index 826e39baab..6877dcdb34 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java +++ b/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java @@ -47,19 +47,17 @@ import org.junit.Test; */ public class ReadWriteAnyAttributeTestCase { - private static final QName ATTRIBUTE = new QName("http://test", "customAttribute"); + private static final QName EXTENDED_ATTRIBUTE = new QName("http://test", "customAttribute"); - // implementation.java for CalculatorServiceComponent appears in a strange place as the - // java implementation extension is not loaded and hence they are loaded as any elements private static final String XML = "<?xml version='1.0' encoding='UTF-8'?>"+ "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" " + "xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" " + "targetNamespace=\"http://calc\" " + "name=\"Calculator\">"+ - "<component name=\"AddServiceComponent\" xmlns:test=\"http://test\" test:customAttribute=\"customValue\">"+ - "<implementation.java class=\"calculator.AddServiceImpl\" />"+ - "</component>"+ - "</composite>"; + "<component name=\"AddServiceComponent\" xmlns:test=\"http://test\" test:customAttribute=\"customValue\">"+ + "<implementation.java class=\"calculator.AddServiceImpl\" />"+ + "</component>"+ + "</composite>"; private XMLInputFactory inputFactory; private ExtensibleStAXArtifactProcessor staxProcessor; @@ -91,7 +89,6 @@ public class ReadWriteAnyAttributeTestCase { * @throws Exception */ @Test - @Ignore public void testReadWriteCompositeWithAttributeProcessor() throws Exception { init(new TestAttributeProcessor()); @@ -104,8 +101,8 @@ public class ReadWriteAnyAttributeTestCase { staxProcessor.write(composite, bos); // used for debug comparison - System.out.println(XML); - System.out.println(bos.toString()); + // System.out.println(XML); + // System.out.println(bos.toString()); assertEquals(XML, bos.toString()); } @@ -116,7 +113,6 @@ public class ReadWriteAnyAttributeTestCase { * @throws Exception */ @Test - @Ignore public void testDefaultReadWriteComposite() throws Exception { init(null); @@ -129,8 +125,8 @@ public class ReadWriteAnyAttributeTestCase { staxProcessor.write(composite, bos); // used for debug comparison - System.out.println(XML); - System.out.println(bos.toString()); + // System.out.println(XML); + // System.out.println(bos.toString()); assertEquals(XML, bos.toString()); } diff --git a/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java index 84beebe466..c34e9e3d22 100644 --- a/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java +++ b/branches/sca-java-1.x/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.contribution.service.ContributionResolveException; import org.apache.tuscany.sca.contribution.service.ContributionWriteException; /** - * A Policy Processor used for testing. + * A Attribute Processor used for testing. * * @version $Rev$ $Date$ */ @@ -51,7 +51,7 @@ public class TestAttributeProcessor extends BaseStAXArtifactProcessor implements } public Class<String> getModelType() { - return String.class; + return null; } public void resolve(String arg0, ModelResolver arg1) throws ContributionResolveException { |