Package com.linkedin.r2.message.rest

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


    HttpClientFactory factory = new HttpClientFactory(FilterChains.empty(), channelFactory, true, scheduler, true);

    Client client = new TransportClientAdapter(factory.getClient(
            Collections.<String, Object>emptyMap()));

    Future<RestResponse> responseFuture = client.restRequest(new RestRequestBuilder(_testServer.resetResponseLatch(1)).build());


    FutureCallback<None> factoryShutdown = new FutureCallback<None>();
    factory.shutdown(factoryShutdown);
View Full Code Here


      String serviceName = proportion.getKey();
      for (int i = 0; i < queryPerSecond; i++)
      {
        final URI uri = new URI("d2://" + serviceName);
        final long sent = System.currentTimeMillis();
        RestRequestBuilder requestBuilder = new RestRequestBuilder(uri).setMethod("get");
        RestRequest request = requestBuilder.build();
        //we don't care about the result from the server after all,
        //you can see the traffic hits the echo server from stdout
        d2Client.restRequest(request, new Callback<RestResponse>()
        {
          @Override
View Full Code Here

    Map<String, ResourceModel> resourceModelMap =
        buildResourceModels(StatusCollectionResource.class, LocationResource.class, DiscoveredItemsResource.class);
    ResourceModel statusResourceModel = resourceModelMap.get("/statuses");
    ResourceMethodDescriptor resourceMethodDescriptor = statusResourceModel.findMethod(ResourceMethod.GET);
    final StatusCollectionResource resource = getMockResource(StatusCollectionResource.class);
    RestRequestBuilder builder =
        new RestRequestBuilder(new URI("/statuses/1")).setMethod("GET")
                                                      .addHeaderValue("Accept", "application/json")
                                                      .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION,
                                                                 AllProtocolVersions.LATEST_PROTOCOL_VERSION.toString());
    RestRequest request = builder.build();
    RoutingResult routingResult =
        new RoutingResult(new ResourceContextImpl(buildPathKeys("statusID", 1L), request, new RequestContext()),
                          resourceMethodDescriptor);
    expect(mockRegistry.getArgumentBuilder(resourceMethodDescriptor.getType())).andReturn(mockBuilder);
    expect(mockBuilder.extractRequestData(routingResult, request)).andReturn(requestData);
View Full Code Here

    String jsonEntityBody = RestLiTestHelper.doubleQuote(
      "{'first': 42, 'last': 42, 'email': 42, " +
      "'company': 42, 'openToMarketingEmails': 'false'}");

    RestRequest request =
            new RestRequestBuilder(new URI("/accounts?action=register"))
                    .setMethod("POST").setEntity(jsonEntityBody.getBytes(Data.UTF_8_CHARSET))
                    .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString())
                    .build();

    RoutingResult routingResult = new RoutingResult(new ResourceContextImpl(null, request,
View Full Code Here

    String jsonEntityBody = RestLiTestHelper.doubleQuote(
      "{'statuses':[1,2,3]}");

    RestRequest request =
            new RestRequestBuilder(new URI("/accounts?action=spamTweets"))
                    .setMethod("POST").setEntity(jsonEntityBody.getBytes(Data.UTF_8_CHARSET))
                    .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString())
                    .build();

    RoutingResult routingResult = new RoutingResult(new ResourceContextImpl(null, request,
View Full Code Here

  {
    ResourceModel repliesResourceModel = buildResourceModel(RepliesCollectionResource.class);
    ResourceMethodDescriptor methodDescriptor = repliesResourceModel.findNamedMethod("noCoercerCustomString");

    RestRequest request =
            new RestRequestBuilder(new URI(uri))
                    .setMethod("GET")
                    .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString())
                    .build();

    RoutingResult routingResult = new RoutingResult(new ResourceContextImpl(null, request,
View Full Code Here

  {
    ResourceModel repliesResourceModel = buildResourceModel(RepliesCollectionResource.class);
    ResourceMethodDescriptor methodDescriptor = repliesResourceModel.findNamedMethod("customLong");

    RestRequest request =
            new RestRequestBuilder(new URI(uri))
                    .setMethod("GET")
                    .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString())
                    .build();

    RoutingResult routingResult = new RoutingResult(new ResourceContextImpl(null, request,
View Full Code Here

  }

  @Test
  public void testInvokeWithUnsupportedAcceptMimeType() throws Exception
  {
    RestRequestBuilder builder = new RestRequestBuilder(new URI(""))
        .addHeaderValue("Accept", "text/plain")
        .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString());
    RestRequest request = builder.build();
    final CountDownLatch latch = new CountDownLatch(1);
    final RestLiCallback<Object> callback =
        new RestLiCallback<Object>(request,
                                   null,
                                   new RestLiResponseHandler.Builder().build(),
View Full Code Here

  }

  @Test
  public void testInvokeWithInvalidAcceptMimeType() throws Exception
  {
    RestRequestBuilder builder = new RestRequestBuilder(new URI(""))
        .addHeaderValue("Accept", "foo")
        .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString());
    RestRequest request = builder.build();
    final CountDownLatch latch = new CountDownLatch(1);
    final RestLiCallback<Object> callback =
        new RestLiCallback<Object>(request,
                                   null,
                                   new RestLiResponseHandler.Builder().build(),
View Full Code Here

    try
    {
      EasyMock.replay(resource);

      RestRequestBuilder builder =
          new RestRequestBuilder(new URI(uri)).setMethod(httpMethod).addHeaderValue("Accept", "application/json")
              .setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, version.toString());
      if (entityBody != null)
      {
        builder.setEntity(entityBody.getBytes(Data.UTF_8_CHARSET));
      }
      RestRequest request = builder.build();
      RoutingResult routingResult = new RoutingResult(new ResourceContextImpl(pathkeys, request,
                                                                              new RequestContext()), resourceMethodDescriptor);
      final CountDownLatch latch = new CountDownLatch(1);
      final RestLiCallback<Object> outerCallback = new RestLiCallback<Object>(request,
                                                                    routingResult,
View Full Code Here

TOP

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

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.