jdk/test/java/net/httpclient/security/Security.java
changeset 37897 bc8dc7bc4a03
parent 37791 ae33107fd8b3
child 38883 d5de564f8089
equal deleted inserted replaced
37896:cd841af7dcd0 37897:bc8dc7bc4a03
    66 import java.util.concurrent.*;
    66 import java.util.concurrent.*;
    67 import java.util.function.*;
    67 import java.util.function.*;
    68 import java.util.logging.ConsoleHandler;
    68 import java.util.logging.ConsoleHandler;
    69 import java.util.logging.Level;
    69 import java.util.logging.Level;
    70 import java.util.logging.Logger;
    70 import java.util.logging.Logger;
       
    71 import java.lang.reflect.InvocationTargetException;
       
    72 import java.net.BindException;
    71 
    73 
    72 /**
    74 /**
    73  * Security checks test
    75  * Security checks test
    74  */
    76  */
    75 public class Security {
    77 public class Security {
   140         } else {
   142         } else {
   141             System.out.printf("NOT moving %s to %s\n", src.toString(), dest.toString());
   143             System.out.printf("NOT moving %s to %s\n", src.toString(), dest.toString());
   142         }
   144         }
   143     }
   145     }
   144 
   146 
   145     static Object getProxy(int port, boolean b) throws Exception {
   147     static Object getProxy(int port, boolean b) throws Throwable {
   146         return proxyConstructor.newInstance(port, b);
   148         try {
       
   149             return proxyConstructor.newInstance(port, b);
       
   150         } catch (InvocationTargetException e) {
       
   151             throw e.getTargetException();
       
   152         }
   147     }
   153     }
   148 
   154 
   149     static Class<?> proxyClass;
   155     static Class<?> proxyClass;
   150     static Constructor<?> proxyConstructor;
   156     static Constructor<?> proxyConstructor;
   151 
   157 
   317 
   323 
   318     private static void directProxyTest(int proxyPort, boolean samePort) throws IOException, InterruptedException {
   324     private static void directProxyTest(int proxyPort, boolean samePort) throws IOException, InterruptedException {
   319         Object proxy = null;
   325         Object proxy = null;
   320         try {
   326         try {
   321             proxy = getProxy(proxyPort, true);
   327             proxy = getProxy(proxyPort, true);
   322         } catch (IOException e) {
   328         } catch (BindException e) {
   323             System.out.println("Cannot bind. Not running test");
   329             System.out.println("Bind failed");
   324             throw new SecurityException("test not run");
   330             throw e;
   325         } catch (Exception ee) {
   331         } catch (Throwable ee) {
   326             throw new RuntimeException(ee);
   332             throw new RuntimeException(ee);
   327         }
   333         }
   328         System.out.println("Proxy port = " + proxyPort);
   334         System.out.println("Proxy port = " + proxyPort);
   329         if (!samePort)
   335         if (!samePort)
   330             proxyPort++;
   336             proxyPort++;