summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-osgi
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-18 22:58:34 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-03-18 22:58:34 +0000
commit5fbcecbe65fc00fd3a2ec28c375d8cc923debda5 (patch)
tree6b731601cf6b7c528cb334e9efb3f1ea7bbd2bba /java/sca/modules/implementation-osgi
parentf7e48d3ddaa6ce6c79ccb25224889949311c40f1 (diff)
Fix the test dependency and add the "write"
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@755769 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-osgi')
-rw-r--r--java/sca/modules/implementation-osgi/pom.xml1
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java26
-rw-r--r--java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java13
3 files changed, 22 insertions, 18 deletions
diff --git a/java/sca/modules/implementation-osgi/pom.xml b/java/sca/modules/implementation-osgi/pom.xml
index 2c4faca03e..2ffb4f4d59 100644
--- a/java/sca/modules/implementation-osgi/pom.xml
+++ b/java/sca/modules/implementation-osgi/pom.xml
@@ -65,6 +65,7 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-assembly-xml</artifactId>
<version>2.0-SNAPSHOT</version>
+ <scope>test</scope>
</dependency>
<dependency>
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
index b3ecc240cc..0a0efd1ec1 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java
@@ -214,31 +214,21 @@ public class OSGiImplementationProcessor implements StAXArtifactProcessor<OSGiIm
}
- private Class getJavaClass(ModelResolver resolver, String className) {
+ private Class<?> getJavaClass(ModelResolver resolver, String className) {
ClassReference ref = new ClassReference(className);
ref = resolver.resolveModel(ClassReference.class, ref);
return ref.getJavaClass();
}
- public void write(OSGiImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException,
+ public void write(OSGiImplementation model, XMLStreamWriter writer) throws ContributionWriteException,
XMLStreamException {
-
- //FIXME Implement this method
- }
-
- private QName getQNameValue(XMLStreamReader reader, String value) {
- if (value != null) {
- int index = value.indexOf(':');
- String prefix = index == -1 ? "" : value.substring(0, index);
- String localName = index == -1 ? value : value.substring(index + 1);
- String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
- if (ns == null) {
- ns = "";
- }
- return new QName(ns, localName, prefix);
- } else {
- return null;
+ String ns = IMPLEMENTATION_OSGI.getNamespaceURI();
+ writer.writeStartElement(ns, IMPLEMENTATION_OSGI.getLocalPart());
+ writer.writeAttribute(BUNDLE_SYMBOLICNAME, model.getBundleSymbolicName());
+ if (model.getBundleVersion() != null) {
+ writer.writeAttribute(BUNDLE_VERSION, model.getBundleVersion());
}
+ writer.writeEndElement();
}
}
diff --git a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
index 306398b94a..43cca15341 100644
--- a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
+++ b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
@@ -25,9 +25,12 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.io.StringWriter;
import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
@@ -40,6 +43,7 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -51,6 +55,7 @@ import org.junit.Test;
public class OSGiReadImplTestCase {
private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
private static StAXArtifactProcessor<Object> staxProcessor;
private static CompositeBuilder compositeBuilder;
@@ -58,6 +63,8 @@ public class OSGiReadImplTestCase {
public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE);
StAXArtifactProcessorExtensionPoint staxProcessors =
new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
@@ -120,6 +127,12 @@ public class OSGiReadImplTestCase {
assertEquals(osgiImpl.getBundleSymbolicName(), "osgi.test");
assertEquals(osgiImpl.getBundleVersion(), "1.0.0");
+
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
+ staxProcessor.write(osgiImpl, writer);
+ writer.flush();
+ Assert.assertTrue(sw.toString().contains("bundleSymbolicName=\"osgi.test\" bundleVersion=\"1.0.0\""));
}
}