Package java.net

Examples of java.net.HttpURLConnection.connect()


        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "POST" );
        client.connect();

        assertTrue( client.getResponseCode() == 200 );
        assertFalse( testServlet.isGetCalled() );
        assertFalse( testServlet.isDeleteCalled() );
        assertTrue( testServlet.isPostCalled() );
View Full Code Here


        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "PUT" );

        client.connect();

        assertTrue( client.getResponseCode() == 200 );
        assertFalse( testServlet.isGetCalled() );
        assertFalse( testServlet.isDeleteCalled() );
        assertFalse( testServlet.isPostCalled() );
View Full Code Here

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "DELETE" );

        client.connect();

        assertTrue( client.getResponseCode() == 200 );
        assertFalse( testServlet.isGetCalled() );
        assertTrue( testServlet.isDeleteCalled() );
        assertFalse( testServlet.isPostCalled() );
View Full Code Here

        BasicTestingServlet testServlet = new BasicTestingServlet( content, false );
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        client.connect();

        assertTrue( client.getResponseCode() == 200 );

        String response = readInputAsString( client.getInputStream() );
View Full Code Here

        testServlet = new BasicTestingServlet( content, true );
        httpService.registerServlet( "/test", testServlet, null, null );

        client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        client.connect();

        assertTrue( client.getResponseCode() == 200 );

        response = readInputAsString( client.getInputStream() );
        printBytes( content.getBytes() );
View Full Code Here

        BasicTestingServlet testServlet = new BasicTestingServlet( content, false );
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        client.connect();

        assertTrue( client.getResponseCode() == 200 );

        byte[] response = readInputAsByteArray( client.getInputStream() );
View Full Code Here

        HttpService httpService = getHTTPService( registry.getBundleContext() );

        httpService.registerResources( "/", "/webroot/", null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/index.html", "GET" );
        client.connect();

        assertTrue( client.getResponseCode() == 200 );
        String response = readInputAsString( client.getInputStream() );
        assertNotNull( response );
        assertTrue( response.indexOf( "boo" ) > -1 );
View Full Code Here

        HttpService httpService = getHTTPService( registry.getBundleContext() );

        httpService.registerResources( "/", "/webroot/", null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/index2.html", "GET" );
        client.connect();

        assertTrue( client.getResponseCode() == 404 );
    }
}
View Full Code Here

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test/a/b/c", "GET" );

        client.connect();
        assertTrue( client.getResponseCode() == 200 );
        assertTrue( testServlet.getPathInfo().equals( "/a/b/c" ) );
    }

View Full Code Here

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test/a/b//c", "GET" );

        client.connect();
        assertTrue( client.getResponseCode() == 200 );
        assertTrue( testServlet.getPathInfo().equals( "/a/b/c" ) );
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.