< prev index next >

test/jdk/com/sun/jdi/ExclusiveBind.java

Print this page
rev 51731 : imported patch 8210732


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4531526
  26  * @summary Test that more than one debuggee cannot bind to same port
  27  *          at the same time.
  28  * @library /lib/testlibrary
  29  * @library /test/lib
  30  *
  31  * @modules java.management
  32  *          jdk.jdi
  33  * @build jdk.testlibrary.* VMConnection ExclusiveBind HelloWorld
  34  * @run driver ExclusiveBind
  35  */
  36 import java.net.ServerSocket;
  37 import com.sun.jdi.Bootstrap;
  38 import com.sun.jdi.VirtualMachine;
  39 import com.sun.jdi.connect.Connector;
  40 import com.sun.jdi.connect.AttachingConnector;
  41 
  42 import java.util.ArrayList;
  43 import java.util.Map;
  44 import java.util.List;
  45 import java.util.Iterator;
  46 import java.util.concurrent.TimeUnit;
  47 
  48 import jdk.test.lib.process.ProcessTools;
  49 import jdk.testlibrary.Utils;
  50 
  51 public class ExclusiveBind {
  52     /*
  53      * Find a connector by name
  54      */
  55     private static Connector findConnector(String name) {
  56         List connectors = Bootstrap.virtualMachineManager().allConnectors();
  57         Iterator iter = connectors.iterator();
  58         while (iter.hasNext()) {
  59             Connector connector = (Connector)iter.next();
  60             if (connector.name().equals(name)) {
  61                 return connector;
  62             }
  63         }
  64         return null;
  65     }
  66 
  67     /*
  68      * Launch (in server mode) a debuggee with the given address and
  69      * suspend mode.




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 4531526
  26  * @summary Test that more than one debuggee cannot bind to same port
  27  *          at the same time.

  28  * @library /test/lib
  29  *
  30  * @modules java.management
  31  *          jdk.jdi
  32  * @build VMConnection ExclusiveBind HelloWorld
  33  * @run driver ExclusiveBind
  34  */
  35 import java.net.ServerSocket;
  36 import com.sun.jdi.Bootstrap;
  37 import com.sun.jdi.VirtualMachine;
  38 import com.sun.jdi.connect.Connector;
  39 import com.sun.jdi.connect.AttachingConnector;
  40 
  41 import java.util.ArrayList;
  42 import java.util.Map;
  43 import java.util.List;
  44 import java.util.Iterator;
  45 import java.util.concurrent.TimeUnit;
  46 
  47 import jdk.test.lib.process.ProcessTools;
  48 import jdk.test.lib.Utils;
  49 
  50 public class ExclusiveBind {
  51     /*
  52      * Find a connector by name
  53      */
  54     private static Connector findConnector(String name) {
  55         List connectors = Bootstrap.virtualMachineManager().allConnectors();
  56         Iterator iter = connectors.iterator();
  57         while (iter.hasNext()) {
  58             Connector connector = (Connector)iter.next();
  59             if (connector.name().equals(name)) {
  60                 return connector;
  61             }
  62         }
  63         return null;
  64     }
  65 
  66     /*
  67      * Launch (in server mode) a debuggee with the given address and
  68      * suspend mode.


< prev index next >