test/jdk/java/nio/channels/TestServers.java
changeset 49255 acdb8531cc8b
parent 47216 71c04702a3d5
equal deleted inserted replaced
49254:422615764e12 49255:acdb8531cc8b
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 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.
    29 import java.net.*;
    29 import java.net.*;
    30 import java.util.ArrayList;
    30 import java.util.ArrayList;
    31 import java.util.Date;
    31 import java.util.Date;
    32 import java.util.List;
    32 import java.util.List;
    33 
    33 
       
    34 import jdk.test.lib.Utils;
       
    35 
    34 
    36 
    35 public class TestServers {
    37 public class TestServers {
    36 
    38 
    37     private TestServers() { }
    39     private TestServers() { }
    38 
    40 
    79         public InetAddress getAddress() {
    81         public InetAddress getAddress() {
    80             return address;
    82             return address;
    81         }
    83         }
    82 
    84 
    83         public static RefusingServer newRefusingServer() throws IOException {
    85         public static RefusingServer newRefusingServer() throws IOException {
    84             // The port 1 is reserved for TCPMUX(RFC 1078), which is seldom used,
    86             return new RefusingServer(InetAddress.getLocalHost(),
    85             // and it's not used on all the test platform through JPRT.
    87                        Utils.refusingEndpoint().getPort());
    86             // So we choose to use it as a refusing "server"'s "listen" port,
       
    87             // it's much more stable than "open->close a server socket".
       
    88             return new RefusingServer(InetAddress.getLocalHost(), 1);
       
    89         }
    88         }
    90     }
    89     }
    91 
    90 
    92     /**
    91     /**
    93      * An abstract class for implementing small TCP servers for the nio tests
    92      * An abstract class for implementing small TCP servers for the nio tests