< prev index next >

test/javax/xml/jaxp/functional/test/gaptest/Bug4515660.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package test.gaptest;
  25 
  26 import static org.testng.Assert.assertTrue;
  27 
  28 import java.io.IOException;
  29 import java.io.StringReader;
  30 import java.io.StringWriter;
  31 
  32 import javax.xml.parsers.ParserConfigurationException;
  33 import javax.xml.parsers.SAXParserFactory;
  34 import javax.xml.transform.Transformer;
  35 import javax.xml.transform.TransformerConfigurationException;
  36 import javax.xml.transform.TransformerException;
  37 import javax.xml.transform.TransformerFactory;
  38 import javax.xml.transform.sax.SAXSource;
  39 import javax.xml.transform.sax.SAXTransformerFactory;
  40 import javax.xml.transform.stream.StreamResult;
  41 
  42 import jaxp.library.JAXPBaseTest;
  43 
  44 import org.testng.annotations.AfterClass;
  45 import org.testng.annotations.BeforeClass;

  46 import org.testng.annotations.Test;
  47 import org.xml.sax.InputSource;
  48 import org.xml.sax.SAXException;
  49 import org.xml.sax.helpers.XMLFilterImpl;
  50 
  51 /*
  52  * @bug 4515660
  53  * @summary verify property org.xml.sax.driver is used by SAXTransformerFactory
  54  */
  55 @Test(singleThreaded = true)
  56 public class Bug4515660 extends JAXPBaseTest {

  57 
  58     @BeforeClass
  59     public void setSaxDrier() {
  60         setSystemProperty("org.xml.sax.driver", ReaderStub.class.getName());
  61     }
  62 
  63     @AfterClass
  64     public void clearSaxDrier() {
  65         setSystemProperty("org.xml.sax.driver", null);
  66     }
  67 
  68     @Test
  69     public void testTransformer() throws TransformerException {
  70         String xml = "<?xml version='1.0'?><root/>";
  71         ReaderStub.used = false;
  72 
  73         TransformerFactory transFactory = TransformerFactory.newInstance();
  74         Transformer transformer = transFactory.newTransformer();
  75         InputSource in = new InputSource(new StringReader(xml));
  76         SAXSource source = new SAXSource(in);
  77         StreamResult result = new StreamResult(new StringWriter());
  78 
  79         transformer.transform(source, result);
  80 
  81         assertTrue(ReaderStub.used);
  82 
  83     }
  84 
  85     @Test


   1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package test.gaptest;
  25 
  26 import static org.testng.Assert.assertTrue;
  27 
  28 import java.io.IOException;
  29 import java.io.StringReader;
  30 import java.io.StringWriter;
  31 
  32 import javax.xml.parsers.ParserConfigurationException;
  33 import javax.xml.parsers.SAXParserFactory;
  34 import javax.xml.transform.Transformer;
  35 import javax.xml.transform.TransformerConfigurationException;
  36 import javax.xml.transform.TransformerException;
  37 import javax.xml.transform.TransformerFactory;
  38 import javax.xml.transform.sax.SAXSource;
  39 import javax.xml.transform.sax.SAXTransformerFactory;
  40 import javax.xml.transform.stream.StreamResult;
  41 


  42 import org.testng.annotations.AfterClass;
  43 import org.testng.annotations.BeforeClass;
  44 import org.testng.annotations.Listeners;
  45 import org.testng.annotations.Test;
  46 import org.xml.sax.InputSource;
  47 import org.xml.sax.SAXException;
  48 import org.xml.sax.helpers.XMLFilterImpl;
  49 
  50 /*
  51  * @bug 4515660
  52  * @summary verify property org.xml.sax.driver is used by SAXTransformerFactory
  53  */
  54 @Test(singleThreaded = true)
  55 @Listeners({jaxp.library.BasePolicy.class})
  56 public class Bug4515660 {
  57 
  58     @BeforeClass
  59     public void setSaxDrier() {
  60         System.setProperty("org.xml.sax.driver", ReaderStub.class.getName());
  61     }
  62 
  63     @AfterClass
  64     public void clearSaxDrier() {
  65         System.clearProperty("org.xml.sax.driver");
  66     }
  67 
  68     @Test
  69     public void testTransformer() throws TransformerException {
  70         String xml = "<?xml version='1.0'?><root/>";
  71         ReaderStub.used = false;
  72 
  73         TransformerFactory transFactory = TransformerFactory.newInstance();
  74         Transformer transformer = transFactory.newTransformer();
  75         InputSource in = new InputSource(new StringReader(xml));
  76         SAXSource source = new SAXSource(in);
  77         StreamResult result = new StreamResult(new StringWriter());
  78 
  79         transformer.transform(source, result);
  80 
  81         assertTrue(ReaderStub.used);
  82 
  83     }
  84 
  85     @Test


< prev index next >