summaryrefslogtreecommitdiff
path: root/testtools
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-06-25 10:53:12 +0000
committerKurt Zenker <kz@openoffice.org>2008-06-25 10:53:12 +0000
commit0c2ff3daa78834e579e3c3702e8bd6fc7ba2e4b8 (patch)
tree0c9fa5b5c6c4801ccf94c0310f36ba717b82c3eb /testtools
parent1cf494675c88f4939d8ba6ef0d3fd142fd3452aa (diff)
INTEGRATION: CWS jl104 (1.1.4); FILE ADDED
2008/06/19 10:04:11 jl 1.1.4.2: #i88078# moving tests from cli_ure to testtools 2008/04/10 15:08:56 jl 1.1.4.1: file runtests.cs was added on branch cws_dev300_jl104 on 2008-06-19 10:04:11 +0000
Diffstat (limited to 'testtools')
-rw-r--r--testtools/source/cliversioning/runtests.cs125
1 files changed, 125 insertions, 0 deletions
diff --git a/testtools/source/cliversioning/runtests.cs b/testtools/source/cliversioning/runtests.cs
new file mode 100644
index 000000000000..52d2752aab0a
--- /dev/null
+++ b/testtools/source/cliversioning/runtests.cs
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: runtests.cs,v $
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+using System;
+using System.Reflection;
+using System.IO;
+
+// __________ implementation ____________________________________
+
+/** Create and modify a spreadsheet document.
+ */
+namespace cliversion
+{
+public class RunTests
+{
+
+ public static int Main(String[] args)
+ {
+// System.Diagnostics.Debugger.Launch();
+ //get the path to the directory
+ string sLocation = Assembly.GetExecutingAssembly().Location;
+ sLocation = sLocation.Substring(0, sLocation.LastIndexOf('\\'));
+ // Create a reference to the current directory.
+ DirectoryInfo di = new DirectoryInfo(sLocation);
+ // Create an array representing the files in the current directory.
+ FileInfo[] fi = di.GetFiles();
+
+ //For every found dll try to figure out if it contains a
+ //cliversion.Version class
+ foreach (FileInfo fiTemp in fi)
+ {
+ if (fiTemp.Extension != ".dll"
+ || ! fiTemp.Name.StartsWith("version"))
+ continue;
+
+ Assembly ass = null;
+ Object objVersion = null;
+ try
+ {
+ string sName = fiTemp.Name.Substring(0, fiTemp.Name.LastIndexOf(".dll"));
+ ass = Assembly.Load(sName);
+ }
+ catch (BadImageFormatException)
+ {
+ continue;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("#Unexpected Exception");
+ Console.WriteLine(e.Message);
+ return -1;
+ }
+
+ //Assembly is loaded, instantiate cliversion.Version
+ try
+ {
+ //This runs the test
+ objVersion = ass.CreateInstance("cliversion.Version");
+ if (objVersion == null)
+ continue;
+ Console.WriteLine("#Tested successfully " + fiTemp.Name);
+ //Starting the office the second time may fail without this pause
+ System.Threading.Thread.Sleep(2000);
+ }
+ catch (Exception e)
+ {
+ TargetInvocationException te = e as TargetInvocationException;
+ if (te != null)
+ {
+ FileNotFoundException fe = e.InnerException as FileNotFoundException;
+ if (fe != null)
+ {
+ Console.WriteLine(fiTemp.Name + " did not find " + fe.FileName +
+ ". Maybe the " + fe.FileName + " is not installed or does not match the referenced version." +
+ "Original message: " + fe.Message + "\n\n FusionLog: \n" + fe.FusionLog );
+ return -1;
+ }
+ FileLoadException fl = e.InnerException as FileLoadException;
+ if (fl != null)
+ {
+ Console.WriteLine(fiTemp.Name + " could not load " + fl.FileName +
+ ". Maybe the version of " + fl.FileName + " does not match the referenced version. " +
+ "Original message: " + fl.Message + "\n\n FusionLog: \n" + fl.FusionLog );
+ return -1;
+ }
+ }
+ Console.WriteLine("#Unexpected Exception");
+ Console.WriteLine(e.Message);
+ return -1;
+ }
+ }
+ //For some unknown reason this program hangs sometimes when started from java. This is
+ //a workaround that makes the problem disappear.
+ System.Threading.Thread.Sleep(1000);
+ return 0;
+ }
+}
+}