Package com.sun.xml.stream.buffer.sax

Source Code of com.sun.xml.stream.buffer.sax.NamespaceTest

package com.sun.xml.stream.buffer.sax;

import com.sun.xml.stream.buffer.XMLStreamBuffer;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.xml.parsers.SAXParserFactory;
import junit.framework.*;
import org.xml.sax.XMLReader;

/**
*
* @author Paul.Sandoz@Sun.Com
*/
public class NamespaceTest extends TestCase {
   
    public NamespaceTest(String testName) {
        super(testName);
    }

    public void testManyNamespaceDeclarations() throws Exception {
        for (int i = 0; i <= 50; i++) {
            _testManyNamespaceDeclarations(i);
        }
    }
   
    private void _testManyNamespaceDeclarations(int n) throws Exception {
        InputStream d = createDocument(n);
       
        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setNamespaceAware(true);
        XMLReader r = spf.newSAXParser().getXMLReader();

        XMLStreamBuffer b = XMLStreamBuffer.createNewBufferFromXMLReader(r, d);
    }
   
    private InputStream createDocument(int n) {
        StringBuilder b = new StringBuilder();
       
        b.append("<root");
        for (int i = 0; i <= n; i++) {
            b.append(" xmlns:p" + i + "='urn:" + i + "'");
        }
        b.append(">");
        b.append("</root>");
       
        return new ByteArrayInputStream(b.toString().getBytes());
    }
}
TOP

Related Classes of com.sun.xml.stream.buffer.sax.NamespaceTest

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.