gpt4 book ai didi

org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 20:45:05 26 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode()方法的一些代码示例,展示了WebServicesTestUtils.assertResponseStatusCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebServicesTestUtils.assertResponseStatusCode()方法的具体详情如下:
包路径:org.apache.hadoop.yarn.webapp.WebServicesTestUtils
类名称:WebServicesTestUtils
方法名:assertResponseStatusCode

WebServicesTestUtils.assertResponseStatusCode介绍

暂无

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-common

public static void assertResponseStatusCode(StatusType expected,
  StatusType actual) {
 assertResponseStatusCode(null, expected, actual);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private JSONObject testListReservationHelper(WebResource resource, Status
    status) throws Exception {
 Thread.sleep(1000);
 ClientResponse response = resource.get(ClientResponse.class);
 if (!this.isAuthenticationEnabled()) {
  assertResponseStatusCode(Status.UNAUTHORIZED, response.getStatusInfo());
  return null;
 }
 assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
   response.getType().toString());
 assertResponseStatusCode(status, response.getStatusInfo());
 return response.getEntity(JSONObject.class);
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Test
public void testInvalidUri2() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr = r.accept(MediaType.APPLICATION_JSON).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
    "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public Void call() throws Exception {
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token").accept(contentType)
     .delete(ClientResponse.class);
  assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo());
  return null;
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public DelegationToken call() throws Exception {
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token").accept(contentType)
     .entity(dtoken, mediaType).post(ClientResponse.class);
  assertResponseStatusCode(Status.OK, response.getStatusInfo());
  DelegationToken tok = getDelegationTokenFromResponse(response);
  return tok;
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private void verifySimpleAuthCancel() {
 // contents of header don't matter; request should never get that far
 ClientResponse response =
   resource().path("ws").path("v1").path("cluster")
    .path("delegation-token").queryParam("user.name", "testuser")
    .header(RMWebServices.DELEGATION_TOKEN_HEADER, "random")
    .delete(ClientResponse.class);
 assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo());
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public DelegationToken call() throws Exception {
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token").accept(contentType)
     .entity(dtoken, mediaType).post(ClientResponse.class);
  assertResponseStatusCode(Status.OK, response.getStatusInfo());
  DelegationToken tok = getDelegationTokenFromResponse(response);
  return tok;
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public Void call() throws Exception {
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token")
     .header(yarnTokenHeader, "random-string").accept(contentType)
     .delete(ClientResponse.class);
  assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo());
  return null;
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public DelegationToken call() throws Exception {
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token").accept(contentType)
     .entity(dtoken, mediaType).post(ClientResponse.class);
  assertResponseStatusCode(Status.OK, response.getStatusInfo());
  DelegationToken tok = getDelegationTokenFromResponse(response);
  return tok;
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-applicationhistoryservice

@Test
public void testInvalidUri2() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr = r.queryParam("user.name", USERS[round])
    .accept(MediaType.APPLICATION_JSON).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
   "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

private void verifySimpleAuthCreate(String mediaType, String contentType,
  String body) {
 ClientResponse response =
   resource().path("ws").path("v1").path("cluster")
    .path("delegation-token").queryParam("user.name", "testuser")
    .accept(contentType).entity(body, mediaType)
    .post(ClientResponse.class);
 assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo());
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public Void call() throws Exception {
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token")
     .header(yarnTokenHeader, tmpToken.getToken())
     .accept(contentType).delete(ClientResponse.class);
  assertResponseStatusCode(Status.OK, response.getStatusInfo());
  assertTokenCancelled(tmpToken.getToken());
  return null;
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public Void call() throws Exception {
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token")
     .header(yarnTokenHeader, tmpToken2.getToken())
     .accept(contentType).delete(ClientResponse.class);
  assertResponseStatusCode(Status.FORBIDDEN,
    response.getStatusInfo());
  assertValidRMToken(tmpToken2.getToken());
  return null;
 }
});

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

@Test
public void testInvalidAccept() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr = r.path("ws").path("v1").path("mapreduce")
    .accept(MediaType.TEXT_PLAIN).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.INTERNAL_SERVER_ERROR,
    response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
    "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

@Test
public void testInvalidUri2() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr = r.path("ws").path("v1").path("invalid")
    .accept(MediaType.APPLICATION_JSON).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
    "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-applicationhistoryservice

@Test
public void testInvalidApp() {
 ApplicationId appId = ApplicationId.newInstance(0, MAX_APPS + 1);
 WebResource r = resource();
 ClientResponse response =
   r.path("ws").path("v1").path("applicationhistory").path("apps")
    .path(appId.toString())
    .queryParam("user.name", USERS[round])
    .accept(MediaType.APPLICATION_JSON)
    .get(ClientResponse.class);
 assertResponseStatusCode("404 not found expected",
   Status.NOT_FOUND, response.getStatusInfo());
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

@Test
public void testInvalidUri() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr = r.path("ws").path("v1").path("mapreduce").path("bogus")
    .accept(MediaType.APPLICATION_JSON).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
    "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Test
public void testInvalidUri() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr = r.path("ws").path("v1").path("cluster").path("bogus")
    .accept(MediaType.APPLICATION_JSON).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
    "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-applicationhistoryservice

@Test
public void testInvalidUri() throws JSONException, Exception {
 WebResource r = resource();
 String responseStr = "";
 try {
  responseStr =
    r.path("ws").path("v1").path("applicationhistory").path("bogus")
     .queryParam("user.name", USERS[round])
     .accept(MediaType.APPLICATION_JSON).get(String.class);
  fail("should have thrown exception on invalid uri");
 } catch (UniformInterfaceException ue) {
  ClientResponse response = ue.getResponse();
  assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo());
  WebServicesTestUtils.checkStringMatch(
   "error string exists and shouldn't", "", responseStr);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public DelegationToken call() throws Exception {
  String body =
    generateRenewTokenBody(mediaType, responseToken.getToken());
  ClientResponse response =
    resource().path("ws").path("v1").path("cluster")
     .path("delegation-token").path("expiration")
     .header(yarnTokenHeader, responseToken.getToken())
     .accept(contentType).entity(body, mediaType)
     .post(ClientResponse.class);
  assertResponseStatusCode(Status.FORBIDDEN,
    response.getStatusInfo());
  return null;
 }
});

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com