ServerSocketChannelTest.java revision a3b57e9cb41fb00ac607cd330fa73270b564b66c
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package libcore.java.nio.channels;
18
19import java.nio.channels.ServerSocketChannel;
20
21public class ServerSocketChannelTest extends junit.framework.TestCase {
22    // http://code.google.com/p/android/issues/detail?id=16579
23    public void testNonBlockingAccept() throws Exception {
24        ServerSocketChannel ssc = ServerSocketChannel.open();
25        try {
26            ssc.configureBlocking(false);
27            ssc.socket().bind(null);
28            // Should return immediately, since we're non-blocking.
29            assertNull(ssc.accept());
30        } finally {
31            ssc.close();
32        }
33    }
34}
35