summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-10 19:25:28 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-10 19:25:28 +0000
commitc6c390ece96a16e76112f84f3f1c43d0421abade (patch)
treed8da2d62de02572496ee8342d82482ff3ebc946c /branches/sca-equinox/modules
parent1feee03e177b77d9c5d96a07ca95b2e3049471af (diff)
Convert the test cases to JUNIT 4
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@703562 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/modules')
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java67
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java32
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java20
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java28
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java23
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java24
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java24
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java22
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java27
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java35
-rw-r--r--branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java20
11 files changed, 186 insertions, 136 deletions
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
index 8516c4a028..a6488c8e29 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
@@ -25,47 +25,48 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
-import junit.framework.TestCase;
+import junit.framework.Assert;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
import org.junit.Test;
-public class AnyElementReadWriteTestCase extends TestCase {
-
- private XMLInputFactory inputFactory;
- String XML = "<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><interface.java xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" target=\"AddServiceComponent\" /><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\" /><component name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component name=\"DivideServiceComponent\" /><x:unknownElement xmlns:x=\"http://x\" uknAttr=\"attribute1\"><x:subUnknownElement1 uknAttr1=\"attribute1\" /><x:subUnknownElement2 /></x:unknownElement></composite>";
- private ExtensibleStAXArtifactProcessor staxProcessor;
-
- @Override
- public void setUp() throws Exception {
- ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
- inputFactory = XMLInputFactory.newInstance();
- StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
- staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
- }
-
- @Override
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testReadWriteComposite() throws Exception{
- InputStream is = getClass().getResourceAsStream("Calculator.composite");
- XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
- Composite composite = (Composite)staxProcessor.read(reader);
- assertNotNull(composite);
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- staxProcessor.write(composite, bos);
- System.out.println(bos.toString());
- assertEquals(XML,bos.toString());
- bos.close();
-
+public class AnyElementReadWriteTestCase {
+
+ private static XMLInputFactory inputFactory;
+ private static String XML =
+ "<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><interface.java xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" target=\"AddServiceComponent\" /><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\" /><component name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component name=\"DivideServiceComponent\" /><x:unknownElement xmlns:x=\"http://x\" uknAttr=\"attribute1\"><x:subUnknownElement1 uknAttr1=\"attribute1\" /><x:subUnknownElement2 /></x:unknownElement></composite>";
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessor =
+ new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory
+ .newInstance(), null);
+ }
+
+ @Test
+ public void testReadWriteComposite() throws Exception {
+ InputStream is = getClass().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = (Composite)staxProcessor.read(reader);
+ Assert.assertNotNull(composite);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(composite, bos);
+ System.out.println(bos.toString());
+ Assert.assertEquals(XML, bos.toString());
+ bos.close();
+
is.close();
- }
+ }
}
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
index 34fba3b893..51d83cbf15 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.assembly.xml;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
@@ -26,8 +29,6 @@ import java.util.List;
import javax.xml.namespace.QName;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.OperationsConfigurator;
@@ -50,22 +51,24 @@ 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.policy.IntentAttachPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test reading SCA XML assembly documents.
*
* @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
*/
-public class BuildPolicyTestCase extends TestCase {
- private URLArtifactProcessor<Object> documentProcessor;
- private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
- private ModelResolver resolver;
- private CompositeBuilder compositeBuilder;
- private Composite composite;
- private Monitor monitor;
+public class BuildPolicyTestCase {
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
+ private static ModelResolver resolver;
+ private static CompositeBuilder compositeBuilder;
+ private static Composite composite;
+ private static Monitor monitor;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
SCABindingFactory scaBindingFactory = new TestSCABindingFactoryImpl();
@@ -88,18 +91,18 @@ public class BuildPolicyTestCase extends TestCase {
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
- URL url = getClass().getResource("CalculatorComponent.constrainingType");
+ URL url = BuildPolicyTestCase.class.getResource("CalculatorComponent.constrainingType");
URI uri = URI.create("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
assertNotNull(constrainingType);
resolver.addModel(constrainingType);
- url = getClass().getResource("TestAllPolicyCalculator.composite");
+ url = BuildPolicyTestCase.class.getResource("TestAllPolicyCalculator.composite");
uri = URI.create("TestAllCalculator.constrainingType");
composite = (Composite)documentProcessor.read(null, uri, url);
assertNotNull(composite);
- url = getClass().getResource("another_test_definitions.xml");
+ url = BuildPolicyTestCase.class.getResource("another_test_definitions.xml");
uri = URI.create("another_test_definitions.xml");
SCADefinitions definitions = (SCADefinitions)policyDefinitionsProcessor.read(null, uri, url);
assertNotNull(definitions);
@@ -111,6 +114,7 @@ public class BuildPolicyTestCase extends TestCase {
compositeBuilder.build(composite, null, monitor);
}
+ @Test
public void testPolicyIntentInheritance() throws Exception {
String namespaceUri = "http://test";
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
index e2aeb85d32..d7836fbc3b 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
@@ -19,13 +19,16 @@
package org.apache.tuscany.sca.assembly.xml;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
import java.io.InputStream;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -39,6 +42,8 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -47,18 +52,19 @@ import org.w3c.dom.Element;
*
* @version $Rev$ $Date$
*/
-public class ReadAllTestCase extends TestCase {
- private StAXArtifactProcessor<Object> staxProcessor;
- private XMLInputFactory inputFactory;
+public class ReadAllTestCase {
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static XMLInputFactory inputFactory;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
inputFactory = XMLInputFactory.newInstance();
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, null);
}
+ @Test
public void testReadComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is));
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
index 111a517552..4918271b1f 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.assembly.xml;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
import java.net.URI;
import java.net.URL;
@@ -29,8 +32,6 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.ValidatorHandler;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.processor.DefaultValidatingXMLInputFactory;
@@ -45,6 +46,8 @@ import org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPo
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -53,15 +56,15 @@ import org.xml.sax.XMLReader;
*
* @version $Rev$ $Date$
*/
-public class ReadDocumentTestCase extends TestCase {
+public class ReadDocumentTestCase {
- private URLArtifactProcessor<Object> documentProcessor;
- private ModelResolver resolver;
- private XMLInputFactory inputFactory;
- private StAXArtifactProcessor<Object> staxProcessor;
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors, null);
@@ -73,6 +76,7 @@ public class ReadDocumentTestCase extends TestCase {
resolver = new DefaultModelResolver();
}
+ @Test
public void testValidateAssembly() throws Exception {
SchemaFactory schemaFactory;
@@ -97,6 +101,7 @@ public class ReadDocumentTestCase extends TestCase {
}
+ @Test
public void testValidateImplementation() throws Exception {
SchemaFactory schemaFactory;
@@ -120,6 +125,7 @@ public class ReadDocumentTestCase extends TestCase {
reader.parse(new InputSource(url.openStream()));
}
+ @Test
public void testReadImplementation() throws Exception {
ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
@@ -133,6 +139,7 @@ public class ReadDocumentTestCase extends TestCase {
assertNotNull(composite);
}
+ @Test
public void testValidateBinding() throws Exception {
SchemaFactory schemaFactory;
@@ -156,6 +163,7 @@ public class ReadDocumentTestCase extends TestCase {
reader.parse(new InputSource(url.openStream()));
}
+ @Test
public void testReadBinding() throws Exception {
ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint();
@@ -169,6 +177,7 @@ public class ReadDocumentTestCase extends TestCase {
assertNotNull(composite);
}
+ @Test
public void testResolveConstrainingType() throws Exception {
URL url = getClass().getResource("CalculatorComponent.constrainingType");
@@ -188,6 +197,7 @@ public class ReadDocumentTestCase extends TestCase {
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
+ @Test
public void testResolveComposite() throws Exception {
URL url = getClass().getResource("Calculator.composite");
URI uri = URI.create("Calculator.composite");
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
index 1aede413a5..ba85769728 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
@@ -19,42 +19,42 @@
package org.apache.tuscany.sca.assembly.xml;
+import static junit.framework.Assert.assertNotNull;
+
import java.io.InputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test reading SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
-public class ReadTestCase extends TestCase {
+public class ReadTestCase {
- private XMLInputFactory inputFactory;
- private StAXArtifactProcessor<Object> staxProcessor;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
}
- @Override
- public void tearDown() throws Exception {
- }
+ @Test
public void testReadComponentType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
@@ -62,6 +62,7 @@ public class ReadTestCase extends TestCase {
is.close();
}
+ @Test
public void testReadConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
@@ -70,6 +71,7 @@ public class ReadTestCase extends TestCase {
}
+ @Test
public void testReadComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
@@ -78,6 +80,7 @@ public class ReadTestCase extends TestCase {
}
+ @Test
public void testReadCompositeAndWireIt() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
index dcf1385e22..cbc5308aab 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAttributeTestCase.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.assembly.xml;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -27,25 +30,24 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test reading SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
-public class ReadWriteAttributeTestCase extends TestCase {
+public class ReadWriteAttributeTestCase {
- private XMLInputFactory inputFactory;
- private ExtensibleStAXArtifactProcessor staxProcessor;
+ private static XMLInputFactory inputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
private static final QName ATTRIBUTE = new QName("http://test", "customAttribute");
@@ -66,8 +68,8 @@ public class ReadWriteAttributeTestCase extends TestCase {
"<component name=\"DivideServiceComponent\" />"+
"</composite>";
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
@@ -79,11 +81,8 @@ public class ReadWriteAttributeTestCase extends TestCase {
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, XMLInputFactory.newInstance(), XMLOutputFactory.newInstance(), null);
}
- @Override
- public void tearDown() throws Exception {
-
- }
+ @Test
public void testReadComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorExtended.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
@@ -92,6 +91,7 @@ public class ReadWriteAttributeTestCase extends TestCase {
is.close();
}
+ @Test
public void testWriteComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorExtended.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
index 32a2d94220..cf8ef0cad9 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
@@ -19,11 +19,15 @@
package org.apache.tuscany.sca.assembly.xml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.net.URI;
import java.net.URL;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
@@ -35,20 +39,22 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.SCADefinitions;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test reading SCA XML assembly documents.
*
* @version $Rev: 561254 $ $Date: 2007-07-31 13:16:27 +0530 (Tue, 31 Jul 2007) $
*/
-public class ResolvePolicyTestCase extends TestCase {
+public class ResolvePolicyTestCase {
- private URLArtifactProcessor<Object> documentProcessor;
- private ModelResolver resolver;
- private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
+ private static URLArtifactProcessor<Object> documentProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
resolver = new DefaultModelResolver();
@@ -61,6 +67,7 @@ public class ResolvePolicyTestCase extends TestCase {
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
}
+ @Test
public void testResolveConstrainingType() throws Exception {
URL url = getClass().getResource("CalculatorComponent.constrainingType");
@@ -142,6 +149,7 @@ public class ResolvePolicyTestCase extends TestCase {
}
+ @Test
public void testResolveComposite() throws Exception {
URL url = getClass().getResource("Calculator.composite");
URI uri = URI.create("Calculator.composite");
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
index df09a56c38..cc8a88f3d5 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
@@ -19,13 +19,14 @@
package org.apache.tuscany.sca.assembly.xml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.InputStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -33,26 +34,30 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtens
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
/**
* Test resolving SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
-public class ResolveTestCase extends TestCase {
+public class ResolveTestCase {
- private XMLInputFactory inputFactory;
- private StAXArtifactProcessorExtensionPoint staxProcessors;
- private ModelResolver resolver;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessorExtensionPoint staxProcessors;
+ private static ModelResolver resolver;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
resolver = new DefaultModelResolver();
}
+ @Test
public void testResolveConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
StAXArtifactProcessor<ConstrainingType> constrainingTypeReader = staxProcessors.getProcessor(ConstrainingType.class);
@@ -75,6 +80,7 @@ public class ResolveTestCase extends TestCase {
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
+ @Test
public void testResolveComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
StAXArtifactProcessor<Composite> compositeReader = staxProcessors.getProcessor(Composite.class);
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
index b4a0ac197b..f42d4195d5 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.assembly.xml;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
@@ -26,8 +29,6 @@ import java.net.URL;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
@@ -48,23 +49,25 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test the wiring of SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
-public class WireTestCase extends TestCase {
+public class WireTestCase {
- private XMLInputFactory inputFactory;
- private StAXArtifactProcessor<Object> staxProcessor;
- private ModelResolver resolver;
- private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
- private CompositeBuilder compositeBuilder;
- private Monitor monitor;
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ModelResolver resolver;
+ private static URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
+ private static CompositeBuilder compositeBuilder;
+ private static Monitor monitor;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
@@ -86,6 +89,7 @@ public class WireTestCase extends TestCase {
policyDefinitionsProcessor = documentProcessors.getProcessor(SCADefinitions.class);
}
+ @Test
public void testResolveConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
@@ -114,6 +118,7 @@ public class WireTestCase extends TestCase {
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
+ @Test
public void testResolveComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("Calculator.composite");
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
index c04463bf0e..2ae7eebbef 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.assembly.xml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -29,8 +32,6 @@ import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
@@ -51,23 +52,25 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test writing SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
-public class WriteAllTestCase extends TestCase {
- private XMLInputFactory inputFactory;
- private XMLOutputFactory outputFactory;
- private ExtensibleStAXArtifactProcessor staxProcessor;
- private ModelResolver resolver;
- private CompositeBuilder compositeBuilder;
- private URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
- private Monitor monitor;
+public class WriteAllTestCase {
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ModelResolver resolver;
+ private static CompositeBuilder compositeBuilder;
+ private static URLArtifactProcessor<SCADefinitions> policyDefinitionsProcessor;
+ private static Monitor monitor;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
inputFactory = XMLInputFactory.newInstance();
outputFactory = XMLOutputFactory.newInstance();
@@ -90,10 +93,7 @@ public class WriteAllTestCase extends TestCase {
policyDefinitionsProcessor = documentProcessors.getProcessor(SCADefinitions.class);
}
- @Override
- public void tearDown() throws Exception {
- }
-
+ @Test
public void testReadWriteComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
Composite composite = staxProcessor.read(is, Composite.class);
@@ -111,6 +111,7 @@ public class WriteAllTestCase extends TestCase {
}
+ @Test
public void testReadWireWriteComposite() throws Exception {
InputStream is = getClass().getResourceAsStream("TestAllCalculator.composite");
Composite composite = staxProcessor.read(is, Composite.class);
@@ -127,6 +128,7 @@ public class WriteAllTestCase extends TestCase {
staxProcessor.write(composite, bos);
}
+ @Test
public void testReadWriteComponentType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
ComponentType componentType = staxProcessor.read(is, ComponentType.class);
@@ -135,6 +137,7 @@ public class WriteAllTestCase extends TestCase {
staxProcessor.write(componentType, bos);
}
+ @Test
public void testReadWriteConstrainingType() throws Exception {
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
diff --git a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
index bfa8c96f6a..dedd0d0660 100644
--- a/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
+++ b/branches/sca-equinox/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.assembly.xml;
+import static org.junit.Assert.assertEquals;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -29,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.assembly.Component;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -38,19 +38,21 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtens
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.BeforeClass;
+import org.junit.Test;
/**
* Test writing SCA XML assemblies.
*
* @version $Rev$ $Date$
*/
-public class WriteNamespacesTestCase extends TestCase {
- private StAXArtifactProcessor<Composite> compositeProcessor;
- private XMLOutputFactory outputFactory;
- private XMLInputFactory inputFactory;
+public class WriteNamespacesTestCase {
+ private static StAXArtifactProcessor<Composite> compositeProcessor;
+ private static XMLOutputFactory outputFactory;
+ private static XMLInputFactory inputFactory;
- @Override
- public void setUp() throws Exception {
+ @BeforeClass
+ public static void setUp() throws Exception {
ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
@@ -61,6 +63,7 @@ public class WriteNamespacesTestCase extends TestCase {
compositeProcessor = artifactProcessors.getProcessor(Composite.class);
}
+ @Test
public void testReadWriteComposite() throws Exception {
// Read
@@ -85,6 +88,7 @@ public class WriteNamespacesTestCase extends TestCase {
// Compare
component = composite.getComponents().get(0);
implementation = (Composite)component.getImplementation();
+
assertEquals(qname, implementation.getName());
}