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 --> <!-- things you may want to change -->
<property name="junit.fork" value="true"/> <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 --> <!-- things you probably don't want to change -->
<property name="test.dir" value="."/> <property name="test.dir" value="."/>
<property name="src.dir" value="src/java"/> <property name="src.dir" value="src/java"/>
@@ -22,15 +18,25 @@
<path id="classpath"> <path id="classpath">
<pathelement location="${classes.dir}"/> <pathelement location="${classes.dir}"/>
<pathelement location="${narya.classes.dir}"/> <pathelement location="${narya.classes.dir}"/>
<fileset dir="${java.libraries}" includes="**/*.jar"/> <fileset dir="../lib" includes="**/*.jar"/>
</path> </path>
<!-- generates .java files for all .dobj files --> <!-- generates additional methods for distributed object classes -->
<target name="gendobj"> <target name="gendobj" depends="prepare">
<apply executable="../bin/gendobj" failonerror="true"> <taskdef name="dobj"
<srcfile/> classname="com.threerings.presents.tools.GenDObjectTask"
<fileset dir="src/java" includes="**/*.dobj"/> classpathref="classpath"/>
</apply> <!-- 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> </target>
<!-- generates marshaller and dispatcher classes for all invocation <!-- generates marshaller and dispatcher classes for all invocation
@@ -60,7 +66,7 @@
</target> </target>
<!-- prepares the application directories --> <!-- prepares the application directories -->
<target name="prepare" depends="gendobj"> <target name="prepare">
<mkdir dir="${deploy.dir}"/> <mkdir dir="${deploy.dir}"/>
<mkdir dir="${classes.dir}"/> <mkdir dir="${classes.dir}"/>
<copy todir="${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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -122,7 +122,7 @@ public class CharSpriteViz extends JPanel
try { try {
ResourceManager rmgr = new ResourceManager("rsrc"); ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles( rmgr.initBundles(
null, "config/resource/manager.properties", null, null); null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, frame); ImageManager imgr = new ImageManager(rmgr, frame);
ComponentRepository crepo = ComponentRepository crepo =
new BundledComponentRepository(rmgr, imgr, "components"); 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -44,7 +44,7 @@ public class TestApp
ResourceManager rmgr = new ResourceManager("rsrc"); ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles( rmgr.initBundles(
null, "config/resource/manager.properties", null, null); null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, _frame); ImageManager imgr = new ImageManager(rmgr, _frame);
ComponentRepository crepo = 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -42,7 +42,7 @@ public class BundledComponentRepositoryTest extends TestCase
try { try {
ResourceManager rmgr = new ResourceManager("rsrc"); ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles( rmgr.initBundles(
null, "config/resource/manager.properties", null, null); null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, null); ImageManager imgr = new ImageManager(rmgr, null);
BundledComponentRepository repo = BundledComponentRepository repo =
new BundledComponentRepository(rmgr, imgr, "components"); 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // 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.Config;
import com.samskivert.util.Queue; 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.client.*;
import com.threerings.presents.dobj.DObjectManager; import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.net.*; import com.threerings.presents.net.*;
import com.threerings.crowd.Log; import com.threerings.crowd.Log;
import com.threerings.crowd.chat.client.ChatDirector;
import com.threerings.crowd.util.CrowdContext; import com.threerings.crowd.util.CrowdContext;
public class TestClient public class TestClient
implements Client.Invoker, ClientObserver implements RunQueue, ClientObserver
{ {
public TestClient (Credentials creds) public TestClient (String username)
{ {
// create our context // create our context
_ctx = new CrowdContextImpl(); _ctx = createContext();
// create the handles on our various services // 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); _locdir = new LocationDirector(_ctx);
_occdir = new OccupantDirector(_ctx); _occdir = new OccupantDirector(_ctx);
_chatdir = new ChatDirector(_ctx, new MessageManager("rsrc"), "global");
// we want to know about logon/logoff // we want to know about logon/logoff
_client.addClientObserver(this); _client.addClientObserver(this);
@@ -53,6 +60,8 @@ public class TestClient
public void run () public void run ()
{ {
_main = Thread.currentThread();
// log on // log on
_client.logon(); _client.logon();
@@ -63,12 +72,17 @@ public class TestClient
} }
} }
public void invokeLater (Runnable run) public void postRunnable (Runnable run)
{ {
// queue it on up // queue it on up
_queue.append(run); _queue.append(run);
} }
public boolean isDispatchThread ()
{
return _main == Thread.currentThread();
}
public void clientDidLogon (Client client) public void clientDidLogon (Client client)
{ {
Log.info("Client did logon [client=" + client + "]."); Log.info("Client did logon [client=" + client + "].");
@@ -106,12 +120,15 @@ public class TestClient
System.exit(0); System.exit(0);
} }
protected CrowdContext createContext ()
{
return new CrowdContextImpl();
}
public static void main (String[] args) public static void main (String[] args)
{ {
UsernamePasswordCreds creds =
new UsernamePasswordCreds("test", "test");
// create our test client // create our test client
TestClient tclient = new TestClient(creds); TestClient tclient = new TestClient("test");
// start it running // start it running
tclient.run(); tclient.run();
} }
@@ -143,6 +160,11 @@ public class TestClient
return _occdir; return _occdir;
} }
public ChatDirector getChatDirector ()
{
return _chatdir;
}
public void setPlaceView (PlaceView view) public void setPlaceView (PlaceView view)
{ {
// nothing to do because we don't create views // nothing to do because we don't create views
@@ -155,9 +177,12 @@ public class TestClient
} }
protected Client _client; protected Client _client;
protected LocationDirector _locdir;
protected OccupantDirector _occdir;
protected CrowdContext _ctx; protected CrowdContext _ctx;
protected LocationDirector _locdir;
protected OccupantDirector _occdir;
protected ChatDirector _chatdir;
protected Thread _main;
protected Queue _queue = new Queue(); 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -41,7 +41,7 @@ public class BundledTileSetRepositoryTest extends TestCase
try { try {
ResourceManager rmgr = new ResourceManager("rsrc"); ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles( rmgr.initBundles(
null, "config/resource/manager.properties", null, null); null, "config/resource/manager.properties", null);
BundledTileSetRepository repo = new BundledTileSetRepository( BundledTileSetRepository repo = new BundledTileSetRepository(
rmgr, new ImageManager(rmgr, null), "tilesets"); rmgr, new ImageManager(rmgr, null), "tilesets");
Iterator sets = repo.enumerateTileSets(); 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -86,8 +86,9 @@ public class ScrollingScene extends MisoSceneModel
return false; return false;
} }
public void addObject (ObjectInfo info) public boolean addObject (ObjectInfo info)
{ {
return true;
} }
public void getObjects (Rectangle region, ObjectSet set) 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // 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 // we don't need to configure anything
ResourceManager rmgr = new ResourceManager("rsrc"); ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles( rmgr.initBundles(
null, "config/resource/manager.properties", null, null); null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, _frame); ImageManager imgr = new ImageManager(rmgr, _frame);
_tilemgr = new MisoTileManager(rmgr, imgr); _tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository( _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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // 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 // we don't need to configure anything
ResourceManager rmgr = new ResourceManager("rsrc"); ResourceManager rmgr = new ResourceManager("rsrc");
rmgr.initBundles( rmgr.initBundles(
null, "config/resource/manager.properties", null, null); null, "config/resource/manager.properties", null);
ImageManager imgr = new ImageManager(rmgr, _frame); ImageManager imgr = new ImageManager(rmgr, _frame);
_tilemgr = new MisoTileManager(rmgr, imgr); _tilemgr = new MisoTileManager(rmgr, imgr);
_tilemgr.setTileSetRepository( _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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -21,66 +21,38 @@
package com.threerings.parlor; package com.threerings.parlor;
import com.samskivert.util.Config; import com.threerings.util.Name;
import com.samskivert.util.Queue;
import com.threerings.presents.client.*; import com.threerings.presents.client.*;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.net.*; import com.threerings.presents.net.*;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.client.*; 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.Log;
import com.threerings.parlor.client.*; import com.threerings.parlor.client.*;
import com.threerings.parlor.game.*; import com.threerings.parlor.game.*;
import com.threerings.parlor.util.ParlorContext; import com.threerings.parlor.util.ParlorContext;
public class TestClient public class TestClient extends com.threerings.crowd.client.TestClient
implements Client.Invoker, ClientObserver, InvitationHandler, implements InvitationHandler, InvitationResponseObserver
InvitationResponseObserver
{ {
public TestClient (Credentials creds) public TestClient (String username)
{ {
// create our context super(username);
_ctx = new ParlorContextImpl();
// create the handles on our various services // create the handles on our various services
_client = new Client(creds, this);
_locdir = new LocationDirector(_ctx);
_occdir = new OccupantDirector(_ctx);
_pardtr = new ParlorDirector(_ctx); _pardtr = new ParlorDirector(_ctx);
// register ourselves as the invitation handler // register ourselves as the invitation handler
_pardtr.setInvitationHandler(this); _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) public void clientDidLogon (Client client)
{ {
// we intentionally don't call super()
Log.info("Client did logon [client=" + client + "]."); Log.info("Client did logon [client=" + client + "].");
// get a casted reference to our body object // get a casted reference to our body object
@@ -90,39 +62,10 @@ public class TestClient
if (_body.username.equals("inviter")) { if (_body.username.equals("inviter")) {
// send the invitation // send the invitation
TestConfig config = new TestConfig(); 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) public void invitationReceived (Invitation invite)
{ {
Log.info("Invitation received [invite=" + invite + "]."); Log.info("Invitation received [invite=" + invite + "].");
@@ -153,67 +96,31 @@ public class TestClient
", config=" + config + "]."); ", config=" + config + "].");
} }
protected CrowdContext createContext ()
{
return (_ctx = new ParlorContextImpl());
}
public static void main (String[] args) public static void main (String[] args)
{ {
String username = System.getProperty("username", "test");
UsernamePasswordCreds creds =
new UsernamePasswordCreds(username, "test");
// create our test client // create our test client
TestClient tclient = new TestClient(creds); TestClient tclient = new TestClient(
System.getProperty("username", "test"));
// start it running // start it running
tclient.run(); 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 () public ParlorDirector getParlorDirector ()
{ {
return _pardtr; return _pardtr;
} }
} }
protected Client _client;
protected LocationDirector _locdir;
protected OccupantDirector _occdir;
protected ParlorDirector _pardtr;
protected ParlorContext _ctx; protected ParlorContext _ctx;
protected ParlorDirector _pardtr;
protected BodyObject _body; protected BodyObject _body;
protected Queue _queue = new Queue();
} }
@@ -39,6 +39,11 @@ public class TestConfig extends GameConfig
return TestController.class; return TestController.class;
} }
public String getBundleName ()
{
return "test";
}
public String getManagerClassName () public String getManagerClassName ()
{ {
return "com.threerings.parlor.test.TestManager"; 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -22,17 +22,20 @@
package com.threerings.presents.client; package com.threerings.presents.client;
import com.samskivert.util.Queue; import com.samskivert.util.Queue;
import com.samskivert.util.RunQueue;
import com.threerings.util.Name;
import com.threerings.presents.Log; import com.threerings.presents.Log;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*; import com.threerings.presents.dobj.*;
import com.threerings.presents.net.*; import com.threerings.presents.net.*;
import com.threerings.presents.server.TestObject;
/** /**
* A standalone test client. * A standalone test client.
*/ */
public class TestClient public class TestClient
implements Client.Invoker, SessionObserver, Subscriber, EventListener, implements RunQueue, SessionObserver, Subscriber, EventListener,
TestService.TestFuncListener, TestService.TestOidListener, TestService.TestFuncListener, TestService.TestOidListener,
TestReceiver TestReceiver
{ {
@@ -41,14 +44,21 @@ public class TestClient
_client = client; _client = client;
} }
public void invokeLater (Runnable run) public void postRunnable (Runnable run)
{ {
// queue it on up // queue it on up
_queue.append(run); _queue.append(run);
} }
public boolean isDispatchThread ()
{
return _main == Thread.currentThread();
}
public void run () public void run ()
{ {
_main = Thread.currentThread();
// loop over our queue, running the runnables // loop over our queue, running the runnables
while (true) { while (true) {
Runnable run = (Runnable)_queue.get(); Runnable run = (Runnable)_queue.get();
@@ -140,7 +150,7 @@ public class TestClient
{ {
TestClient tclient = new TestClient(); TestClient tclient = new TestClient();
UsernamePasswordCreds creds = UsernamePasswordCreds creds =
new UsernamePasswordCreds("test", "test"); new UsernamePasswordCreds(new Name("test"), "test");
Client client = new Client(creds, tclient); Client client = new Client(creds, tclient);
tclient.setClient(client); tclient.setClient(client);
client.addClientObserver(tclient); client.addClientObserver(tclient);
@@ -150,6 +160,7 @@ public class TestClient
tclient.run(); tclient.run();
} }
protected Thread _main;
protected Queue _queue = new Queue(); protected Queue _queue = new Queue();
protected Client _client; 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // 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.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*; 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -25,6 +25,7 @@ import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.threerings.presents.Log; import com.threerings.presents.Log;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*; 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // 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.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*; 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -22,6 +22,7 @@
package com.threerings.presents.server; package com.threerings.presents.server;
import com.threerings.presents.Log; import com.threerings.presents.Log;
import com.threerings.presents.data.TestObject;
import com.threerings.presents.dobj.*; import com.threerings.presents.dobj.*;
public class TestServer extends PresentsServer 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 // Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -21,17 +21,13 @@
package com.threerings.whirled; package com.threerings.whirled;
import com.samskivert.util.Config; import com.threerings.presents.client.Client;
import com.samskivert.util.Queue;
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.Log;
import com.threerings.crowd.client.*; import com.threerings.crowd.client.*;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.util.CrowdContext;
import com.threerings.whirled.client.SceneDirector; import com.threerings.whirled.client.SceneDirector;
import com.threerings.whirled.client.persist.SceneRepository; 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.SceneFactory;
import com.threerings.whirled.util.WhirledContext; import com.threerings.whirled.util.WhirledContext;
public class TestClient public class TestClient extends com.threerings.crowd.client.TestClient
implements Client.Invoker, ClientObserver, LocationObserver implements LocationObserver
{ {
public TestClient (Credentials creds) public TestClient (String username)
{ {
// create our context super(username);
_ctx = new WhirledContextImpl();
// create the handles for our various services // create the handles for our various services
_client = new Client(creds, this);
_screp = new DummyClientSceneRepository(); _screp = new DummyClientSceneRepository();
_occdir = new OccupantDirector(_ctx);
_locdir = new LocationDirector(_ctx);
SceneFactory sfact = new SceneFactory() { SceneFactory sfact = new SceneFactory() {
public Scene createScene (SceneModel model, PlaceConfig config) { public Scene createScene (SceneModel model, PlaceConfig config) {
@@ -62,71 +54,20 @@ public class TestClient
}; };
_scdir = new SceneDirector(_ctx, _locdir, _screp, sfact); _scdir = new SceneDirector(_ctx, _locdir, _screp, sfact);
// we want to know about logon/logoff
_client.addClientObserver(this);
// we want to know about location changes // we want to know about location changes
_locdir.addLocationObserver(this); _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) public void clientDidLogon (Client client)
{ {
// we specifically do not call super()
Log.info("Client did logon [client=" + client + "]."); Log.info("Client did logon [client=" + client + "].");
// request to move to scene 0 // request to move to scene 0
_ctx.getSceneDirector().moveTo(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) public boolean locationMayChange (int placeId)
{ {
// we're easy // we're easy
@@ -145,65 +86,30 @@ public class TestClient
", reason=" + reason + "]."); ", reason=" + reason + "].");
} }
protected CrowdContext createContext ()
{
return (_ctx = new WhirledContextImpl());
}
public static void main (String[] args) public static void main (String[] args)
{ {
UsernamePasswordCreds creds =
new UsernamePasswordCreds("test", "test");
// create our test client // create our test client
TestClient tclient = new TestClient(creds); TestClient tclient = new TestClient("test");
// start it running // start it running
tclient.run(); 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 () public SceneDirector getSceneDirector ()
{ {
return _scdir; return _scdir;
} }
} }
protected Client _client;
protected LocationDirector _locdir;
protected SceneDirector _scdir;
protected OccupantDirector _occdir;
protected SceneRepository _screp;
protected WhirledContext _ctx; protected WhirledContext _ctx;
protected SceneDirector _scdir;
protected Queue _queue = new Queue(); protected SceneRepository _screp;
} }