1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EnhancedComplexTestCase.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import complexlib
.ComplexTestCase
;
34 import helper
.ProcessHandler
;
35 import convwatch
.GraphicalTestArguments
;
38 * Some Helperfunctions which are nice in ReferenceBuilder and ConvWatchTest
41 public abstract class EnhancedComplexTestCase
extends ComplexTestCase
43 // public void before()
45 // // System.out.println("before()");
48 // public void after()
50 // // System.out.println("after()");
53 void checkExistance(String _sScriptFile
, String _sName
)
55 boolean bBackValue
= false;
56 // Process testshl = Runtime.getRuntime().exec(scriptFile);
57 ProcessHandler aHandler
= new ProcessHandler(_sScriptFile
);
58 bBackValue
= aHandler
.executeSynchronously();
59 TimeHelper
.waitInSeconds(1, "wait after ProcessHandler.executeSynchronously()");
61 StringBuffer aBuffer
= new StringBuffer();
62 aBuffer
.append(aHandler
.getErrorText()).append(aHandler
.getOutputText());
63 String sText
= aBuffer
.toString();
65 if (sText
.length() == 0)
67 String sError
= "Must quit. " + _sName
+ " may be not accessable.";
68 assure(sError
, false);
73 // System.out.println("Output from script:");
74 // System.out.println(sText);
78 // -----------------------------------------------------------------------------
80 protected void checkEnvironment(Object
[] _aList
)
82 // checks if some packages already installed,
83 // this function will not return if packages are not installed,
84 // it will call System.exit(1)!
86 if (needCheckForInstalledSoftware())
88 for (int i
=0;i
<_aList
.length
;i
++)
90 String sCommand
= (String
)_aList
[i
];
91 // TODO: nice to have, a pair object
92 checkExistance(sCommand
, sCommand
);
97 // -----------------------------------------------------------------------------
99 protected abstract Object
[] mustInstalledSoftware();
100 public boolean needCheckForInstalledSoftware()
102 String sNEEDCHECK
= (String
)param
.get( PropertyName
.CHECK_NEED_TOOLS
);
103 // TODO: I need to get the boolean value with get("name") because, if it is not given getBool() returns
104 // with a default of 'false' which is not very helpful if the default should be 'true'
105 // maybe a getBoolean("name", true) could be a better choise.
106 if (sNEEDCHECK
== null)
108 sNEEDCHECK
= "false";
110 if (sNEEDCHECK
.toLowerCase().equals("yes") ||
111 sNEEDCHECK
.toLowerCase().equals("true"))
118 // -----------------------------------------------------------------------------
120 public GraphicalTestArguments
getGraphicalTestArguments()
122 GraphicalTestArguments aGTA
= new GraphicalTestArguments(param
);
123 if (aGTA
.getImportFilterName() != null && aGTA
.getImportFilterName().toLowerCase().equals("help"))
127 if (aGTA
.getExportFilterName() != null && aGTA
.getExportFilterName().toLowerCase().equals("help"))