60 import java.net.InetSocketAddress; |
62 import java.net.InetSocketAddress; |
61 import java.net.Socket; |
63 import java.net.Socket; |
62 import java.nio.channels.AsynchronousSocketChannel; |
64 import java.nio.channels.AsynchronousSocketChannel; |
63 import java.nio.channels.ClosedChannelException; |
65 import java.nio.channels.ClosedChannelException; |
64 import java.nio.channels.SocketChannel; |
66 import java.nio.channels.SocketChannel; |
|
67 import java.security.Security; |
65 import java.util.concurrent.ExecutionException; |
68 import java.util.concurrent.ExecutionException; |
66 import jdk.test.lib.Utils; |
69 import jdk.test.lib.Utils; |
67 |
70 |
68 public class ExceptionText { |
71 public class ExceptionText { |
69 |
72 |
70 enum TestTarget {SOCKET, CHANNEL, ASYNC_CHANNEL}; |
73 enum TestTarget {SOCKET, CHANNEL, ASYNC_CHANNEL}; |
71 |
74 |
72 public static void main(String args[]) throws Exception { |
75 public static void main(String args[]) throws Exception { |
73 String passOrFail = args[0]; |
76 if (args.length == 0) { |
74 boolean expectEnhancedText; |
77 testSecProp(); |
75 if (passOrFail.equals("expectEnhancedText")) { |
|
76 expectEnhancedText = true; |
|
77 } else { |
78 } else { |
78 expectEnhancedText = false; |
79 String passOrFail = args[0]; |
|
80 boolean expectEnhancedText; |
|
81 if (passOrFail.equals("expectEnhancedText")) { |
|
82 expectEnhancedText = true; |
|
83 } else { |
|
84 expectEnhancedText = false; |
|
85 } |
|
86 test(expectEnhancedText); |
79 } |
87 } |
80 test(expectEnhancedText); |
|
81 } |
88 } |
82 |
89 |
83 static final InetSocketAddress dest = Utils.refusingEndpoint(); |
90 static final InetSocketAddress dest = Utils.refusingEndpoint(); |
84 static final String PORT = ":" + Integer.toString(dest.getPort()); |
91 static final String PORT = ":" + Integer.toString(dest.getPort()); |
85 static final String HOST = dest.getHostString(); |
92 static final String HOST = dest.getHostString(); |
|
93 |
|
94 static void testSecProp() { |
|
95 String incInExc = Security.getProperty("jdk.includeInExceptions"); |
|
96 if (incInExc != null) { |
|
97 throw new RuntimeException("Test failed: default value of " + |
|
98 "jdk.includeInExceptions security property is not null: " + |
|
99 incInExc); |
|
100 } |
|
101 } |
86 |
102 |
87 static void test(boolean withProperty) { |
103 static void test(boolean withProperty) { |
88 // Socket |
104 // Socket |
89 IOException e = getException(TestTarget.SOCKET); |
105 IOException e = getException(TestTarget.SOCKET); |
90 checkResult(e, withProperty); |
106 checkResult(e, withProperty); |