当前位置: 首页>>代码示例>>Java>>正文


Java ClientResponse类代码示例

本文整理汇总了Java中com.sun.jersey.api.client.ClientResponse的典型用法代码示例。如果您正苦于以下问题:Java ClientResponse类的具体用法?Java ClientResponse怎么用?Java ClientResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClientResponse类属于com.sun.jersey.api.client包,在下文中一共展示了ClientResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTaskAttemptsSlash

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testTaskAttemptsSlash() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    for (Task task : jobsMap.get(id).getTasks().values()) {

      String tid = MRApps.toString(task.getID());
      ClientResponse response = r.path("ws").path("v1").path("mapreduce")
          .path("jobs").path(jobId).path("tasks").path(tid).path("attempts/")
          .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
      assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
      JSONObject json = response.getEntity(JSONObject.class);
      verifyAMTaskAttempts(json, task);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestAMWebServicesAttempts.java

示例2: testSendHeartbeat

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testSendHeartbeat() throws InterruptedException {
    ZSession session = createSession("2");
    
    Thread.sleep(1000);
    WebResource wr = sessionsr.path(session.id);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    
    ClientResponse cr = b.put(ClientResponse.class, null);
    assertEquals(ClientResponse.Status.OK, cr.getClientResponseStatus());
    
    Thread.sleep(1500);
    assertTrue(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
    
    Thread.sleep(1000);
    assertFalse(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:18,代码来源:SessionTest.java

示例3: testGet

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testGet() throws Exception {
    LOG.info("STARTING " + getName());

    if (expectedStat != null) {
        if (expectedStat.data64 != null || expectedStat.dataUtf8 == null) {
            zk.setData(expectedStat.path, expectedStat.data64, -1);
        } else {
            zk.setData(expectedStat.path,
                    expectedStat.dataUtf8.getBytes(), -1);
        }
    }

    ClientResponse cr = znodesr.path(path).queryParam("dataformat", encoding)
        .accept(accept).get(ClientResponse.class);
    assertEquals(expectedStatus, cr.getClientResponseStatus());

    if (expectedStat == null) {
        return;
    }

    ZStat zstat = cr.getEntity(ZStat.class);
    assertEquals(expectedStat, zstat);
    assertEquals(znodesr.path(path).toString(), zstat.uri);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:26,代码来源:GetTest.java

示例4: postRest

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
/**
 * Performs a REST POST operation of a json string on the base
 * XOS REST URI with an optional additional URI suffix.
 *
 * @param uri URI suffix to append to base URI
 * @param json JSON string to post
 */
public void postRest(String uri, String json) {
    WebResource.Builder builder = getClientBuilder(uri);
    ClientResponse response;

    try {
        response = builder.post(ClientResponse.class, json);
    } catch (ClientHandlerException e) {
        log.warn("Unable to contact REST server: {}", e.getMessage());
        return;
    }

    if (response.getStatus() != HTTP_CREATED) {
        log.info("REST POST request returned error code {}",
                 response.getStatus());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:XosManagerRestUtils.java

示例5: testTasksXML

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testTasksXML() throws JSONException, Exception {

  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    ClientResponse response = r.path("ws").path("v1").path("mapreduce")
        .path("jobs").path(jobId).path("tasks")
        .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
    String xml = response.getEntity(String.class);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource is = new InputSource();
    is.setCharacterStream(new StringReader(xml));
    Document dom = db.parse(is);
    NodeList tasks = dom.getElementsByTagName("tasks");
    assertEquals("incorrect number of elements", 1, tasks.getLength());
    NodeList task = dom.getElementsByTagName("task");
    verifyAMTaskXML(task, jobsMap.get(id));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestAMWebServicesTasks.java

示例6: testTasksQueryReduce

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testTasksQueryReduce() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    String type = "r";
    ClientResponse response = r.path("ws").path("v1").path("history")
        .path("mapreduce").path("jobs").path(jobId).path("tasks")
        .queryParam("type", type).accept(MediaType.APPLICATION_JSON)
        .get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject tasks = json.getJSONObject("tasks");
    JSONArray arr = tasks.getJSONArray("task");
    assertEquals("incorrect number of elements", 1, arr.length());
    verifyHsTask(arr, jobsMap.get(id), type);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestHsWebServicesTasks.java

示例7: testJobIdSlash

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testJobIdSlash() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    ClientResponse response = r.path("ws").path("v1").path("history")
        .path("mapreduce").path("jobs").path(jobId + "/")
        .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject info = json.getJSONObject("job");

    VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestHsWebServicesJobs.java

示例8: testTaskAttemptsDefault

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testTaskAttemptsDefault() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    for (Task task : jobsMap.get(id).getTasks().values()) {

      String tid = MRApps.toString(task.getID());
      ClientResponse response = r.path("ws").path("v1").path("mapreduce")
          .path("jobs").path(jobId).path("tasks").path(tid).path("attempts")
          .get(ClientResponse.class);
      assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
      JSONObject json = response.getEntity(JSONObject.class);
      verifyAMTaskAttempts(json, task);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestAMWebServicesAttempts.java

示例9: testJobsQueryFinishTimeBegin

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testJobsQueryFinishTimeBegin() throws JSONException, Exception {
  WebResource r = resource();
  // the mockJobs finish time is the current time + some random amount
  Long now = System.currentTimeMillis();
  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs")
      .queryParam("finishedTimeBegin", String.valueOf(now))
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject jobs = json.getJSONObject("jobs");
  JSONArray arr = jobs.getJSONArray("job");
  assertEquals("incorrect number of elements", 3, arr.length());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestHsWebServicesJobsQuery.java

示例10: testJobsQueryFinishTimeBeginNegative

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testJobsQueryFinishTimeBeginNegative() throws JSONException,
    Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs")
      .queryParam("finishedTimeBegin", String.valueOf(-1000))
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject msg = response.getEntity(JSONObject.class);
  JSONObject exception = msg.getJSONObject("RemoteException");
  assertEquals("incorrect number of elements", 3, exception.length());
  String message = exception.getString("message");
  String type = exception.getString("exception");
  String classname = exception.getString("javaClassName");
  WebServicesTestUtils.checkStringMatch("exception message",
      "java.lang.Exception: finishedTimeBegin must be greater than 0",
      message);
  WebServicesTestUtils.checkStringMatch("exception type",
      "BadRequestException", type);
  WebServicesTestUtils.checkStringMatch("exception classname",
      "org.apache.hadoop.yarn.webapp.BadRequestException", classname);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestHsWebServicesJobsQuery.java

示例11: testJobAttempts

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testJobAttempts() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    ClientResponse response = r.path("ws").path("v1")
        .path("mapreduce").path("jobs").path(jobId).path("jobattempts")
        .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject info = json.getJSONObject("jobAttempts");
    verifyJobAttempts(info, jobsMap.get(id));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestAMWebServicesJobs.java

示例12: testJobsDefault

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testJobsDefault() throws JSONException, Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs").get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject jobs = json.getJSONObject("jobs");
  JSONArray arr = jobs.getJSONArray("job");
  assertEquals("incorrect number of elements", 1, arr.length());
  JSONObject info = arr.getJSONObject(0);
  Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
  VerifyJobsUtils.verifyHsJobPartial(info, job);

}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestHsWebServicesJobs.java

示例13: testTaskIdSlash

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testTaskIdSlash() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    for (Task task : jobsMap.get(id).getTasks().values()) {

      String tid = MRApps.toString(task.getID());
      ClientResponse response = r.path("ws").path("v1").path("mapreduce")
          .path("jobs").path(jobId).path("tasks").path(tid + "/")
          .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
      assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
      JSONObject json = response.getEntity(JSONObject.class);
      assertEquals("incorrect number of elements", 1, json.length());
      JSONObject info = json.getJSONObject("task");
      verifyAMSingleTask(info, task);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestAMWebServicesTasks.java

示例14: testAppsQueryQueue

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testAppsQueryQueue() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  rm.submitApp(CONTAINER_MB);
  rm.submitApp(CONTAINER_MB);

  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps").queryParam("queue", "default")
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject apps = json.getJSONObject("apps");
  assertEquals("incorrect number of elements", 1, apps.length());
  JSONArray array = apps.getJSONArray("app");
  assertEquals("incorrect number of elements", 2, array.length());
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRMWebServicesApps.java

示例15: testJobConfXML

import com.sun.jersey.api.client.ClientResponse; //导入依赖的package包/类
@Test
public void testJobConfXML() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    ClientResponse response = r.path("ws").path("v1").path("mapreduce")
        .path("jobs").path(jobId).path("conf")
        .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
    String xml = response.getEntity(String.class);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource is = new InputSource();
    is.setCharacterStream(new StringReader(xml));
    Document dom = db.parse(is);
    NodeList info = dom.getElementsByTagName("conf");
    verifyAMJobConfXML(info, jobsMap.get(id));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestAMWebServicesJobConf.java


注:本文中的com.sun.jersey.api.client.ClientResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。