Package com.google.greaze.definition.webservice

Examples of com.google.greaze.definition.webservice.RequestSpec


 
  public void testUrlParams() {
    HeaderMapSpec headersSpec = new HeaderMapSpec.Builder().build();
    UrlParamsSpec urlParamSpec = new UrlParamsSpec.Builder().put("foo", String.class).build();
    RequestBodySpec bodySpec = new RequestBodySpec.Builder().build();
    RequestSpec spec = new RequestSpec(headersSpec, urlParamSpec, bodySpec);
    RequestReceiver receiver = new RequestReceiver(new GsonBuilder(), spec);
    HttpServletRequest req = new HttpServletRequestFake()
      .setRequestMethod("GET")
      .setUrlParam("foo", "bar");
    WebServiceRequest request = receiver.receive(req);
View Full Code Here


  }

  @SuppressWarnings({"unchecked", "rawtypes"})
  @Override
  public List<R> query(Q query, WebContext context) {
    RequestSpec requestSpec = callSpec.getRequestSpec();
    HeaderMap.Builder requestHeadersBuilder = new HeaderMap.Builder(requestSpec.getHeadersSpec());
    if (context != null) {
      context.populate(requestHeadersBuilder);
    }
    RequestBody requestBody = new RequestBody.Builder(requestSpec.getBodySpec())
      .build();
    UrlParams urlParams = new UrlParams.Builder(requestSpec.getUrlParamsSpec(), query).build();
    WebServiceRequest request = new WebServiceRequest(
        HttpMethod.GET, requestHeadersBuilder.build(), urlParams, requestBody, inlined);
    WebServiceResponse response = stub.getResponse(callSpec, request, gson);
    ResponseBody body = response.getBody();
    // Using a local variable for listBody otherwise Maven freaks out while compiling
View Full Code Here

    Preconditions.checkNotNull(resourceQuery);
    WebContextSpec webContextSpec = resourceQuery.getWebContextSpec();
    WebServiceCallSpec spec = ResourceQueryUtils.generateCallSpec(callPath,
        resourceQuery.getResourceType(), resourceQuery.getQueryType(),
        webContextSpec);
    RequestSpec requestSpec = spec.getRequestSpec();
    RequestReceiver requestReceiver = new RequestReceiver(gsonBuilder.get(), requestSpec);
    WebServiceRequest webServiceRequest = requestReceiver.receive(req);

    ResourceQueryParams queryParams =
      (ResourceQueryParams) webServiceRequest.getUrlParameters().getParamsObject();
View Full Code Here

      .put("X-Name", "bob")
      .put("X-Salary", 10000)
      .build();
    UrlParams urlParams = null;
    RequestBody requestBody = null;
    RequestSpec requestSpec = null;
    WebServiceRequest request = new WebServiceRequest(
        HttpMethod.GET, requestHeaders, urlParams, requestBody, requestSpec, false);
    HttpUrlConnectionMock conn = new HttpUrlConnectionMock();
    sender.send(conn, request);
    assertEquals("bob", conn.getHeaders().get("X-Name"));
View Full Code Here

    HeaderMap requestHeaders = new HeaderMap.Builder(requestHeaderSpec)
      .put("X-Number", new ComplexNumber(10, 3))
      .build();
    UrlParams urlParams = null;
    RequestBody requestBody = null;
    RequestSpec requestSpec = null;
    WebServiceRequest request = new WebServiceRequest(
        HttpMethod.GET, requestHeaders, urlParams, requestBody, requestSpec, false);
    HttpUrlConnectionMock conn = new HttpUrlConnectionMock();
    sender.send(conn, request);
    assertEquals("{\"real\":10,\"imaginary\":3}", conn.getHeaders().get("X-Number"));
View Full Code Here

    this.injector = injector;
  }

  public void service(HttpServletRequest req, HttpServletResponse res) {
    WebServiceCallSpec spec = injector.getInstance(WebServiceCallSpec.class);
    RequestSpec requestSpec = spec.getRequestSpec();
    ResponseSpec responseSpec = spec.getResponseSpec();
    GsonBuilder gsonBuilder = injector.getInstance(GsonBuilder.class);
    RequestReceiver requestReceiver = new RequestReceiver(gsonBuilder, requestSpec);
    WebServiceRequest webServiceRequest = requestReceiver.receive(req);
View Full Code Here

TOP

Related Classes of com.google.greaze.definition.webservice.RequestSpec

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.