1 18 package org.apache.batik.transcoder.image; 19 20 import java.io.IOException ; 21 import java.net.URL ; 22 23 import org.w3c.dom.DOMImplementation ; 24 import org.w3c.dom.Document ; 25 26 import org.apache.batik.dom.GenericDOMImplementation; 27 import org.apache.batik.dom.util.SAXDocumentFactory; 28 import org.apache.batik.transcoder.TranscoderInput; 29 import org.apache.batik.util.XMLResourceDescriptor; 30 31 37 public class GenericDocumentTest extends AbstractImageTranscoderTest { 38 39 40 protected String inputURI; 41 42 43 protected String refImageURI; 44 45 51 public GenericDocumentTest(String inputURI, String refImageURI) { 52 this.inputURI = inputURI; 53 this.refImageURI = refImageURI; 54 } 55 56 59 protected TranscoderInput createTranscoderInput() { 60 try { 61 URL url = resolveURL(inputURI); 62 String parser = XMLResourceDescriptor.getXMLParserClassName(); 63 DOMImplementation impl = 64 GenericDOMImplementation.getDOMImplementation(); 65 SAXDocumentFactory f = new SAXDocumentFactory(impl, parser); 66 Document doc = f.createDocument(url.toString()); 67 TranscoderInput input = new TranscoderInput(doc); 68 input.setURI(url.toString()); return input; 70 } catch (IOException ex) { 71 ex.printStackTrace(); 72 throw new IllegalArgumentException (inputURI); 73 } 74 } 75 76 79 protected byte [] getReferenceImageData() { 80 return createBufferedImageData(resolveURL(refImageURI)); 81 } 82 } 83 | Popular Tags |