Package org.apache.harmony.luni.internal.net.www.protocol.file

Examples of org.apache.harmony.luni.internal.net.www.protocol.file.FileURLConnection


    static String getContentType(String fileName) throws IOException {
        String resourceName = "org/apache/harmony/luni/tests/" + fileName;
        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        assertNotNull("Cannot find test resource " + resourceName, url);
        return new FileURLConnection(url).getContentType();
    }
View Full Code Here


    static String getContentType(String fileName) throws IOException {
        String resourceName = "org/apache/harmony/luni/tests/" + fileName;
        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        assertNotNull("Cannot find test resource " + resourceName, url);
        return new FileURLConnection(url).getContentType();
    }
View Full Code Here

    static String getContentType(String fileName) throws IOException {
        String resourceName = "org/apache/harmony/luni/tests/" + fileName;
        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        assertNotNull("Cannot find test resource " + resourceName, url);
        return new FileURLConnection(url).getContentType();
    }
View Full Code Here

        String resourceName = "org/apache/harmony/luni/tests/" + "test.rtf";
        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        URL anchorUrl = new URL(url,"#anchor");
        assertNotNull("Cannot find test resource " + resourceName, anchorUrl);
       
        FileURLConnection conn = new FileURLConnection(anchorUrl);
        assertNotNull(conn.getInputStream());
       
        // Regression for Harmony-5779
        String localURLString = "file://localhost/" + url.getFile();
        URL localURL = new URL(localURLString);
        conn = new FileURLConnection(localURL);
        assertNotNull(conn.getInputStream());
        assertEquals("file",conn.getURL().getProtocol());
    }
View Full Code Here

    static String getContentType(String fileName) throws IOException {
        String resourceName = "org/apache/harmony/luni/tests/" + fileName;
        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        assertNotNull("Cannot find test resource " + resourceName, url);
        return new FileURLConnection(url).getContentType();
    }
View Full Code Here

        String resourceName = "org/apache/harmony/luni/tests/" + "test.rtf";
        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        URL anchorUrl = new URL(url,"#anchor");
        assertNotNull("Cannot find test resource " + resourceName, anchorUrl);
       
        FileURLConnection conn = new FileURLConnection(anchorUrl);
        assertNotNull(conn.getInputStream());
       
        // Regression for Harmony-5779
        String localURLString = "file://localhost/" + url.getFile();
        URL localURL = new URL(localURLString);
        conn = new FileURLConnection(localURL);
        assertNotNull(conn.getInputStream());
        assertEquals("file",conn.getURL().getProtocol());
    }
View Full Code Here

    }

    public void testHeaderFunctions() throws IOException {
        String resourceName = "org/apache/harmony/luni/tests/"//folder name
        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        FileURLConnection conn = new FileURLConnection(url);
        assertNotNull(conn.getInputStream());
        assertEquals(conn.getContentType(),  conn.getHeaderField("content-type")) ;
       
        resourceName = "org/apache/harmony/luni/tests/" "test.rtf";;  //folder name
        url = ClassLoader.getSystemClassLoader().getResource(resourceName);
        conn = new FileURLConnection(url);
        assertNotNull(conn.getInputStream());
        assertEquals(conn.getContentType(),  conn.getHeaderField("content-type")) ;
        assertEquals(Integer.toString(conn.getContentLength()),  conn.getHeaderField("content-length")) ;
        assertEquals(conn.getHeaderField(0), conn.getHeaderField("content-type"));
        assertEquals(conn.getHeaderField(1), conn.getHeaderField("content-length"));
        assertEquals(conn.getHeaderField(2), conn.getHeaderField("last-modified"));
        assertEquals("last-modified", conn.getHeaderFieldKey(2));
        assertEquals("content-length", conn.getHeaderFieldKey(1));
        assertEquals("content-type", conn.getHeaderFieldKey(0));
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.luni.internal.net.www.protocol.file.FileURLConnection

Copyright © 2018 www.massapicom. 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.