Package java.net

Examples of java.net.HttpURLConnection.disconnect()


          } else if ("http".equals(url.getProtocol())) {
            final HttpURLConnection uc = (HttpURLConnection)
              url.openConnection();
            uc.connect();
            final int rc = uc.getResponseCode();
            uc.disconnect();
            if (rc != HttpURLConnection.HTTP_OK) {
              continue; // Noope; try next.
            }
          } else {
            // Generic case; Check if we can read data from this URL
View Full Code Here


                            msg = br.readLine();
                        } finally {
                            br.close();
                        }
                    } finally {
                connection.disconnect();
                    }
        }
      }
    } catch (final IOException e) {
      if (firstWelcomeException) {
View Full Code Here

      retVal = sb.toString();
    }catch(Exception e){
      throw new CheckForUpdateException(e);
    }finally{
      if(urlConn != null){
        urlConn.disconnect();
      }
    }
    return retVal;
  }
}
View Full Code Here

        HttpURLConnection connection = (HttpURLConnection) new URL(connector.getConnectUrl() "/test/hello.txt").openConnection();
        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
        assertEquals("Hello World", reader.readLine());
        connection.disconnect();
    }

    protected void setUp() throws Exception {
        super.setUp();
        super.init(null);
View Full Code Here

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
            assertEquals("Hello World", reader.readLine());
        } finally {
            connection.disconnect();
        }
        container.removeWebService(contextPath);
        connection = (HttpURLConnection) new URL(connector.getConnectUrl() + contextPath).openConnection();
        try {
            connection.getInputStream();
View Full Code Here

            connection.getInputStream();
            fail();
        } catch (Exception e) {
            // see if we removed the ws.
            assertEquals(HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());
            connection.disconnect();
        }
    }

    public void testSecureWebServiceHandler() throws Exception {
View Full Code Here

            connection.getInputStream();
            fail();
        } catch (Exception e) {
            assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, connection.getResponseCode());
        } finally {
            connection.disconnect();
        }

        //Authenticate
        connection = (HttpURLConnection) new URL(connector.getConnectUrl() + contextPath).openConnection();
        String authentication = new String(Base64.encode("alan:starcraft".getBytes()));
View Full Code Here

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
            assertEquals("Hello World", reader.readLine());
        } finally {
            connection.disconnect();
        }
        container.removeWebService(contextPath);
        connection = (HttpURLConnection) new URL(connector.getConnectUrl() + contextPath).openConnection();
        try {
            connection.getInputStream();
View Full Code Here

            connection.getInputStream();
            fail();
        } catch (Exception e) {
            // see if we removed the ws.
            assertEquals(HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());
            connection.disconnect();
        }

    }

View Full Code Here

                /*System.out.println("              lastSampleTime = " + aStts.getLastSampleTime() +
                  "  startTime = " + aStts.getStartTime());
                System.out.println(aStts);*/
            }
            if (k == n-2) component.resetStats(); // test reset
            connection.disconnect();
            Thread.sleep(1000)// connection interval
        }      
    }

    protected void setUp() throws Exception {
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.