diff --git a/tests/src/java/com/threerings/bureau/server/RegistryTester.java b/tests/src/java/com/threerings/bureau/server/RegistryTester.java
index 55bb605ee..d9a4fab8b 100644
--- a/tests/src/java/com/threerings/bureau/server/RegistryTester.java
+++ b/tests/src/java/com/threerings/bureau/server/RegistryTester.java
@@ -114,7 +114,7 @@ public class RegistryTester
*/
public void start ()
{
- TestServer.setClientTarget(_clientTarget);
+ _server.setClientTarget(_clientTarget);
Thread thread = new Thread("Registry test thread") {
public void run () {
@@ -181,7 +181,7 @@ public class RegistryTester
_omgr.postRunnable(new Runnable() {
public void run () {
for (AgentObject obj : _agents) {
- TestServer.breg.destroyAgent(obj);
+ _bureauReg.destroyAgent(obj);
}
}
});
@@ -197,7 +197,7 @@ public class RegistryTester
(size != 0 && _rng1.nextInt(100) >= _createChance)) {
AgentObject toRemove = _agents.remove(_rng1.nextInt(size));
log.info("Removing agent " + toRemove.getOid());
- TestServer.breg.destroyAgent(toRemove);
+ _bureauReg.destroyAgent(toRemove);
}
else {
AgentObject added = create(_rng1.nextInt(_numBureaus) + 1);
@@ -214,11 +214,12 @@ public class RegistryTester
AgentObject obj = new AgentObject();
obj.bureauType = "test";
obj.bureauId = "test-" + bureau;
- TestServer.breg.startAgent(obj);
+ _bureauReg.startAgent(obj);
return obj;
}
@Inject protected RootDObjectManager _omgr;
+ @Inject protected BureauRegistry _bureauReg;
protected TestServer _server;
protected boolean _stop;
diff --git a/tests/src/java/com/threerings/bureau/server/TestServer.java b/tests/src/java/com/threerings/bureau/server/TestServer.java
index 5fb3aa891..f3a5584d6 100644
--- a/tests/src/java/com/threerings/bureau/server/TestServer.java
+++ b/tests/src/java/com/threerings/bureau/server/TestServer.java
@@ -22,7 +22,9 @@
package com.threerings.bureau.server;
import com.google.inject.Guice;
+import com.google.inject.Inject;
import com.google.inject.Injector;
+import com.google.inject.Singleton;
import com.threerings.presents.server.PresentsServer;
@@ -31,13 +33,9 @@ import static com.threerings.bureau.Log.log;
/**
* Extends a presents server to include a bureau registry.
*/
+@Singleton
public class TestServer extends PresentsServer
{
- /**
- * The bureau registry for the server. Will be null until init is called.
- */
- public static BureauRegistry breg;
-
/**
* Creates a new server and runs it.
*/
@@ -47,7 +45,7 @@ public class TestServer extends PresentsServer
TestServer server = injector.getInstance(TestServer.class);
try {
server.init(injector);
- setClientTarget("bureau-runclient");
+ server.setClientTarget("bureau-runclient");
server.run();
} catch (Exception e) {
@@ -55,38 +53,34 @@ public class TestServer extends PresentsServer
}
}
+ public static BureauRegistry.CommandGenerator antCommandGenerator (final String target)
+ {
+ return new BureauRegistry.CommandGenerator() {
+ public String[] createCommand (String serverNameAndPort, String bureauId, String token) {
+ int colon = serverNameAndPort.indexOf(':');
+ return new String[] {
+ "ant",
+ "-DserverName=" + serverNameAndPort.substring(0, colon),
+ "-DserverPort=" + serverNameAndPort.substring(colon + 1),
+ "-DbureauId=" + bureauId,
+ "-Dtoken=" + token,
+ target };
+ }
+ };
+ }
+
@Override // from PresentsServer
public void init (Injector injector)
throws Exception
{
super.init(injector);
- breg = new BureauRegistry("localhost:47624", _invmgr, _omgr, _invoker);
+ _bureauReg.init("localhost:47624");
}
-
- public static void setClientTarget (String target)
- {
- breg.setCommandGenerator("test", antCommandGenerator(target));
- }
-
- public static BureauRegistry.CommandGenerator antCommandGenerator (
- final String target)
- {
- return new BureauRegistry.CommandGenerator() {
- public String[] createCommand (
- String serverNameAndPort,
- String bureauId,
- String token) {
-
- int colon = serverNameAndPort.indexOf(':');
- String [] cmd = {"ant",
- "-DserverName=" + serverNameAndPort.substring(0, colon),
- "-DserverPort=" + serverNameAndPort.substring(colon + 1),
- "-DbureauId=" + bureauId,
- "-Dtoken=" + token,
- target};
- return cmd;
- }
- };
+ public void setClientTarget (String target)
+ {
+ _bureauReg.setCommandGenerator("test", antCommandGenerator(target));
}
+
+ @Inject protected BureauRegistry _bureauReg;
}
diff --git a/tests/src/java/com/threerings/crowd/server/JabberServer.java b/tests/src/java/com/threerings/crowd/server/JabberServer.java
index 7e01e7b62..24216fad8 100644
--- a/tests/src/java/com/threerings/crowd/server/JabberServer.java
+++ b/tests/src/java/com/threerings/crowd/server/JabberServer.java
@@ -12,21 +12,11 @@ import com.threerings.crowd.data.PlaceObject;
import static com.threerings.crowd.Log.log;
/**
- * A basic server that creates a single room and sticks everyone in it
- * where they can chat with one another.
+ * A basic server that creates a single room and sticks everyone in it where they can chat with one
+ * another.
*/
public class JabberServer extends CrowdServer
{
- // documentation inherited
- public void init (Injector injector)
- throws Exception
- {
- super.init(injector);
-
- // create a single location
- _pmgr = plreg.createPlace(new JabberConfig());
- }
-
public static void main (String[] args)
{
Injector injector = Guice.createInjector(new Module());
@@ -40,5 +30,15 @@ public class JabberServer extends CrowdServer
}
}
+ @Override // from CrowdServer
+ public void init (Injector injector)
+ throws Exception
+ {
+ super.init(injector);
+
+ // create a single location
+ _pmgr = _plreg.createPlace(new JabberConfig());
+ }
+
protected PlaceManager _pmgr;
}
diff --git a/tests/src/java/com/threerings/presents/data/TestMarshaller.java b/tests/src/java/com/threerings/presents/data/TestMarshaller.java
index 1ee09dbcf..7f1b76899 100644
--- a/tests/src/java/com/threerings/presents/data/TestMarshaller.java
+++ b/tests/src/java/com/threerings/presents/data/TestMarshaller.java
@@ -2,7 +2,7 @@
// $Id$
//
// Narya library - tools for developing networked games
-// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
+// Copyright (C) 2002-2008 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
@@ -23,8 +23,8 @@ package com.threerings.presents.data;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.TestService;
-import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.dobj.InvocationResponseEvent;
+import com.threerings.presents.net.Transport;
import java.util.ArrayList;
/**
@@ -37,7 +37,9 @@ import java.util.ArrayList;
public class TestMarshaller extends InvocationMarshaller
implements TestService
{
- // documentation inherited
+ /**
+ * Marshalls results to implementations of {@link TestFuncListener}.
+ */
public static class TestFuncMarshaller extends ListenerMarshaller
implements TestFuncListener
{
@@ -45,16 +47,16 @@ public class TestMarshaller extends InvocationMarshaller
* responses. */
public static final int TEST_SUCCEEDED = 1;
- // documentation inherited from interface
+ // from interface TestFuncMarshaller
public void testSucceeded (String arg1, int arg2)
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, TEST_SUCCEEDED,
- new Object[] { arg1, Integer.valueOf(arg2) }));
+ new Object[] { arg1, Integer.valueOf(arg2) }, transport));
}
- // documentation inherited
+ @Override // from InvocationMarshaller
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
@@ -70,7 +72,9 @@ public class TestMarshaller extends InvocationMarshaller
}
}
- // documentation inherited
+ /**
+ * Marshalls results to implementations of {@link TestOidListener}.
+ */
public static class TestOidMarshaller extends ListenerMarshaller
implements TestOidListener
{
@@ -78,16 +82,16 @@ public class TestMarshaller extends InvocationMarshaller
* responses. */
public static final int GOT_TEST_OID = 1;
- // documentation inherited from interface
+ // from interface TestOidMarshaller
public void gotTestOid (int arg1)
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, GOT_TEST_OID,
- new Object[] { Integer.valueOf(arg1) }));
+ new Object[] { Integer.valueOf(arg1) }, transport));
}
- // documentation inherited
+ @Override // from InvocationMarshaller
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
@@ -106,7 +110,7 @@ public class TestMarshaller extends InvocationMarshaller
/** The method id used to dispatch {@link #getTestOid} requests. */
public static final int GET_TEST_OID = 1;
- // documentation inherited from interface
+ // from interface TestService
public void getTestOid (Client arg1, TestService.TestOidListener arg2)
{
TestMarshaller.TestOidMarshaller listener2 = new TestMarshaller.TestOidMarshaller();
@@ -119,7 +123,7 @@ public class TestMarshaller extends InvocationMarshaller
/** The method id used to dispatch {@link #test} requests. */
public static final int TEST = 2;
- // documentation inherited from interface
+ // from interface TestService
public void test (Client arg1, String arg2, int arg3, ArrayList arg4, TestService.TestFuncListener arg5)
{
TestMarshaller.TestFuncMarshaller listener5 = new TestMarshaller.TestFuncMarshaller();
@@ -128,5 +132,4 @@ public class TestMarshaller extends InvocationMarshaller
arg2, Integer.valueOf(arg3), arg4, listener5
});
}
-
}
diff --git a/tests/src/java/com/threerings/presents/server/TestDispatcher.java b/tests/src/java/com/threerings/presents/server/TestDispatcher.java
index 36504474a..bff009206 100644
--- a/tests/src/java/com/threerings/presents/server/TestDispatcher.java
+++ b/tests/src/java/com/threerings/presents/server/TestDispatcher.java
@@ -2,7 +2,7 @@
// $Id$
//
// Narya library - tools for developing networked games
-// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
+// Copyright (C) 2002-2008 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
@@ -25,14 +25,12 @@ import com.threerings.presents.client.TestService;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.data.TestMarshaller;
-import com.threerings.presents.server.InvocationDispatcher;
-import com.threerings.presents.server.InvocationException;
import java.util.ArrayList;
/**
* Dispatches requests to the {@link TestProvider}.
*/
-public class TestDispatcher extends InvocationDispatcher
+public class TestDispatcher extends InvocationDispatcher
{
/**
* Creates a dispatcher that may be registered to dispatch invocation
@@ -43,13 +41,14 @@ public class TestDispatcher extends InvocationDispatcher
this.provider = provider;
}
- // documentation inherited
- public InvocationMarshaller createMarshaller ()
+ @Override // documentation inherited
+ public TestMarshaller createMarshaller ()
{
return new TestMarshaller();
}
- @SuppressWarnings("unchecked") // documentation inherited
+ @SuppressWarnings("unchecked")
+ @Override // documentation inherited
public void dispatchRequest (
ClientObject source, int methodId, Object[] args)
throws InvocationException
diff --git a/tests/src/java/com/threerings/presents/server/TestProvider.java b/tests/src/java/com/threerings/presents/server/TestProvider.java
index b0341186a..71ac53884 100644
--- a/tests/src/java/com/threerings/presents/server/TestProvider.java
+++ b/tests/src/java/com/threerings/presents/server/TestProvider.java
@@ -2,7 +2,7 @@
// $Id$
//
// Narya library - tools for developing networked games
-// Copyright (C) 2002-2006 Three Rings Design, Inc., All Rights Reserved
+// Copyright (C) 2002-2008 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
@@ -23,8 +23,6 @@ package com.threerings.presents.server;
import com.threerings.presents.client.TestService;
import com.threerings.presents.data.ClientObject;
-import com.threerings.presents.server.InvocationException;
-import com.threerings.presents.server.InvocationProvider;
import java.util.ArrayList;
/**