diff --git a/core/src/test/java/com/threerings/presents/client/TestService.java b/core/src/test/java/com/threerings/presents/client/TestService.java index 9754fef52..3557b2097 100644 --- a/core/src/test/java/com/threerings/presents/client/TestService.java +++ b/core/src/test/java/com/threerings/presents/client/TestService.java @@ -23,12 +23,12 @@ package com.threerings.presents.client; import java.util.List; -import com.threerings.presents.data.ClientObject; +import com.threerings.presents.data.TestClientObject; /** * A test of the invocation services. */ -public interface TestService extends InvocationService +public interface TestService extends InvocationService { /** Used to dispatch responses to {@link TestService#test} requests. */ public static interface TestFuncListener extends InvocationListener diff --git a/core/src/test/java/com/threerings/presents/data/TestClientObject.java b/core/src/test/java/com/threerings/presents/data/TestClientObject.java new file mode 100644 index 000000000..57aec96e2 --- /dev/null +++ b/core/src/test/java/com/threerings/presents/data/TestClientObject.java @@ -0,0 +1,29 @@ +// +// $Id$ +// +// Narya library - tools for developing networked games +// Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved +// http://code.google.com/p/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; + +/** + * Used to test using a custom client object in invocation services. + */ +public class TestClientObject extends ClientObject +{ +} diff --git a/core/src/test/java/com/threerings/presents/data/TestMarshaller.java b/core/src/test/java/com/threerings/presents/data/TestMarshaller.java index 36c1c4273..8b4c96a03 100644 --- a/core/src/test/java/com/threerings/presents/data/TestMarshaller.java +++ b/core/src/test/java/com/threerings/presents/data/TestMarshaller.java @@ -37,7 +37,7 @@ import com.threerings.presents.client.TestService; */ @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, comments="Derived from TestService.java.") -public class TestMarshaller extends InvocationMarshaller +public class TestMarshaller extends InvocationMarshaller implements TestService { /** diff --git a/core/src/test/java/com/threerings/presents/server/TestManager.java b/core/src/test/java/com/threerings/presents/server/TestManager.java index c664c58fd..b50239903 100644 --- a/core/src/test/java/com/threerings/presents/server/TestManager.java +++ b/core/src/test/java/com/threerings/presents/server/TestManager.java @@ -26,7 +26,7 @@ import java.util.List; import com.google.inject.Inject; import com.threerings.presents.client.TestService; -import com.threerings.presents.data.ClientObject; +import com.threerings.presents.data.TestClientObject; import com.threerings.presents.server.ClientManager; import static com.threerings.presents.Log.log; @@ -38,7 +38,7 @@ public class TestManager implements TestProvider { // from interface TestProvider - public void getTestOid (ClientObject caller, + public void getTestOid (TestClientObject caller, TestService.TestOidListener listener) throws InvocationException { @@ -51,7 +51,7 @@ public class TestManager } // from interface TestProvider - public void test (ClientObject caller, String one, int two, List three, + public void test (TestClientObject caller, String one, int two, List three, TestService.TestFuncListener listener) throws InvocationException { @@ -62,7 +62,7 @@ public class TestManager } // from interface TestProvider - public void giveMeThePower (ClientObject caller, TestService.ConfirmListener listener) + public void giveMeThePower (TestClientObject caller, TestService.ConfirmListener listener) { log.info("Giving " + caller.who() + " the power!"); _clmgr.getClient(caller.username).setIncomingMessageThrottle(20); diff --git a/core/src/test/java/com/threerings/presents/server/TestProvider.java b/core/src/test/java/com/threerings/presents/server/TestProvider.java index d9995d939..e5fbc3ecf 100644 --- a/core/src/test/java/com/threerings/presents/server/TestProvider.java +++ b/core/src/test/java/com/threerings/presents/server/TestProvider.java @@ -27,7 +27,7 @@ import javax.annotation.Generated; import com.threerings.presents.client.InvocationService; import com.threerings.presents.client.TestService; -import com.threerings.presents.data.ClientObject; +import com.threerings.presents.data.TestClientObject; /** * Defines the server-side of the {@link TestService}. @@ -39,18 +39,18 @@ public interface TestProvider extends InvocationProvider /** * Handles a {@link TestService#getTestOid} request. */ - void getTestOid (ClientObject caller, TestService.TestOidListener arg1) + void getTestOid (TestClientObject caller, TestService.TestOidListener arg1) throws InvocationException; /** * Handles a {@link TestService#giveMeThePower} request. */ - void giveMeThePower (ClientObject caller, InvocationService.ConfirmListener arg1) + void giveMeThePower (TestClientObject caller, InvocationService.ConfirmListener arg1) throws InvocationException; /** * Handles a {@link TestService#test} request. */ - void test (ClientObject caller, String arg1, int arg2, List arg3, TestService.TestFuncListener arg4) + void test (TestClientObject caller, String arg1, int arg2, List arg3, TestService.TestFuncListener arg4) throws InvocationException; } diff --git a/core/src/test/java/com/threerings/presents/server/TestServer.java b/core/src/test/java/com/threerings/presents/server/TestServer.java index 50c2cbcfc..d29576450 100644 --- a/core/src/test/java/com/threerings/presents/server/TestServer.java +++ b/core/src/test/java/com/threerings/presents/server/TestServer.java @@ -23,8 +23,12 @@ package com.threerings.presents.server; import com.google.inject.Injector; +import com.threerings.presents.data.ClientObject; +import com.threerings.presents.data.TestClientObject; import com.threerings.presents.data.TestMarshaller; import com.threerings.presents.data.TestObject; +import com.threerings.presents.net.AuthRequest; +import com.threerings.util.Name; public class TestServer extends PresentsServer { @@ -40,6 +44,15 @@ public class TestServer extends PresentsServer _invmgr.registerProvider(injector.getInstance(TestManager.class), TestMarshaller.class, "test"); + _clmgr.setDefaultSessionFactory(new SessionFactory() { + @Override public Class getSessionClass (AuthRequest areq) { + return PresentsSession.class; + } + @Override public Class getClientResolverClass (Name username) { + return TestClientResolver.class; + } + }); + // create a test object testobj = _omgr.registerObject(new TestObject()); testobj.longs.add(System.currentTimeMillis()); @@ -52,4 +65,10 @@ public class TestServer extends PresentsServer { runServer(new PresentsModule(), new PresentsServerModule(TestServer.class)); } + + protected static class TestClientResolver extends ClientResolver { + @Override public ClientObject createClientObject () { + return new TestClientObject(); + } + } }