author | jlahoda |
Fri, 30 Jun 2017 20:03:07 +0200 | |
changeset 45757 | 1017cd5d6506 |
parent 42272 | 82e273c4f2b3 |
permissions | -rw-r--r-- |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
1 |
/* |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
4 |
* |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
8 |
* |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
13 |
* accompanied this code). |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
14 |
* |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
18 |
* |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
21 |
* questions. |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
22 |
*/ |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
23 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
24 |
/* |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
25 |
* @test |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
26 |
* @bug 8169519 |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
27 |
* @summary Tests for JDI connector timeout failure |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
28 |
* @modules jdk.jshell/jdk.jshell jdk.jshell/jdk.jshell.spi jdk.jshell/jdk.jshell.execution |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
29 |
* @build HangingRemoteAgent |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
30 |
* @run testng JdiHangingLaunchExecutionControlTest |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
31 |
*/ |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
32 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
33 |
import org.testng.annotations.Test; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
34 |
import static org.testng.Assert.assertTrue; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
35 |
import static org.testng.Assert.fail; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
36 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
37 |
@Test |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
38 |
public class JdiHangingLaunchExecutionControlTest { |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
39 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
40 |
private static final String EXPECTED_ERROR = |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
41 |
"Launching JShell execution engine threw: Accept timed out"; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
42 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
43 |
public void hangLaunchTimeoutTest() { |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
44 |
try { |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
45 |
System.err.printf("Unexpected return value: %s\n", |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
46 |
HangingRemoteAgent.state(true, null).eval("33;")); |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
47 |
} catch (IllegalStateException ex) { |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
48 |
assertTrue(ex.getMessage().startsWith(EXPECTED_ERROR), ex.getMessage()); |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
49 |
return; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
50 |
} |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
51 |
fail("Expected IllegalStateException"); |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
52 |
} |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
53 |
} |