1.1 --- a/test/tools/jdeps/Basic.java Mon Oct 28 12:29:34 2013 -0700 1.2 +++ b/test/tools/jdeps/Basic.java Wed Oct 30 08:35:52 2013 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -23,9 +23,9 @@ 1.11 1.12 /* 1.13 * @test 1.14 - * @bug 8003562 8005428 8015912 1.15 + * @bug 8003562 8005428 8015912 8027481 1.16 * @summary Basic tests for jdeps tool 1.17 - * @build Test p.Foo 1.18 + * @build Test p.Foo p.Bar javax.activity.NotCompactProfile 1.19 * @run main Basic 1.20 */ 1.21 1.22 @@ -33,10 +33,12 @@ 1.23 import java.io.IOException; 1.24 import java.io.PrintWriter; 1.25 import java.io.StringWriter; 1.26 +import java.nio.file.Files; 1.27 import java.nio.file.Path; 1.28 import java.nio.file.Paths; 1.29 import java.util.*; 1.30 import java.util.regex.*; 1.31 +import static java.nio.file.StandardCopyOption.*; 1.32 1.33 public class Basic { 1.34 private static boolean symbolFileExist = initProfiles(); 1.35 @@ -74,23 +76,25 @@ 1.36 new String[] {"java.lang", "p"}, 1.37 new String[] {"compact1", "not found"}); 1.38 // test a directory 1.39 + // also test non-SE javax.activity class dependency 1.40 test(new File(testDir, "p"), 1.41 - new String[] {"java.lang", "java.util", "java.lang.management"}, 1.42 - new String[] {"compact1", "compact1", "compact3"}); 1.43 + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"}, 1.44 + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, 1.45 + new String[] {"-classpath", testDir.getPath()}); 1.46 // test class-level dependency output 1.47 test(new File(testDir, "Test.class"), 1.48 - new String[] {"java.lang.Object", "java.lang.String", "p.Foo"}, 1.49 - new String[] {"compact1", "compact1", "not found"}, 1.50 + new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, 1.51 + new String[] {"compact1", "compact1", "not found", "not found"}, 1.52 new String[] {"-verbose:class"}); 1.53 // test -p option 1.54 test(new File(testDir, "Test.class"), 1.55 - new String[] {"p.Foo"}, 1.56 - new String[] {"not found"}, 1.57 + new String[] {"p.Foo", "p.Bar"}, 1.58 + new String[] {"not found", "not found"}, 1.59 new String[] {"-verbose:class", "-p", "p"}); 1.60 // test -e option 1.61 test(new File(testDir, "Test.class"), 1.62 - new String[] {"p.Foo"}, 1.63 - new String[] {"not found"}, 1.64 + new String[] {"p.Foo", "p.Bar"}, 1.65 + new String[] {"not found", "not found"}, 1.66 new String[] {"-verbose:class", "-e", "p\\..*"}); 1.67 test(new File(testDir, "Test.class"), 1.68 new String[] {"java.lang"}, 1.69 @@ -99,13 +103,34 @@ 1.70 // test -classpath and -include options 1.71 test(null, 1.72 new String[] {"java.lang", "java.util", 1.73 - "java.lang.management"}, 1.74 - new String[] {"compact1", "compact1", "compact3"}, 1.75 + "java.lang.management", "javax.crypto"}, 1.76 + new String[] {"compact1", "compact1", "compact3", "compact1"}, 1.77 new String[] {"-classpath", testDir.getPath(), "-include", "p.+|Test.class"}); 1.78 test(new File(testDir, "Test.class"), 1.79 - new String[] {"java.lang.Object", "java.lang.String", "p.Foo"}, 1.80 - new String[] {"compact1", "compact1", testDir.getName()}, 1.81 + new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, 1.82 + new String[] {"compact1", "compact1", testDir.getName(), testDir.getName()}, 1.83 new String[] {"-v", "-classpath", testDir.getPath(), "Test.class"}); 1.84 + 1.85 + // split package p - move p/Foo.class to dir1 and p/Bar.class to dir2 1.86 + Path testClassPath = testDir.toPath(); 1.87 + Path dirP = testClassPath.resolve("p"); 1.88 + Path dir1 = testClassPath.resolve("dir1"); 1.89 + Path subdir1P = dir1.resolve("p"); 1.90 + Path dir2 = testClassPath.resolve("dir2"); 1.91 + Path subdir2P = dir2.resolve("p"); 1.92 + if (!Files.exists(subdir1P)) 1.93 + Files.createDirectories(subdir1P); 1.94 + if (!Files.exists(subdir2P)) 1.95 + Files.createDirectories(subdir2P); 1.96 + Files.move(dirP.resolve("Foo.class"), subdir1P.resolve("Foo.class"), REPLACE_EXISTING); 1.97 + Files.move(dirP.resolve("Bar.class"), subdir2P.resolve("Bar.class"), REPLACE_EXISTING); 1.98 + StringBuilder cpath = new StringBuilder(testDir.toString()); 1.99 + cpath.append(File.pathSeparator).append(dir1.toString()); 1.100 + cpath.append(File.pathSeparator).append(dir2.toString()); 1.101 + test(new File(testDir, "Test.class"), 1.102 + new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, 1.103 + new String[] {"compact1", "compact1", dir1.toFile().getName(), dir2.toFile().getName()}, 1.104 + new String[] {"-v", "-classpath", cpath.toString(), "Test.class"}); 1.105 return errors; 1.106 } 1.107 1.108 @@ -148,7 +173,7 @@ 1.109 // Use the linePattern to break the given String into lines, applying 1.110 // the pattern to each line to see if we have a match 1.111 private static Map<String,String> findDeps(String out) { 1.112 - Map<String,String> result = new HashMap<>(); 1.113 + Map<String,String> result = new LinkedHashMap<>(); 1.114 Matcher lm = linePattern.matcher(out); // Line matcher 1.115 Matcher pm = null; // Pattern matcher 1.116 int lines = 0;