Package tests.support

Examples of tests.support.Support_URLConnector


        // create a server socket
        Support_HttpServerSocket serversocket = new Support_HttpServerSocket();

        // create a client connector
        Support_URLConnector client = new Support_URLConnector();

        // pass both to the HttpTest
        Support_HttpTests test = new Support_HttpTests(serversocket, client);

        // run various tests common to both HttpConnections and
        // HttpURLConnections
        test.runTests(this);

        // 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();
            }
View Full Code Here


    // create a serversocket
    Support_HttpServerSocket serversocket = new Support_HttpServerSocket();

    // create a client connector
    Support_URLConnector client = new Support_URLConnector();

    // pass both to the HttpTest
    Support_HttpTests test = new Support_HttpTests(serversocket, client);

    // run various tests common to both HttpConnections and
    // HttpURLConnections
    test.runTests(this);

    // 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();
View Full Code Here

    public void testClosingOutputStream() throws IOException {
//      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;
        final String postTestUrl = "http://localhost:" + portNumber
            + Support_HttpServer.POSTTEST;

        String toWrite = "abcdef";
        connector.open(postTestUrl);
        OutputStream out = connector.getOutputStream();
        System.out.println("Output stream = " + out.hashCode());
        out.write(toWrite.getBytes("ISO8859_1"));
        out.close();
        is = connector.getInputStream();
        bout.reset();
        do {
            c = is.read();
            if (c != -1) {
                bout.write(c);
            }
        } while (c != -1);
        is.close();
        connector.close();
        String result = new String(bout.toByteArray(), "ISO8859_1");
        assertTrue("Error sending data 1: " + result, toWrite
                .equals(result));  
       
        toWrite = "zyxwvuts";
        connector.open(postTestUrl);
        connector.setRequestProperty("Transfer-encoding", "chunked");
        out = connector.getOutputStream();
        System.out.println("Output stream = " + out.hashCode());
        out.write(toWrite.getBytes("ISO8859_1"));
        out.close();
        is = connector.getInputStream();
        bout.reset();
        do {
            c = is.read();
            if (c != -1) {
                bout.write(c);
            }
        } while (c != -1);
        is.close();
        connector.close();
        result = new String(bout.toByteArray(), "ISO8859_1");
        assertEquals(toWrite, result);
       
    }
View Full Code Here

    // create a serversocket
    Support_HttpServerSocket serversocket = new Support_HttpServerSocket();

    // create a client connector
    Support_URLConnector client = new Support_URLConnector();

    // pass both to the HttpTest
    Support_HttpTests test = new Support_HttpTests(serversocket, client);

    // run various tests common to both HttpConnections and
    // HttpURLConnections
    test.runTests(this);

    // 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();
View Full Code Here

        // create a server socket
        Support_HttpServerSocket serversocket = new Support_HttpServerSocket();

        // create a client connector
        Support_URLConnector client = new Support_URLConnector();

        // pass both to the HttpTest
        Support_HttpTests test = new Support_HttpTests(serversocket, client);

        // run various tests common to both HttpConnections and
        // HttpURLConnections
        test.runTests(this);

        // 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();
            }
View Full Code Here

        // create a server socket
        Support_HttpServerSocket serversocket = new Support_HttpServerSocket();

        // create a client connector
        Support_URLConnector client = new Support_URLConnector();

        // pass both to the HttpTest
        Support_HttpTests test = new Support_HttpTests(serversocket, client);

        // run various tests common to both HttpConnections and
        // HttpURLConnections
        test.runTests(this);

        // 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();
            }
View Full Code Here

    public void testClosingOutputStream() throws IOException {
//      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;
        final String postTestUrl = "http://localhost:" + portNumber
            + Support_HttpServer.POSTTEST;

        String toWrite = "abcdef";
        connector.open(postTestUrl);
        OutputStream out = connector.getOutputStream();
        System.out.println("Output stream = " + out.hashCode());
        out.write(toWrite.getBytes("ISO8859_1"));
        out.close();
        is = connector.getInputStream();
        bout.reset();
        do {
            c = is.read();
            if (c != -1) {
                bout.write(c);
            }
        } while (c != -1);
        is.close();
        connector.close();
        String result = new String(bout.toByteArray(), "ISO8859_1");
        assertTrue("Error sending data 1: " + result, toWrite
                .equals(result));  
       
        toWrite = "zyxwvuts";
        connector.open(postTestUrl);
        connector.setRequestProperty("Transfer-encoding", "chunked");
        out = connector.getOutputStream();
        System.out.println("Output stream = " + out.hashCode());
        out.write(toWrite.getBytes("ISO8859_1"));
        out.close();
        is = connector.getInputStream();
        bout.reset();
        do {
            c = is.read();
            if (c != -1) {
                bout.write(c);
            }
        } while (c != -1);
        is.close();
        connector.close();
        result = new String(bout.toByteArray(), "ISO8859_1");
        assertEquals(toWrite, result);
       
    }
View Full Code Here

        // create a server socket
        Support_HttpServerSocket serversocket = new Support_HttpServerSocket();

        // create a client connector
        Support_URLConnector client = new Support_URLConnector();

        // pass both to the HttpTest
        Support_HttpTests test = new Support_HttpTests(serversocket, client);

        // run various tests common to both HttpConnections and
        // HttpURLConnections
        test.runTests(this);

        // 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();
            }
View Full Code Here

        // create a server socket
        Support_HttpServerSocket serversocket = new Support_HttpServerSocket();

        // create a client connector
        Support_URLConnector client = new Support_URLConnector();

        // pass both to the HttpTest
        Support_HttpTests test = new Support_HttpTests(serversocket, client);

        // run various tests common to both HttpConnections and
        // HttpURLConnections
        test.runTests(this);

        // 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();
            }
View Full Code Here

TOP

Related Classes of tests.support.Support_URLConnector

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.