Bundles! Got all the tileset bundle stuff working and wrote some tests to

inrease my confidence in the use of the word "working".


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@635 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-11-21 02:42:16 +00:00
parent 39c6b9d9b1
commit 7ad2acca11
20 changed files with 625 additions and 137 deletions
@@ -1,5 +1,5 @@
//
// $Id: TestApp.java,v 1.5 2001/11/18 04:09:20 mdb Exp $
// $Id: TestApp.java,v 1.6 2001/11/21 02:42:16 mdb Exp $
package com.threerings.cast.tools.builder;
@@ -29,7 +29,7 @@ public class TestApp
// create the handles on our various services
_config = MisoUtil.createConfig();
ResourceManager rsrcmgr = new ResourceManager("rsrc");
ResourceManager rsrcmgr = new ResourceManager(null, "rsrc");
// TBD: sort out component repository
ComponentRepository crepo = null;
@@ -0,0 +1,26 @@
//
// $Id: BundledTileSetRepositoryTest.java,v 1.1 2001/11/21 02:42:16 mdb Exp $
package com.threerings.media.tile.bundle;
import java.util.Iterator;
import com.threerings.resource.ResourceManager;
public class BundledTileSetRepositoryTest
{
public static void main (String[] args)
{
try {
ResourceManager rmgr = new ResourceManager(null, "rsrc");
BundledTileSetRepository repo =
new BundledTileSetRepository(rmgr, "bundle_test");
Iterator sets = repo.enumerateTileSets();
while (sets.hasNext()) {
System.out.println(sets.next());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,74 @@
//
// $Id: BuildTestTileSetBundle.java,v 1.1 2001/11/21 02:42:16 mdb Exp $
package com.threerings.media.tools.tile.bundle;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import junit.framework.Test;
import junit.framework.TestCase;
import com.samskivert.io.PersistenceException;
import com.samskivert.test.TestUtil;
import com.threerings.media.tile.TileSetIDBroker;
public class TileSetBundlerTest
{
public static void main (String[] args)
{
try {
TileSetIDBroker broker = new DummyTileSetIDBroker();
// sort out some paths
String configPath = TestUtil.getResourcePath(CONFIG_PATH);
String descPath = TestUtil.getResourcePath(BUNDLE_DESC_PATH);
String targetPath = TestUtil.getResourcePath(TARGET_PATH);
// create our bundler and get going
TileSetBundler bundler = new TileSetBundler(configPath);
File descFile = new File(descPath);
bundler.createBundle(broker, descFile, targetPath);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
/** Dummy tileset id broker that makes up tileset ids (which are
* consistent in the course of execution of the application, but not
* between invocations). */
protected static class DummyTileSetIDBroker
extends HashMap
implements TileSetIDBroker
{
public int getTileSetID (String tileSetName)
throws PersistenceException
{
Integer id = (Integer)get(tileSetName);
if (id == null) {
id = new Integer(++_nextId);
put(tileSetName, id);
}
return id.intValue();
}
public void commit ()
throws PersistenceException
{
}
protected int _nextId;
}
protected static final String CONFIG_PATH =
"media/tools/tile/bundle/bundler-config.xml";
protected static final String BUNDLE_DESC_PATH =
"media/tools/tile/bundle/bundle.xml";
protected static final String TARGET_PATH =
"media/tools/tile/bundle.jar";
}
@@ -0,0 +1,59 @@
//
// $Id: XMLTileSetParserTest.java,v 1.1 2001/11/21 02:42:16 mdb Exp $
package com.threerings.media.tools.tile.xml;
import java.io.IOException;
import java.util.Iterator;
import java.util.HashMap;
import junit.framework.Test;
import junit.framework.TestCase;
public class XMLTileSetParserTest extends TestCase
{
public XMLTileSetParserTest ()
{
super(XMLTileSetParserTest.class.getName());
}
public void runTest ()
{
HashMap sets = new HashMap();
XMLTileSetParser parser = new XMLTileSetParser();
// add some rulesets
parser.addRuleSet("tilesets/uniform", new UniformTileSetRuleSet());
parser.addRuleSet("tilesets/swissarmy", new SwissArmyTileSetRuleSet());
// parser.addRuleSet("tilesets/object", new ObjectTileSetRuleSet());
// load up the tilesets
try {
parser.loadTileSets(TILESET_PATH, sets);
// print them out
Iterator iter = sets.values().iterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
} catch (IOException ioe) {
ioe.printStackTrace();
fail("loadTileSets() failed");
}
}
public static Test suite ()
{
return new XMLTileSetParserTest();
}
public static void main (String[] args)
{
XMLTileSetParserTest test = new XMLTileSetParserTest();
test.runTest();
}
protected static final String TILESET_PATH =
"rsrc/media/tools/tile/xml/tilesets.xml";
}
@@ -1,5 +1,5 @@
//
// $Id: ViewerApp.java,v 1.15 2001/11/18 04:09:20 mdb Exp $
// $Id: ViewerApp.java,v 1.16 2001/11/21 02:42:16 mdb Exp $
package com.threerings.miso.viewer;
@@ -29,7 +29,7 @@ public class ViewerApp
{
// we don't need to configure anything
_config = new Config();
_rsrcmgr = new ResourceManager("rsrc");
_rsrcmgr = new ResourceManager(null, "rsrc");
_tilemgr = new TileManager(_rsrcmgr);
// create the context object