equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2014, 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. |
26 // system properties in samevm/agentvm mode. |
26 // system properties in samevm/agentvm mode. |
27 // |
27 // |
28 |
28 |
29 /* |
29 /* |
30 * @test |
30 * @test |
31 * @bug 4366807 |
31 * @bug 4366807 |
32 * @summary Need new APIs to get/set session timeout and session cache size. |
32 * @summary Need new APIs to get/set session timeout and session cache size. |
33 * @run main/othervm SessionCacheSizeTests |
33 * @run main/othervm SessionCacheSizeTests |
34 */ |
34 */ |
35 |
35 |
36 import java.io.*; |
36 import java.io.*; |
108 |
108 |
109 void doServerSide(int serverPort, int serverConns) throws Exception { |
109 void doServerSide(int serverPort, int serverConns) throws Exception { |
110 |
110 |
111 SSLServerSocket sslServerSocket = |
111 SSLServerSocket sslServerSocket = |
112 (SSLServerSocket) sslssf.createServerSocket(serverPort); |
112 (SSLServerSocket) sslssf.createServerSocket(serverPort); |
|
113 sslServerSocket.setSoTimeout(45000); // timeout to accept a connection |
113 serverPorts[createdPorts++] = sslServerSocket.getLocalPort(); |
114 serverPorts[createdPorts++] = sslServerSocket.getLocalPort(); |
114 |
115 |
115 /* |
116 /* |
116 * Signal Client, we're ready for his connect. |
117 * Signal Client, we're ready for his connect. |
117 */ |
118 */ |
126 * than one session. |
127 * than one session. |
127 */ |
128 */ |
128 SSLSession sessions [] = new SSLSession [serverConns]; |
129 SSLSession sessions [] = new SSLSession [serverConns]; |
129 SSLSessionContext sessCtx = sslctx.getServerSessionContext(); |
130 SSLSessionContext sessCtx = sslctx.getServerSessionContext(); |
130 |
131 |
131 while (nConnections < serverConns) { |
132 try { |
132 SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); |
133 while (nConnections < serverConns) { |
133 InputStream sslIS = sslSocket.getInputStream(); |
134 try (SSLSocket sslSocket = |
134 OutputStream sslOS = sslSocket.getOutputStream(); |
135 (SSLSocket)sslServerSocket.accept()) { |
135 read = sslIS.read(); |
136 sslSocket.setSoTimeout(90000); // timeout to read |
136 sessions[nConnections] = sslSocket.getSession(); |
137 InputStream sslIS = sslSocket.getInputStream(); |
137 sslOS.write(85); |
138 OutputStream sslOS = sslSocket.getOutputStream(); |
138 sslOS.flush(); |
139 read = sslIS.read(); |
139 sslSocket.close(); |
140 sessions[nConnections] = sslSocket.getSession(); |
140 nConnections++; |
141 sslOS.write(85); |
|
142 sslOS.flush(); |
|
143 nConnections++; |
|
144 } |
|
145 } |
|
146 } finally { |
|
147 sslServerSocket.close(); |
141 } |
148 } |
142 } |
149 } |
143 |
150 |
144 /* |
151 /* |
145 * Define the client side of the test. |
152 * Define the client side of the test. |