test/jdk/sun/security/ssl/SSLEngineImpl/EngineEnforceUseClientMode.java
changeset 51141 2dd2d73c52f6
parent 50768 68fa3d4026ea
equal deleted inserted replaced
51140:1edcf36fe15f 51141:2dd2d73c52f6
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 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.
    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 4980882
    31  * @bug 4980882 8207250
    32  * @summary SSLEngine should enforce setUseClientMode
    32  * @summary SSLEngine should enforce setUseClientMode
    33  * @run main/othervm EngineEnforceUseClientMode
    33  * @run main/othervm EngineEnforceUseClientMode
    34  * @author Brad R. Wetmore
    34  * @author Brad R. Wetmore
    35  */
    35  */
    36 
    36 
   188                     (appOut2.limit() == appIn1.position())) {
   188                     (appOut2.limit() == appIn1.position())) {
   189 
   189 
   190                 checkTransfer(appOut1, appIn2);
   190                 checkTransfer(appOut1, appIn2);
   191                 checkTransfer(appOut2, appIn1);
   191                 checkTransfer(appOut2, appIn1);
   192 
   192 
       
   193                 // Should not be able to set mode now, no matter if
       
   194                 // it is the same of different.
   193                 System.out.println("Try changing modes...");
   195                 System.out.println("Try changing modes...");
   194                 try {
   196                 for (boolean b : new Boolean[] {true, false}) {
   195                     ssle2.setUseClientMode(true);
   197                     try {
   196                     throw new RuntimeException(
   198                         ssle2.setUseClientMode(b);
   197                         "setUseClientMode():  " +
   199                         throw new RuntimeException(
   198                         "Didn't catch the exception properly");
   200                                 "setUseClientMode(" + b + "):  " +
   199                 } catch (IllegalArgumentException e) {
   201                                         "Didn't catch the exception properly");
   200                     System.out.println("Caught the correct exception.");
   202                     } catch (IllegalArgumentException e) {
       
   203                         System.out.println("Caught the correct exception.");
       
   204                     }
   201                 }
   205                 }
   202 
   206 
   203                 return;
   207                 return;
   204             }
   208             }
   205         }
   209         }