From 2198748dcb97fc94e1ecfe142080189eba42230c Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 17 Feb 2005 01:54:54 +0000 Subject: [PATCH] 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 --- tests/build.xml | 30 +-- .../com/threerings/cast/CharSpriteViz.java | 4 +- .../com/threerings/cast/builder/TestApp.java | 4 +- .../BundledComponentRepositoryTest.java | 4 +- .../threerings/crowd/client/TestClient.java | 47 +++-- .../bundle/BundledTileSetRepositoryTest.java | 4 +- .../miso/client/ScrollingScene.java | 5 +- .../miso/client/ScrollingTestApp.java | 4 +- .../com/threerings/miso/viewer/ViewerApp.java | 4 +- .../com/threerings/parlor/TestClient.java | 137 +++----------- .../com/threerings/parlor/TestConfig.java | 5 + .../presents/client/TestClient.java | 21 ++- .../threerings/presents/data/TestObject.java | 177 ++++++++++++++++++ .../threerings/presents/server/DOMTest.java | 3 +- .../presents/server/DestroyedRefTest.java | 3 +- .../threerings/presents/server/RefTest.java | 3 +- .../presents/server/TestObject.java | 155 --------------- .../presents/server/TestServer.java | 3 +- .../com/threerings/whirled/TestClient.java | 134 ++----------- 19 files changed, 317 insertions(+), 430 deletions(-) create mode 100644 tests/src/java/com/threerings/presents/data/TestObject.java delete mode 100644 tests/src/java/com/threerings/presents/server/TestObject.java diff --git a/tests/build.xml b/tests/build.xml index a5def67c8..3b065fcca 100644 --- a/tests/build.xml +++ b/tests/build.xml @@ -4,10 +4,6 @@ - - - - @@ -22,15 +18,25 @@ - + - - - - - - + + + + + + + + + + + + - + diff --git a/tests/src/java/com/threerings/cast/CharSpriteViz.java b/tests/src/java/com/threerings/cast/CharSpriteViz.java index 5c9e842ba..48980e89b 100644 --- a/tests/src/java/com/threerings/cast/CharSpriteViz.java +++ b/tests/src/java/com/threerings/cast/CharSpriteViz.java @@ -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"); diff --git a/tests/src/java/com/threerings/cast/builder/TestApp.java b/tests/src/java/com/threerings/cast/builder/TestApp.java index d1c8902a2..7854adbe4 100644 --- a/tests/src/java/com/threerings/cast/builder/TestApp.java +++ b/tests/src/java/com/threerings/cast/builder/TestApp.java @@ -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 = diff --git a/tests/src/java/com/threerings/cast/bundle/BundledComponentRepositoryTest.java b/tests/src/java/com/threerings/cast/bundle/BundledComponentRepositoryTest.java index e76106681..ba1477c42 100644 --- a/tests/src/java/com/threerings/cast/bundle/BundledComponentRepositoryTest.java +++ b/tests/src/java/com/threerings/cast/bundle/BundledComponentRepositoryTest.java @@ -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"); diff --git a/tests/src/java/com/threerings/crowd/client/TestClient.java b/tests/src/java/com/threerings/crowd/client/TestClient.java index ce40d25bb..1ad0d3239 100644 --- a/tests/src/java/com/threerings/crowd/client/TestClient.java +++ b/tests/src/java/com/threerings/crowd/client/TestClient.java @@ -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(); } diff --git a/tests/src/java/com/threerings/media/tile/bundle/BundledTileSetRepositoryTest.java b/tests/src/java/com/threerings/media/tile/bundle/BundledTileSetRepositoryTest.java index 723df5727..1f2502ee7 100644 --- a/tests/src/java/com/threerings/media/tile/bundle/BundledTileSetRepositoryTest.java +++ b/tests/src/java/com/threerings/media/tile/bundle/BundledTileSetRepositoryTest.java @@ -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(); diff --git a/tests/src/java/com/threerings/miso/client/ScrollingScene.java b/tests/src/java/com/threerings/miso/client/ScrollingScene.java index 7a036f75c..9057430d7 100644 --- a/tests/src/java/com/threerings/miso/client/ScrollingScene.java +++ b/tests/src/java/com/threerings/miso/client/ScrollingScene.java @@ -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) diff --git a/tests/src/java/com/threerings/miso/client/ScrollingTestApp.java b/tests/src/java/com/threerings/miso/client/ScrollingTestApp.java index adb94718e..549b82657 100644 --- a/tests/src/java/com/threerings/miso/client/ScrollingTestApp.java +++ b/tests/src/java/com/threerings/miso/client/ScrollingTestApp.java @@ -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( diff --git a/tests/src/java/com/threerings/miso/viewer/ViewerApp.java b/tests/src/java/com/threerings/miso/viewer/ViewerApp.java index 4dbd34256..075ab5ee2 100644 --- a/tests/src/java/com/threerings/miso/viewer/ViewerApp.java +++ b/tests/src/java/com/threerings/miso/viewer/ViewerApp.java @@ -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( diff --git a/tests/src/java/com/threerings/parlor/TestClient.java b/tests/src/java/com/threerings/parlor/TestClient.java index acb993036..01eb95862 100644 --- a/tests/src/java/com/threerings/parlor/TestClient.java +++ b/tests/src/java/com/threerings/parlor/TestClient.java @@ -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(); } diff --git a/tests/src/java/com/threerings/parlor/TestConfig.java b/tests/src/java/com/threerings/parlor/TestConfig.java index 84364168b..626ee0ae6 100644 --- a/tests/src/java/com/threerings/parlor/TestConfig.java +++ b/tests/src/java/com/threerings/parlor/TestConfig.java @@ -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"; diff --git a/tests/src/java/com/threerings/presents/client/TestClient.java b/tests/src/java/com/threerings/presents/client/TestClient.java index 40f23cbf7..b052003bd 100644 --- a/tests/src/java/com/threerings/presents/client/TestClient.java +++ b/tests/src/java/com/threerings/presents/client/TestClient.java @@ -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; } diff --git a/tests/src/java/com/threerings/presents/data/TestObject.java b/tests/src/java/com/threerings/presents/data/TestObject.java new file mode 100644 index 000000000..1e099db89 --- /dev/null +++ b/tests/src/java/com/threerings/presents/data/TestObject.java @@ -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 foo field. */ + public static final String FOO = "foo"; + + /** The field name of the bar field. */ + public static final String BAR = "bar"; + + /** The field name of the ints field. */ + public static final String INTS = "ints"; + + /** The field name of the strings field. */ + public static final String STRINGS = "strings"; + + /** The field name of the list 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 foo 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 bar 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 ints 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 indexth element of + * ints 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 strings 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 indexth element of + * strings 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 oid be added to the list + * 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 oid be removed from the + * list 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 +} diff --git a/tests/src/java/com/threerings/presents/server/DOMTest.java b/tests/src/java/com/threerings/presents/server/DOMTest.java index ee48d3fac..42003e7d7 100644 --- a/tests/src/java/com/threerings/presents/server/DOMTest.java +++ b/tests/src/java/com/threerings/presents/server/DOMTest.java @@ -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.*; /** diff --git a/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java b/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java index 137bccb2f..53aaefd21 100644 --- a/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java +++ b/tests/src/java/com/threerings/presents/server/DestroyedRefTest.java @@ -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.*; /** diff --git a/tests/src/java/com/threerings/presents/server/RefTest.java b/tests/src/java/com/threerings/presents/server/RefTest.java index 2df4f661a..9ca3b8c3a 100644 --- a/tests/src/java/com/threerings/presents/server/RefTest.java +++ b/tests/src/java/com/threerings/presents/server/RefTest.java @@ -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.*; /** diff --git a/tests/src/java/com/threerings/presents/server/TestObject.java b/tests/src/java/com/threerings/presents/server/TestObject.java deleted file mode 100644 index 194726d57..000000000 --- a/tests/src/java/com/threerings/presents/server/TestObject.java +++ /dev/null @@ -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 foo field. */ - public static final String FOO = "foo"; - - /** The field name of the bar field. */ - public static final String BAR = "bar"; - - /** The field name of the ints field. */ - public static final String INTS = "ints"; - - /** The field name of the strings field. */ - public static final String STRINGS = "strings"; - - /** The field name of the list 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 foo 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 bar 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 ints 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 indexth element of - * ints 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 strings 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 indexth element of - * strings 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 - * list 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 - * list oid list. The list will not change until the - * event is actually propagated through the system. - */ - public void removeFromList (int oid) - { - requestOidRemove(LIST, oid); - } -} diff --git a/tests/src/java/com/threerings/presents/server/TestServer.java b/tests/src/java/com/threerings/presents/server/TestServer.java index 1b0e7739b..a3ffcfec2 100644 --- a/tests/src/java/com/threerings/presents/server/TestServer.java +++ b/tests/src/java/com/threerings/presents/server/TestServer.java @@ -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 diff --git a/tests/src/java/com/threerings/whirled/TestClient.java b/tests/src/java/com/threerings/whirled/TestClient.java index 1a7a90cbc..8d868c919 100644 --- a/tests/src/java/com/threerings/whirled/TestClient.java +++ b/tests/src/java/com/threerings/whirled/TestClient.java @@ -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; }