1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 // Common Qetest / Xalan testing imports 19 import org.apache.qetest.Datalet; 20 import org.apache.qetest.Logger; 21 import org.apache.qetest.TestletImpl; 22 import org.apache.qetest.trax.LoggingErrorListener; 23 24 // REPLACE_imports needed for reproducing the bug 25 import javax.xml.transform.*; 26 import javax.xml.transform.stream.*; 27 import java.io.File; 28 29 30 /** 31 * Testlet for reproducing Bugzilla reported bugs. 32 * 33 * @author [email protected] 34 * @author [email protected] 35 */ 36 public class Bugzilla1283 extends TestletImpl 37 { 38 // Initialize our classname for TestletImpl's main() method - must be updated! 39 static { thisClassName = "Bugzilla1283"; } 40 41 /** 42 * Write Minimal code to reproduce your Bugzilla bug report. 43 */ execute(Datalet d)44 public void execute(Datalet d) 45 { 46 logger.logMsg(Logger.STATUSMSG, "Reproducing Bugzilla#1283 Xalan hangs if javax.xml.transform.TransformerException thrown when invoked through JAXP"); 47 logger.logMsg(Logger.CRITICALMSG, "WARNING! THIS TEST MAY HANG! (i.e. don't run in automation)"); 48 try 49 { 50 TransformerFactory transformerFactory = TransformerFactory.newInstance(); 51 Source transformerSource = new StreamSource(new File("identity.xsl")); 52 Transformer transformer = 53 transformerFactory.newTransformer(transformerSource); 54 // Use nifty utility from testxsl.jar 55 LoggingErrorListener loggingErrorListener = new LoggingErrorListener(logger); 56 transformer.setErrorListener(loggingErrorListener); // default is to throw when fatalError 57 58 Source input = new StreamSource(new File("error.xml")); 59 Result output = new StreamResult(new File("Bugzilla1283.out")); 60 logger.logMsg(Logger.STATUSMSG, "About to transform error.xml into Bugzilla1283.out"); 61 transformer.transform(input, output); 62 logger.checkFail("Transform should have had fatalError which threw Exception"); 63 } 64 catch (Exception e) 65 { 66 logger.logThrowable(Logger.ERRORMSG, e, "Transform properly had fatalError and threw"); 67 logger.checkPass("Transform properly had fatalError and threw: " + e.toString()); 68 } 69 logger.logMsg(Logger.CRITICALMSG, "Bug occours now: system hangs"); 70 logger.checkPass("if we got here, we didn't hang!"); 71 } 72 73 /** 74 * <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1283"> 75 * Link to Bugzilla report</a> 76 * @return Xalan hangs if javax.xml.transform.TransformerException thrown when invoked through JAXP. 77 */ getDescription()78 public String getDescription() 79 { 80 return "Xalan hangs if javax.xml.transform.TransformerException thrown when invoked through JAXP"; 81 } 82 83 } // end of class Bugzilla1283 84 85