1 // Tags: JDK1.0 |
|
2 // Depends: destroy_child |
|
3 |
|
4 // Copyright (C) 2008 Christian Thalinger |
|
5 |
|
6 // This file is part of Mauve. |
|
7 |
|
8 // Mauve is free software; you can redistribute it and/or modify |
|
9 // it under the terms of the GNU General Public License as published by |
|
10 // the Free Software Foundation; either version 2, or (at your option) |
|
11 // any later version. |
|
12 |
|
13 // Mauve is distributed in the hope that it will be useful, |
|
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 // GNU General Public License for more details. |
|
17 |
|
18 // You should have received a copy of the GNU General Public License |
|
19 // along with Mauve; see the file COPYING. If not, write to |
|
20 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
21 // Boston, MA 02111-1307, USA. |
|
22 |
|
23 |
|
24 package gnu.testlet.java.lang.Process; |
|
25 |
|
26 import gnu.testlet.Testlet; |
|
27 import gnu.testlet.TestHarness; |
|
28 import java.io.BufferedReader; |
|
29 import java.io.InputStreamReader; |
|
30 import java.io.IOException; |
|
31 |
|
32 public class destroy implements Testlet |
|
33 { |
|
34 public void test(TestHarness harness) |
|
35 { |
|
36 try |
|
37 { |
|
38 Process p = Runtime.getRuntime().exec(harness.getTestJava() + " gnu.testlet.java.lang.Process.destroy_child"); |
|
39 BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); |
|
40 |
|
41 String line = in.readLine(); |
|
42 |
|
43 // Wait until the child process is up and running. |
|
44 if (line.equals("UP")) |
|
45 { |
|
46 harness.check(true); |
|
47 // Now destroy it. |
|
48 p.destroy(); |
|
49 } |
|
50 else |
|
51 harness.check(false); |
|
52 |
|
53 // Wait until the child Process is going down. |
|
54 try |
|
55 { |
|
56 p.waitFor(); |
|
57 harness.check(true); |
|
58 } |
|
59 catch (InterruptedException e) |
|
60 { |
|
61 harness.debug(e); |
|
62 harness.check(false); |
|
63 } |
|
64 } |
|
65 catch (IOException e) |
|
66 { |
|
67 harness.debug(e); |
|
68 harness.check(false); |
|
69 } |
|
70 } |
|
71 } |
|