private boolean isClassAvailableToDeployment(String deploymentName, Class<?> clazz)
     throws IOException, HttpException {
   String className = clazz.getName();
   String CONTEXT_URL = PortProviderUtil.generateURL("/", deploymentName);
   HttpGet httpget =
       new HttpGet(
           CONTEXT_URL
               + TestResource.LOAD_CLASS_PATH
               + "?"
               + TestResource.CLASSNAME_PARAM
               + "="
               + className);
   try {
     String responseString = new String();
     HttpClientContext context = HttpClientContext.create();
     CloseableHttpResponse response = client.execute(httpget, context);
     HttpEntity entity = response.getEntity();
     if (entity != null) {
       responseString = EntityUtils.toString(entity, StandardCharsets.UTF_8);
     }
     return (HttpStatus.SC_OK == response.getStatusLine().getStatusCode())
         && (className.equals(responseString));
   } finally {
     httpget.releaseConnection();
   }
 }
  private void assertResponse(String deploymentName) throws IOException, HttpException {

    String CONTEXT_URL = PortProviderUtil.generateURL("/", deploymentName);

    HttpGet httpget = new HttpGet(CONTEXT_URL + TestResource.TEST_PATH);

    HttpClientContext context = HttpClientContext.create();
    CloseableHttpResponse response = client.execute(httpget, context);
    assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
    HttpEntity entity = response.getEntity();
    String responseString = EntityUtils.toString(entity, StandardCharsets.UTF_8);
    assertEquals(
        "The server resource didn't send correct response",
        TestResource.TEST_RESPONSE,
        responseString);
    httpget.releaseConnection();
  }
예제 #3
0
 private String generateURL(String path) {
   return PortProviderUtil.generateURL(path, GenericEntityTest.class.getSimpleName());
 }
예제 #4
0
 private String generateURL(String path) {
   return PortProviderUtil.generateURL(path, XmlHeaderTest.class.getSimpleName());
 }