summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-osgi/src
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-03-18 01:34:22 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-03-18 01:34:22 +0000
commitbc902f7edf8ea0a278e322c485dd2fc977d02294 (patch)
treeef9aa67c64adb9ce03a88fccc7e92d8872846968 /sca-java-2.x/trunk/modules/implementation-osgi/src
parent0155d4682e2fcc0a677eff08df8dca36cb046f7f (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')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java34
-rw-r--r--sca-java-2.x/trunk/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType31
2 files changed, 54 insertions, 11 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();
}
}
diff --git a/sca-java-2.x/trunk/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType b/sca-java-2.x/trunk/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType
index d58fb634aa..401809c197 100644
--- a/sca-java-2.x/trunk/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType
+++ b/sca-java-2.x/trunk/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType
@@ -25,30 +25,39 @@
<!-- The interface will be mapped into the OSGi service class -->
<interface.java interface="calculator.dosgi.CalculatorService"/>
<!-- The list of OSGi properties -->
- <t:osgi.property name="prop1">1</t:osgi.property>
- <t:osgi.property name="prop2">ABC</t:osgi.property>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
</service>
<!-- The reference elment defines an SCA proxy to a remote OSGi service -->
<reference name="addService">
<interface.java interface="calculator.dosgi.operations.AddService"/>
- <t:osgi.property name="prop1">1</t:osgi.property>
- <t:osgi.property name="prop2">ABC</t:osgi.property>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
</reference>
<reference name="subtractService">
<interface.java interface="calculator.dosgi.operations.SubtractService"/>
- <t:osgi.property name="prop1">1</t:osgi.property>
- <t:osgi.property name="prop2">ABC</t:osgi.property>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
</reference>
<reference name="multiplyService">
<interface.java interface="calculator.dosgi.operations.MultiplyService"/>
- <t:osgi.property name="prop1">1</t:osgi.property>
- <t:osgi.property name="prop2">ABC</t:osgi.property>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
</reference>
<reference name="divideService">
<interface.java interface="calculator.dosgi.operations.DivideService"/>
- <t:osgi.property name="prop1">1</t:osgi.property>
- <t:osgi.property name="prop2">ABC</t:osgi.property>
+ <extensions>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </extensions>
</reference>
-
</componentType>