1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
30 import complexlib
.ComplexTestCase
;
33 public class CLITest
extends ComplexTestCase
35 public String
[] getTestMethodNames()
37 // TODO think about trigger of sub-tests from outside
44 public void runCLITests()
48 String testProgram
= System
.getProperty("cli_test", "");
49 if (testProgram
.length() == 0)
50 failed("Check the make file. Java must be called with -Dcli_test=pathtoexe");
52 String arg1
= System
.getProperty("cli_test_arg", "");
53 if (arg1
.length() == 0)
54 failed("Check the make file. Java must be called with " +
55 "-Dcli_test_arg=path_to_bootstrap_ini");
56 String
[] cmdarray
= new String
[] {testProgram
, arg1
};
63 proc
= Runtime
.getRuntime().exec(cmdarray
);
64 outReader
= new Reader(proc
.getInputStream());
65 errReader
= new Reader(proc
.getErrorStream());
71 System
.out
.println("\n ###" + e
.getMessage() + "\n");
74 // System.out.println("### waiting for " + testProgram);
76 // System.out.println("### " + testProgram + " finished");
77 int retVal
= proc
.exitValue();
79 failed("CLI test failed.");
80 } catch( java
.lang
.Exception e
)
82 failed("Unexpected exception.");
89 /* This reads reads from an InputStream and discards the data.
91 class Reader
extends Thread
94 public Reader(InputStream stream
)
104 byte[] buf
= new byte[1024];
105 while (-1 != is
.read(buf
));
107 catch (java
.io
.IOException exc
)