Code example for PasswordAuthentication

0
            connection.setReadTimeout(2000);
 
            server.start();
            synchronized(bound) {
                if (!server.started) bound.wait(5000);
            } 
            proxy.start();
            synchronized(bound) {
                if (!proxy.started) bound.wait(5000);
            } 
            connection.connect();
 
            // wait while server and proxy run 
            server.join();
            proxy.join();
 
            assertTrue("Connection does not use proxy", 
                                            connection.usingProxy());
            assertTrue("Proxy server was not used", proxy.accepted);
        } finally { 
            // restore default proxy selector