@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 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 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 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 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 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 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 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 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 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 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 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 testFailTokenAuthInvalidateAppResource() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "POST"); params.put(InvalidationHandler.KEYS_PARAM, new String[]{"http://www.example.org/gadget.xml"}); try { operation.execute(params, null, token, converter).get(); fail("Expected error"); } catch (ExecutionException ee) { assertTrue(ee.getCause() instanceof ProtocolException); } }
@Test public void testFailTokenAuthInvalidateAppResource() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "POST"); params.put(InvalidationHandler.KEYS_PARAM, new String[]{"http://www.example.org/gadget.xml"}); try { operation.execute(params, null, token, converter).get(); fail("Expected error"); } catch (ExecutionException ee) { assertTrue(ee.getCause() instanceof ProtocolException); } }
@Test public void testFailTokenAuthInvalidateAppResource() throws Exception { String path = "/cache/invalidate"; RestHandler operation = registry.getRestHandler(path, "POST"); params.put(InvalidationHandler.KEYS_PARAM, new String[]{"http://www.example.org/gadget.xml"}); try { operation.execute(params, null, token, converter).get(); fail("Expected error"); } catch (ExecutionException ee) { assertTrue(ee.getCause() instanceof ProtocolException); } }
@Test public void testHandleGetSuportedFields() throws Exception { String path = "/activities/@supportedFields"; RestHandler operation = registry.getRestHandler(path, "GET"); replay(); @SuppressWarnings("unchecked") List<Object> received = (List<Object>) operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get(); assertEquals(2, received.size()); assertEquals("id", received.get(0).toString()); assertEquals("title", received.get(1).toString()); verify(); } }
@Test public void testHandleGetSupportedFields() throws Exception { String path = "/activitystreams/@supportedFields"; RestHandler operation = registry.getRestHandler(path, "GET"); replay(); @SuppressWarnings("unchecked") List<Object> received = (List<Object>) operation.execute(Maps.<String, String[]>newHashMap(), null, token, converter).get(); assertEquals(2, received.size()); assertEquals("id", received.get(0).toString()); assertEquals("title", received.get(1).toString()); verify(); } }