Skip to content

Commit

Permalink
Make Java 1.4 compatible again.
Browse files Browse the repository at this point in the history
  • Loading branch information
joehni committed Dec 23, 2016
1 parent 3fa4883 commit 71ad703
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions BUILD.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ For Java 1.4 build with Maven 2.0.11

Before building:

For Java 1.4 remove the profiles/osgi files.

To build:

mvn clean install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@
import com.bea.xml.stream.MXParserFactory;
import com.thoughtworks.acceptance.objects.StandardObject;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.core.JVM;
import com.thoughtworks.xstream.io.HierarchicalStreamDriver;
import com.thoughtworks.xstream.io.xml.BEAStaxDriver;
import com.thoughtworks.xstream.io.xml.Dom4JDriver;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.thoughtworks.xstream.io.xml.JDom2Driver;
import com.thoughtworks.xstream.io.xml.JDomDriver;
import com.thoughtworks.xstream.io.xml.KXml2DomDriver;
import com.thoughtworks.xstream.io.xml.KXml2Driver;
import com.thoughtworks.xstream.io.xml.StandardStaxDriver;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.thoughtworks.xstream.io.xml.WstxDriver;
import com.thoughtworks.xstream.io.xml.XomDriver;
import com.thoughtworks.xstream.io.xml.XppDomDriver;
import com.thoughtworks.xstream.io.xml.XppDriver;

import junit.framework.Assert;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
Expand All @@ -61,10 +61,28 @@ public EncodingTestSuite() {
addDriverTest(new Dom4JDriver());
addDriverTest(new DomDriver());
addDriverTest(new JDomDriver());
addDriverTest(new JDom2Driver());
if (JVM.is15()) {
final Class driverType = JVM.loadClassForName("com.thoughtworks.xstream.io.xml.JDom2Driver");
try {
addDriverTest((HierarchicalStreamDriver)driverType.newInstance());
} catch (final InstantiationException e) {
throw new AssertionFailedError("Cannot instantiate " + driverType.getName());
} catch (final IllegalAccessException e) {
throw new AssertionFailedError("Cannot access default constructor of " + driverType.getName());
}
}
addDriverTest(new StaxDriver());
if (!SystemUtils.IS_OS_WINDOWS) { // see comment below for Windows
addDriverTest(new StandardStaxDriver());
if (JVM.is16()) {
final Class driverType = JVM.loadClassForName("com.thoughtworks.xstream.io.xml.StandardStaxDriver");
try {
addDriverTest((HierarchicalStreamDriver)driverType.newInstance());
} catch (final InstantiationException e) {
throw new AssertionFailedError("Cannot instantiate " + driverType.getName());
} catch (final IllegalAccessException e) {
throw new AssertionFailedError("Cannot access default constructor of " + driverType.getName());
}
}
addDriverTest(new BEAStaxDriver());
addDriverTest(new WstxDriver());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ private void testObject(final HierarchicalStreamDriver driver) {
final XStream xstream = new XStream(driver);
xstream.registerConverter(new CollectionConverter(xstream.getMapper()) {

@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final ExtendedHierarchicalStreamReader exReader = (ExtendedHierarchicalStreamReader)reader;
if (exReader.peekNextChild() == null) {
Expand Down Expand Up @@ -164,13 +163,11 @@ private void testStream(final HierarchicalStreamDriver driver) {
private void addDriverTest(final HierarchicalStreamDriver driver) {
final String testName = getShortName(driver);
addTest(new TestCase(testName + "_Object") {
@Override
protected void runTest() throws Throwable {
testObject(driver);
}
});
addTest(new TestCase(testName + "_Stream") {
@Override
protected void runTest() throws Throwable {
testStream(driver);
}
Expand Down

0 comments on commit 71ad703

Please sign in to comment.