Package java.net

Examples of java.net.HttpURLConnection.connect()


     * @throws java.io.IOException
     */
    protected String getOriginatingIp() throws IOException {
        URL url = new URL("http://checkip.amazonaws.com/");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.connect();
        InputStream in = connection.getInputStream();
        try {
            return CharStreams.toString(new InputStreamReader(in)).trim() + "/32";
        } finally {
            in.close();
View Full Code Here


   
    @Test
    public void testGetSayHi() throws Exception {
        HttpURLConnection httpConnection =
            getHttpConnection("http://localhost:" + PORT + "/SoapContext/SoapPort/sayHi");
        httpConnection.connect();
       
        httpConnection.connect();
       
        assertEquals(200, httpConnection.getResponseCode());
       
View Full Code Here

    public void testGetSayHi() throws Exception {
        HttpURLConnection httpConnection =
            getHttpConnection("http://localhost:" + PORT + "/SoapContext/SoapPort/sayHi");
        httpConnection.connect();
       
        httpConnection.connect();
       
        assertEquals(200, httpConnection.getResponseCode());
       
        assertEquals("text/xml;charset=utf-8", httpConnection.getContentType().toLowerCase());
        assertEquals("OK", httpConnection.getResponseMessage());
View Full Code Here

    @Test
    public void testGetGreetMe() throws Exception {
        HttpURLConnection httpConnection =
            getHttpConnection("http://localhost:" + PORT
                              + "/SoapContext/SoapPort/greetMe/requestType/cxf");   
        httpConnection.connect();       
       
        assertEquals(200, httpConnection.getResponseCode());
   
        assertEquals("text/xml;charset=utf-8", httpConnection.getContentType().toLowerCase());
        assertEquals("OK", httpConnection.getResponseMessage());
View Full Code Here

        String url = "http://localhost:" + PORT + "/SoapContext/SoapPort?wsdl";
        HttpURLConnection httpConnection = getHttpConnection(url);

        // just testing that GZIP is not enabled by default
        httpConnection.setRequestProperty("Accept-Encoding", "gzip, deflate");
        httpConnection.connect();       
       
        assertEquals(200, httpConnection.getResponseCode());
   
        assertEquals("text/xml;charset=utf-8", httpConnection.getContentType().toLowerCase());
        assertEquals("OK", httpConnection.getResponseMessage());
View Full Code Here

    @Test
    public void testGetWSDLWithGzip() throws Exception {
        String url = "http://localhost:" + PORT + "/SoapContext/SoapPortWithGzip?wsdl";
        HttpURLConnection httpConnection = getHttpConnection(url);
        httpConnection.setRequestProperty("Accept-Encoding", "gzip, deflate");
        httpConnection.connect();
        assertEquals(200, httpConnection.getResponseCode());
        assertEquals("text/xml;charset=utf-8", httpConnection.getContentType().toLowerCase());
        assertEquals("OK", httpConnection.getResponseMessage());
        assertEquals("gzip", httpConnection.getContentEncoding());
        InputStream in = httpConnection.getInputStream();
View Full Code Here

    public void testGetGreetMeFromQuery() throws Exception {
        String url = "http://localhost:" + PORT + "/SoapContext/SoapPort/greetMe?requestType="
            + URLEncoder.encode("cxf (was CeltixFire)", "UTF-8");
       
        HttpURLConnection httpConnection = getHttpConnection(url);   
        httpConnection.connect();       
       
        assertEquals(200, httpConnection.getResponseCode());
   
        assertEquals("text/xml;charset=utf-8", httpConnection.getContentType().toLowerCase());
        assertEquals("OK", httpConnection.getResponseMessage());
View Full Code Here

   
    @Test
    public void testAnonymousMinOccursConfig() throws Exception {
        HttpURLConnection httpConnection =
            getHttpConnection(ServerMisc.DOCLIT_CODEFIRST_SETTINGS_URL + "?wsdl");   
        httpConnection.connect();       
       
        assertEquals(200, httpConnection.getResponseCode());
        assertEquals("OK", httpConnection.getResponseMessage());
        InputStream in = httpConnection.getInputStream();
        assertNotNull(in);
View Full Code Here

            for (retry = 0; retry <= MAX_CONN_RETRIES; retry++) {
                try {
                    conn = setupConnection(url, method, res);
                    // Attempt the connection:
                    savedConn = conn;
                    conn.connect();
                    break;
                } catch (BindException e) {
                    if (retry >= MAX_CONN_RETRIES) {
                        log.error("Can't connect after "+retry+" retries, "+e);
                        throw e;
View Full Code Here

    public void testDeleteHost() throws Exception
    {
        String hostToDelete = TEST3_VIRTUALHOST;
        HttpURLConnection connection = getRestTestHelper().openManagementConnection("/rest/virtualhost/" + hostToDelete, "DELETE");
        connection.connect();
        assertEquals("Unexpected response code", 200, connection.getResponseCode());

        // make sure that changes are saved in the broker store
        restartBroker();
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.