1 30 package org.objectweb.asm.xml; 31 32 import java.io.ByteArrayOutputStream ; 33 34 import javax.xml.transform.TransformerFactory ; 35 import javax.xml.transform.sax.SAXResult ; 36 import javax.xml.transform.sax.SAXTransformerFactory ; 37 import javax.xml.transform.sax.TransformerHandler ; 38 39 import junit.framework.TestSuite; 40 41 import org.objectweb.asm.AbstractTest; 42 import org.objectweb.asm.ClassReader; 43 44 49 public class SAXAdapterTest extends AbstractTest { 50 51 public static TestSuite suite() throws Exception { 52 return new SAXAdapterTest().getSuite(); 53 } 54 55 public void test() throws Exception { 56 ClassReader cr = new ClassReader(is); 57 ByteArrayOutputStream bos = new ByteArrayOutputStream (); 58 59 SAXTransformerFactory saxtf = (SAXTransformerFactory ) TransformerFactory.newInstance(); 60 TransformerHandler handler = saxtf.newTransformerHandler(); 61 handler.setResult(new SAXResult (new ASMContentHandler(bos, false))); 62 handler.startDocument(); 63 cr.accept(new SAXClassAdapter(handler, false), false); 64 handler.endDocument(); 65 66 assertEquals(cr, new ClassReader(bos.toByteArray())); 67 } 68 } 69 | Popular Tags |