test/jdk/javax/net/ssl/compatibility/Compatibility.java
changeset 50968 14708e1acdc3
parent 47955 0887e20e7173
child 51058 44c355346475
equal deleted inserted replaced
50967:1e24c7152e47 50968:14708e1acdc3
     1 /*
     1 /*
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2017, 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.
    49 import java.util.concurrent.ExecutorService;
    49 import java.util.concurrent.ExecutorService;
    50 import java.util.concurrent.Executors;
    50 import java.util.concurrent.Executors;
    51 import java.util.concurrent.Future;
    51 import java.util.concurrent.Future;
    52 import java.util.concurrent.TimeUnit;
    52 import java.util.concurrent.TimeUnit;
    53 import java.util.stream.Collectors;
    53 import java.util.stream.Collectors;
       
    54 import java.util.stream.Stream;
    54 
    55 
    55 import jdk.test.lib.process.OutputAnalyzer;
    56 import jdk.test.lib.process.OutputAnalyzer;
    56 
    57 
    57 public class Compatibility {
    58 public class Compatibility {
    58 
    59 
   155                         testCases.add(testCase);
   156                         testCases.add(testCase);
   156                         System.out.printf(
   157                         System.out.printf(
   157                                 "ServerStatus=%s, ClientStatus=%s, CaseStatus=%s%n",
   158                                 "ServerStatus=%s, ClientStatus=%s, CaseStatus=%s%n",
   158                                 serverStatus, clientStatus, testCase.getStatus());
   159                                 serverStatus, clientStatus, testCase.getStatus());
   159 
   160 
   160                         // Confirm the server has stopped.
       
   161                         if(new File(Utils.PORT_LOG).exists()) {
       
   162                             throw new RuntimeException("Server doesn't stop.");
       
   163                         }
       
   164                         System.out.println("----- Case end -----");
   161                         System.out.println("----- Case end -----");
   165                     }
   162                     }
   166                 }
   163                 }
   167             }
   164             }
   168 
   165 
   234     }
   231     }
   235 
   232 
   236     private static List<String> jdkList(String listFileProp) throws IOException {
   233     private static List<String> jdkList(String listFileProp) throws IOException {
   237         String listFile = System.getProperty(listFileProp);
   234         String listFile = System.getProperty(listFileProp);
   238         System.out.println(listFileProp + "=" + listFile);
   235         System.out.println(listFileProp + "=" + listFile);
   239         if (listFile != null && new File(listFile).exists()) {
   236         if (listFile != null && Files.exists(Paths.get(listFile))) {
   240             return Files.lines(Paths.get(listFile))
   237             try (Stream<String> lines = Files.lines(Paths.get(listFile))) {
   241                         .filter(line -> { return !line.trim().isEmpty(); })
   238                 return lines.filter(line -> {
   242                         .collect(Collectors.toList());
   239                     return !line.trim().isEmpty();
       
   240                 }).collect(Collectors.toList());
       
   241             }
   243         } else {
   242         } else {
   244             return new ArrayList<>();
   243             return new ArrayList<>();
   245         }
   244         }
   246     }
   245     }
   247 
   246 
   261         return port;
   260         return port;
   262     }
   261     }
   263 
   262 
   264     // Retrieves the latest server port from port.log.
   263     // Retrieves the latest server port from port.log.
   265     private static int getServerPort() throws IOException {
   264     private static int getServerPort() throws IOException {
   266         if (!new File(Utils.PORT_LOG).exists()) {
   265         if (!Files.exists(Paths.get(Utils.PORT_LOG))) {
   267             return -1;
   266             return -1;
   268         }
   267         }
   269 
   268 
   270         return Integer.valueOf(
   269         try (Stream<String> lines = Files.lines(Paths.get(Utils.PORT_LOG))) {
   271                 Files.lines(Paths.get(Utils.PORT_LOG)).findFirst().get());
   270             return Integer.valueOf(lines.findFirst().get());
       
   271         }
   272     }
   272     }
   273 
   273 
   274     private static OutputAnalyzer runServer(String jdkPath,
   274     private static OutputAnalyzer runServer(String jdkPath,
   275             Map<String, String> props) {
   275             Map<String, String> props) {
   276         return ProcessUtils.java(jdkPath, props, Server.class);
   276         return ProcessUtils.java(jdkPath, props, Server.class);