Package tests.support

Examples of tests.support.Support_HttpServer$ServerThread


        // Authentication test is separate from other tests because it is only
        // in HttpURLConnection and not supported in HttpConnection

        serversocket = new Support_HttpServerSocket();
        Support_HttpServer server = new Support_HttpServer(serversocket, this);
        int p = Support_PortManager.getNextPort();
        server.startServer(p);

        // it is the Support_HttpServer's responsibility to close this
        // serversocket
        serversocket = null;

        final String authTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.AUTHTEST;

        // Authentication test
        // set up a very simple authenticator
        Authenticator.setDefault(new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("test", "password"
                        .toCharArray());
            }
        });
        try {
            client.open(authTestUrl);
            is = client.getInputStream();
            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
        } catch (FileNotFoundException e) {
            fail("Error performing authentication test: " + e);
        }

        final String invalidLocation = "/missingFile.htm";
        final String redirectTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.REDIRECTTEST;

        // test redirecting to a non-existent URL on the same host
        try {
            // append the response code for the server to return

            client.open(redirectTestUrl + "/" + Support_HttpServer.MOVED_PERM
                    + "-" + invalidLocation);
            is = client.getInputStream();

            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
            fail("Incorrect data returned on redirect to non-existent file.");
        } catch (FileNotFoundException e) {
        }
        server.stopServer();

    }
View Full Code Here


    // Authentication test is separate from other tests because it is only
    // in HttpURLConnection and not supported in HttpConnection

    serversocket = new Support_HttpServerSocket();
    Support_HttpServer server = new Support_HttpServer(serversocket, this);
    int p = Support_PortManager.getNextPort();
    server.startServer(p);

    // it is the Support_HttpServer's responsibility to close this
    // serversocket
    serversocket = null;

    final String authTestUrl = "http://localhost:" + server.getPort()
        + Support_HttpServer.AUTHTEST;

    // Authentication test
    try {
      // set up a very simple authenticator
      Authenticator.setDefault(new Authenticator() {
        public PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication("test", "password"
              .toCharArray());
        }
      });
      try {
        client.open(authTestUrl);
        is = client.getInputStream();
        int c = is.read();
        while (c > 0)
          c = is.read();
        c = is.read();
        is.close();
      } catch (FileNotFoundException e) {
        fail("Error performing authentication test: " + e);
      }
    } catch (Exception e) {
      fail("Exception during test3: " + e);
      e.printStackTrace();
    }

    final String invalidLocation = "/missingFile.htm";
    final String redirectTestUrl = "http://localhost:" + server.getPort()
        + Support_HttpServer.REDIRECTTEST;

    // test redirecting to a non-existent URL on the same host
    try {
      // append the response code for the server to return

      client.open(redirectTestUrl + "/" + Support_HttpServer.MOVED_PERM
          + "-" + invalidLocation);
      is = client.getInputStream();

      int c = is.read();
      while (c > 0)
        c = is.read();
      c = is.read();
      is.close();
      fail("Incorrect data returned on redirect to non-existent file.");
    } catch (FileNotFoundException e) {
    } catch (Exception e) {

      e.printStackTrace();
      fail("Exception during test4: " + e);
    }
    server.stopServer();

  }
View Full Code Here

//      create a serversocket
        Support_HttpServerSocket serversocket = new Support_HttpServerSocket();
        int portNumber = Support_PortManager.getNextPort();
        // create a client connector
        Support_URLConnector connector = new Support_URLConnector();
        Support_HttpServer server = new Support_HttpServer(serversocket, this);
       
        server.startServer(portNumber);


        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        InputStream is;
        int c;
View Full Code Here

    // Authentication test is separate from other tests because it is only
    // in HttpURLConnection and not supported in HttpConnection

    serversocket = new Support_HttpServerSocket();
    Support_HttpServer server = new Support_HttpServer(serversocket, this);
    int p = Support_PortManager.getNextPort();
    server.startServer(p);

    // it is the Support_HttpServer's responsibility to close this
    // serversocket
    serversocket = null;

    final String authTestUrl = "http://localhost:" + server.getPort()
        + Support_HttpServer.AUTHTEST;

    // Authentication test
                // set up a very simple authenticator
                Authenticator.setDefault(new Authenticator() {
                        public PasswordAuthentication getPasswordAuthentication() {
                                return new PasswordAuthentication("test", "password"
                                                .toCharArray());
                        }
                });
                try {
                        client.open(authTestUrl);
                        is = client.getInputStream();
                        int c = is.read();
                        while (c > 0)
                                c = is.read();
                        c = is.read();
                        is.close();
                } catch (FileNotFoundException e) {
                        fail("Error performing authentication test: " + e);
                }

    final String invalidLocation = "/missingFile.htm";
    final String redirectTestUrl = "http://localhost:" + server.getPort()
        + Support_HttpServer.REDIRECTTEST;

    // test redirecting to a non-existent URL on the same host
    try {
      // append the response code for the server to return

      client.open(redirectTestUrl + "/" + Support_HttpServer.MOVED_PERM
          + "-" + invalidLocation);
      is = client.getInputStream();

      int c = is.read();
      while (c > 0)
        c = is.read();
      c = is.read();
      is.close();
      fail("Incorrect data returned on redirect to non-existent file.");
    } catch (FileNotFoundException e) {
    }
    server.stopServer();

  }
