Mercurial > hg > openjdk > jdk8 > jdk
changeset 6099:9edfa0e761b9
8001569: Regression test GetPeerHost uses static port number
Reviewed-by: weijun
author | xuelei |
---|---|
date | Fri, 09 Nov 2012 01:15:04 -0800 |
parents | 1e7dd9e05ce2 |
children | 220d2458ce4b c3e7ceb22d37 |
files | test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHost.java test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostClient.java test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostServer.java |
diffstat | 3 files changed, 19 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHost.java Thu Nov 08 12:51:25 2012 -0500 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHost.java Fri Nov 09 01:15:04 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,13 +21,15 @@ * questions. */ +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + /** * @test * @bug 4302026 * @run main/othervm GetPeerHost - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. * @summary make sure the server side doesn't do DNS lookup. */ import javax.net.*; @@ -41,7 +43,8 @@ + "/../../../../../../../etc/truststore"); GetPeerHostServer server = new GetPeerHostServer(); server.start(); - GetPeerHostClient client = new GetPeerHostClient(); + GetPeerHostClient client = + new GetPeerHostClient(server.getServerPort()); client.start(); server.join (); if (!server.getPassStatus ()) {
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostClient.java Thu Nov 08 12:51:25 2012 -0500 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostClient.java Fri Nov 09 01:15:04 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,13 +38,13 @@ SSLSocket s; String server; - public GetPeerHostClient () + public GetPeerHostClient (int serverPort) { try { SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory .getDefault(); server = InetAddress.getLocalHost().getHostName(); - s = (SSLSocket) factory.createSocket(server, 9999); + s = (SSLSocket) factory.createSocket(server, serverPort); System.out.println("CLIENT: connected to the server- " + server); } catch (Exception e) { System.err.println("Unexpected exceptions: " + e);
--- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostServer.java Thu Nov 08 12:51:25 2012 -0500 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ServerHandshaker/GetPeerHostServer.java Fri Nov 09 01:15:04 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ private String host; ServerSocket ss; boolean isHostIPAddr = false; + int serverPort = 0; public GetPeerHostServer () { @@ -57,7 +58,8 @@ kmf.init(ks, passphrase); ctx.init(kmf.getKeyManagers(), null, null); ServerSocketFactory ssf = ctx.getServerSocketFactory(); - ss = ssf.createServerSocket(9999); + ss = ssf.createServerSocket(serverPort); + serverPort = ss.getLocalPort(); }catch (Exception e) { System.err.println("Unexpected exceptions: " + e); e.printStackTrace(); @@ -90,4 +92,8 @@ boolean getPassStatus () { return isHostIPAddr; } + + int getServerPort() { + return serverPort; + } }