Exemplo n.º 1
0
  protected void waitForTomcat() throws IOException, InterruptedException {
    logger.info("Waiting for tomcat");

    String uri = String.format("http://%s:%d/motech-platform-server/module/server", HOST, PORT);
    HttpGet waitGet = new HttpGet(uri);
    HttpResponse response = HTTP_CLIENT.execute(waitGet);
    logger.info("Proceeding after getting a response: {}", response);

    logger.info("Tomcat is running");
  }
Exemplo n.º 2
0
  protected void logout() throws IOException, InterruptedException {
    String uri =
        String.format(
            "http://%s:%d/motech-platform-server/module/server/j_spring_security_logout",
            HOST, PORT);

    final HttpGet logoutGet = new HttpGet(uri);

    logger.info("Trying to logout from MOTECH");
    HttpResponse response = HTTP_CLIENT.execute(logoutGet);
    logger.info("Response status: {}", response.getStatusLine().getStatusCode());
    EntityUtils.consume(response.getEntity());
    logger.info("Logged out from MOTECH");
  }
Exemplo n.º 3
0
  protected JSONArray getBundleStatusFromServer(PollingHttpClient httpClient)
      throws IOException, JSONException, InterruptedException {
    logger.info("Trying to get a list of bundles installed in MOTECH");

    String uri =
        String.format("http://%s:%d/motech-platform-server/module/admin/api/bundles", HOST, PORT);
    String response = httpClient.execute(new HttpGet(uri), new BasicResponseHandler());
    logger.info("Collected the list of bundles installed in MOTECH");

    assertNotNull(response, "Unable to retrieve bundle status from server");

    logger.debug("Server response for bundle status request: \n" + response);

    return new JSONArray(response);
  }
Exemplo n.º 4
0
  protected void createAdminUser() throws IOException, InterruptedException {
    String url =
        String.format("http://%s:%d/motech-platform-server/module/server/startup", HOST, PORT);
    String json =
        "{\"language\":\"en\", \"adminLogin\":\"motech\", \"adminPassword\":\"motech\", \"adminConfirmPassword\": \"motech\", \"adminEmail\":\"[email protected]\", \"loginMode\":\"repository\"}";

    StringEntity entity = new StringEntity(json, HTTP.UTF_8);
    entity.setContentType("application/json");

    HttpPost post = new HttpPost(url);
    post.setEntity(entity);

    logger.info("Trying to create admin user ({}) in MOTECH", MOTECH);
    HttpResponse response = HTTP_CLIENT.execute(post);
    logger.info("Response status: {}", response.getStatusLine().getStatusCode());
    EntityUtils.consume(response.getEntity());
    logger.info("Created admin user ({}) in MOTECH", MOTECH);
  }
Exemplo n.º 5
0
  protected void login() throws IOException, InterruptedException {
    String uri =
        String.format(
            "http://%s:%d/motech-platform-server/module/server/motech-platform-server/j_spring_security_check",
            HOST, PORT);

    final HttpPost loginPost = new HttpPost(uri);

    List<NameValuePair> nvps = new ArrayList<>();
    nvps.add(new BasicNameValuePair("j_username", MOTECH));
    nvps.add(new BasicNameValuePair("j_password", MOTECH));

    loginPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF8"));

    logger.info("Trying to login into MOTECH as {}", MOTECH);
    HttpResponse response = HTTP_CLIENT.execute(loginPost);
    logger.info("Response status: {}", response.getStatusLine().getStatusCode());
    EntityUtils.consume(response.getEntity());
    logger.info("Logged into MOTECH as {}", MOTECH);
  }