• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /*
19  * $Id$
20  */
21 
22 package org.apache.qetest.xsl;
23 
24 import java.io.File;
25 
26 import org.apache.qetest.Datalet;
27 
28 /**
29  * Testlet for conformance testing of xsl stylesheet files using
30  * XalanC commandline instead of a TransformWrapper.
31  *
32  * Note: this class simply uses CmdlineTestlet's implementation.
33  *
34  * @author Shane_Curcuru@lotus.com
35  * @version $Id$
36  */
37 public class XalanCTestlet extends CmdlineTestlet
38 {
39     // Initialize our classname for TestletImpl's main() method
40     static { thisClassName = "org.apache.qetest.xsl.XalanCTestlet"; }
41 
42     // Initialize our defaultDatalet
43     { defaultDatalet = (Datalet)new StylesheetDatalet(); }
44 
45     /**
46      * Accesor method for a brief description of this test.
47      * @return String describing what this XalanCTestlet does.
48      */
getDescription()49     public String getDescription()
50     {
51         return "XalanCTestlet";
52     }
53 
54     /**
55      * Default Actual name of external program to call.
56      * @return Xalan, the Xalan-C command line.
57      */
getDefaultProgName()58     public String getDefaultProgName()
59     {
60         return "Xalan";
61     }
62 
63     /**
64      * Worker method to get list of arguments specific to this program.
65      *
66      * <p>Must be overridden for different processors, obviously.
67      * This implementation returns the args for Xalan-C TestXSLT</p>
68      *
69      * @param program path\name of program to Runtime.exec()
70      * @param defaultArgs any additional arguments to pass
71      * @return String array of arguments suitable to pass to
72      * Runtime.exec()
73      */
getProgramArguments(StylesheetDatalet datalet, String[] defaultArgs)74     public String[] getProgramArguments(StylesheetDatalet datalet, String[] defaultArgs)
75     {
76         final int NUMARGS = 5;
77         String[] args = new String[defaultArgs.length + NUMARGS];
78         String progName = datalet.options.getProperty(OPT_PROGNAME, getDefaultProgName());
79         String progPath = datalet.options.getProperty(OPT_PROGPATH);
80         if ((null != progPath) && (progPath.length() > 0))
81         {
82             args[0] = progPath + File.separator + progName;
83         }
84         else
85         {
86             // Pesume the program is on the PATH already...
87             args[0] = progName;
88         }
89 
90         // Default args for Xalan-C TestXSLT
91         args[1] = "-o";
92         args[2] = datalet.outputName;
93         args[3] = datalet.xmlName;
94         args[4] = datalet.inputName;
95 
96         if (defaultArgs.length > 0)
97             System.arraycopy(defaultArgs, 0, args, NUMARGS, defaultArgs.length);
98 
99         return args;
100     }
101 
102 
103 }  // end of class XalanCTestlet
104 
105