/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4921888
* @summary Tests that we do not get a NullPointException.
* @author Shanliang JIANG
* @run clean CloseFailedClientTest
* @run build CloseFailedClientTest
* @run main CloseFailedClientTest
*/
import javax.management.*;
/**
* Try to connect a client to a no-existing or not started server,
* expected to receive an IOException.
*
*/
public class CloseFailedClientTest {
/**
* we use a fix port on which we hope no server is running,
* or a server running on it will give an IOException when our
* clients try to connect to it.
* The port 999 is specified in
* as:
* garcon 999/tcp
* applix 999/udp Applix ac
* puprouter 999/tcp
* puprouter 999/udp
*
* If the test fails because a server runs on this port and does
* not give back an IOException, we can change to another one like
* 9999
*/
boolean ok = true;
try {
ok = false;
} else {
}
} catch (Exception e) {
ok = false;
}
}
if (ok) {
return;
} else {
}
}
throws Exception {
for (int i=0; i<20; i++) {
// no server
try {
} catch (MalformedURLException e) {
return true;
}
try {
throw new RuntimeException("Do not get expected IOEeption.");
} catch (IOException e) {
// OK, the expected IOException is thrown.");
}
// close the connector client
// with server but not started
try {
} catch (MalformedURLException e) {
return true;
}
try {
throw new RuntimeException("Do not get expected IOEeption.");
} catch (IOException e) {
// OK, the expected IOException is thrown.");
}
// close the connector client
}
return true;
}
}