Package com.sun.syndication.io

Examples of com.sun.syndication.io.XmlReader


        test.testHttp();
    }

    protected void _testRawNoBomValid(String encoding) throws Exception {
        InputStream is = getXmlStream("no-bom",XML1,encoding,encoding);
        XmlReader xmlReader = new XmlReader(is,false);
        assertEquals(xmlReader.getEncoding(),"UTF-8");

        is = getXmlStream("no-bom",XML2,encoding,encoding);
        xmlReader = new XmlReader(is);
        assertEquals(xmlReader.getEncoding(),"UTF-8");

        is = getXmlStream("no-bom",XML3,encoding,encoding);
        xmlReader = new XmlReader(is);
        assertEquals(xmlReader.getEncoding(),encoding);

        is = getXmlStream("no-bom", XML4, encoding, encoding);
        xmlReader = new XmlReader(is);
        assertEquals(xmlReader.getEncoding(), encoding);

        is = getXmlStream("no-bom", XML5, encoding, encoding);
        xmlReader = new XmlReader(is);
        assertEquals(xmlReader.getEncoding(), encoding);
    }
View Full Code Here


    }

    protected void _testRawNoBomInvalid(String encoding) throws Exception {
        InputStream is = getXmlStream("no-bom",XML3,encoding,encoding);
        try {
            XmlReader xmlReader = new XmlReader(is,false);
            fail("It should have failed");
        }
        catch (IOException ex) {
            assertTrue(ex.getMessage().indexOf("Invalid encoding,")>-1);
        }
View Full Code Here

        _testRawNoBomValid("ISO-8859-1");
    }

    protected void _testRawBomValid(String encoding) throws Exception {
        InputStream is = getXmlStream(encoding+"-bom",XML3,encoding,encoding);
        XmlReader xmlReader = new XmlReader(is,false);
        if (!encoding.equals("UTF-16")) {
            assertEquals(xmlReader.getEncoding(),encoding);
        }
        else {
            assertEquals(xmlReader.getEncoding().substring(0,encoding.length()),encoding);
        }
    }
View Full Code Here

    }

    protected void _testRawBomInvalid(String bomEnc,String streamEnc,String prologEnc) throws Exception {
        InputStream is = getXmlStream(bomEnc,XML3,streamEnc,prologEnc);
        try {
            XmlReader xmlReader = new XmlReader(is,false);
            fail("It should have failed for BOM "+bomEnc+", streamEnc "+streamEnc+" and prologEnc "+prologEnc);
        }
        catch (IOException ex) {
            assertTrue(ex.getMessage().indexOf("Invalid encoding,")>-1);
        }
View Full Code Here

        _testHttpLenient("text/html;charset=UTF-16BE","no-bom","US-ASCII","UTF-8", "UTF-8");
    }

    public void _testHttpValid(String cT,String bomEnc,String streamEnc,String prologEnc) throws Exception {
        InputStream is = getXmlStream(bomEnc,(prologEnc==null)?XML1 :XML3,streamEnc,prologEnc);
        XmlReader xmlReader = new XmlReader(is,cT,false);
        if (!streamEnc.equals("UTF-16")) {
            // we can not assert things here becuase UTF-8, US-ASCII and ISO-8859-1 look alike for the chars used for detection
        }
        else {
            assertEquals(xmlReader.getEncoding().substring(0,streamEnc.length()),streamEnc);
        }
    }
View Full Code Here

    }

    protected void _testHttpInvalid(String cT,String bomEnc,String streamEnc,String prologEnc) throws Exception {
        InputStream is = getXmlStream(bomEnc,(prologEnc==null)?XML2 :XML3,streamEnc,prologEnc);
        try {
            new XmlReader(is,cT,false);
            fail("It should have failed for HTTP Content-type "+cT+", BOM "+bomEnc+", streamEnc "+streamEnc+" and prologEnc "+prologEnc);
        }
        catch (IOException ex) {
            assertTrue(ex.getMessage().indexOf("Invalid encoding,")>-1);
        }
View Full Code Here

        }
     }

    protected void _testHttpLenient(String cT, String bomEnc, String streamEnc, String prologEnc, String shouldbe) throws Exception {
        InputStream is = getXmlStream(bomEnc,(prologEnc==null)?XML2 :XML3,streamEnc,prologEnc);
        XmlReader xmlReader = new XmlReader(is,cT,true);
        assertEquals(xmlReader.getEncoding(),shouldbe);
    }
View Full Code Here

        _testInvalidEntities(" <!-- just in case -->\n"+XML_PROLOG+"<hello>&Pi;&Rho;&#9x13;&Rho;</hello>");
    }

    protected void _testXmlParse(String garbish,String xmlDoc) throws Exception {
        InputStream is = getStream(garbish,xmlDoc);
        Reader reader = new XmlReader(is);
        reader = new XmlFixerReader(reader);
        SAXBuilder saxBuilder = new SAXBuilder();
        saxBuilder.build(reader);
    }
View Full Code Here

        stream = new GZIPInputStream(method.getResponseBodyAsStream());
    } else {
        stream = method.getResponseBodyAsStream();
    }   
    try {   
        XmlReader reader = null;
        if (method.getResponseHeader("Content-Type") != null) {
            reader = new XmlReader(stream, method.getResponseHeader("Content-Type").getValue(), true);
        } else {
            reader = new XmlReader(stream, true);
        }
      return new SyndFeedInput().build(reader);
    } finally {
        if (stream != null) {
            stream.close();
View Full Code Here

        test.testHttp();
    }

    protected void _testRawNoBomValid(String encoding) throws Exception {
        InputStream is = getXmlStream("no-bom","xml",encoding,encoding);
        XmlReader xmlReader = new XmlReader(is,false);
        assertEquals(xmlReader.getEncoding(),"UTF-8");

        is = getXmlStream("no-bom","xml-prolog",encoding,encoding);
        xmlReader = new XmlReader(is);
        assertEquals(xmlReader.getEncoding(),"UTF-8");

        is = getXmlStream("no-bom","xml-prolog-encoding",encoding,encoding);
        xmlReader = new XmlReader(is);
        assertEquals(xmlReader.getEncoding(),encoding);
    }
View Full Code Here

TOP

Related Classes of com.sun.syndication.io.XmlReader

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.