diff --git a/core/src/main/java/com/threerings/whirled/tools/xml/SceneParser.java b/core/src/main/java/com/threerings/whirled/tools/xml/SceneParser.java index b7857886..459f9e70 100644 --- a/core/src/main/java/com/threerings/whirled/tools/xml/SceneParser.java +++ b/core/src/main/java/com/threerings/whirled/tools/xml/SceneParser.java @@ -23,6 +23,7 @@ package com.threerings.whirled.tools.xml; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import org.xml.sax.SAXException; @@ -90,15 +91,23 @@ public class SceneParser } /** - * Parses the XML file at the specified path into a scene model - * instance. + * Parses the XML file at the specified path into a scene model instance. */ public SceneModel parseScene (String path) 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; _digester.push(this); - _digester.parse(new FileInputStream(path)); + _digester.parse(scene); return _model; } diff --git a/core/src/test/java/com/threerings/whirled/spot/tools/xml/SpotSceneParserTest.java b/core/src/test/java/com/threerings/whirled/spot/tools/xml/SpotSceneParserTest.java index 4f202344..0ee44856 100644 --- a/core/src/test/java/com/threerings/whirled/spot/tools/xml/SpotSceneParserTest.java +++ b/core/src/test/java/com/threerings/whirled/spot/tools/xml/SpotSceneParserTest.java @@ -24,8 +24,6 @@ package com.threerings.whirled.spot.tools.xml; import junit.framework.Test; import junit.framework.TestCase; -import com.samskivert.test.TestUtil; - import com.threerings.whirled.data.SceneModel; import com.threerings.whirled.spot.data.Location; import com.threerings.whirled.tools.xml.SceneParser; @@ -50,8 +48,8 @@ public class SpotSceneParserTest extends TestCase return new StageLocation(); // breaks package, but ok } }); - String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH); - SceneModel scene = parser.parseScene(tspath); + SceneModel scene = parser.parseScene( + getClass().getClassLoader().getResourceAsStream(TEST_SCENE_PATH)); System.out.println("Parsed " + scene + "."); } catch (Exception e) { diff --git a/core/src/test/java/com/threerings/whirled/tools/xml/SceneParserTest.java b/core/src/test/java/com/threerings/whirled/tools/xml/SceneParserTest.java index 61d54858..c4adc6fe 100644 --- a/core/src/test/java/com/threerings/whirled/tools/xml/SceneParserTest.java +++ b/core/src/test/java/com/threerings/whirled/tools/xml/SceneParserTest.java @@ -24,8 +24,6 @@ package com.threerings.whirled.tools.xml; import junit.framework.Test; import junit.framework.TestCase; -import com.samskivert.test.TestUtil; - import com.threerings.whirled.data.SceneModel; public class SceneParserTest extends TestCase @@ -40,8 +38,8 @@ public class SceneParserTest extends TestCase { try { SceneParser parser = new SceneParser("scene"); - String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH); - SceneModel scene = parser.parseScene(tspath); + SceneModel scene = parser.parseScene( + getClass().getClassLoader().getResourceAsStream(TEST_SCENE_PATH)); System.out.println("Parsed " + scene + "."); } catch (Exception e) {