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: runtests.cs,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 ************************************************************************/
32 using System
.Reflection
;
35 // __________ implementation ____________________________________
37 /** Create and modify a spreadsheet document.
44 public static int Main(String
[] args
)
46 // System.Diagnostics.Debugger.Launch();
47 //get the path to the directory
48 string sLocation
= Assembly
.GetExecutingAssembly().Location
;
49 sLocation
= sLocation
.Substring(0, sLocation
.LastIndexOf('\\'));
50 // Create a reference to the current directory.
51 DirectoryInfo di
= new DirectoryInfo(sLocation
);
52 // Create an array representing the files in the current directory.
53 FileInfo
[] fi
= di
.GetFiles();
55 //For every found dll try to figure out if it contains a
56 //cliversion.Version class
57 foreach (FileInfo fiTemp
in fi
)
59 if (fiTemp
.Extension
!= ".dll"
60 || ! fiTemp
.Name
.StartsWith("version"))
64 Object objVersion
= null;
67 string sName
= fiTemp
.Name
.Substring(0, fiTemp
.Name
.LastIndexOf(".dll"));
68 ass
= Assembly
.Load(sName
);
70 catch (BadImageFormatException
)
76 Console
.WriteLine("#Unexpected Exception");
77 Console
.WriteLine(e
.Message
);
81 //Assembly is loaded, instantiate cliversion.Version
85 objVersion
= ass
.CreateInstance("cliversion.Version");
86 if (objVersion
== null)
88 Console
.WriteLine("#Tested successfully " + fiTemp
.Name
);
89 //Starting the office the second time may fail without this pause
90 System
.Threading
.Thread
.Sleep(2000);
94 TargetInvocationException te
= e
as TargetInvocationException
;
97 FileNotFoundException fe
= e
.InnerException
as FileNotFoundException
;
100 Console
.WriteLine(fiTemp
.Name
+ " did not find " + fe
.FileName
+
101 ". Maybe the " + fe
.FileName
+ " is not installed or does not match the referenced version." +
102 "Original message: " + fe
.Message
+ "\n\n FusionLog: \n" + fe
.FusionLog
);
105 FileLoadException fl
= e
.InnerException
as FileLoadException
;
108 Console
.WriteLine(fiTemp
.Name
+ " could not load " + fl
.FileName
+
109 ". Maybe the version of " + fl
.FileName
+ " does not match the referenced version. " +
110 "Original message: " + fl
.Message
+ "\n\n FusionLog: \n" + fl
.FusionLog
);
114 if (e
.InnerException
!= null)
116 Console
.WriteLine(e
.InnerException
);
119 Console
.WriteLine("#Unexpected Exception");
120 Console
.WriteLine(e
.Message
);
124 //For some unknown reason this program hangs sometimes when started from java. This is
125 //a workaround that makes the problem disappear.
126 System
.Threading
.Thread
.Sleep(1000);