Update test case to JUNIT 4
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@704675 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6f1396d4e4
commit
d8153166e2
2 changed files with 29 additions and 32 deletions
|
@ -19,60 +19,51 @@
|
|||
|
||||
package org.apache.tuscany.sca.interfacedef.java.xml;
|
||||
|
||||
import static org.junit.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.assembly.AssemblyFactory;
|
||||
import org.apache.tuscany.sca.assembly.ComponentType;
|
||||
import org.apache.tuscany.sca.assembly.Composite;
|
||||
import org.apache.tuscany.sca.assembly.ConstrainingType;
|
||||
import org.apache.tuscany.sca.assembly.SCABindingFactory;
|
||||
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
|
||||
import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
|
||||
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
|
||||
import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
|
||||
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.FactoryExtensionPoint;
|
||||
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
|
||||
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
|
||||
import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test reading Java interfaces.
|
||||
*
|
||||
* @version $Rev$ $Date$
|
||||
*/
|
||||
public class ReadTestCase extends TestCase {
|
||||
public class ReadTestCase {
|
||||
|
||||
private XMLInputFactory inputFactory;
|
||||
private XMLOutputFactory outputFactory;
|
||||
private StAXArtifactProcessor<Object> staxProcessor;
|
||||
private CompositeBuilder compositeBuilder;
|
||||
private static XMLInputFactory inputFactory;
|
||||
private static XMLOutputFactory outputFactory;
|
||||
private static StAXArtifactProcessor<Object> staxProcessor;
|
||||
private static CompositeBuilder compositeBuilder;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
|
||||
inputFactory = XMLInputFactory.newInstance();
|
||||
outputFactory = XMLOutputFactory.newInstance();
|
||||
StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
|
||||
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
|
||||
|
||||
FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
|
||||
AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
|
||||
SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
|
||||
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
|
||||
InterfaceContractMapper mapper = utilities.getUtility(InterfaceContractMapper.class);
|
||||
IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
|
||||
compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, attachPointTypeFactory, mapper);
|
||||
compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadComponentType() throws Exception {
|
||||
InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
|
||||
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
|
||||
|
@ -80,6 +71,7 @@ public class ReadTestCase extends TestCase {
|
|||
assertNotNull(componentType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadConstrainingType() throws Exception {
|
||||
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
|
||||
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
|
||||
|
@ -87,6 +79,7 @@ public class ReadTestCase extends TestCase {
|
|||
assertNotNull(constrainingType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadComposite() throws Exception {
|
||||
InputStream is = getClass().getResourceAsStream("Calculator.composite");
|
||||
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
package org.apache.tuscany.sca.interfacedef.java.xml;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
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;
|
||||
|
@ -35,20 +35,21 @@ import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProce
|
|||
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.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test writing Java interfaces.
|
||||
*
|
||||
* @version $Rev$ $Date$
|
||||
*/
|
||||
public class WriteTestCase extends TestCase {
|
||||
public class WriteTestCase {
|
||||
private static XMLInputFactory inputFactory;
|
||||
private static XMLOutputFactory outputFactory;
|
||||
private static StAXArtifactProcessor<Object> staxProcessor;
|
||||
|
||||
private XMLInputFactory inputFactory;
|
||||
private XMLOutputFactory outputFactory;
|
||||
private StAXArtifactProcessor<Object> staxProcessor;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
|
||||
inputFactory = XMLInputFactory.newInstance();
|
||||
outputFactory = XMLOutputFactory.newInstance();
|
||||
|
@ -56,6 +57,7 @@ public class WriteTestCase extends TestCase {
|
|||
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWriteComponentType() throws Exception {
|
||||
InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
|
||||
ComponentType componentType = (ComponentType)staxProcessor.read(inputFactory.createXMLStreamReader(is));
|
||||
|
@ -64,6 +66,7 @@ public class WriteTestCase extends TestCase {
|
|||
staxProcessor.write(componentType, outputFactory.createXMLStreamWriter(bos));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWriteConstrainingType() throws Exception {
|
||||
InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
|
||||
ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(inputFactory.createXMLStreamReader(is));
|
||||
|
@ -72,6 +75,7 @@ public class WriteTestCase extends TestCase {
|
|||
staxProcessor.write(constrainingType, outputFactory.createXMLStreamWriter(bos));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadWriteComposite() throws Exception {
|
||||
InputStream is = getClass().getResourceAsStream("Calculator.composite");
|
||||
Composite composite = (Composite)staxProcessor.read(inputFactory.createXMLStreamReader(is));
|
||||
|
|
Loading…
Reference in a new issue