@Test public void testSupportedRpcServices() throws Exception { assertEquals(registry.getSupportedRpcServices(), Sets.newHashSet("test.create", "test.get", "test.overridden", "test.exception", "test.futureException", "test.override.rpcname", "test.echo", "test.noArg")); }
@Test public void testSupportedRestServices() throws Exception { assertEquals(registry.getSupportedRestServices(), Sets.newHashSet("GET /test/{someParam}/{someOtherParam}", "PUT /test/{someParam}/{someOtherParam}", "DELETE /test/{someParam}/{someOtherParam}", "POST /test/{someParam}/{someOtherParam}", "GET /test/overridden/method", "GET /test/echo")); }
@Test public void testRpcWithInputClassThatIsntRequestItem() throws Exception { JSONObject rpc = new JSONObject("{ method : test.echo, params: {value: 'Bob' }}"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }
@Test public void testRestWithInputClassThatIsntRequestItem() throws Exception { RestHandler handler = registry.getRestHandler("/test/echo", "GET"); String[] value = {"Bob"}; Future<?> future = handler.execute(ImmutableMap.of("value", value), null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }
@Test public void testRpcWithInputClassThatIsntRequestItem() throws Exception { JSONObject rpc = new JSONObject("{ method : test.echo, params: {value: 'Bob' }}"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }
@Test public void testNoArgumentClass() throws Exception { JSONObject rpc = new JSONObject("{ method : test.noArg }"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(TestHandler.NO_ARG_RESPONSE, future.get()); }
@Test public void testNonFutureDispatch() throws Exception { // Test calling a handler method which does not return a future RestHandler handler = registry.getRestHandler("/test", "GET"); Future<?> future = handler.execute(Maps.<String, String[]>newHashMap(), null, null, null); assertEquals(TestHandler.GET_RESPONSE, future.get()); }
@Test public void testNoArgumentClass() throws Exception { JSONObject rpc = new JSONObject("{ method : test.noArg }"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(TestHandler.NO_ARG_RESPONSE, future.get()); }
@Test public void testRpcWithInputClassThatIsntRequestItem() throws Exception { JSONObject rpc = new JSONObject("{ method : test.echo, params: {value: 'Bob' }}"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }
@Test public void testRestWithInputClassThatIsntRequestItem() throws Exception { RestHandler handler = registry.getRestHandler("/test/echo", "GET"); String[] value = {"Bob"}; Future<?> future = handler.execute(ImmutableMap.of("value", value), null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }
@Test public void testNoArgumentClass() throws Exception { JSONObject rpc = new JSONObject("{ method : test.noArg }"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(TestHandler.NO_ARG_RESPONSE, future.get()); }
@Test public void testNonFutureDispatch() throws Exception { // Test calling a handler method which does not return a future RestHandler handler = registry.getRestHandler("/test", "GET"); Future<?> future = handler.execute(Maps.<String, String[]>newHashMap(), null, null, null); assertEquals(TestHandler.GET_RESPONSE, future.get()); }
@Test public void testRestWithInputClassThatIsntRequestItem() throws Exception { RestHandler handler = registry.getRestHandler("/test/echo", "GET"); String[] value = {"Bob"}; Future<?> future = handler.execute(ImmutableMap.of("value", value), null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }
@Test public void testNoArgumentClass() throws Exception { JSONObject rpc = new JSONObject("{ method : test.noArg }"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(TestHandler.NO_ARG_RESPONSE, future.get()); }
@Test public void testNonFutureDispatch() throws Exception { // Test calling a handler method which does not return a future RestHandler handler = registry.getRestHandler("/test", "GET"); Future<?> future = handler.execute(Maps.<String, String[]>newHashMap(), null, null, null); assertEquals(TestHandler.GET_RESPONSE, future.get()); }
@Test public void testRpcWithInputClassThatIsntRequestItem() throws Exception { JSONObject rpc = new JSONObject("{ method : test.echo, params: {value: 'Bob' }}"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }
@Test public void testNoArgumentClass() throws Exception { JSONObject rpc = new JSONObject("{ method : test.noArg }"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(TestHandler.NO_ARG_RESPONSE, future.get()); }
@Test public void testFutureDispatch() throws Exception { // Test calling a handler method which does not return a future RestHandler handler = registry.getRestHandler("/test", "POST"); Future<?> future = handler.execute(Maps.<String, String[]>newHashMap(), null, null, null); assertEquals(TestHandler.CREATE_RESPONSE, future.get()); }
@Test public void testFutureDispatch() throws Exception { // Test calling a handler method which does not return a future RestHandler handler = registry.getRestHandler("/test", "POST"); Future<?> future = handler.execute(Maps.<String, String[]>newHashMap(), null, null, null); assertEquals(TestHandler.CREATE_RESPONSE, future.get()); }
@Test public void testRpcWithInputClassThatIsntRequestItem() throws Exception { JSONObject rpc = new JSONObject("{ method : test.echo, params: {value: 'Bob' }}"); RpcHandler handler = registry.getRpcHandler(rpc); Future<?> future = handler.execute(null, null, converter); assertEquals(future.get(), TestHandler.ECHO_PREFIX + "Bob"); }