look for java, javac and javadoc with the .exe suffix on windows
[LibreOffice.git] / testtools / qa / cliversioning / VersionTestCase.java
blobd32faaa64276256df582fdb88a7a6c07fc0cc6df
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package cliversioning;
21 import complexlib.ComplexTestCase;
24 public class VersionTestCase extends ComplexTestCase
26 @Override
27 public String[] getTestMethodNames()
29 return new String[]
31 "checkVersion"
35 public void checkVersion()
37 int retVal = 0;
38 try
40 String testProgram = System.getProperty("cli_test_program");
41 if (testProgram == null || testProgram.length() == 0)
42 failed("Check the make file. Java must be called with -Dcli_ure_test=pathtoexe");
43 String unoPath = System.getProperty("path");
44 if (unoPath == null || unoPath.length() == 0)
45 failed("Check the make file. Java must be called with -Duno_path=path_to_ure_bin_folder");
46 String sSystemRoot = System.getProperty("SystemRoot");
47 if (sSystemRoot == null || sSystemRoot.length() == 0)
48 failed("Check the make file. Java must be called with -DSystemRoot=%SystemRoot%.");
50 //We need to set the PATH because otherwise it appears that runtests inherits the PATH
51 //from build environment. Then the bootstrapping fails because the libraries
52 //are not used from the office.
53 //.NET 2 requires SystemRoot being set.
54 String[] arEnv = new String[] {
55 "PATH=" + unoPath, "SystemRoot=" + sSystemRoot};
56 Process proc = null;
58 proc = Runtime.getRuntime().exec(testProgram, arEnv);
59 new Reader(proc.getInputStream());
60 new Reader(proc.getErrorStream());
61 proc.waitFor();
62 retVal = proc.exitValue();
63 } catch(Exception e)
65 e.printStackTrace();
66 System.out.println(e.getMessage());
67 failed("Unexpected exception.");
69 if (retVal != 0)
70 failed("Tests for library versioning failed.");
75 /* This reads from an InputStream and discards the data.
77 class Reader extends Thread
79 private java.io.InputStream is;
80 public Reader(java.io.InputStream stream)
82 is = stream;
83 start();
86 @Override
87 public void run()
89 try
91 byte[] buf = new byte[1024];
92 while (-1 != is.read(buf)) {}
94 catch (java.io.IOException exc)