001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Serguei S.Zapreyev
020: * @version $Revision$
021: */package java.lang;
022:
023: import junit.framework.TestCase;
024:
025: /*
026: * Created on March 29, 2006
027: *
028: * This RuntimeAdditionalTest class is used to test the Core API Runtime class
029: *
030: */
031:
032: /**
033: * ###############################################################################
034: * ###############################################################################
035: * TODO: 1.
036: * ###############################################################################
037: * ###############################################################################
038: */
039:
040: public class RuntimeAdditionalTest18 extends TestCase {
041: /**
042: * read jvm output, destroy, exitValue, exitValue and, maybe, read again
043: */
044: public void test_18() {
045: System.out.println("==test_18===");
046: if (RuntimeAdditionalTest0.os.equals("Unk")) {
047: fail("WARNING (test_18): unknown operating system.");
048: }
049: try {
050: String cmnd = RuntimeAdditionalTest0.javaStarter;
051: Process pi3 = Runtime.getRuntime().exec(cmnd);
052: pi3.getOutputStream();
053: pi3.getErrorStream();
054: java.io.InputStream is = pi3.getInputStream();
055: int ia;
056: while (true) {
057: while ((ia = is.available()) != 0) {
058: byte[] bbb = new byte[ia];
059: is.read(bbb);
060: //System.out.println(new String(bbb));
061: }
062: try {
063: pi3.exitValue();
064: while ((ia = is.available()) != 0) {
065: byte[] bbb = new byte[ia];
066: is.read(bbb);
067: //System.out.println(new String(bbb));
068: }
069: break;
070: } catch (IllegalThreadStateException e) {
071: continue;
072: }
073: }
074: pi3.destroy();
075: /*System.out.println(*/pi3.exitValue()/*)*/;
076: /*System.out.println(*/pi3.exitValue()/*)*/;
077: while (true) {
078: while ((ia = is.available()) != 0) {
079: byte[] bbb = new byte[ia];
080: is.read(bbb);
081: //System.out.println(new String(bbb));
082: }
083: try {
084: pi3.exitValue();
085: while ((ia = is.available()) != 0) {
086: byte[] bbb = new byte[ia];
087: is.read(bbb);
088: //System.out.println(new String(bbb));
089: }
090: break;
091: } catch (IllegalThreadStateException e) {
092: continue;
093: }
094: }
095: } catch (Exception eeee) {
096: eeee.printStackTrace();
097: fail("ERROR (test_18): unexpected exception.");
098: }
099: }
100: }
|