Code example for JarURLConnection

Methods: connect, getJarFile

0
    public void test_getJarFile() throws IOException { 
        URL url = createContent("lf.jar", "missing");
 
        JarURLConnection connection = (JarURLConnection) url.openConnection();
        try { 
            connection.connect();
            fail("Did not throw exception on connect");
        } catch (IOException e) {
            // expected 
        } 
 
        try { 
            connection.getJarFile();
            fail("Did not throw exception after connect");
        } catch (IOException e) {
            // expected 
        } 
 
        URL invURL = createContent("InvalidJar.jar", "Test.class");
 
        JarURLConnection juConn = (JarURLConnection) invURL.openConnection();