test/jdk/com/sun/jndi/ldap/lib/LdapPlaybackServer.java
branchJDK-8210696-branch
changeset 57351 b9e5f8090688
parent 57345 ff884a2f247b
equal deleted inserted replaced
57346:3efc6cb7ffdb 57351:b9e5f8090688
    58      * The first element in the list is the LDAP request,
    58      * The first element in the list is the LDAP request,
    59      * the remaining elements are the LDAP responses.
    59      * the remaining elements are the LDAP responses.
    60      */
    60      */
    61     private final Map<Integer, List<byte[]>> cache = new HashMap<>();
    61     private final Map<Integer, List<byte[]>> cache = new HashMap<>();
    62 
    62 
    63     private String fileName;
       
    64 
       
    65     public LdapPlaybackServer(ServerSocket serverSocket, String fileName) {
    63     public LdapPlaybackServer(ServerSocket serverSocket, String fileName) {
    66         super(serverSocket);
    64         super(serverSocket);
    67         this.fileName = fileName;
       
    68         setDebugLevel(DebugLevel.CUSTOMIZE, this.getClass());
    65         setDebugLevel(DebugLevel.CUSTOMIZE, this.getClass());
    69         setCommonRequestHandler(this::handleRequest);
    66         setCommonRequestHandler(this::handleRequest);
       
    67         try {
       
    68             debug("Loading LDAP cache from: " + fileName);
       
    69             loadCaptureFile(fileName);
       
    70         } catch (IOException e) {
       
    71             throw new RuntimeException("ERROR: failed to load LDAP cache", e);
       
    72         }
    70     }
    73     }
    71 
    74 
    72     /*
    75     /*
    73      * Load a capture file containing an LDAP protocol exchange in the
    76      * Load a capture file containing an LDAP protocol exchange in the
    74      * hexadecimal dump format emitted by sun.misc.HexDumpEncoder:
    77      * hexadecimal dump format emitted by sun.misc.HexDumpEncoder:
   165     }
   168     }
   166 
   169 
   167     @Override
   170     @Override
   168     public void run() {
   171     public void run() {
   169         try {
   172         try {
   170             debug("Loading LDAP cache from: " + fileName);
       
   171             loadCaptureFile(fileName);
       
   172             debug("listening on port " + getPort());
   173             debug("listening on port " + getPort());
   173 
       
   174             super.run();
   174             super.run();
   175         } catch (Exception e) {
   175         } catch (Exception e) {
   176             debug("ERROR: " + e);
   176             debug("ERROR: " + e);
   177             e.printStackTrace();
   177             e.printStackTrace();
   178         }
   178         }