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 java.lang;
19:
20: import junit.framework.TestCase;
21:
22: /*
23: * Created on March 29, 2006
24: *
25: * This RuntimeAdditionalTest class is used to test the Core API Runtime class
26: *
27: */
28:
29: /**
30: * ###############################################################################
31: * ###############################################################################
32: * TODO: 1.
33: * ###############################################################################
34: * ###############################################################################
35: */
36:
37: public class RuntimeAdditionalTest14 extends TestCase {
38: /**
39: * reading the streams after destroy
40: */
41: public void test_14() {
42: System.out.println("==test_14===");
43: if (RuntimeAdditionalTest0.os.equals("Unk")) {
44: fail("WARNING (test_14): unknown operating system.");
45: }
46: try {
47: String cmnd = RuntimeAdditionalTest0.javaStarter;
48: Process pi3 = Runtime.getRuntime().exec(cmnd);
49: pi3.getOutputStream();
50: pi3.getErrorStream();
51: java.io.InputStream is = pi3.getInputStream();
52: pi3.destroy();
53: Thread.sleep(5000);
54: int ia;
55: while (true) {
56: while ((ia = is.available()) != 0) {
57: byte[] bbb = new byte[ia];
58: is.read(bbb);
59: //System.out.println(new String(bbb));
60: }
61: try {
62: pi3.exitValue();
63: while ((ia = is.available()) != 0) {
64: byte[] bbb = new byte[ia];
65: is.read(bbb);
66: //System.out.println(new String(bbb));
67: }
68: break;
69: } catch (IllegalThreadStateException e) {
70: continue;
71: }
72: }
73: } catch (Exception eeee) {
74: eeee.printStackTrace();
75: fail("ERROR (test_14): unexpected exception.");
76: }
77: }
78: }
|