コード例 #1
0
  @Test
  public void testServiceRegistryFunctionsOnJsonRequestBody() throws Exception {
    Map<String, String> initParams = new HashMap<String, String>();
    initParams.put("request.body", "oozie-conf");
    setUp("test-user", initParams);

    String input =
        TestUtils.getResourceString(
            ServiceRegistryFunctionsTest.class, "test-input-body.json", "UTF-8");
    String expect =
        TestUtils.getResourceString(
            ServiceRegistryFunctionsTest.class, "test-expect-body.json", "UTF-8");

    // Setup the server side request/response interaction.
    interaction
        .expect()
        .method("PUT")
        .requestUrl("http://test-host:42/test-path")
        .contentType("application/json")
        .characterEncoding("UTF-8")
        .content(expect, Charset.forName("UTF-8"));
    interaction.respond().status(200);
    interactions.add(interaction);
    request.setMethod("PUT");
    request.setURI("/test-path");
    request.setVersion("HTTP/1.1");
    request.setHeader("Host", "test-host:42");
    request.setContentType("application/json; charset=UTF-8");
    request.setContent(input);

    response.parse(server.getResponses(request.generate()));

    // Test the results.
    assertThat(response.getStatus(), Is.is(200));
  }