Package com.google.greaze.server.fixtures

Examples of com.google.greaze.server.fixtures.HttpServletRequestFake


    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);
    assertEquals("bar", request.getUrlParameters().getParamsMap().get("foo"));
  }
View Full Code Here


  }

  public void testNoParams() {
    UrlParamsSpec spec = new UrlParamsSpec.Builder().build();
    UrlParamsExtractor extractor = new UrlParamsExtractor(spec, gson);
    HttpServletRequestFake request = new HttpServletRequestFake().setRequestMethod("GET");
    UrlParams urlParams = extractor.extractUrlParams(request);
    assertEquals(0, urlParams.getParamsMap().entrySet().size());
  }
View Full Code Here

    UrlParamsSpec spec = new UrlParamsSpec.Builder().put("foo", String.class).build();
    UrlParams urlParameters = new UrlParams.Builder(spec)
      .put("foo", "bar bar").build();
    String urlParamsString = urlParamBuilder.add(urlParameters).build();
    UrlParamsExtractor extractor = new UrlParamsExtractor(spec, gson);
    HttpServletRequestFake request = new HttpServletRequestFake()
      .setRequestMethod("GET")
      .setUrlParams(urlParamsString);
    UrlParams urlParams = extractor.extractUrlParams(request);
    assertEquals("bar bar", urlParams.getParamsMap().get("foo"));
  }
View Full Code Here

    };
  }

  @Override
  protected void switchNetwork(HttpURLConnectionFake conn) throws IOException {
    HttpServletRequest req = new HttpServletRequestFake()
      .setResourceUrlPaths(conn.getURL(), urlPaths)
      .setRequestMethod(conn.getRequestMethod())
      .setHeaders(conn.getHeaders())
      .setInputStream(conn.getForwardForInput());
    OutputStream reverseForOutput = conn.getReverseForOutput();
View Full Code Here

TOP

Related Classes of com.google.greaze.server.fixtures.HttpServletRequestFake

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.