8217657: Move the test for default value of jdk.includeInExceptions into own test
Reviewed-by: mullan, goetz
This commit is contained in:
parent
f5dedad7a1
commit
f828beb2d0
test/jdk
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,10 @@
|
||||
* @test
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.Utils
|
||||
* @bug 8204233 8207846 8208691
|
||||
* @bug 8204233
|
||||
* @summary Add configurable option for enhanced socket IOException messages
|
||||
* @run main/othervm
|
||||
* ExceptionText
|
||||
* @run main/othervm
|
||||
* ExceptionText
|
||||
* WITHOUT_Enhanced_Text
|
||||
* @run main/othervm
|
||||
* -Djdk.includeInExceptions=
|
||||
@ -64,7 +62,6 @@ import java.net.Socket;
|
||||
import java.nio.channels.AsynchronousSocketChannel;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.security.Security;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
@ -73,33 +70,20 @@ public class ExceptionText {
|
||||
enum TestTarget {SOCKET, CHANNEL, ASYNC_CHANNEL};
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
if (args.length == 0) {
|
||||
testSecProp();
|
||||
String passOrFail = args[0];
|
||||
boolean expectEnhancedText;
|
||||
if (passOrFail.equals("expectEnhancedText")) {
|
||||
expectEnhancedText = true;
|
||||
} else {
|
||||
String passOrFail = args[0];
|
||||
boolean expectEnhancedText;
|
||||
if (passOrFail.equals("expectEnhancedText")) {
|
||||
expectEnhancedText = true;
|
||||
} else {
|
||||
expectEnhancedText = false;
|
||||
}
|
||||
test(expectEnhancedText);
|
||||
expectEnhancedText = false;
|
||||
}
|
||||
test(expectEnhancedText);
|
||||
}
|
||||
|
||||
static final InetSocketAddress dest = Utils.refusingEndpoint();
|
||||
static final String PORT = ":" + Integer.toString(dest.getPort());
|
||||
static final String HOST = dest.getHostString();
|
||||
|
||||
static void testSecProp() {
|
||||
String incInExc = Security.getProperty("jdk.includeInExceptions");
|
||||
if (incInExc != null) {
|
||||
throw new RuntimeException("Test failed: default value of " +
|
||||
"jdk.includeInExceptions security property is not null: " +
|
||||
incInExc);
|
||||
}
|
||||
}
|
||||
|
||||
static void test(boolean withProperty) {
|
||||
// Socket
|
||||
IOException e = getException(TestTarget.SOCKET);
|
||||
@ -132,10 +116,11 @@ public class ExceptionText {
|
||||
static IOException getException(TestTarget target) {
|
||||
try {
|
||||
if (target == TestTarget.SOCKET) {
|
||||
Socket s = new Socket();
|
||||
s.connect(dest);
|
||||
try (Socket s = new Socket()) {
|
||||
s.connect(dest);
|
||||
}
|
||||
} else if (target == TestTarget.CHANNEL) {
|
||||
SocketChannel c = SocketChannel.open(dest);
|
||||
SocketChannel.open(dest);
|
||||
} else if (target == TestTarget.ASYNC_CHANNEL) {
|
||||
AsynchronousSocketChannel c = AsynchronousSocketChannel.open();
|
||||
try {
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.security.Security;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8207846 8208691
|
||||
* @summary Test the default setting of the jdk.net.includeInExceptions
|
||||
* security property
|
||||
* @comment In OpenJDK, this property is empty by default and on purpose.
|
||||
* This test assures the default is not changed.
|
||||
* @run main TestJDKIncludeInExceptions
|
||||
*/
|
||||
public class TestJDKIncludeInExceptions {
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
String incInExc = Security.getProperty("jdk.includeInExceptions");
|
||||
if (incInExc != null) {
|
||||
throw new RuntimeException("Test failed: default value of " +
|
||||
"jdk.includeInExceptions security property is not null: " +
|
||||
incInExc);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user