Package com.linkedin.r2.message.rest

Examples of com.linkedin.r2.message.rest.RestResponse


  }

  @Test
  public void testRestResponseReversible3() throws IOException
  {
    final RestResponse res = createRestResponse().builder()
            .setEntity(new byte[] {1,2,3,4})
            .build();
    assertMsgEquals(res, readRestRes(writeRes(res)));
  }
View Full Code Here


  }

  @Test
  public void testRestResponseReversible4() throws IOException
  {
    final RestResponse res = createRestResponse().builder()
            .setHeader("field-key1", "field-val1")
            .setHeader("field-key2", "field-val2")
            .build();
    assertMsgEquals(res, readRestRes(writeRes(res)));
  }
View Full Code Here

  }

  @Test
  public void testRestResponseReversible5() throws IOException
  {
    final RestResponse res = createRestResponse().builder()
            .addHeaderValue("field-key1", "field-val1")
            .addHeaderValue("field-key1", "field-val2")
            .build();
    assertMsgEquals(res, readRestRes(writeRes(res)));
  }
View Full Code Here

    FutureCallback<RestResponse> futureCallback = new FutureCallback<RestResponse>();
    TransportCallback<RestResponse> callback =
        new TransportCallbackAdapter<RestResponse>(futureCallback);
    TransportCallback<RestResponse> bridgeCallback = HttpBridge.httpToRestCallback(callback);

    RestResponse restResponse = new RestResponseBuilder().build();

    // Note: FutureCallback will fail if called twice. An exception would be raised on the current
    // thread because we begin the callback sequence here in onResponse.
    // (test originally added due to bug with double callback invocation)
    bridgeCallback.onResponse(TransportResponseImpl.<RestResponse> error(new RestException(restResponse)));

    RestResponse resp = futureCallback.get(30, TimeUnit.SECONDS);
    // should have unpacked restResponse from the RestException that we passed in without
    // propagating the actual exception
    Assert.assertSame(resp, restResponse);
  }
View Full Code Here

            }
            double start = System.nanoTime();
            sendMessage(client, request, callback);
            try
            {
              RestResponse response = callback.get();
              resptime = (System.nanoTime() - start)/1000000;
              int resplength = response.getEntity().length();
              if ( resplength > 0)
              {
                NumberFormat formatter = new DecimalFormat("####.##");
                _log.info(message("OK",String.valueOf(resplength)," in "+formatter.format(resptime)+"ms", relative_uri,remote_host, current_host));
              }
View Full Code Here

    throws Exception
  {
    final Request<BatchKVResponse<ComplexResourceKey<TwoPartKey, TwoPartKey>, EntityResponse<Message>>> request = builder.build();
    final FutureCallback<RestResponse> callback = new FutureCallback<RestResponse>();
    REST_CLIENT.sendRestRequest(request, new RequestContext(), callback);
    final RestResponse result = callback.get();

    final DataMap responseMap = DataMapUtils.readMap(result);
    final DataMap resultsMap = responseMap.getDataMap(BatchKVResponse.RESULTS);
    Assert.assertNotNull(resultsMap, "Response does not contain results map");
    Assert.assertTrue(resultsMap.isEmpty());
View Full Code Here

  {
    String result = "foo";
    RequestExecutionReport executionReport = new RequestExecutionReportBuilder().build();
    AugmentedRestLiResponseData responseData = new AugmentedRestLiResponseData.Builder(ResourceMethod.GET).build();
    PartialRestResponse partialResponse = new PartialRestResponse.Builder().build();
    RestResponse restResponse = new RestResponseBuilder().build();
    // Set up.
    when(_responseHandler.buildRestLiResponseData(_restRequest, _routingResult, result)).thenReturn(responseData);
    when(_responseHandler.buildPartialResponse(_routingResult, responseData)).thenReturn(partialResponse);
    when(_responseHandler.buildResponse(_routingResult, partialResponse)).thenReturn(restResponse);
View Full Code Here

        context.getResponseHeaders().putAll(headersFromFilters);
        return null;
      }
    }).when(_filter).onResponse(eq(_filterRequestContext), any(FilterResponseContext.class));

    RestResponse restResponse = new RestResponseBuilder().build();
    when(_responseHandler.buildResponse(_routingResult, partialResponse)).thenReturn(restResponse);

    // Invoke.
    _twoFilterRestLiCallback.onSuccess(result, executionReport);
View Full Code Here

                                                                   .headers(headersFromFilter).build();
    final RecordTemplate entityFromFilter = Foo.createFoo("Key", "Two");
    PartialRestResponse partialFilterErrorResponse = new PartialRestResponse.Builder().build();
    final Exception exFromFilter = new RuntimeException("Exception From Filter");
    // Common stuff.
    RestResponse restResponse = new RestResponseBuilder().build();
    // Setup.
    when(_responseHandler.buildRestLiResponseData(_restRequest, _routingResult, entityFromApp)).thenReturn(appResponseData);
    when(_restRequest.getHeaders()).thenReturn(null);
    when(
         _responseHandler.buildErrorResponseData(eq(_restRequest), eq(_routingResult),
View Full Code Here

        context.getResponseHeaders().putAll(headersFromFilter);
        return null;
      }
    }).when(_filter).onResponse(eq(_filterRequestContext), any(FilterResponseContext.class));

    RestResponse restResponse = new RestResponseBuilder().build();
    when(_responseHandler.buildResponse(_routingResult, partialResponse)).thenReturn(restResponse);


    // Invoke.
    _twoFilterRestLiCallback.onError(exFromApp, executionReport);
View Full Code Here

TOP

Related Classes of com.linkedin.r2.message.rest.RestResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.