8223015: Cleanups for zipfs tests
Reviewed-by: redestad, lancea
This commit is contained in:
parent
919b40be45
commit
1d7eb52dc1
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@ import java.nio.channels.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.spi.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.net.*;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@ -98,8 +97,6 @@ public class Demo {
|
||||
|
||||
mkdirs, // <java Demo mkdirs zipfile dir>
|
||||
|
||||
rmdirs, // <java Demo rmdirs zipfile dir>
|
||||
|
||||
list, // <java Demo list zipfile [dir]>
|
||||
// recursively list all entries of dir
|
||||
// via DirectoryStream
|
||||
@ -144,7 +141,7 @@ public class Demo {
|
||||
}
|
||||
|
||||
Action action = Action.valueOf(args[0]);
|
||||
Map<String, Object> env = env = new HashMap<>();
|
||||
Map<String, Object> env = new HashMap<>();
|
||||
if (action == Action.create)
|
||||
env.put("create", "true");
|
||||
try (FileSystem fs = provider.newFileSystem(Paths.get(args[1]), env)) {
|
||||
@ -534,10 +531,10 @@ public class Demo {
|
||||
Files.createDirectory(path);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/**
|
||||
* Not used in demo, but included for demonstrational purposes.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static void rmdirs(Path path) throws IOException {
|
||||
while (path != null && path.getNameCount() != 0) {
|
||||
Files.delete(path);
|
||||
@ -561,11 +558,11 @@ public class Demo {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/**
|
||||
* Checks that the content of two paths are equal.
|
||||
* Not used in demo, but included for demonstrational purposes.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static void checkEqual(Path src, Path dst) throws IOException
|
||||
{
|
||||
//System.out.printf("checking <%s> vs <%s>...%n",
|
||||
@ -638,8 +635,11 @@ public class Demo {
|
||||
}
|
||||
}
|
||||
|
||||
private static void fchCopy(Path src, Path dst) throws IOException
|
||||
{
|
||||
/**
|
||||
* Not used in demo, but included for demonstrational purposes.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static void fchCopy(Path src, Path dst) throws IOException {
|
||||
Set<OpenOption> read = new HashSet<>();
|
||||
read.add(READ);
|
||||
Set<OpenOption> openwrite = new HashSet<>();
|
||||
@ -658,8 +658,11 @@ public class Demo {
|
||||
}
|
||||
}
|
||||
|
||||
private static void chCopy(Path src, Path dst) throws IOException
|
||||
{
|
||||
/**
|
||||
* Not used in demo, but included for demonstrational purposes.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static void chCopy(Path src, Path dst) throws IOException {
|
||||
Set<OpenOption> read = new HashSet<>();
|
||||
read.add(READ);
|
||||
Set<OpenOption> openwrite = new HashSet<>();
|
||||
@ -678,8 +681,11 @@ public class Demo {
|
||||
}
|
||||
}
|
||||
|
||||
private static void streamCopy(Path src, Path dst) throws IOException
|
||||
{
|
||||
/**
|
||||
* Not used in demo, but included for demonstrational purposes.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private static void streamCopy(Path src, Path dst) throws IOException {
|
||||
byte[] buf = new byte[8192];
|
||||
try (InputStream isSrc = Files.newInputStream(src);
|
||||
OutputStream osDst = Files.newOutputStream(dst))
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,13 +46,11 @@ public class PathOps {
|
||||
static final java.io.PrintStream out = System.out;
|
||||
static FileSystem fs;
|
||||
|
||||
private String input;
|
||||
private Path path;
|
||||
private Exception exc;
|
||||
|
||||
private PathOps(String first, String... more) {
|
||||
out.println();
|
||||
input = first;
|
||||
try {
|
||||
path = fs.getPath(first, more);
|
||||
out.format("%s -> %s", first, path);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -533,10 +533,7 @@ public class ZipFSTester {
|
||||
try (var zfs = newZipFileSystem(zpath, Collections.emptyMap())) {
|
||||
for (Object[] e : entries) {
|
||||
Path path = zfs.getPath((String)e[0]);
|
||||
int method = (int)e[1];
|
||||
byte[] bytes = (byte[])e[2];
|
||||
// System.out.printf("checking read [%s, %d, %d]%n",
|
||||
// path.toString(), bytes.length, method);
|
||||
checkRead(path, bytes);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -48,7 +48,7 @@ import org.testng.Assert;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
public class MultiReleaseJarTest {
|
||||
final private int MAJOR_VERSION = Runtime.version().major();
|
||||
final private int MAJOR_VERSION = Runtime.version().feature();
|
||||
|
||||
final private String userdir = System.getProperty("user.dir",".");
|
||||
final private CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars();
|
||||
@ -101,13 +101,13 @@ public class MultiReleaseJarTest {
|
||||
@DataProvider(name="integers")
|
||||
public Object[][] createIntegers() {
|
||||
return new Object[][] {
|
||||
{new Integer(-5), 8},
|
||||
{new Integer(0), 8},
|
||||
{new Integer(8), 8},
|
||||
{new Integer(9), 9},
|
||||
{new Integer(MAJOR_VERSION), MAJOR_VERSION},
|
||||
{new Integer(MAJOR_VERSION + 1), MAJOR_VERSION},
|
||||
{new Integer(100), MAJOR_VERSION}
|
||||
{Integer.valueOf(-5), 8},
|
||||
{Integer.valueOf(0), 8},
|
||||
{Integer.valueOf(8), 8},
|
||||
{Integer.valueOf(9), 9},
|
||||
{Integer.valueOf(MAJOR_VERSION), MAJOR_VERSION},
|
||||
{Integer.valueOf(MAJOR_VERSION + 1), MAJOR_VERSION},
|
||||
{Integer.valueOf(100), MAJOR_VERSION}
|
||||
};
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class MultiReleaseJarTest {
|
||||
byte [] bytes = Files.readAllBytes(version);
|
||||
Class<?> vcls = (new ByteArrayClassLoader(fs)).defineClass(className, bytes);
|
||||
MethodHandle mh = MethodHandles.lookup().findVirtual(vcls, "getVersion", mt);
|
||||
Assert.assertEquals((int)mh.invoke(vcls.newInstance()), expected);
|
||||
Assert.assertEquals((int)mh.invoke(vcls.getDeclaredConstructor().newInstance()), expected);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,7 +69,7 @@ public class CreateMultiReleaseTestJars {
|
||||
+ " return 9;\n"
|
||||
+ " }\n"
|
||||
+ "}\n";
|
||||
final int currentVersion = Runtime.version().major();
|
||||
final int currentVersion = Runtime.version().feature();
|
||||
final String currentVersionStr = Integer.toString(currentVersion);
|
||||
final private String javaCurrent = java8.replace("8", currentVersionStr);
|
||||
final String readme8 = "This is the root readme file";
|
||||
|
Loading…
x
Reference in New Issue
Block a user