test/jdk/java/nio/channels/DatagramChannel/Connect.java
changeset 49284 a51ca91c2cde
parent 47216 71c04702a3d5
equal deleted inserted replaced
49283:a14ede52a278 49284:a51ca91c2cde
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 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.
   100                 address = InetAddress.getLocalHost();
   100                 address = InetAddress.getLocalHost();
   101                 InetSocketAddress bogus = new InetSocketAddress(address, 3333);
   101                 InetSocketAddress bogus = new InetSocketAddress(address, 3333);
   102                 try {
   102                 try {
   103                     dc.send(bb, bogus);
   103                     dc.send(bb, bogus);
   104                     throw new RuntimeException("Allowed bogus send while connected");
   104                     throw new RuntimeException("Allowed bogus send while connected");
   105                 } catch (IllegalArgumentException iae) {
   105                 } catch (AlreadyConnectedException ace) {
   106                     // Correct behavior
   106                     // Correct behavior
   107                 }
   107                 }
   108 
   108 
   109                 // Read a reply
   109                 // Read a reply
   110                 bb.flip();
   110                 bb.flip();