Converted the rest of the tests to JUnit unit tests.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@610 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,22 +1,31 @@
|
||||
//
|
||||
// $Id: DOMTest.java,v 1.5 2001/11/08 02:07:36 mdb Exp $
|
||||
// $Id: DOMTest.java,v 1.6 2001/11/08 05:40:07 mdb Exp $
|
||||
|
||||
package com.threerings.presents.server;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
import com.threerings.presents.dobj.*;
|
||||
|
||||
/**
|
||||
* A simple test case for the dobjmgr.
|
||||
*/
|
||||
public class DOMTest implements Subscriber, AttributeChangeListener
|
||||
public class DOMTest
|
||||
extends TestCase
|
||||
implements Subscriber, AttributeChangeListener
|
||||
{
|
||||
public DOMTest ()
|
||||
{
|
||||
super(DOMTest.class.getName());
|
||||
}
|
||||
|
||||
public void objectAvailable (DObject object)
|
||||
{
|
||||
// add ourselves as a listener
|
||||
object.addListener(this);
|
||||
|
||||
Log.info("Object available: " + object);
|
||||
// set some values
|
||||
TestObject to = (TestObject)object;
|
||||
to.setFoo(25);
|
||||
@@ -25,29 +34,26 @@ public class DOMTest implements Subscriber, AttributeChangeListener
|
||||
|
||||
public void requestFailed (int oid, ObjectAccessException cause)
|
||||
{
|
||||
Log.info("Request failed: " + cause);
|
||||
fail("Request failed: " + cause);
|
||||
omgr.shutdown();
|
||||
}
|
||||
|
||||
public void attributeChanged (AttributeChangedEvent event)
|
||||
{
|
||||
Log.info("Got event [event=" + event + "].");
|
||||
|
||||
// if this is the second event, request a shutdown
|
||||
if (event.getName().equals(TestObject.BAR)) {
|
||||
if (event.getName().equals(TestObject.FOO)) {
|
||||
assert("foo=25", event.getIntValue() == 25);
|
||||
|
||||
} else if (event.getName().equals(TestObject.BAR)) {
|
||||
assert("bar=howdy", "howdy".equals(event.getValue()));
|
||||
omgr.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
public static PresentsDObjectMgr omgr = new PresentsDObjectMgr();
|
||||
|
||||
public static void main (String[] args)
|
||||
public void runTest ()
|
||||
{
|
||||
// create our subscriber who will do things
|
||||
DOMTest sub = new DOMTest();
|
||||
|
||||
// request that a new TestObject be created
|
||||
omgr.createObject(TestObject.class, sub);
|
||||
omgr.createObject(TestObject.class, this);
|
||||
|
||||
// or for fun you can try this bogus create request
|
||||
// omgr.createObject(Integer.class, sub);
|
||||
@@ -55,4 +61,11 @@ public class DOMTest implements Subscriber, AttributeChangeListener
|
||||
// and run the object manager
|
||||
omgr.run();
|
||||
}
|
||||
|
||||
public static Test suite ()
|
||||
{
|
||||
return new RefTest();
|
||||
}
|
||||
|
||||
public static PresentsDObjectMgr omgr = new PresentsDObjectMgr();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user