jdk/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java
changeset 29117 7956b5dc0eac
parent 24628 a78064864267
child 36237 963d1115678b
equal deleted inserted replaced
29116:9918719cfcc0 29117:7956b5dc0eac
     1 /*
     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2015, 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.
    30  */
    30  */
    31 import java.io.File;
    31 import java.io.File;
    32 import java.io.IOException;
    32 import java.io.IOException;
    33 import java.util.ArrayList;
    33 import java.util.ArrayList;
    34 import java.util.List;
    34 import java.util.List;
       
    35 import java.util.function.Predicate;
    35 import java.nio.file.Files;
    36 import java.nio.file.Files;
    36 import java.nio.file.Path;
    37 import java.nio.file.Path;
    37 import java.nio.file.Paths;
    38 import java.nio.file.Paths;
    38 import java.nio.file.attribute.PosixFileAttributeView;
    39 import java.nio.file.attribute.PosixFileAttributeView;
    39 
    40 
   233                                longFQCN);
   234                                longFQCN);
   234         assertEquals(tr.testOutput.stream()
   235         assertEquals(tr.testOutput.stream()
   235                                   .filter(s -> s.startsWith("WARNING: Exception"))
   236                                   .filter(s -> s.startsWith("WARNING: Exception"))
   236                                   .count(),
   237                                   .count(),
   237                      2, "show error each capture");
   238                      2, "show error each capture");
   238         // dumpLong/com/example/nosense/nosense
   239         // dumpLong/com/example/nonsense/nonsense
   239         assertEquals(Files.walk(Paths.get("dumpLong")).count(), 5, "Two lambda captured failed to log");
   240         Path dumpPath = Paths.get("dumpLong/com/example/nonsense");
       
   241         Predicate<Path> filter = p -> p.getParent() == null || dumpPath.startsWith(p) || p.startsWith(dumpPath);
       
   242         boolean debug = true;
       
   243         if (debug) {
       
   244            Files.walk(Paths.get("dumpLong"))
       
   245                 .forEachOrdered(p -> {
       
   246                     if (filter.test(p)) {
       
   247                         System.out.println("accepted: " + p.toString());
       
   248                     } else {
       
   249                         System.out.println("filetered out: " + p.toString());
       
   250                     }
       
   251                  });
       
   252         }
       
   253         assertEquals(Files.walk(Paths.get("dumpLong"))
       
   254                 .filter(filter)
       
   255                 .count(), 5, "Two lambda captured failed to log");
   240         tr.assertZero("Should still return 0");
   256         tr.assertZero("Should still return 0");
   241     }
   257     }
   242 }
   258 }