/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id$ */ package org.apache.qetest.xsl; import java.io.File; import java.util.Hashtable; import org.apache.qetest.Datalet; import org.apache.qetest.Logger; /** * Testlet for conformance testing of xsl stylesheet files using * the MSXSL command line instead of a TransformWrapper. * * @author Shane_Curcuru@lotus.com * @version $Id$ */ public class MSXSLTestlet extends CmdlineTestlet { // Initialize our classname for TestletImpl's main() method static { thisClassName = "org.apache.qetest.xsl.MSXSLTestlet"; } // Initialize our defaultDatalet { defaultDatalet = (Datalet)new StylesheetDatalet(); } /** * Accesor method for a brief description of this test. * * @return String describing what this MSXSLTestlet does. */ public String getDescription() { return "MSXSLTestlet"; } /** * Default Actual name of external program to call. * @return msxsl, the MSXSL 4.0 command line. */ public String getDefaultProgName() { return "msxsl"; } /** * Worker method to get list of arguments specific to this program. * *
Must be overridden for different processors, obviously. * This implementation returns the args for Xalan-C TestXSLT
* * @param program path\name of program to Runtime.exec() * @param defaultArgs any additional arguments to pass * @return String array of arguments suitable to pass to * Runtime.exec() */ public String[] getProgramArguments(StylesheetDatalet datalet, String[] defaultArgs) { final int NUMARGS = 6; String[] args = new String[defaultArgs.length + NUMARGS]; String progName = datalet.options.getProperty(OPT_PROGNAME, getDefaultProgName()); String progPath = datalet.options.getProperty(OPT_PROGPATH); if ((null != progPath) && (progPath.length() > 0)) { args[0] = progPath + File.separator + progName; } else { // Pesume the program is on the PATH already... args[0] = progName; } // Default args for MSXSL 4.0 args[1] = datalet.xmlName; args[2] = datalet.inputName; args[3] = "-o"; // Write output to named file args[4] = datalet.outputName; args[5] = "-t"; // Show load and transformation timings if (defaultArgs.length > 0) System.arraycopy(defaultArgs, 0, args, NUMARGS, defaultArgs.length); return args; } /** * Worker method to evaluate the System.out/.err streams of * a particular processor. * * Overridden to parse out -t timings from msxsl output. * * @param cmdline that was used for execProcess * @param outBuf buffer from execProcess' System.out * @param errBuf buffer from execProcess' System.err * @param processReturnVal from execProcess */ protected void checkOutputStreams(String[] cmdline, StringBuffer outBuf, StringBuffer errBuf, int processReturnVal) { Hashtable attrs = new Hashtable(); attrs.put("program", cmdline[0]); attrs.put("returnVal", String.valueOf(processReturnVal)); StringBuffer buf = new StringBuffer(); if ((null != errBuf) && (errBuf.length() > 0)) { buf.append("