Convert the test cases to JUNIT 4

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@703592 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rfeng 2008-10-10 22:35:58 +00:00
parent 9134aecc4e
commit b0110591ba
3 changed files with 37 additions and 28 deletions

View file

@ -66,7 +66,7 @@
<Bundle-Version>${tuscany.version}</Bundle-Version>
<Bundle-SymbolicName>org.apache.tuscany.sca.contribution.namespace</Bundle-SymbolicName>
<Bundle-Description>${pom.name}</Bundle-Description>
<Export-Package>org.apache.tuscany.sca.contribution.namespace*</Export-Package>
<Export-Package>org.apache.tuscany.sca.contribution.namespace</Export-Package>
</instructions>
</configuration>
</plugin>

View file

@ -19,13 +19,14 @@
package org.apache.tuscany.sca.contribution.namespace.impl;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import java.io.StringReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import junit.framework.TestCase;
import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@ -37,38 +38,39 @@ 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 NamespaceExportProcessorTestCase
*
* @version $Rev$ $Date$
*/
public class NamespaceExportProcessorTestCase extends TestCase {
public class NamespaceExportProcessorTestCase {
private static final String VALID_XML =
"<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ "<export xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\" namespace=\"http://foo\"/>";
"<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<export xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\" namespace=\"http://foo\"/>";
private static final String INVALID_XML =
"<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ "<export xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\"/>";
"<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<export xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\"/>";
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
private Monitor monitor;
private static XMLInputFactory inputFactory;
private static StAXArtifactProcessor<Object> staxProcessor;
private static Monitor monitor;
@Override
protected void setUp() throws Exception {
@BeforeClass
public static void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.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, null, monitor);
}
@ -76,6 +78,7 @@ public class NamespaceExportProcessorTestCase extends TestCase {
* Test loading a valid export element from a contribution metadata stream
* @throws Exception
*/
@Test
public void testLoad() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
NamespaceExport namespaceExport = (NamespaceExport)staxProcessor.read(reader);
@ -86,6 +89,7 @@ public class NamespaceExportProcessorTestCase extends TestCase {
* Test loading an INVALID export element from a contribution metadata stream
* @throws Exception
*/
@Test
public void testLoadInvalid() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
/*try {
@ -95,8 +99,8 @@ public class NamespaceExportProcessorTestCase extends TestCase {
assertTrue(true);
}*/
staxProcessor.read(reader);
Problem problem = monitor.getLastProblem();
Problem problem = monitor.getLastProblem();
assertNotNull(problem);
assertEquals("AttributeNameSpaceMissing", problem.getMessageId());
}
}
}

View file

@ -21,13 +21,14 @@ package org.apache.tuscany.sca.contribution.namespace.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.StringReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import junit.framework.TestCase;
import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@ -39,13 +40,15 @@ 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 NamespaceImportProcessorTestCase
*
* @version $Rev$ $Date$
*/
public class NamespaceImportProcessorTestCase extends TestCase {
public class NamespaceImportProcessorTestCase {
private static final String VALID_XML =
"<?xml version=\"1.0\" encoding=\"ASCII\"?>"
@ -55,12 +58,12 @@ public class NamespaceImportProcessorTestCase extends TestCase {
"<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ "<import xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns=\"http://ns\" location=\"sca://contributions/001\"/>";
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
private Monitor monitor;
private static XMLInputFactory inputFactory;
private static StAXArtifactProcessor<Object> staxProcessor;
private static Monitor monitor;
@Override
protected void setUp() throws Exception {
@BeforeClass
public static void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
// Create a monitor
@ -78,6 +81,7 @@ public class NamespaceImportProcessorTestCase extends TestCase {
* Test loading a valid import element from a contribution metadata stream
* @throws Exception
*/
@Test
public void testLoad() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(VALID_XML));
NamespaceImport namespaceImport = (NamespaceImport)staxProcessor.read(reader);
@ -90,6 +94,7 @@ public class NamespaceImportProcessorTestCase extends TestCase {
* Test loading a INVALID import element from a contribution metadata stream
* @throws Exception
*/
@Test
public void testLoadInvalid() throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(INVALID_XML));
/*try {