diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-18 01:34:22 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-18 01:34:22 +0000 |
commit | bc902f7edf8ea0a278e322c485dd2fc977d02294 (patch) | |
tree | ef9aa67c64adb9ce03a88fccc7e92d8872846968 /sca-java-2.x/trunk/modules/implementation-osgi/src/test/java | |
parent | 0155d4682e2fcc0a677eff08df8dca36cb046f7f (diff) |
TUSCANY-3452 - Adding support for new extensibility for contract based elements, adjusting current xml for the new model and adapting our element extension list to read/write semantycally same xml when these extensions are in use
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@924584 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-osgi/src/test/java')
-rw-r--r-- | sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java index 6b59b498fc..614f243eb3 100644 --- a/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java +++ b/sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.io.StringReader; import java.io.StringWriter; import javax.xml.stream.XMLInputFactory; @@ -34,6 +35,7 @@ import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.ComponentType; import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.ContributionMetadata; import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.ProcessorContext; @@ -45,6 +47,7 @@ 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.Ignore; import org.junit.Test; /** @@ -77,9 +80,35 @@ public class OSGiReadImplTestCase { XMLStreamReader reader = inputFactory.createXMLStreamReader(is); Composite composite = (Composite)staxProcessor.read(reader, context); assertNotNull(composite); + reader.close(); } @Test + public void testReadWriteComponentType() throws Exception { + InputStream is = getClass().getClassLoader().getResourceAsStream("OSGI-INF/sca/bundle.componentType"); + XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + ComponentType componentType = (ComponentType)staxProcessor.read(reader, context); + assertNotNull(componentType); + + assertEquals(2, componentType.getServices().get(0).getExtensions().size()); + + //write composite back + StringWriter stringWriter = new StringWriter(); + XMLStreamWriter writer = outputFactory.createXMLStreamWriter(stringWriter); + staxProcessor.write(componentType, writer, context); + stringWriter.close(); + + //read from the output from write + reader = inputFactory.createXMLStreamReader(new StringReader(stringWriter.toString())); + componentType = (ComponentType)staxProcessor.read(reader, context); + assertNotNull(componentType); + + assertEquals(2, componentType.getServices().get(0).getExtensions().size()); + + reader.close(); + } + + @Test public void testReadAndResolveComposite() throws Exception { InputStream is = getClass().getClassLoader().getResourceAsStream("osgitest.composite"); XMLStreamReader reader = inputFactory.createXMLStreamReader(is); @@ -109,6 +138,8 @@ public class OSGiReadImplTestCase { resolver.addModel(componentType, context); staxProcessor.resolve(composite, resolver, context); + + reader.close(); } @Test @@ -133,7 +164,10 @@ public class OSGiReadImplTestCase { XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw); staxProcessor.write(osgiImpl, writer, context); writer.flush(); + writer.close(); Assert.assertTrue(sw.toString().contains("bundleSymbolicName=\"osgi.test\" bundleVersion=\"1.0.0\"")); + + reader.close(); } } |