From c626095393e15703f407f16dfc8a3afbaf9abf84 Mon Sep 17 00:00:00 2001 From: Jamie Doornbos Date: Fri, 9 May 2008 06:40:53 +0000 Subject: [PATCH] First stab at test code to run a thane bureau - not yet runnable * New directory tests/src/as with port of java test client * New build target "abclib" to create a library of the test classes specified in etc/asc_files.txt * New target to compile TestClientMain.as against testslib.abc and another to run it. (This proposes the naming convention of *Main.as for "main" thane code and main-*.abc for the compiled code) git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5058 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- tests/build.xml | 60 +++++++++++++++++++ tests/etc/asc-files.txt | 1 + .../threerings/bureau/client/TestClient.as | 50 ++++++++++++++++ .../bureau/client/TestClientMain.as | 28 +++++++++ 4 files changed, 139 insertions(+) create mode 100644 tests/etc/asc-files.txt create mode 100644 tests/src/as/com/threerings/bureau/client/TestClient.as create mode 100644 tests/src/as/com/threerings/bureau/client/TestClientMain.as diff --git a/tests/build.xml b/tests/build.xml index c3c3d9ba9..fff1d2f7f 100644 --- a/tests/build.xml +++ b/tests/build.xml @@ -99,6 +99,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -180,6 +208,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/etc/asc-files.txt b/tests/etc/asc-files.txt new file mode 100644 index 000000000..f9da2d836 --- /dev/null +++ b/tests/etc/asc-files.txt @@ -0,0 +1 @@ +com/threerings/bureau/client/TestClient.as diff --git a/tests/src/as/com/threerings/bureau/client/TestClient.as b/tests/src/as/com/threerings/bureau/client/TestClient.as new file mode 100644 index 000000000..811950266 --- /dev/null +++ b/tests/src/as/com/threerings/bureau/client/TestClient.as @@ -0,0 +1,50 @@ +package com.threerings.bureau.client { + +public class TestClient extends BureauClient +{ + public function TestClient (token :String, bureauId :String) + { + super(token, bureauId); + } + + protected override function createDirector () :BureauDirector + { + return new TestDirector(_ctx); + } +} + +} + +import com.threerings.bureau.client.Agent; +import com.threerings.bureau.client.BureauDirector; +import com.threerings.bureau.Log; +import com.threerings.bureau.data.AgentObject; +import com.threerings.bureau.util.BureauContext; + +class TestAgent extends Agent +{ + public override function start () :void + { + Log.info("Starting agent " + _agentObj.getOid()); + } + + public override function stop () :void + { + Log.info("Stopping agent " + _agentObj.getOid()); + } +} + +class TestDirector extends BureauDirector +{ + public function TestDirector (ctx :BureauContext) + { + super(ctx); + } + + // just use our test agent exclusively - in the real world, the agent created would depend + // on the object's type and/or properties + protected override function createAgent (agentObj :AgentObject) :Agent + { + return new TestAgent(); + } +} diff --git a/tests/src/as/com/threerings/bureau/client/TestClientMain.as b/tests/src/as/com/threerings/bureau/client/TestClientMain.as new file mode 100644 index 000000000..5390fb026 --- /dev/null +++ b/tests/src/as/com/threerings/bureau/client/TestClientMain.as @@ -0,0 +1,28 @@ + +/** + * The main entry point for the bureau test client to be run in thane. Arguments: + * 0: the token to use to log back into the server + * 1: the bureau id of this instance + * 2: the name of the server to log into + * 3: the port to connect to on the server + */ + +import avmplus.System; + +for (var i :int = 0; i < System.argv.length; ++i) { + print("Argv[" + i + "] = " + System.argv[i]); +} + +/* +// create the client and log on +var client :TestClient = new TestClient( + System.getProperty("token"), + System.getProperty("bureauId")); +client.setServer( + System.getProperty("serverName"), + new int[] {Integer.parseInt(System.getProperty("serverPort"))}); +client.logon(); + +// run it +client.run(); +*/