Whipped unit tests into shape. Added simple test for dobject transactions.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@978 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
#
|
#
|
||||||
# $Id: server.properties,v 1.2 2001/10/11 04:07:50 mdb Exp $
|
# $Id: server.properties,v 1.3 2002/02/09 07:50:03 mdb Exp $
|
||||||
#
|
#
|
||||||
# Configuration for the Presents test server
|
# Configuration for the Presents test server
|
||||||
|
|
||||||
# These invocation service providers will be registered with the
|
# These invocation service providers will be registered with the
|
||||||
# invocation manager during the server init process
|
# invocation manager during the server init process
|
||||||
providers = \
|
providers = \
|
||||||
test = com.threerings.presents.server.test.TestProvider
|
test = com.threerings.presents.server.TestProvider
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# $Id: manager.properties,v 1.6 2002/02/07 06:55:46 mdb Exp $
|
# $Id: manager.properties,v 1.7 2002/02/09 07:50:03 mdb Exp $
|
||||||
#
|
#
|
||||||
# Test resource manager configuration
|
# Test resource manager configuration
|
||||||
|
|
||||||
@@ -10,6 +10,3 @@ resource.set.tilesets = bundles/tiles/ground/bundle.jar:\
|
|||||||
# configure the BundledComponentRepository
|
# configure the BundledComponentRepository
|
||||||
resource.set.components = bundles/components/pirate/metadata.jar:\
|
resource.set.components = bundles/components/pirate/metadata.jar:\
|
||||||
bundles/components/pirate/components.jar
|
bundles/components/pirate/components.jar
|
||||||
|
|
||||||
# used to test the BundledTileSetRepository
|
|
||||||
resource.set.bundle_test = media/tile/bundle/tools/bundle.jar
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: BundledComponentRepositoryTest.java,v 1.5 2002/01/16 03:01:24 mdb Exp $
|
// $Id: BundledComponentRepositoryTest.java,v 1.6 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cast.bundle;
|
package com.threerings.cast.bundle;
|
||||||
|
|
||||||
@@ -28,21 +28,21 @@ public class BundledComponentRepositoryTest extends TestCase
|
|||||||
BundledComponentRepository repo =
|
BundledComponentRepository repo =
|
||||||
new BundledComponentRepository(rmgr, imgr, "components");
|
new BundledComponentRepository(rmgr, imgr, "components");
|
||||||
|
|
||||||
System.out.println("Classes: " + StringUtil.toString(
|
// System.out.println("Classes: " + StringUtil.toString(
|
||||||
repo.enumerateComponentClasses()));
|
// repo.enumerateComponentClasses()));
|
||||||
|
|
||||||
System.out.println("Actions: " + StringUtil.toString(
|
// System.out.println("Actions: " + StringUtil.toString(
|
||||||
repo.enumerateActionSequences()));
|
// repo.enumerateActionSequences()));
|
||||||
|
|
||||||
System.out.println("Action sets: " + StringUtil.toString(
|
// System.out.println("Action sets: " + StringUtil.toString(
|
||||||
repo._actionSets.values().iterator()));
|
// repo._actionSets.values().iterator()));
|
||||||
|
|
||||||
Iterator iter = repo.enumerateComponentClasses();
|
Iterator iter = repo.enumerateComponentClasses();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
ComponentClass cclass = (ComponentClass)iter.next();
|
ComponentClass cclass = (ComponentClass)iter.next();
|
||||||
System.out.println("IDs [" + cclass + "]: " +
|
// System.out.println("IDs [" + cclass + "]: " +
|
||||||
StringUtil.toString(
|
// StringUtil.toString(
|
||||||
repo.enumerateComponentIds(cclass)));
|
// repo.enumerateComponentIds(cclass)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: BundledTileSetRepositoryTest.java,v 1.5 2002/01/16 03:01:24 mdb Exp $
|
// $Id: BundledTileSetRepositoryTest.java,v 1.6 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile.bundle;
|
package com.threerings.media.tile.bundle;
|
||||||
|
|
||||||
@@ -27,7 +27,8 @@ public class BundledTileSetRepositoryTest extends TestCase
|
|||||||
new BundledTileSetRepository(rmgr, imgr, "tilesets");
|
new BundledTileSetRepository(rmgr, imgr, "tilesets");
|
||||||
Iterator sets = repo.enumerateTileSets();
|
Iterator sets = repo.enumerateTileSets();
|
||||||
while (sets.hasNext()) {
|
while (sets.hasNext()) {
|
||||||
System.out.println(sets.next());
|
sets.next();
|
||||||
|
// System.out.println(sets.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: XMLTileSetParserTest.java,v 1.3 2002/02/05 20:29:09 mdb Exp $
|
// $Id: XMLTileSetParserTest.java,v 1.4 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile.tools.xml;
|
package com.threerings.media.tile.tools.xml;
|
||||||
|
|
||||||
@@ -34,7 +34,8 @@ public class XMLTileSetParserTest extends TestCase
|
|||||||
// print them out
|
// print them out
|
||||||
Iterator iter = sets.values().iterator();
|
Iterator iter = sets.values().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
System.out.println(iter.next());
|
iter.next();
|
||||||
|
// System.out.println(iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DOMTest.java,v 1.6 2001/11/08 05:40:07 mdb Exp $
|
// $Id: DOMTest.java,v 1.7 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.server;
|
package com.threerings.presents.server;
|
||||||
|
|
||||||
@@ -12,8 +12,7 @@ import com.threerings.presents.dobj.*;
|
|||||||
/**
|
/**
|
||||||
* A simple test case for the dobjmgr.
|
* A simple test case for the dobjmgr.
|
||||||
*/
|
*/
|
||||||
public class DOMTest
|
public class DOMTest extends TestCase
|
||||||
extends TestCase
|
|
||||||
implements Subscriber, AttributeChangeListener
|
implements Subscriber, AttributeChangeListener
|
||||||
{
|
{
|
||||||
public DOMTest ()
|
public DOMTest ()
|
||||||
@@ -26,8 +25,15 @@ public class DOMTest
|
|||||||
// add ourselves as a listener
|
// add ourselves as a listener
|
||||||
object.addListener(this);
|
object.addListener(this);
|
||||||
|
|
||||||
// set some values
|
|
||||||
TestObject to = (TestObject)object;
|
TestObject to = (TestObject)object;
|
||||||
|
|
||||||
|
// test transactions
|
||||||
|
to.startTransaction();
|
||||||
|
to.setFoo(99);
|
||||||
|
to.setBar("hoopie");
|
||||||
|
to.commitTransaction();
|
||||||
|
|
||||||
|
// now set some values straight up
|
||||||
to.setFoo(25);
|
to.setFoo(25);
|
||||||
to.setBar("howdy");
|
to.setBar("howdy");
|
||||||
}
|
}
|
||||||
@@ -35,37 +41,53 @@ public class DOMTest
|
|||||||
public void requestFailed (int oid, ObjectAccessException cause)
|
public void requestFailed (int oid, ObjectAccessException cause)
|
||||||
{
|
{
|
||||||
fail("Request failed: " + cause);
|
fail("Request failed: " + cause);
|
||||||
omgr.shutdown();
|
_omgr.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attributeChanged (AttributeChangedEvent event)
|
public void attributeChanged (AttributeChangedEvent event)
|
||||||
{
|
{
|
||||||
// if this is the second event, request a shutdown
|
assert(fields[_fcount] + " == " + values[_fcount],
|
||||||
if (event.getName().equals(TestObject.FOO)) {
|
event.getName().equals(fields[_fcount]) &&
|
||||||
assert("foo=25", event.getIntValue() == 25);
|
event.getValue().equals(values[_fcount]));
|
||||||
|
|
||||||
} else if (event.getName().equals(TestObject.BAR)) {
|
// shutdown once we receive our last update
|
||||||
assert("bar=howdy", "howdy".equals(event.getValue()));
|
if (++_fcount == fields.length) {
|
||||||
omgr.shutdown();
|
_omgr.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runTest ()
|
public void runTest ()
|
||||||
{
|
{
|
||||||
// request that a new TestObject be created
|
// request that a new TestObject be created
|
||||||
omgr.createObject(TestObject.class, this);
|
_omgr.createObject(TestObject.class, this);
|
||||||
|
|
||||||
// or for fun you can try this bogus create request
|
// or for fun you can try this bogus create request
|
||||||
// omgr.createObject(Integer.class, sub);
|
// _omgr.createObject(Integer.class, sub);
|
||||||
|
|
||||||
// and run the object manager
|
// and run the object manager
|
||||||
omgr.run();
|
_omgr.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite ()
|
public static Test suite ()
|
||||||
{
|
{
|
||||||
return new RefTest();
|
return new DOMTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PresentsDObjectMgr omgr = new PresentsDObjectMgr();
|
public static void main (String[] args)
|
||||||
|
{
|
||||||
|
DOMTest test = new DOMTest();
|
||||||
|
test.runTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int _fcount = 0;
|
||||||
|
|
||||||
|
// the fields that will change in attribute changed events
|
||||||
|
protected Object[] fields = {
|
||||||
|
TestObject.FOO, TestObject.BAR, TestObject.FOO, TestObject.BAR };
|
||||||
|
|
||||||
|
// the values we'll receive via attribute changed events
|
||||||
|
protected Object[] values = {
|
||||||
|
new Integer(99), "hoopie", new Integer(25), "howdy" };
|
||||||
|
|
||||||
|
protected static PresentsDObjectMgr _omgr = new PresentsDObjectMgr();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DestroyedRefTest.java,v 1.6 2001/11/08 05:40:07 mdb Exp $
|
// $Id: DestroyedRefTest.java,v 1.7 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.server;
|
package com.threerings.presents.server;
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ public class DestroyedRefTest
|
|||||||
|
|
||||||
} else if (event instanceof AttributeChangedEvent) {
|
} else if (event instanceof AttributeChangedEvent) {
|
||||||
// go bye bye
|
// go bye bye
|
||||||
PresentsServer.shutdown();
|
_omgr.shutdown();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fail("Got unexpected event: " + event);
|
fail("Got unexpected event: " + event);
|
||||||
@@ -80,23 +80,12 @@ public class DestroyedRefTest
|
|||||||
|
|
||||||
public void runTest ()
|
public void runTest ()
|
||||||
{
|
{
|
||||||
PresentsServer server = new TestPresentsServer();
|
// create two test objects
|
||||||
try {
|
_omgr.createObject(TestObject.class, this);
|
||||||
// initialize the server
|
_omgr.createObject(TestObject.class, this);
|
||||||
server.init();
|
|
||||||
|
|
||||||
// create two test objects
|
// and run the object manager
|
||||||
PresentsServer.omgr.createObject(TestObject.class, this);
|
_omgr.run();
|
||||||
PresentsServer.omgr.createObject(TestObject.class, this);
|
|
||||||
|
|
||||||
// start the server to running (this method call won't return
|
|
||||||
// until the server is shut down)
|
|
||||||
server.run();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.warning("Unable to initialize server.");
|
|
||||||
Log.logStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite ()
|
public static Test suite ()
|
||||||
@@ -106,4 +95,6 @@ public class DestroyedRefTest
|
|||||||
|
|
||||||
protected TestObject _objone;
|
protected TestObject _objone;
|
||||||
protected TestObject _objtwo;
|
protected TestObject _objtwo;
|
||||||
|
|
||||||
|
protected static PresentsDObjectMgr _omgr = new PresentsDObjectMgr();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: RefTest.java,v 1.6 2001/11/08 05:40:07 mdb Exp $
|
// $Id: RefTest.java,v 1.7 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.server;
|
package com.threerings.presents.server;
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class RefTest
|
|||||||
} else {
|
} else {
|
||||||
// Log.info("Other object destroyed.");
|
// Log.info("Other object destroyed.");
|
||||||
// go bye bye
|
// go bye bye
|
||||||
PresentsServer.shutdown();
|
_omgr.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (event instanceof ObjectRemovedEvent) {
|
} else if (event instanceof ObjectRemovedEvent) {
|
||||||
@@ -76,23 +76,12 @@ public class RefTest
|
|||||||
|
|
||||||
public void runTest ()
|
public void runTest ()
|
||||||
{
|
{
|
||||||
PresentsServer server = new TestPresentsServer();
|
// create two test objects
|
||||||
try {
|
_omgr.createObject(TestObject.class, this);
|
||||||
// initialize the server
|
_omgr.createObject(TestObject.class, this);
|
||||||
server.init();
|
|
||||||
|
|
||||||
// create two test objects
|
// and run the object manager
|
||||||
PresentsServer.omgr.createObject(TestObject.class, this);
|
_omgr.run();
|
||||||
PresentsServer.omgr.createObject(TestObject.class, this);
|
|
||||||
|
|
||||||
// start the server to running (this method call won't return
|
|
||||||
// until the server is shut down)
|
|
||||||
server.run();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.warning("Unable to initialize server.");
|
|
||||||
Log.logStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite ()
|
public static Test suite ()
|
||||||
@@ -102,4 +91,6 @@ public class RefTest
|
|||||||
|
|
||||||
protected TestObject _objone;
|
protected TestObject _objone;
|
||||||
protected TestObject _objtwo;
|
protected TestObject _objtwo;
|
||||||
|
|
||||||
|
protected static PresentsDObjectMgr _omgr = new PresentsDObjectMgr();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
//
|
|
||||||
// $Id: TestPresentsServer.java,v 1.1 2001/11/08 05:40:07 mdb Exp $
|
|
||||||
|
|
||||||
package com.threerings.presents.server;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This test version of the server avoids creating a connection manager
|
|
||||||
* because that requires a shared library which we don't have available
|
|
||||||
* when testing via ant/JUnit.
|
|
||||||
*/
|
|
||||||
public class TestPresentsServer extends PresentsServer
|
|
||||||
{
|
|
||||||
protected boolean createConnectionManager ()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SpotSceneParserTest.java,v 1.2 2001/12/13 01:35:52 mdb Exp $
|
// $Id: SpotSceneParserTest.java,v 1.3 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.whirled.tools.spot.xml;
|
package com.threerings.whirled.tools.spot.xml;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ public class SpotSceneParserTest extends TestCase
|
|||||||
SpotSceneParser parser = new SpotSceneParser("scene");
|
SpotSceneParser parser = new SpotSceneParser("scene");
|
||||||
String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH);
|
String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH);
|
||||||
EditableSpotScene scene = parser.parseScene(tspath);
|
EditableSpotScene scene = parser.parseScene(tspath);
|
||||||
System.out.println("Parsed " + scene.getSpotSceneModel() + ".");
|
// System.out.println("Parsed " + scene.getSpotSceneModel() + ".");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SceneParserTest.java,v 1.2 2001/12/13 01:35:52 mdb Exp $
|
// $Id: SceneParserTest.java,v 1.3 2002/02/09 07:50:04 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.whirled.tools.xml;
|
package com.threerings.whirled.tools.xml;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ public class SceneParserTest extends TestCase
|
|||||||
SceneParser parser = new SceneParser("scene");
|
SceneParser parser = new SceneParser("scene");
|
||||||
String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH);
|
String tspath = TestUtil.getResourcePath(TEST_SCENE_PATH);
|
||||||
EditableScene scene = parser.parseScene(tspath);
|
EditableScene scene = parser.parseScene(tspath);
|
||||||
System.out.println("Parsed " + scene.getSceneModel() + ".");
|
// System.out.println("Parsed " + scene.getSceneModel() + ".");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user