jdk/test/java/net/SocketOption/MinimumRcvBufferSize.java
author jjg
Wed, 04 Jan 2017 18:33:20 -0800
changeset 43029 1cd1c816581e
parent 42475 c80ab3b11401
permissions -rw-r--r--
8172260: remove tests from ProblemList Reviewed-by: rfield
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42475
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     1
/*
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     4
 *
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     8
 *
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    13
 * accompanied this code).
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    14
 *
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    18
 *
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    21
 * questions.
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    22
 */
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    23
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    24
/*
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    25
 * @test
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    26
 * @bug 8170920
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    27
 * @run main MinimumRcvBufferSize
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    28
 */
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    29
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    30
import java.nio.channels.*;
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    31
import java.net.*;
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    32
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    33
public class MinimumRcvBufferSize {
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    34
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    35
    public static void main(String args[]) throws Exception {
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    36
        boolean error = false;
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    37
        ServerSocketChannel channel = ServerSocketChannel.open();
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    38
        int before = channel.getOption(StandardSocketOptions.SO_RCVBUF);
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    39
        channel.setOption(StandardSocketOptions.SO_RCVBUF, Integer.MAX_VALUE);
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    40
        int after = channel.getOption(StandardSocketOptions.SO_RCVBUF);
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    41
        if (before > after) {
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    42
            System.err.println("Test failed: SO_RCVBUF");
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    43
            error = true;
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    44
        }
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    45
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    46
        SocketChannel channel1 = SocketChannel.open();
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    47
        before = channel1.getOption(StandardSocketOptions.SO_SNDBUF);
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    48
        channel1.setOption(StandardSocketOptions.SO_SNDBUF, Integer.MAX_VALUE);
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    49
        after = channel1.getOption(StandardSocketOptions.SO_SNDBUF);
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    50
        if (before > after) {
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    51
            System.err.println("Test failed: SO_SNDBUF");
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    52
            error = true;
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    53
        }
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    54
        if (error)
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    55
            throw new RuntimeException("Test failed");
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    56
    }
c80ab3b11401 8170920: SO_RCVBUF and SO_SNDBUF options problem for network channels on MacOS
michaelm
parents:
diff changeset
    57
}