< prev index next >

jdk/test/jdk/internal/util/jar/TestVersionedStream.java

Print this page
rev 17249 : 8180887: move FileUtils to top level testlibrary
Reviewed-by: duke


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8163798
  27  * @summary basic tests for multi-release jar versioned streams
  28  * @library /lib/testlibrary
  29  * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar
  30  * @build jdk.testlibrary.FileUtils
  31  * @run testng TestVersionedStream
  32  */
  33 
  34 import org.testng.Assert;
  35 import org.testng.annotations.AfterClass;
  36 import org.testng.annotations.DataProvider;
  37 import org.testng.annotations.Test;
  38 
  39 import java.io.File;
  40 import java.io.IOException;
  41 import java.io.InputStream;
  42 import java.io.UncheckedIOException;
  43 import java.nio.file.Files;
  44 import java.nio.file.Path;
  45 import java.nio.file.Paths;
  46 import java.util.ArrayList;
  47 import java.util.Arrays;
  48 import java.util.HashMap;
  49 import java.util.Iterator;
  50 import java.util.LinkedHashSet;
  51 import java.util.List;
  52 import java.util.Map;
  53 import java.util.Set;
  54 import java.util.jar.JarEntry;
  55 import java.util.jar.JarFile;
  56 import java.util.stream.Collectors;
  57 import java.util.stream.Stream;
  58 import java.util.zip.ZipFile;
  59 
  60 import jdk.testlibrary.FileUtils;
  61 
  62 public class TestVersionedStream {
  63     private final Path userdir;
  64     private final Set<String> unversionedEntryNames;
  65 
  66     public TestVersionedStream() throws IOException {
  67         userdir = Paths.get(System.getProperty("user.dir", "."));
  68 
  69         // These are not real class files even though they end with .class.
  70         // They are resource files so jar tool validation won't reject them.
  71         // But they are what we want to test, especially q/Bar.class that
  72         // could be in a concealed package if this was a modular multi-release
  73         // jar.
  74         createFiles(
  75                 "base/p/Bar.class",
  76                 "base/p/Foo.class",
  77                 "base/p/Main.class",
  78                 "v9/p/Foo.class",
  79                 "v10/p/Foo.class",
  80                 "v10/q/Bar.class",




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8163798
  27  * @summary basic tests for multi-release jar versioned streams
  28  * @library /test/lib
  29  * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar

  30  * @run testng TestVersionedStream
  31  */
  32 
  33 import org.testng.Assert;
  34 import org.testng.annotations.AfterClass;
  35 import org.testng.annotations.DataProvider;
  36 import org.testng.annotations.Test;
  37 
  38 import java.io.File;
  39 import java.io.IOException;
  40 import java.io.InputStream;
  41 import java.io.UncheckedIOException;
  42 import java.nio.file.Files;
  43 import java.nio.file.Path;
  44 import java.nio.file.Paths;
  45 import java.util.ArrayList;
  46 import java.util.Arrays;
  47 import java.util.HashMap;
  48 import java.util.Iterator;
  49 import java.util.LinkedHashSet;
  50 import java.util.List;
  51 import java.util.Map;
  52 import java.util.Set;
  53 import java.util.jar.JarEntry;
  54 import java.util.jar.JarFile;
  55 import java.util.stream.Collectors;
  56 import java.util.stream.Stream;
  57 import java.util.zip.ZipFile;
  58 
  59 import jdk.test.lib.util.FileUtils;
  60 
  61 public class TestVersionedStream {
  62     private final Path userdir;
  63     private final Set<String> unversionedEntryNames;
  64 
  65     public TestVersionedStream() throws IOException {
  66         userdir = Paths.get(System.getProperty("user.dir", "."));
  67 
  68         // These are not real class files even though they end with .class.
  69         // They are resource files so jar tool validation won't reject them.
  70         // But they are what we want to test, especially q/Bar.class that
  71         // could be in a concealed package if this was a modular multi-release
  72         // jar.
  73         createFiles(
  74                 "base/p/Bar.class",
  75                 "base/p/Foo.class",
  76                 "base/p/Main.class",
  77                 "v9/p/Foo.class",
  78                 "v10/p/Foo.class",
  79                 "v10/q/Bar.class",


< prev index next >