1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 package climaker; 28 29 30 import complexlib.ComplexTestCase; 31 32 33 public class ClimakerTestCase extends ComplexTestCase 34 { 35 public String[] getTestMethodNames() 36 { 37 // TODO think about trigger of sub-tests from outside 38 return new String[] 39 { 40 "checkGeneratedCLITypes" 41 }; 42 } 43 44 public void checkGeneratedCLITypes() 45 { 46 try 47 { 48 String testProgram = System.getProperty("cli_ure_test"); 49 if (testProgram == null || testProgram.length() == 0) 50 failed("Check the make file. Java must be called with -Dcli_ure_test=pathtoexe"); 51 Process proc = null; 52 try{ 53 54 proc = Runtime.getRuntime().exec(testProgram); 55 Reader outReader = new Reader(proc.getInputStream()); 56 Reader errReader = new Reader(proc.getErrorStream()); 57 58 } catch(Exception e) 59 { 60 System.out.println("\n ###" + e.getMessage() + "\n"); 61 62 } 63 proc.waitFor(); 64 int retVal = proc.exitValue(); 65 if (retVal != 0) 66 failed("Tests for generated CLI code failed."); 67 } catch( java.lang.Exception e) 68 { 69 failed("Unexpected exception."); 70 } 71 72 } 73 } 74 75 76 /* This reads reads from an InputStream and discards the data. 77 */ 78 class Reader extends Thread 79 { 80 java.io.InputStream is; 81 public Reader(java.io.InputStream stream) 82 { 83 is = stream; 84 start(); 85 } 86 87 public void run() 88 { 89 try 90 { 91 byte[] buf = new byte[1024]; 92 while (-1 != is.read(buf)); 93 } 94 catch (java.io.IOException exc) 95 { 96 } 97 } 98 } 99