author | rfield |
Thu, 22 Feb 2018 12:26:01 -0800 | |
changeset 48934 | 3390b463d7a2 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
1 |
/* |
48934
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
42272
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 |
48934
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
26 |
* @bug 8169519 8168615 8176474 |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
27 |
* @summary Tests for JDI connector 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 |
* @run testng JdiBogusHostListenExecutionControlTest |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
30 |
*/ |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
31 |
|
44683
610dc2b48954
8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents:
42969
diff
changeset
|
32 |
import java.util.logging.Level; |
610dc2b48954
8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents:
42969
diff
changeset
|
33 |
import java.util.logging.Logger; |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
34 |
import org.testng.annotations.Test; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
35 |
import jdk.jshell.JShell; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
36 |
import static org.testng.Assert.assertTrue; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
37 |
import static org.testng.Assert.fail; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
38 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
39 |
@Test |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
40 |
public class JdiBogusHostListenExecutionControlTest { |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
41 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
42 |
private static final String EXPECTED_ERROR = |
48934
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
43 |
"Launching JShell execution engine threw: Failed remote listen:"; |
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
44 |
private static final String EXPECTED_LOCATION = |
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
45 |
"@ com.sun.jdi.SocketListen"; |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
46 |
|
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
47 |
public void badOptionListenTest() { |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
48 |
try { |
44683
610dc2b48954
8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents:
42969
diff
changeset
|
49 |
// turn on logging of launch failures |
610dc2b48954
8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents:
42969
diff
changeset
|
50 |
Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL); |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
51 |
JShell.builder() |
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
42272
diff
changeset
|
52 |
.executionEngine("jdi:hostname(BattyRumbleBuckets-Snurfle-99-Blip)") |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
53 |
.build(); |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
54 |
} catch (IllegalStateException ex) { |
48934
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
55 |
assertTrue(ex.getMessage().startsWith(EXPECTED_ERROR), |
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
56 |
ex.getMessage() + "\nExpected: " + EXPECTED_ERROR); |
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
57 |
assertTrue(ex.getMessage().contains(EXPECTED_LOCATION), |
3390b463d7a2
8176474: test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java fails with java.net.BindException
rfield
parents:
47216
diff
changeset
|
58 |
ex.getMessage() + "\nExpected: " + EXPECTED_LOCATION); |
42272
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
59 |
return; |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
60 |
} |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
61 |
fail("Expected IllegalStateException"); |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
62 |
} |
82e273c4f2b3
8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff
changeset
|
63 |
} |