@Before public void setUp() throws Exception { converter = new BeanJsonConverter(Guice.createInjector()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(Sets.<Object>newHashSet(new TestHandler())); }
if (m.isAnnotationPresent(Operation.class)) { Operation op = m.getAnnotation(Operation.class); createRpcHandler(handlerProvider, service, op, m); createRestHandler(handlerProvider, service, op, m);
@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"); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); messageService = EasyMock.createMock(MessageService.class); messageService = EasyMock.createMock(MessageService.class); converter = EasyMock.createMock(BeanJsonConverter.class); sender = new UserId(UserId.Type.userId, "message.sender"); recipients = ImmutableList.of("second.recipient", "first.recipient"); handler = new MessageHandler(messageService); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
@Test public void testGetHandlerRPC() throws Exception { assertNotNull(registry.getRpcHandler(new JSONObject("{method : test.get}"))); }
@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(expected = IllegalStateException.class) public void testAddNonService() { registry.addHandlers(Sets.newHashSet(new Object())); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); messageService = EasyMock.createMock(MessageService.class); messageService = EasyMock.createMock(MessageService.class); converter = EasyMock.createMock(BeanJsonConverter.class); sender = new UserId(UserId.Type.userId, "message.sender"); recipients = ImmutableList.of("second.recipient", "first.recipient"); handler = new MessageHandler(messageService, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
@Test public void testOverrideHandlerRPC() throws Exception { assertNotNull(registry.getRpcHandler(new JSONObject("{method : test.overidden}"))); }
@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(expected = IllegalStateException.class) public void testAddNonService() { registry.addHandlers(Sets.newHashSet(new Object())); }
@Before public void setUp() throws Exception { token = new FakeGadgetToken(); messageService = EasyMock.createMock(MessageService.class); messageService = EasyMock.createMock(MessageService.class); converter = EasyMock.createMock(BeanJsonConverter.class); sender = new UserId(UserId.Type.userId, "message.sender"); recipients = ImmutableList.of("second.recipient", "first.recipient"); handler = new MessageHandler(messageService, new CollectionOptionsFactory()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(ImmutableSet.<Object>of(handler)); }
@Before public void setUp() throws Exception { converter = new BeanJsonConverter(Guice.createInjector()); registry = new DefaultHandlerRegistry(null, converter, new HandlerExecutionListener.NoOpHandler()); registry.addHandlers(Sets.<Object>newHashSet(new TestHandler())); }
@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 testOverrideHandlerRPC() throws Exception { assertNotNull(registry.getRpcHandler(new JSONObject("{method : test.overidden}"))); }
if (m.isAnnotationPresent(Operation.class)) { Operation op = m.getAnnotation(Operation.class); createRpcHandler(handlerProvider, service, op, m); createRestHandler(handlerProvider, service, op, m);
@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")); }