equal
deleted
inserted
replaced
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* @test |
24 /* @test |
25 * @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 |
25 * @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 |
26 * @summary Comprehensive test of asynchronous closing and interruption |
26 * @summary Comprehensive test of asynchronous closing and interruption |
27 * @author Mark Reinhold |
27 * @author Mark Reinhold |
28 */ |
28 */ |
29 |
29 |
30 import java.io.*; |
30 import java.io.*; |
86 refuser.socket().bind(wildcardAddress); |
86 refuser.socket().bind(wildcardAddress); |
87 pumpRefuser("Initializing refuser..."); |
87 pumpRefuser("Initializing refuser..."); |
88 } |
88 } |
89 |
89 |
90 private static void pumpRefuser(String msg) throws IOException { |
90 private static void pumpRefuser(String msg) throws IOException { |
|
91 // Can't reliably saturate connection backlog on Windows Server editions |
|
92 assert !TestUtil.onWindows(); |
|
93 |
91 log.print(msg); |
94 log.print(msg); |
92 int n = refuserClients.size(); |
95 int n = refuserClients.size(); |
93 |
96 |
94 // Saturate the refuser's connection backlog so that further connection |
97 // Saturate the refuser's connection backlog so that further connection |
95 // attempts will block |
98 // attempts will block |
201 |
204 |
202 static ChannelFactory datagramChannelFactory |
205 static ChannelFactory datagramChannelFactory |
203 = new ChannelFactory("DatagramChannel") { |
206 = new ChannelFactory("DatagramChannel") { |
204 InterruptibleChannel create() throws IOException { |
207 InterruptibleChannel create() throws IOException { |
205 DatagramChannel dc = DatagramChannel.open(); |
208 DatagramChannel dc = DatagramChannel.open(); |
206 dc.socket().bind(wildcardAddress); |
209 InetAddress lb = InetAddress.getByName("127.0.0.1"); |
207 InetAddress ia = InetAddress.getByName("127.0.0.1"); |
210 dc.bind(new InetSocketAddress(lb, 0)); |
208 dc.connect(new InetSocketAddress(ia, 80)); |
211 dc.connect(new InetSocketAddress(lb, 80)); |
209 return dc; |
212 return dc; |
210 } |
213 } |
211 }; |
214 }; |
212 |
215 |
213 static ChannelFactory pipeSourceChannelFactory |
216 static ChannelFactory pipeSourceChannelFactory |
634 |
637 |
635 public static void main(String[] args) throws Exception { |
638 public static void main(String[] args) throws Exception { |
636 |
639 |
637 wildcardAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0); |
640 wildcardAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0); |
638 initAcceptor(); |
641 initAcceptor(); |
639 initRefuser(); |
642 if (!TestUtil.onWindows()) |
|
643 initRefuser(); |
640 initPipes(); |
644 initPipes(); |
641 initFile(); |
645 initFile(); |
642 |
646 |
643 if (TestUtil.onME()) { |
647 if (TestUtil.onME()) { |
644 log.println("WARNING: Cannot test FileChannel transfer operations" |
648 log.println("WARNING: Cannot test FileChannel transfer operations" |
656 // |
660 // |
657 // Testing map is impractical and arguably unnecessary: It's |
661 // Testing map is impractical and arguably unnecessary: It's |
658 // unclear under what conditions mmap(2) will actually block. |
662 // unclear under what conditions mmap(2) will actually block. |
659 |
663 |
660 test(connectedSocketChannelFactory); |
664 test(connectedSocketChannelFactory); |
661 test(socketChannelFactory, CONNECT); |
665 |
662 test(socketChannelFactory, FINISH_CONNECT); |
666 if (TestUtil.onWindows()) { |
|
667 log.println("WARNING Cannot reliably test connect/finishConnect" |
|
668 + " operations on Windows"); |
|
669 } else { |
|
670 test(socketChannelFactory, CONNECT); |
|
671 test(socketChannelFactory, FINISH_CONNECT); |
|
672 } |
|
673 |
663 test(serverSocketChannelFactory, ACCEPT); |
674 test(serverSocketChannelFactory, ACCEPT); |
664 test(datagramChannelFactory); |
675 test(datagramChannelFactory); |
665 test(pipeSourceChannelFactory); |
676 test(pipeSourceChannelFactory); |
666 test(pipeSinkChannelFactory); |
677 test(pipeSinkChannelFactory); |
667 |
678 |