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 /* 23 * 24 * TestableExtension.java 25 * 26 */ 27 package org.apache.qetest.xsl; 28 import org.apache.qetest.Logger; 29 30 31 /** 32 * Simple base class defining test hooks for Java extensions. 33 * 34 * Currently provides generic but limited verification for 35 * basic extensions in the context of being called from standard 36 * transformations. I would have preferred an interface, but then 37 * methods couldn't be static, which makes validation simpler 38 * since the test doesn't have to try to grab the same instance of 39 * an extension that the transformer used. 40 * 41 * @author Shane_Curcuru@lotus.com 42 * @version $Id$ 43 */ 44 public class TestableExtension 45 { 46 /** 47 * Perform and log any pre-transformation info. 48 * 49 * The extension should log out to the logger brief info 50 * about what the extension does. It may also use items in 51 * the datalet to perform additional validation (like ensuring 52 * that counters are zeroed, etc.). 53 * 54 * TestableExtensions should validate any output files needed in 55 * their postCheck method; ExtensionTestlets simply rely on this 56 * method to both validate the internal actions of the extension 57 * as well as any output files, as needed. 58 * 59 * This should only return false if some horrendous error with 60 * the extension appears to have occoured; it will likely prevent 61 * any callers from completing the test. 62 * 63 * @return true if OK; false if any fatal error occoured 64 * @param logger Logger to dump any info to 65 * @param datalet Datalet of current stylesheet test 66 */ preCheck(Logger logger, StylesheetDatalet datalet)67 public static boolean preCheck(Logger logger, StylesheetDatalet datalet) 68 { 69 /* Must be overridden */ 70 return false; 71 } 72 73 74 /** 75 * Perform and log any post-transformation info. 76 * 77 * The extension should validate that it's extension was 78 * properly called. It should also validate any output files 79 * specified in the datalet, etc. It may also 80 * validate against extension-specific data in the options 81 * (like validating that some extension call was hit a 82 * certain number of times or the like). 83 * 84 * @param logger Logger to dump any info to 85 * @param datalet Datalet of current stylesheet test 86 */ postCheck(Logger logger, StylesheetDatalet datalet)87 public static void postCheck(Logger logger, StylesheetDatalet datalet) 88 { 89 /* Must be overridden */ 90 return; 91 } 92 93 94 /** 95 * Description of what this extension does. 96 * @return String description of extension 97 */ getDescription()98 public static String getDescription() 99 { 100 return "Must be overridden"; 101 } 102 103 } // end of class TestableExtension 104 105