/* * Copyright (c) 2003, 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 * 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 4932837 6582235 * @summary Test SslRMI[Client|Server]SocketFactory equals() and hashCode(). * This test does not affect VM global state, so othervm is * not required. * @author Daniel Fuchs * * @run main SocketFactoryTest
*/
publicstatic Object serializeAndClone(Object o) throws Exception {
System.out.println("Serializing object: " + o); final ByteArrayOutputStream obytes = new ByteArrayOutputStream(); final ObjectOutputStream ostr = new ObjectOutputStream(obytes);
ostr.writeObject(o);
ostr.flush();
System.out.println("Deserializing object"); final ByteArrayInputStream ibytes = new ByteArrayInputStream(obytes.toByteArray()); final ObjectInputStream istr = new ObjectInputStream(ibytes); return istr.readObject();
}
publicstaticvoid testEquals(Object a, Object b, boolean expected) { finalboolean found = a.equals(b); if (found != expected) thrownew RuntimeException("testEquals failed: objects are " +
((found)?"equals":"not equals")); if (found && a.hashCode()!=b.hashCode()) thrownew RuntimeException("testEquals failed: objects are " + "equals but their hashcode differ");
}
final SSLContext context = SSLContext.getInstance("SSL");
context.init(null, null, null);
final SslRMIClientSocketFactory client1 = new SslRMIClientSocketFactory(); final SslRMIClientSocketFactory client2 = new SslRMIClientSocketFactory(); final SslRMIClientSocketFactory client11 =
(SslRMIClientSocketFactory) serializeAndClone(client1); final SslRMIClientSocketFactory client21 =
(SslRMIClientSocketFactory) serializeAndClone(client2); final SslRMIServerSocketFactory server1 = new SslRMIServerSocketFactory(); final SslRMIServerSocketFactory server2 = new SslRMIServerSocketFactory(null, null, false); final SslRMIServerSocketFactory server3 = new SslRMIServerSocketFactory(ciphersuite, null, false); final SslRMIServerSocketFactory server4 = new SslRMIServerSocketFactory(null,
protocol, false); final SslRMIServerSocketFactory server5 = new SslRMIServerSocketFactory(null, null, true); final SslRMIServerSocketFactory server6 = new SslRMIServerSocketFactory(null, null, null, false); final SslRMIServerSocketFactory server7 = new SslRMIServerSocketFactory(SSLContext.getDefault(), null, null, false); final SslRMIServerSocketFactory server8 = new SslRMIServerSocketFactory(null, null, null, true); final SslRMIServerSocketFactory server9 = new SslRMIServerSocketFactory(SSLContext.getDefault(), null, null, true); final SslRMIServerSocketFactory server10 = new SslRMIServerSocketFactory(context, null, null, true); final MySslRMIClientSocketFactory subclient1 = new MySslRMIClientSocketFactory(); final MySslRMIClientSocketFactory subclient2 = new MySslRMIClientSocketFactory(); final MySslRMIServerSocketFactory subserver1 = new MySslRMIServerSocketFactory(); final MySslRMIServerSocketFactory subserver2 = new MySslRMIServerSocketFactory(null, null, false); final MySslRMIServerSocketFactory subserver3 = new MySslRMIServerSocketFactory(ciphersuite, null, false); final MySslRMIServerSocketFactory subserver4 = new MySslRMIServerSocketFactory(null,
protocol, false); final MySslRMIServerSocketFactory subserver5 = new MySslRMIServerSocketFactory(null, null, true); final MySslRMIServerSocketFactory subserver6 = new MySslRMIServerSocketFactory(null,
ciphersuite, null, false); final MySslRMIServerSocketFactory subserver7 = new MySslRMIServerSocketFactory(SSLContext.getDefault(),
ciphersuite, null, false); final MySslRMIServerSocketFactory subserver8 = new MySslRMIServerSocketFactory(context, null, null, true);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.