Brought the tests back into the land of compilability.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3355 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-02-17 01:54:54 +00:00
parent ebf4d7cfa2
commit 2198748dcb
19 changed files with 317 additions and 430 deletions
+18 -12
View File
@@ -4,10 +4,6 @@
<!-- things you may want to change -->
<property name="junit.fork" value="true"/>
<!-- we want to access the environment -->
<property environment="env"/>
<property name="java.libraries" value="${env.JAVA_LIBS}"/>
<!-- things you probably don't want to change -->
<property name="test.dir" value="."/>
<property name="src.dir" value="src/java"/>
@@ -22,15 +18,25 @@
<path id="classpath">
<pathelement location="${classes.dir}"/>
<pathelement location="${narya.classes.dir}"/>
<fileset dir="${java.libraries}" includes="**/*.jar"/>
<fileset dir="../lib" includes="**/*.jar"/>
</path>
<!-- generates .java files for all .dobj files -->
<target name="gendobj">
<apply executable="../bin/gendobj" failonerror="true">
<srcfile/>
<fileset dir="src/java" includes="**/*.dobj"/>
</apply>
<!-- generates additional methods for distributed object classes -->
<target name="gendobj" depends="prepare">
<taskdef name="dobj"
classname="com.threerings.presents.tools.GenDObjectTask"
classpathref="classpath"/>
<!-- make sure the dobject class files are all compiled -->
<javac srcdir="src/java" destdir="${classes.dir}"
debug="on" optimize="${build.optimize}" deprecation="on"
source="1.4" target="1.4">
<classpath refid="classpath"/>
<include name="**/*Object.java"/>
</javac>
<!-- now generate the associated files -->
<dobj classpathref="classpath">
<fileset dir="src/java" includes="**/*Object.java"/>
</dobj>
</target>
<!-- generates marshaller and dispatcher classes for all invocation
@@ -60,7 +66,7 @@
</target>
<!-- prepares the application directories -->
<target name="prepare" depends="gendobj">
<target name="prepare">
<mkdir dir="${deploy.dir}"/>
<mkdir dir="${classes.dir}"/>
<copy todir="${classes.dir}">
@@ -1,5 +1,5 @@
//
// $Id: CharSpriteViz.java,v 1.6 2004/08/27 02:20:53 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -122,7 +122,7 @@ public class CharSpriteViz extends JPanel
try {
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null, null);
null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, frame);
ComponentRepository crepo =
new BundledComponentRepository(rmgr, imgr, "components");
@@ -1,5 +1,5 @@
//
// $Id: TestApp.java,v 1.18 2004/08/27 02:20:54 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -44,7 +44,7 @@ public class TestApp
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null, null);
null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, _frame);
ComponentRepository crepo =
@@ -1,5 +1,5 @@
//
// $Id: BundledComponentRepositoryTest.java,v 1.10 2004/08/27 02:20:55 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -42,7 +42,7 @@ public class BundledComponentRepositoryTest extends TestCase
try {
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null, null);
null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, null);
BundledComponentRepository repo =
new BundledComponentRepository(rmgr, imgr, "components");
@@ -1,5 +1,5 @@
//
// $Id: TestClient.java,v 1.14 2004/08/27 02:20:55 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -23,26 +23,33 @@ package com.threerings.crowd.client;
import com.samskivert.util.Config;
import com.samskivert.util.Queue;
import com.samskivert.util.RunQueue;
import com.threerings.util.MessageManager;
import com.threerings.util.Name;
import com.threerings.presents.client.*;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.net.*;
import com.threerings.crowd.Log;
import com.threerings.crowd.chat.client.ChatDirector;
import com.threerings.crowd.util.CrowdContext;
public class TestClient
implements Client.Invoker, ClientObserver
implements RunQueue, ClientObserver
{
public TestClient (Credentials creds)
public TestClient (String username)
{
// create our context
_ctx = new CrowdContextImpl();
_ctx = createContext();
// create the handles on our various services
_client = new Client(creds, this);
_client = new Client(
new UsernamePasswordCreds(new Name(username), "test"), this);
_locdir = new LocationDirector(_ctx);
_occdir = new OccupantDirector(_ctx);
_chatdir = new ChatDirector(_ctx, new MessageManager("rsrc"), "global");
// we want to know about logon/logoff
_client.addClientObserver(this);
@@ -53,6 +60,8 @@ public class TestClient
public void run ()
{
_main = Thread.currentThread();
// log on
_client.logon();
@@ -63,12 +72,17 @@ public class TestClient
}
}
public void invokeLater (Runnable run)
public void postRunnable (Runnable run)
{
// queue it on up
_queue.append(run);
}
public boolean isDispatchThread ()
{
return _main == Thread.currentThread();
}
public void clientDidLogon (Client client)
{
Log.info("Client did logon [client=" + client + "].");
@@ -106,12 +120,15 @@ public class TestClient
System.exit(0);
}
protected CrowdContext createContext ()
{
return new CrowdContextImpl();
}
public static void main (String[] args)
{
UsernamePasswordCreds creds =
new UsernamePasswordCreds("test", "test");
// create our test client
TestClient tclient = new TestClient(creds);
TestClient tclient = new TestClient("test");
// start it running
tclient.run();
}
@@ -143,6 +160,11 @@ public class TestClient
return _occdir;
}
public ChatDirector getChatDirector ()
{
return _chatdir;
}
public void setPlaceView (PlaceView view)
{
// nothing to do because we don't create views
@@ -155,9 +177,12 @@ public class TestClient
}
protected Client _client;
protected LocationDirector _locdir;
protected OccupantDirector _occdir;
protected CrowdContext _ctx;
protected LocationDirector _locdir;
protected OccupantDirector _occdir;
protected ChatDirector _chatdir;
protected Thread _main;
protected Queue _queue = new Queue();
}
@@ -1,5 +1,5 @@
//
// $Id: BundledTileSetRepositoryTest.java,v 1.10 2004/08/27 02:20:58 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -41,7 +41,7 @@ public class BundledTileSetRepositoryTest extends TestCase
try {
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null, null);
null, "config/resource/manager.properties", null);
BundledTileSetRepository repo = new BundledTileSetRepository(
rmgr, new ImageManager(rmgr, null), "tilesets");
Iterator sets = repo.enumerateTileSets();
@@ -1,5 +1,5 @@
//
// $Id: ScrollingScene.java,v 1.16 2004/10/28 17:49:02 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -86,8 +86,9 @@ public class ScrollingScene extends MisoSceneModel
return false;
}
public void addObject (ObjectInfo info)
public boolean addObject (ObjectInfo info)
{
return true;
}
public void getObjects (Rectangle region, ObjectSet set)
@@ -1,5 +1,5 @@
//
// $Id: ScrollingTestApp.java,v 1.25 2004/08/27 02:21:01 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -93,7 +93,7 @@ public class ScrollingTestApp
// we don't need to configure anything
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null, null);
null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, _frame);
_tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository(
@@ -1,5 +1,5 @@
//
// $Id: ViewerApp.java,v 1.41 2004/08/27 02:21:01 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -86,7 +86,7 @@ public class ViewerApp
// we don't need to configure anything
ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles(
null, "config/resource/manager.properties", null, null);
null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, _frame);
_tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository(
@@ -1,5 +1,5 @@
//
// $Id: TestClient.java,v 1.13 2004/08/27 02:21:02 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -21,66 +21,38 @@
package com.threerings.parlor;
import com.samskivert.util.Config;
import com.samskivert.util.Queue;
import com.threerings.util.Name;
import com.threerings.presents.client.*;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.net.*;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.client.*;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.util.CrowdContext;
import com.threerings.parlor.Log;
import com.threerings.parlor.client.*;
import com.threerings.parlor.game.*;
import com.threerings.parlor.util.ParlorContext;
public class TestClient
implements Client.Invoker, ClientObserver, InvitationHandler,
InvitationResponseObserver
public class TestClient extends com.threerings.crowd.client.TestClient
implements InvitationHandler, InvitationResponseObserver
{
public TestClient (Credentials creds)
public TestClient (String username)
{
// create our context
_ctx = new ParlorContextImpl();
super(username);
// create the handles on our various services
_client = new Client(creds, this);
_locdir = new LocationDirector(_ctx);
_occdir = new OccupantDirector(_ctx);
_pardtr = new ParlorDirector(_ctx);
// register ourselves as the invitation handler
_pardtr.setInvitationHandler(this);
// we want to know about logon/logoff
_client.addClientObserver(this);
// for test purposes, hardcode the server info
_client.setServer("localhost", 4007);
}
public void run ()
{
// log on
_client.logon();
// loop over our queue, running the runnables
while (true) {
Runnable run = (Runnable)_queue.get();
run.run();
}
}
public void invokeLater (Runnable run)
{
// queue it on up
_queue.append(run);
}
public void clientDidLogon (Client client)
{
// we intentionally don't call super()
Log.info("Client did logon [client=" + client + "].");
// get a casted reference to our body object
@@ -90,39 +62,10 @@ public class TestClient
if (_body.username.equals("inviter")) {
// send the invitation
TestConfig config = new TestConfig();
_pardtr.invite("invitee", config, this);
_pardtr.invite(new Name("invitee"), config, this);
}
}
public void clientObjectDidChange (Client client)
{
Log.info("Client object did change [client=" + client + "].");
}
public void clientFailedToLogon (Client client, Exception cause)
{
Log.info("Client failed to logon [client=" + client +
", cause=" + cause + "].");
}
public void clientConnectionFailed (Client client, Exception cause)
{
Log.info("Client connection failed [client=" + client +
", cause=" + cause + "].");
}
public boolean clientWillLogoff (Client client)
{
Log.info("Client will logoff [client=" + client + "].");
return true;
}
public void clientDidLogoff (Client client)
{
Log.info("Client did logoff [client=" + client + "].");
System.exit(0);
}
public void invitationReceived (Invitation invite)
{
Log.info("Invitation received [invite=" + invite + "].");
@@ -153,67 +96,31 @@ public class TestClient
", config=" + config + "].");
}
protected CrowdContext createContext ()
{
return (_ctx = new ParlorContextImpl());
}
public static void main (String[] args)
{
String username = System.getProperty("username", "test");
UsernamePasswordCreds creds =
new UsernamePasswordCreds(username, "test");
// create our test client
TestClient tclient = new TestClient(creds);
TestClient tclient = new TestClient(
System.getProperty("username", "test"));
// start it running
tclient.run();
}
protected class ParlorContextImpl implements ParlorContext
protected class ParlorContextImpl
extends com.threerings.crowd.client.TestClient.CrowdContextImpl
implements ParlorContext
{
public Config getConfig ()
{
return null;
}
public Client getClient ()
{
return _client;
}
public DObjectManager getDObjectManager ()
{
return _client.getDObjectManager();
}
public LocationDirector getLocationDirector ()
{
return _locdir;
}
public OccupantDirector getOccupantDirector ()
{
return _occdir;
}
public void setPlaceView (PlaceView view)
{
// nothing to do because we don't create views
}
public void clearPlaceView (PlaceView view)
{
// nothing to do because we don't create views
}
public ParlorDirector getParlorDirector ()
{
return _pardtr;
}
}
protected Client _client;
protected LocationDirector _locdir;
protected OccupantDirector _occdir;
protected ParlorDirector _pardtr;
protected ParlorContext _ctx;
protected ParlorDirector _pardtr;
protected BodyObject _body;
protected Queue _queue = new Queue();
}
@@ -39,6 +39,11 @@ public class TestConfig extends GameConfig
return TestController.class;
}
public String getBundleName ()
{
return "test";
}
public String getManagerClassName ()
{
return "com.threerings.parlor.test.TestManager";
@@ -1,5 +1,5 @@
//
// $Id: TestClient.java,v 1.16 2004/08/27 02:21:02 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -22,17 +22,20 @@
package com.threerings.presents.client;
import com.samskivert.util.Queue;
import com.samskivert.util.RunQueue;
import com.threerings.util.Name;
import com.threerings.presents.Log;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*;
import com.threerings.presents.net.*;
import com.threerings.presents.server.TestObject;
/**
* A standalone test client.
*/
public class TestClient
implements Client.Invoker, SessionObserver, Subscriber, EventListener,
implements RunQueue, SessionObserver, Subscriber, EventListener,
TestService.TestFuncListener, TestService.TestOidListener,
TestReceiver
{
@@ -41,14 +44,21 @@ public class TestClient
_client = client;
}
public void invokeLater (Runnable run)
public void postRunnable (Runnable run)
{
// queue it on up
_queue.append(run);
}
public boolean isDispatchThread ()
{
return _main == Thread.currentThread();
}
public void run ()
{
_main = Thread.currentThread();
// loop over our queue, running the runnables
while (true) {
Runnable run = (Runnable)_queue.get();
@@ -140,7 +150,7 @@ public class TestClient
{
TestClient tclient = new TestClient();
UsernamePasswordCreds creds =
new UsernamePasswordCreds("test", "test");
new UsernamePasswordCreds(new Name("test"), "test");
Client client = new Client(creds, tclient);
tclient.setClient(client);
client.addClientObserver(tclient);
@@ -150,6 +160,7 @@ public class TestClient
tclient.run();
}
protected Thread _main;
protected Queue _queue = new Queue();
protected Client _client;
}
@@ -0,0 +1,177 @@
//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.data;
import com.threerings.presents.dobj.*;
/**
* A test distributed object.
*/
public class TestObject extends DObject
{
// AUTO-GENERATED: FIELDS START
/** The field name of the <code>foo</code> field. */
public static final String FOO = "foo";
/** The field name of the <code>bar</code> field. */
public static final String BAR = "bar";
/** The field name of the <code>ints</code> field. */
public static final String INTS = "ints";
/** The field name of the <code>strings</code> field. */
public static final String STRINGS = "strings";
/** The field name of the <code>list</code> field. */
public static final String LIST = "list";
// AUTO-GENERATED: FIELDS END
public int foo;
public String bar;
public int[] ints = new int[5];
public String[] strings = new String[5];
public OidList list = new OidList();
// AUTO-GENERATED: METHODS START
/**
* Requests that the <code>foo</code> field be set to the
* specified value. The local value will be updated immediately and an
* event will be propagated through the system to notify all listeners
* that the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setFoo (int value)
{
int ovalue = this.foo;
requestAttributeChange(
FOO, new Integer(value), new Integer(ovalue));
this.foo = value;
}
/**
* Requests that the <code>bar</code> field be set to the
* specified value. The local value will be updated immediately and an
* event will be propagated through the system to notify all listeners
* that the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setBar (String value)
{
String ovalue = this.bar;
requestAttributeChange(
BAR, value, ovalue);
this.bar = value;
}
/**
* Requests that the <code>ints</code> field be set to the
* specified value. The local value will be updated immediately and an
* event will be propagated through the system to notify all listeners
* that the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setInts (int[] value)
{
int[] ovalue = this.ints;
requestAttributeChange(
INTS, value, ovalue);
this.ints = (value == null) ? null : (int[])value.clone();
}
/**
* Requests that the <code>index</code>th element of
* <code>ints</code> field be set to the specified value.
* The local value will be updated immediately and an event will be
* propagated through the system to notify all listeners that the
* attribute did change. Proxied copies of this object (on clients)
* will apply the value change when they received the attribute
* changed notification.
*/
public void setIntsAt (int value, int index)
{
int ovalue = this.ints[index];
requestElementUpdate(
INTS, index, new Integer(value), new Integer(ovalue));
this.ints[index] = value;
}
/**
* Requests that the <code>strings</code> field be set to the
* specified value. The local value will be updated immediately and an
* event will be propagated through the system to notify all listeners
* that the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setStrings (String[] value)
{
String[] ovalue = this.strings;
requestAttributeChange(
STRINGS, value, ovalue);
this.strings = (value == null) ? null : (String[])value.clone();
}
/**
* Requests that the <code>index</code>th element of
* <code>strings</code> field be set to the specified value.
* The local value will be updated immediately and an event will be
* propagated through the system to notify all listeners that the
* attribute did change. Proxied copies of this object (on clients)
* will apply the value change when they received the attribute
* changed notification.
*/
public void setStringsAt (String value, int index)
{
String ovalue = this.strings[index];
requestElementUpdate(
STRINGS, index, value, ovalue);
this.strings[index] = value;
}
/**
* Requests that <code>oid</code> be added to the <code>list</code>
* oid list. The list will not change until the event is actually
* propagated through the system.
*/
public void addToList (int oid)
{
requestOidAdd(LIST, oid);
}
/**
* Requests that <code>oid</code> be removed from the
* <code>list</code> oid list. The list will not change until the
* event is actually propagated through the system.
*/
public void removeFromList (int oid)
{
requestOidRemove(LIST, oid);
}
// AUTO-GENERATED: METHODS END
}
@@ -1,5 +1,5 @@
//
// $Id: DOMTest.java,v 1.11 2004/08/27 02:21:04 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -24,6 +24,7 @@ package com.threerings.presents.server;
import junit.framework.Test;
import junit.framework.TestCase;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*;
/**
@@ -1,5 +1,5 @@
//
// $Id: DestroyedRefTest.java,v 1.10 2004/08/27 02:21:04 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -25,6 +25,7 @@ import junit.framework.Test;
import junit.framework.TestCase;
import com.threerings.presents.Log;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*;
/**
@@ -1,5 +1,5 @@
//
// $Id: RefTest.java,v 1.10 2004/08/27 02:21:04 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -24,6 +24,7 @@ package com.threerings.presents.server;
import junit.framework.Test;
import junit.framework.TestCase;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*;
/**
@@ -1,155 +0,0 @@
//
// $Id: TestObject.java,v 1.5 2004/08/27 02:21:04 mdb Exp $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.server;
import com.threerings.presents.dobj.*;
/**
* A test distributed object.
*/
public class TestObject extends DObject
{
/** The field name of the <code>foo</code> field. */
public static final String FOO = "foo";
/** The field name of the <code>bar</code> field. */
public static final String BAR = "bar";
/** The field name of the <code>ints</code> field. */
public static final String INTS = "ints";
/** The field name of the <code>strings</code> field. */
public static final String STRINGS = "strings";
/** The field name of the <code>list</code> field. */
public static final String LIST = "list";
public int foo;
public String bar;
public int[] ints = new int[5];
public String[] strings = new String[5];
public OidList list = new OidList();
/**
* Requests that the <code>foo</code> field be set to the specified
* value. The local value will be updated immediately and an event
* will be propagated through the system to notify all listeners that
* the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setFoo (int foo)
{
requestAttributeChange(FOO, new Integer(foo));
this.foo = foo;
}
/**
* Requests that the <code>bar</code> field be set to the specified
* value. The local value will be updated immediately and an event
* will be propagated through the system to notify all listeners that
* the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setBar (String bar)
{
requestAttributeChange(BAR, bar);
this.bar = bar;
}
/**
* Requests that the <code>ints</code> field be set to the specified
* value. The local value will be updated immediately and an event
* will be propagated through the system to notify all listeners that
* the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setInts (int[] ints)
{
requestAttributeChange(INTS, ints);
this.ints = ints;
}
/**
* Requests that the <code>index</code>th element of
* <code>ints</code> field be set to the specified value. The local
* value will be updated immediately and an event will be propagated
* through the system to notify all listeners that the attribute did
* change. Proxied copies of this object (on clients) will apply the
* value change when they received the attribute changed notification.
*/
public void setIntsAt (int value, int index)
{
requestElementUpdate(INTS, new Integer(value), index);
this.ints[index] = value;
}
/**
* Requests that the <code>strings</code> field be set to the specified
* value. The local value will be updated immediately and an event
* will be propagated through the system to notify all listeners that
* the attribute did change. Proxied copies of this object (on
* clients) will apply the value change when they received the
* attribute changed notification.
*/
public void setStrings (String[] strings)
{
requestAttributeChange(STRINGS, strings);
this.strings = strings;
}
/**
* Requests that the <code>index</code>th element of
* <code>strings</code> field be set to the specified value. The local
* value will be updated immediately and an event will be propagated
* through the system to notify all listeners that the attribute did
* change. Proxied copies of this object (on clients) will apply the
* value change when they received the attribute changed notification.
*/
public void setStringsAt (String value, int index)
{
requestElementUpdate(STRINGS, value, index);
this.strings[index] = value;
}
/**
* Requests that the specified oid be added to the
* <code>list</code> oid list. The list will not change until the
* event is actually propagated through the system.
*/
public void addToList (int oid)
{
requestOidAdd(LIST, oid);
}
/**
* Requests that the specified oid be removed from the
* <code>list</code> oid list. The list will not change until the
* event is actually propagated through the system.
*/
public void removeFromList (int oid)
{
requestOidRemove(LIST, oid);
}
}
@@ -1,5 +1,5 @@
//
// $Id: TestServer.java,v 1.10 2004/08/27 02:21:04 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -22,6 +22,7 @@
package com.threerings.presents.server;
import com.threerings.presents.Log;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*;
public class TestServer extends PresentsServer
@@ -1,5 +1,5 @@
//
// $Id: TestClient.java,v 1.17 2004/08/27 02:21:05 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -21,17 +21,13 @@
package com.threerings.whirled;
import com.samskivert.util.Config;
import com.samskivert.util.Queue;
import com.threerings.presents.client.*;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.net.*;
import com.threerings.presents.client.Client;
import com.threerings.crowd.Log;
import com.threerings.crowd.client.*;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext;
import com.threerings.whirled.client.SceneDirector;
import com.threerings.whirled.client.persist.SceneRepository;
@@ -41,19 +37,15 @@ import com.threerings.whirled.data.SceneModel;
import com.threerings.whirled.util.SceneFactory;
import com.threerings.whirled.util.WhirledContext;
public class TestClient
implements Client.Invoker, ClientObserver, LocationObserver
public class TestClient extends com.threerings.crowd.client.TestClient
implements LocationObserver
{
public TestClient (Credentials creds)
public TestClient (String username)
{
// create our context
_ctx = new WhirledContextImpl();
super(username);
// create the handles for our various services
_client = new Client(creds, this);
_screp = new DummyClientSceneRepository();
_occdir = new OccupantDirector(_ctx);
_locdir = new LocationDirector(_ctx);
SceneFactory sfact = new SceneFactory() {
public Scene createScene (SceneModel model, PlaceConfig config) {
@@ -62,71 +54,20 @@ public class TestClient
};
_scdir = new SceneDirector(_ctx, _locdir, _screp, sfact);
// we want to know about logon/logoff
_client.addClientObserver(this);
// we want to know about location changes
_locdir.addLocationObserver(this);
// for test purposes, hardcode the server info
_client.setServer("localhost", 4007);
}
public void run ()
{
// log on
_client.logon();
// loop over our queue, running the runnables
while (true) {
Runnable run = (Runnable)_queue.get();
run.run();
}
}
public void invokeLater (Runnable run)
{
// queue it on up
_queue.append(run);
}
public void clientDidLogon (Client client)
{
// we specifically do not call super()
Log.info("Client did logon [client=" + client + "].");
// request to move to scene 0
_ctx.getSceneDirector().moveTo(0);
}
public void clientObjectDidChange (Client client)
{
Log.info("Client object did change [client=" + client + "].");
}
public void clientFailedToLogon (Client client, Exception cause)
{
Log.info("Client failed to logon [client=" + client +
", cause=" + cause + "].");
}
public void clientConnectionFailed (Client client, Exception cause)
{
Log.info("Client connection failed [client=" + client +
", cause=" + cause + "].");
}
public boolean clientWillLogoff (Client client)
{
Log.info("Client will logoff [client=" + client + "].");
return true;
}
public void clientDidLogoff (Client client)
{
Log.info("Client did logoff [client=" + client + "].");
System.exit(0);
}
public boolean locationMayChange (int placeId)
{
// we're easy
@@ -145,65 +86,30 @@ public class TestClient
", reason=" + reason + "].");
}
protected CrowdContext createContext ()
{
return (_ctx = new WhirledContextImpl());
}
public static void main (String[] args)
{
UsernamePasswordCreds creds =
new UsernamePasswordCreds("test", "test");
// create our test client
TestClient tclient = new TestClient(creds);
TestClient tclient = new TestClient("test");
// start it running
tclient.run();
}
protected class WhirledContextImpl implements WhirledContext
protected class WhirledContextImpl
extends com.threerings.crowd.client.TestClient.CrowdContextImpl
implements WhirledContext
{
public Config getConfig ()
{
return null;
}
public Client getClient ()
{
return _client;
}
public DObjectManager getDObjectManager ()
{
return _client.getDObjectManager();
}
public LocationDirector getLocationDirector ()
{
return _locdir;
}
public OccupantDirector getOccupantDirector ()
{
return _occdir;
}
public void setPlaceView (PlaceView view)
{
// nothing to do because we don't create views
}
public void clearPlaceView (PlaceView view)
{
// nothing to do because we don't create views
}
public SceneDirector getSceneDirector ()
{
return _scdir;
}
}
protected Client _client;
protected LocationDirector _locdir;
protected SceneDirector _scdir;
protected OccupantDirector _occdir;
protected SceneRepository _screp;
protected WhirledContext _ctx;
protected Queue _queue = new Queue();
protected SceneDirector _scdir;
protected SceneRepository _screp;
}