< prev index next >

test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java

Print this page

        

*** 21,49 **** * questions. */ package javax.xml.transform.ptests; import java.io.*; ! import java.io.FileOutputStream; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; import javax.xml.transform.stream.*; import jaxp.library.JAXPFileBaseTest; import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.compareWithGold; import static org.testng.Assert.assertTrue; import org.testng.annotations.Test; import org.w3c.dom.*; /** * Class containing the test cases for TransformerFactory API's ! * getAssociatedStyleSheet method. */ public class TransformerFactoryTest extends JAXPFileBaseTest { /** * This test case checks for the getAssociatedStylesheet method * of TransformerFactory. * The style sheet returned is then copied to an tfactory01.out * It will then be verified to see if it matches the golden files. --- 21,91 ---- * questions. */ package javax.xml.transform.ptests; import java.io.*; ! import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; + import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR; import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR; + import javax.xml.transform.stream.*; + import jaxp.library.JAXPFileBaseTest; import static jaxp.library.JAXPTestUtilities.USER_DIR; import static jaxp.library.JAXPTestUtilities.compareWithGold; + import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; + + import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.w3c.dom.*; /** * Class containing the test cases for TransformerFactory API's ! * getAssociatedStyleSheet method and TransformerFactory.newInstance(factoryClassName , classLoader). */ public class TransformerFactoryTest extends JAXPFileBaseTest { + private static final String TRANSFORMER_FACTORY_CLASSNAME = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"; + + @DataProvider(name = "parameters") + public Object[][] getValidateParameters() { + return new Object[][] { { TRANSFORMER_FACTORY_CLASSNAME, null }, { TRANSFORMER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } }; + } + + /* + * test for TransformerFactory.newInstance(java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName + * points to correct implementation of + * javax.xml.transform.TransformerFactory , should return newInstance of + * TransformerFactory + */ + @Test(dataProvider = "parameters") + public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws TransformerConfigurationException { + TransformerFactory tf = TransformerFactory.newInstance(factoryClassName, classLoader); + Transformer transformer = tf.newTransformer(); + assertNotNull(transformer); + } + + @DataProvider(name = "invalid-parameters") + public Object[][] getInvalidateParameters() { + return new Object[][] { { null, null }, { null, this.getClass().getClassLoader() } }; + } + + /* + * test for TransformerFactory.newInstance(java.lang.String + * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is + * null , should throw TransformerFactoryConfigurationError + */ + @Test(expectedExceptions = TransformerFactoryConfigurationError.class, dataProvider = "invalid-parameters") + public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) { + TransformerFactory.newInstance(factoryClassName, classLoader); + } + /** * This test case checks for the getAssociatedStylesheet method * of TransformerFactory. * The style sheet returned is then copied to an tfactory01.out * It will then be verified to see if it matches the golden files.
< prev index next >