01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.drlvm.tests.regression.h1800;
19:
20: import junit.framework.TestCase;
21: import java.io.*;
22:
23: public class ExecTest extends TestCase {
24:
25: public void testExec() throws Exception {
26: String[] cmdL = new String[5];
27: cmdL[0] = System.getProperty("java.home") + File.separator
28: + "bin" + File.separator + "java";
29: cmdL[1] = "-classpath";
30: cmdL[2] = ".";
31: cmdL[3] = "testExec1_App";
32: cmdL[4] = null;
33: try {
34: Process p = Runtime.getRuntime().exec(cmdL);
35: p.waitFor();
36: int ans = p.exitValue();
37: InputStream is = p.getErrorStream();
38: int toRead = is.available();
39: byte[] out = new byte[100];
40: int sz = 0;
41: while (true) {
42: int r = is.read();
43: if (r == -1) {
44: break;
45: }
46: out[sz] = (byte) r;
47: sz++;
48: if (sz == 100) {
49: break;
50: }
51: }
52: System.out
53: .println("========Application error message======");
54: System.out.println(new String(out, 0, sz));
55: System.out
56: .println("=======================================");
57:
58: fail("NullPointerException was not thrown. exitValue = "
59: + ans);
60: } catch (NullPointerException e) {
61: }
62: }
63: }
|