summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-10 22:59:30 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-10 22:59:30 +0000
commit0b4357a5bbbc43ce545881b651b9c9d87b6a2ecf (patch)
tree10be18ad8006f39cd0709a79b2f9a0cd56845816 /branches/sca-equinox
parent84bb75d4d350854217c1f2df48b366475e9ce287 (diff)
Restrict Export-Package and convert test cases
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@703597 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox')
-rw-r--r--branches/sca-equinox/modules/contribution-xml/pom.xml2
-rw-r--r--branches/sca-equinox/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java85
2 files changed, 46 insertions, 41 deletions
diff --git a/branches/sca-equinox/modules/contribution-xml/pom.xml b/branches/sca-equinox/modules/contribution-xml/pom.xml
index 4fb3e06a57..fb1a9641f6 100644
--- a/branches/sca-equinox/modules/contribution-xml/pom.xml
+++ b/branches/sca-equinox/modules/contribution-xml/pom.xml
@@ -60,7 +60,7 @@
<Bundle-Version>${tuscany.version}</Bundle-Version>
<Bundle-SymbolicName>org.apache.tuscany.sca.contribution.xml</Bundle-SymbolicName>
<Bundle-Description>${pom.name}</Bundle-Description>
- <Export-Package>org.apache.tuscany.sca.contribution.xml*</Export-Package>
+ <Export-Package></Export-Package>
</instructions>
</configuration>
</plugin>
diff --git a/branches/sca-equinox/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java b/branches/sca-equinox/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
index 8dc6ab7ab1..ddb660a139 100644
--- a/branches/sca-equinox/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
+++ b/branches/sca-equinox/modules/contribution-xml/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.contribution.xml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.StringReader;
import java.io.StringWriter;
@@ -28,8 +31,6 @@ import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.contribution.ContributionMetadata;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -41,6 +42,8 @@ import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.Problem;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test the contribution metadata processor.
@@ -48,52 +51,53 @@ import org.apache.tuscany.sca.monitor.Problem;
* @version $Rev$ $Date$
*/
-public class ContributionMetadataProcessorTestCase extends TestCase {
+public class ContributionMetadataProcessorTestCase {
private static final String VALID_XML =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<contribution xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\">"
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\">"
+ "<deployable composite=\"ns:Composite1\"/>"
+ "<deployable composite=\"ns:Composite2\"/>"
+ "</contribution>";
private static final String INVALID_XML =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<contribution xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\">"
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\">"
+ "<deployable composite=\"ns:Composite1\"/>"
+ "<deployable/>"
+ "</contribution>";
-
- private XMLInputFactory inputFactory;
- private XMLOutputFactory outputFactory;
- private StAXArtifactProcessor<Object> staxProcessor;
- private Monitor monitor;
-
- @Override
- protected void setUp() throws Exception {
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static Monitor monitor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
-
+
inputFactory = XMLInputFactory.newInstance();
outputFactory = XMLOutputFactory.newInstance();
-
+
// Create a monitor
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
if (monitorFactory != null) {
- monitor = monitorFactory.createMonitor();
- utilities.addUtility(monitorFactory);
- }
- StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ monitor = monitorFactory.createMonitor();
+ utilities.addUtility(monitorFactory);
+ }
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
}
+ @Test
public void testRead() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader);
assertNotNull(contribution);
assertEquals(2, contribution.getDeployables().size());
- }
+ }
+ @Test
public void testReadInvalid() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
/*try {
@@ -103,17 +107,18 @@ public class ContributionMetadataProcessorTestCase extends TestCase {
assertTrue(true);
}*/
staxProcessor.read(reader);
- Problem problem = monitor.getLastProblem();
+ Problem problem = monitor.getLastProblem();
assertNotNull(problem);
assertEquals("AttributeCompositeMissing", problem.getMessageId());
- }
+ }
+ @Test
public void testWrite() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
ContributionMetadata contribution = (ContributionMetadata)staxProcessor.read(reader);
validateContribution(contribution);
-
+
//write the contribution metadata contents
StringWriter stringWriter = new StringWriter();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(stringWriter);
@@ -122,19 +127,19 @@ public class ContributionMetadataProcessorTestCase extends TestCase {
reader = inputFactory.createXMLStreamReader(new StringReader(stringWriter.toString()));
contribution = (ContributionMetadata)staxProcessor.read(reader);
-
+
validateContribution(contribution);
- }
-
- private void validateContribution(ContributionMetadata contribution) {
- QName deployable;
-
- assertNotNull(contribution);
- assertEquals(2, contribution.getDeployables().size());
- deployable = new QName("http://ns", "Composite1");
- assertEquals(deployable, contribution.getDeployables().get(0).getName());
- deployable = new QName("http://ns", "Composite2");
- assertEquals(deployable, contribution.getDeployables().get(1).getName());
- }
-
+ }
+
+ private void validateContribution(ContributionMetadata contribution) {
+ QName deployable;
+
+ assertNotNull(contribution);
+ assertEquals(2, contribution.getDeployables().size());
+ deployable = new QName("http://ns", "Composite1");
+ assertEquals(deployable, contribution.getDeployables().get(0).getName());
+ deployable = new QName("http://ns", "Composite2");
+ assertEquals(deployable, contribution.getDeployables().get(1).getName());
+ }
+
}