View Full Code Here

        // Authentication test is separate from other tests because it is only
        // in HttpURLConnection and not supported in HttpConnection

        serversocket = new Support_HttpServerSocket();
        Support_HttpServer server = new Support_HttpServer(serversocket, this);
        int p = Support_PortManager.getNextPort();
        server.startServer(p);

        // it is the Support_HttpServer's responsibility to close this
        // serversocket
        serversocket = null;

        final String authTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.AUTHTEST;

        // Authentication test
        // set up a very simple authenticator
        Authenticator.setDefault(new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("test", "password"
                        .toCharArray());
            }
        });
        try {
            client.open(authTestUrl);
            is = client.getInputStream();
            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
        } catch (FileNotFoundException e) {
            fail("Error performing authentication test: " + e);
        }

        final String invalidLocation = "/missingFile.htm";
        final String redirectTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.REDIRECTTEST;

        // test redirecting to a non-existent URL on the same host
        try {
            // append the response code for the server to return

            client.open(redirectTestUrl + "/" + Support_HttpServer.MOVED_PERM
                    + "-" + invalidLocation);
            is = client.getInputStream();

            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
            fail("Incorrect data returned on redirect to non-existent file.");
        } catch (FileNotFoundException e) {
        }
        server.stopServer();

    }
View Full Code Here

        // Authentication test is separate from other tests because it is only
        // in HttpURLConnection and not supported in HttpConnection

        serversocket = new Support_HttpServerSocket();
        Support_HttpServer server = new Support_HttpServer(serversocket, this);
        int p = Support_PortManager.getNextPort();
        server.startServer(p);

        // it is the Support_HttpServer's responsibility to close this
        // serversocket
        serversocket = null;

        final String authTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.AUTHTEST;

        // Authentication test
        // set up a very simple authenticator
        Authenticator.setDefault(new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("test", "password"
                        .toCharArray());
            }
        });
        try {
            client.open(authTestUrl);
            is = client.getInputStream();
            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
        } catch (FileNotFoundException e) {
            fail("Error performing authentication test: " + e);
        }

        final String invalidLocation = "/missingFile.htm";
        final String redirectTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.REDIRECTTEST;

        // test redirecting to a non-existent URL on the same host
        try {
            // append the response code for the server to return

            client.open(redirectTestUrl + "/" + Support_HttpServer.MOVED_PERM
                    + "-" + invalidLocation);
            is = client.getInputStream();

            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
            fail("Incorrect data returned on redirect to non-existent file.");
        } catch (FileNotFoundException e) {
        }
        server.stopServer();

    }
View Full Code Here

//      create a serversocket
        Support_HttpServerSocket serversocket = new Support_HttpServerSocket();
        int portNumber = Support_PortManager.getNextPort();
        // create a client connector
        Support_URLConnector connector = new Support_URLConnector();
        Support_HttpServer server = new Support_HttpServer(serversocket, this);
       
        server.startServer(portNumber);


        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        InputStream is;
        int c;
View Full Code Here

        // Authentication test is separate from other tests because it is only
        // in HttpURLConnection and not supported in HttpConnection

        serversocket = new Support_HttpServerSocket();
        Support_HttpServer server = new Support_HttpServer(serversocket, this);
        int p = Support_PortManager.getNextPort();
        server.startServer(p);

        // it is the Support_HttpServer's responsibility to close this
        // serversocket
        serversocket = null;

        final String authTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.AUTHTEST;

        // Authentication test
        // set up a very simple authenticator
        Authenticator.setDefault(new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("test", "password"
                        .toCharArray());
            }
        });
        try {
            client.open(authTestUrl);
            is = client.getInputStream();
            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
        } catch (FileNotFoundException e) {
            fail("Error performing authentication test: " + e);
        }

        final String invalidLocation = "/missingFile.htm";
        final String redirectTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.REDIRECTTEST;

        // test redirecting to a non-existent URL on the same host
        try {
            // append the response code for the server to return

            client.open(redirectTestUrl + "/" + Support_HttpServer.MOVED_PERM
                    + "-" + invalidLocation);
            is = client.getInputStream();

            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
            fail("Incorrect data returned on redirect to non-existent file.");
        } catch (FileNotFoundException e) {
        }
        server.stopServer();

    }
View Full Code Here

        // Authentication test is separate from other tests because it is only
        // in HttpURLConnection and not supported in HttpConnection

        serversocket = new Support_HttpServerSocket();
        Support_HttpServer server = new Support_HttpServer(serversocket, this);
        int p = Support_PortManager.getNextPort();
        server.startServer(p);

        // it is the Support_HttpServer's responsibility to close this
        // serversocket
        serversocket = null;

        final String authTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.AUTHTEST;

        // Authentication test
        // set up a very simple authenticator
        Authenticator.setDefault(new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("test", "password"
                        .toCharArray());
            }
        });
        try {
            client.open(authTestUrl);
            is = client.getInputStream();
            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
        } catch (FileNotFoundException e) {
            fail("Error performing authentication test: " + e);
        }

        final String invalidLocation = "/missingFile.htm";
        final String redirectTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.REDIRECTTEST;

        // test redirecting to a non-existent URL on the same host
        try {
            // append the response code for the server to return

            client.open(redirectTestUrl + "/" + Support_HttpServer.MOVED_PERM
                    + "-" + invalidLocation);
            is = client.getInputStream();

            int c = is.read();
            while (c > 0) {
                c = is.read();
            }
            c = is.read();
            is.close();
            fail("Incorrect data returned on redirect to non-existent file.");
        } catch (FileNotFoundException e) {
        }
        server.stopServer();

    }
View Full Code Here

TOP

Related Classes of tests.support.Support_HttpServer$ServerThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.