Eliminate use of TestUtil.

This commit is contained in:
Michael Bayne
2015-03-14 09:54:42 -07:00
parent 95294dd6fe
commit 2199bfd21a
3 changed files with 16 additions and 11 deletions
@@ -23,6 +23,7 @@ package com.threerings.whirled.tools.xml;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@@ -90,15 +91,23 @@ public class SceneParser
} }
/** /**
* Parses the XML file at the specified path into a scene model * Parses the XML file at the specified path into a scene model instance.
* instance.
*/ */
public SceneModel parseScene (String path) public SceneModel parseScene (String path)
throws IOException, SAXException throws IOException, SAXException
{
return parseScene(new FileInputStream(path));
}
/**
* Parses the XML file provided by {@code scene} into a scene model instance.
*/
public SceneModel parseScene (InputStream scene)
throws IOException, SAXException
{ {
_model = null; _model = null;
_digester.push(this); _digester.push(this);
_digester.parse(new FileInputStream(path)); _digester.parse(scene);
return _model; return _model;
} }
@@ -24,8 +24,6 @@ package com.threerings.whirled.spot.tools.xml;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.samskivert.test.TestUtil;
import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.spot.data.Location; import com.threerings.whirled.spot.data.Location;
import com.threerings.whirled.tools.xml.SceneParser; import com.threerings.whirled.tools.xml.SceneParser;
@@ -50,8 +48,8 @@ public class SpotSceneParserTest extends TestCase
return new StageLocation(); // breaks package, but ok return new StageLocation(); // breaks package, but ok
} }
}); });
String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH); SceneModel scene = parser.parseScene(
SceneModel scene = parser.parseScene(tspath); getClass().getClassLoader().getResourceAsStream(TEST_SCENE_PATH));
System.out.println("Parsed " + scene + "."); System.out.println("Parsed " + scene + ".");
} catch (Exception e) { } catch (Exception e) {
@@ -24,8 +24,6 @@ package com.threerings.whirled.tools.xml;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.samskivert.test.TestUtil;
import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.data.SceneModel;
public class SceneParserTest extends TestCase public class SceneParserTest extends TestCase
@@ -40,8 +38,8 @@ public class SceneParserTest extends TestCase
{ {
try { try {
SceneParser parser = new SceneParser("scene"); SceneParser parser = new SceneParser("scene");
String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH); SceneModel scene = parser.parseScene(
SceneModel scene = parser.parseScene(tspath); getClass().getClassLoader().getResourceAsStream(TEST_SCENE_PATH));
System.out.println("Parsed " + scene + "."); System.out.println("Parsed " + scene + ".");
} catch (Exception e) { } catch (Exception e) {