예제 #1
0
  public static void main(String args[]) {

    // The stat reporter writes out the test info and results
    // into the top-level quicklook directory during a run.

    stat.addDescription("Unit test for IT 13555");

    WebTest webTest = new WebTest(args);

    int port = new Integer(webTest.portS).intValue();
    String name;

    try {
      webTest.goGet(webTest.host, port, webTest.contextRoot + "/test");
    } catch (Throwable t) {
      System.out.println(t.getMessage());
      stat.addStatus(" Test " + TEST_NAME + " UNPREDICTED-FAILURE", stat.FAIL);
    } finally {
      try {
        if (webTest.sock != null) {
          webTest.sock.close();
        }
      } catch (IOException ioe) {
        // ignore
      }
    }

    stat.printSummary(TEST_NAME + " ---> PASS");
  }
예제 #2
0
  public static void main(String args[]) {

    // The stat reporter writes out the test info and results
    // into the top-level quicklook directory during a run.

    stat.addDescription("http-listener reader-threads unit tests.");

    String host = args[0];
    String portS = args[1];
    String contextRoot = args[2];

    int port = new Integer(portS).intValue();
    String name;

    try {
      goGet(host, port, "FILTER", contextRoot + "/ServletTest");
    } catch (Throwable t) {
      System.out.println(t.getMessage());
    }

    if (count != EXPECTED_COUNT) {
      stat.addStatus("web-readerThreadsConfig", stat.FAIL);
    }
    stat.printSummary("web/standalonewar---> expect " + EXPECTED_COUNT);
  }
예제 #3
0
  private void goGet(String host, int port, String contextPath) throws Exception {

    sock = new Socket(host, port);
    OutputStream os = sock.getOutputStream();

    System.out.println(("GET " + contextPath + " HTTP/1.0\n"));
    os.write(("GET " + contextPath + " HTTP/1.0\n").getBytes());
    os.write("\n".getBytes());

    InputStream is = null;
    BufferedReader bis = null;
    String line = null;
    boolean pass = false;
    try {
      is = sock.getInputStream();
      bis = new BufferedReader(new InputStreamReader(is));
      while ((line = bis.readLine()) != null) {
        System.out.println(line);
        // Check if the filter was invoked
        if (EXPECTED_RESPONSE.equals("LLiFFiSSi")) {
          pass = true;
          break;
        }
      }
    } finally {
      try {
        if (is != null) {
          is.close();
        }
      } catch (IOException ioe) {
        // ignore
      }
      try {
        if (bis != null) {
          bis.close();
        }
      } catch (IOException ioe) {
        // ignore
      }
    }

    if (pass) {
      System.out.println("security constraint processed");
      stat.addStatus(TEST_NAME + " PASSED", stat.PASS);
    } else {
      System.out.println("security constraint NOT processed");
      stat.addStatus(TEST_NAME + " FAILED", stat.FAIL);
    }
  }
예제 #4
0
  public static void main(String args[]) {

    // The stat reporter writes out the test info and results
    // into the top-level quicklook directory during a run.

    stat.addDescription("Test BodyTag behavior when tag is reused");

    String host = args[0];
    String portS = args[1];
    String contextRoot = args[2];
    int port = new Integer(portS).intValue();

    try {
      goGet(host, port, contextRoot + "/test.jsp");
      stat.addStatus("BodyTag test", pass ? stat.PASS : stat.FAIL);
    } catch (Throwable t) {
      System.out.println(t.getMessage());
      stat.addStatus("Test UNPREDICTED-FAILURE", stat.FAIL);
    }

    stat.printSummary("BodyTag Reuse");
  }
예제 #5
0
  private static void goGet(String host, int port, String result, String contextPath)
      throws Exception {
    long time = System.currentTimeMillis();
    Socket s = new Socket(host, port);
    s.setSoTimeout(5000);
    OutputStream os = s.getOutputStream();

    System.out.println(("GET " + contextPath + " HTTP/1.1\n"));
    os.write(("GET " + contextPath + " HTTP/1.1\n").getBytes());
    os.write(("Host: localhost\n").getBytes());
    os.write("\n".getBytes());

    InputStream is = s.getInputStream();
    System.out.println("Time: " + (System.currentTimeMillis() - time));
    BufferedReader bis = new BufferedReader(new InputStreamReader(is));
    String line = null;

    try {
      int index;
      while ((line = bis.readLine()) != null) {
        index = line.indexOf(result);
        System.out.println(line);
        if (index != -1) {
          index = line.indexOf(":");
          String status = line.substring(index + 1);

          if (status.equalsIgnoreCase("PASS")) {
            stat.addStatus("web-readerThreadsConfig: " + line.substring(0, index), stat.PASS);
          } else {
            stat.addStatus("web-readerThreadsConfig: " + line.substring(0, index), stat.FAIL);
          }
          count++;
        }
      }
    } catch (Exception ex) {
    }
  }