1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package convwatch; 29 30 import complexlib.ComplexTestCase; 31 import helper.ProcessHandler; 32 import convwatch.GraphicalTestArguments; 33 34 /** 35 * Some Helperfunctions which are nice in ReferenceBuilder and ConvWatchTest 36 */ 37 38 public abstract class EnhancedComplexTestCase extends ComplexTestCase 39 { 40 // public void before() 41 // { 42 // // System.out.println("before()"); 43 // } 44 // 45 // public void after() 46 // { 47 // // System.out.println("after()"); 48 // } 49 50 void checkExistance(String _sScriptFile, String _sName) 51 { 52 boolean bBackValue = false; 53 // Process testshl = Runtime.getRuntime().exec(scriptFile); 54 ProcessHandler aHandler = new ProcessHandler(_sScriptFile); 55 bBackValue = aHandler.executeSynchronously(); 56 TimeHelper.waitInSeconds(1, "wait after ProcessHandler.executeSynchronously()"); 57 58 StringBuffer aBuffer = new StringBuffer(); 59 aBuffer.append(aHandler.getErrorText()).append(aHandler.getOutputText()); 60 String sText = aBuffer.toString(); 61 62 if (sText.length() == 0) 63 { 64 String sError = "Must quit. " + _sName + " may be not accessable."; 65 assure(sError, false); 66 // System.exit(1); 67 } 68 else 69 { 70 // System.out.println("Output from script:"); 71 // System.out.println(sText); 72 } 73 } 74 75 // ----------------------------------------------------------------------------- 76 77 protected void checkEnvironment(Object[] _aList) 78 { 79 // checks if some packages already installed, 80 // this function will not return if packages are not installed, 81 // it will call System.exit(1)! 82 83 if (needCheckForInstalledSoftware()) 84 { 85 for (int i=0;i<_aList.length;i++) 86 { 87 String sCommand = (String)_aList[i]; 88 // TODO: nice to have, a pair object 89 checkExistance(sCommand, sCommand); 90 } 91 } 92 } 93 94 // ----------------------------------------------------------------------------- 95 96 protected abstract Object[] mustInstalledSoftware(); 97 public boolean needCheckForInstalledSoftware() 98 { 99 String sNEEDCHECK = (String)param.get( PropertyName.CHECK_NEED_TOOLS ); 100 // TODO: I need to get the boolean value with get("name") because, if it is not given getBool() returns 101 // with a default of 'false' which is not very helpful if the default should be 'true' 102 // maybe a getBoolean("name", true) could be a better choise. 103 if (sNEEDCHECK == null) 104 { 105 sNEEDCHECK = "false"; 106 } 107 if (sNEEDCHECK.toLowerCase().equals("yes") || 108 sNEEDCHECK.toLowerCase().equals("true")) 109 { 110 return true; 111 } 112 return false; 113 } 114 115 // ----------------------------------------------------------------------------- 116 117 public GraphicalTestArguments getGraphicalTestArguments() 118 { 119 GraphicalTestArguments aGTA = new GraphicalTestArguments(param); 120 if (aGTA.getImportFilterName() != null && aGTA.getImportFilterName().toLowerCase().equals("help")) 121 { 122 aGTA = null; 123 } 124 if (aGTA.getExportFilterName() != null && aGTA.getExportFilterName().toLowerCase().equals("help")) 125 { 126 aGTA = null; 127 } 128 return aGTA; 129 } 130 } 131