equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
40 import java.nio.channels.SelectionKey; |
40 import java.nio.channels.SelectionKey; |
41 import java.nio.channels.Selector; |
41 import java.nio.channels.Selector; |
42 import java.nio.channels.ServerSocketChannel; |
42 import java.nio.channels.ServerSocketChannel; |
43 import java.nio.channels.SocketChannel; |
43 import java.nio.channels.SocketChannel; |
44 |
44 |
|
45 import jdk.test.lib.Utils; |
|
46 |
45 public class StateTest { |
47 public class StateTest { |
46 |
48 |
47 private static int failures = 0; |
49 private static int failures = 0; |
48 |
50 |
49 private static String TEST_SERVICE = "StateTestService"; |
51 private static String TEST_SERVICE = "StateTestService"; |
64 /* |
66 /* |
65 * Wait for service to connect |
67 * Wait for service to connect |
66 */ |
68 */ |
67 ssc.configureBlocking(false); |
69 ssc.configureBlocking(false); |
68 sk = ssc.register(sel, SelectionKey.OP_ACCEPT); |
70 sk = ssc.register(sel, SelectionKey.OP_ACCEPT); |
69 long to = 15*1000; |
71 long to = Utils.adjustTimeout(15*1000); |
70 sc = null; |
72 sc = null; |
71 for (;;) { |
73 for (;;) { |
72 long st = System.currentTimeMillis(); |
74 long st = System.currentTimeMillis(); |
73 sel.select(to); |
75 sel.select(to); |
74 if (sk.isAcceptable() && ((sc = ssc.accept()) != null)) { |
76 if (sk.isAcceptable() && ((sc = ssc.accept()) != null)) { |
87 /* |
89 /* |
88 * Wait for service to report test result |
90 * Wait for service to report test result |
89 */ |
91 */ |
90 sc.configureBlocking(false); |
92 sc.configureBlocking(false); |
91 sk = sc.register(sel, SelectionKey.OP_READ); |
93 sk = sc.register(sel, SelectionKey.OP_READ); |
92 to = 5000; |
94 to = Utils.adjustTimeout(5000); |
93 ByteBuffer bb = ByteBuffer.allocateDirect(20); |
95 ByteBuffer bb = ByteBuffer.allocateDirect(20); |
94 for (;;) { |
96 for (;;) { |
95 long st = System.currentTimeMillis(); |
97 long st = System.currentTimeMillis(); |
96 sel.select(to); |
98 sel.select(to); |
97 if (sk.isReadable()) { |
99 if (sk.isReadable()) { |