Package com.fasterxml.aalto

Examples of com.fasterxml.aalto.AsyncXMLInputFactory


     */
   
    private void _testSimplest(String spaces, int chunkSize) throws Exception
    {
        String XML = spaces+"<!DOCTYPE root>  <root />";
        AsyncXMLInputFactory f = new InputFactoryImpl();
        AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
        AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
        int t = verifyStart(reader);
        assertTokenType(DTD, t);
        // as per Stax API, can't call getLocalName (ugh), but Stax2 gives us this:
        assertEquals("root", sr.getPrefixedName());
View Full Code Here


    private void _testWithIds(String spaces, int chunkSize) throws Exception
    {
        final String PUBLIC_ID = "some-id";
        final String SYSTEM_ID = "file:/something";
        String XML = spaces+"<!DOCTYPE root PUBLIC '"+PUBLIC_ID+"' \""+SYSTEM_ID+"\"><root/>";
        AsyncXMLInputFactory f = new InputFactoryImpl();
        AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
        AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
        int t = verifyStart(reader);
        assertTokenType(DTD, t);
        assertTokenType(DTD, sr.getEventType());
        assertEquals("root", sr.getPrefixedName());
View Full Code Here

            +"<!ELEMENT html (head, body)>"
            +"<!ATTLIST head title CDATA #IMPLIED>"
            ;
        final String SYSTEM_ID = "file:/something";
        String XML = spaces+"<!DOCTYPE root SYSTEM '"+SYSTEM_ID+"' ["+INTERNAL_SUBSET+"]>\n<root/>";
        AsyncXMLInputFactory f = new InputFactoryImpl();
        AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
        AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
        int t = verifyStart(reader);
        assertTokenType(DTD, t);
        if (checkValue) {
            assertNull(sr.getDTDInfo().getDTDPublicId());
View Full Code Here

    }

    private void _testInvalidDup(String spaces, int chunkSize) throws Exception
    {
        String XML = spaces+"<!DOCTYPE root> <!DOCTYPE root> <root />";
        AsyncXMLInputFactory f = new InputFactoryImpl();
        AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
        AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
        int t = verifyStart(reader);
        assertTokenType(DTD, t);
        assertEquals("root", sr.getPrefixedName());
View Full Code Here

    private final static String XML = "<!--comments&s\r\ntuf-fy>--><root><!----></root><!--\nHi - "+UNICODE_SEGMENT+" - ho->-->";
   
    private void _testComments(String spaces, int chunkSize) throws Exception
    {
        AsyncXMLInputFactory f = new InputFactoryImpl();
        AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
        AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, spaces+XML);
        int t = verifyStart(reader);
        assertTokenType(COMMENT, t);
        assertEquals("comments&s\ntuf-fy>", sr.getText());
        assertTokenType(START_ELEMENT, reader.nextToken());
View Full Code Here

        assertTokenType(END_DOCUMENT, reader.nextToken());
    }

    private void _testSkipComments(String spaces, int chunkSize) throws Exception
    {
        AsyncXMLInputFactory f = new InputFactoryImpl();
        AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
        AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, spaces+XML);
        int t = verifyStart(reader);
        assertTokenType(COMMENT, t);
        assertTokenType(START_ELEMENT, reader.nextToken());
        assertTokenType(COMMENT, reader.nextToken());
View Full Code Here

{
    private final int[] CHUNK_SIZES = new int[] { 1, 2, 3, 5, 9, 33 };

    public void testNoDeclaration() throws Exception
    {
        AsyncXMLInputFactory f = new InputFactoryImpl();
        for (String XML : new String[] { "   <root />", "<root/>" }) {
            for (int chunkSize : CHUNK_SIZES) {
                AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
                AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
                assertEquals(EVENT_INCOMPLETE, reader.currentToken());
                assertTokenType(START_DOCUMENT, reader.nextToken());
                // no info, however; except for encoding auto-detection
                assertNull(sr.getCharacterEncodingScheme());
View Full Code Here

    }

    public void testVersionOnlyDeclaration() throws Exception
    {
        String XML = "<?xml version='1.0' ?><root />";
        AsyncXMLInputFactory f = new InputFactoryImpl();

        for (int chunkSize : CHUNK_SIZES) {
            AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
            AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
            assertEquals(EVENT_INCOMPLETE, reader.currentToken());
            assertTokenType(START_DOCUMENT, reader.nextToken());
            assertNull(sr.getCharacterEncodingScheme());
            assertEquals("UTF-8", sr.getEncoding());
View Full Code Here

    }

    public void testEncodingDeclaration() throws Exception
    {
        String XML = "<?xml version= \"1.0\"   encoding='UTF-8' ?><root/>";
        AsyncXMLInputFactory f = new InputFactoryImpl();

        for (int chunkSize : CHUNK_SIZES) {
            AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
            AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
            assertEquals(EVENT_INCOMPLETE, reader.currentToken());
            assertTokenType(START_DOCUMENT, reader.nextToken());
            assertEquals("UTF-8", sr.getEncoding());
            assertEquals("UTF-8", sr.getCharacterEncodingScheme());
View Full Code Here

    }

    public void testStandAloneDeclaration() throws Exception
    {
        String XML = "<?xml version  ='1.0' encoding=\"UTF-8\"  standalone='yes' ?>  <root />";
        AsyncXMLInputFactory f = new InputFactoryImpl();

        for (int chunkSize : CHUNK_SIZES) {
            AsyncXMLStreamReader sr = f.createAsyncXMLStreamReader();
            AsyncReaderWrapper reader = new AsyncReaderWrapper(sr, chunkSize, XML);
            assertEquals(EVENT_INCOMPLETE, reader.currentToken());
            assertTokenType(START_DOCUMENT, reader.nextToken());
            assertEquals("UTF-8", sr.getEncoding());
            assertEquals("UTF-8", sr.getCharacterEncodingScheme());
View Full Code Here

TOP

Related Classes of com.fasterxml.aalto.AsyncXMLInputFactory

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.