8180887: move FileUtils to top level testlibrary
Reviewed-by: psandoz
This commit is contained in:
parent
4f2e94d65a
commit
c85d273e7d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 7130985
|
||||
* @summary Four helper classes missing in Sun JDK
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @build jdk.testlibrary.*
|
||||
* @modules java.corba
|
||||
* @run main CorbaExceptionsCompileTest
|
||||
@ -35,12 +35,12 @@ import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.omg.CORBA.ORBPackage.InvalidName;
|
||||
import org.omg.CORBA.TypeCodePackage.BadKind;
|
||||
import org.omg.CORBA.TypeCodePackage.Bounds;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import jdk.testlibrary.JDKToolLauncher;
|
||||
|
||||
public class CorbaExceptionsCompileTest implements CorbaExceptionsTest {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -26,8 +26,7 @@
|
||||
* @bug 8071474
|
||||
* @summary Better failure atomicity for default read object.
|
||||
* @modules jdk.compiler
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @library /test/lib
|
||||
* @compile FailureAtomicity.java SerialRef.java
|
||||
* @run main failureAtomicity.FailureAtomicity
|
||||
*/
|
||||
@ -59,7 +58,7 @@ import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.StandardLocation;
|
||||
import javax.tools.ToolProvider;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FailureAtomicity {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -29,7 +29,7 @@ import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import static jdk.testlibrary.ProcessTools.*;
|
||||
|
||||
import org.testng.annotations.BeforeClass;
|
||||
@ -40,9 +40,9 @@ import static org.testng.Assert.assertTrue;
|
||||
* @test
|
||||
* @bug 8087335
|
||||
* @summary Tests for Class.forName(Module,String)
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler
|
||||
* @build TestDriver CompilerUtils jdk.testlibrary.ProcessTools jdk.testlibrary.FileUtils TestMain TestLayer
|
||||
* @build TestDriver CompilerUtils jdk.testlibrary.ProcessTools TestMain TestLayer
|
||||
* @run testng TestDriver
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2017, 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
|
||||
@ -24,7 +24,7 @@
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.file.Files;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import static java.nio.file.StandardCopyOption.*;
|
||||
|
||||
public class Common {
|
||||
|
@ -24,9 +24,9 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6899919
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler
|
||||
* @build jdk.testlibrary.FileUtils JarUtils CompilerUtils
|
||||
* @build JarUtils CompilerUtils
|
||||
* @run main/othervm GetResourceAsStream
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -26,7 +26,7 @@
|
||||
* @modules jdk.incubator.httpclient
|
||||
* java.logging
|
||||
* jdk.httpserver
|
||||
* @library /lib/testlibrary/
|
||||
* @library /lib/testlibrary/ /test/lib
|
||||
* @compile ../../../com/sun/net/httpserver/LogFilter.java
|
||||
* @compile ../../../com/sun/net/httpserver/FileServerHandler.java
|
||||
* @build LightWeightHttpServer
|
||||
@ -52,7 +52,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.function.Supplier;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import static java.nio.charset.StandardCharsets.*;
|
||||
import static java.nio.file.StandardOpenOption.*;
|
||||
import static jdk.incubator.http.HttpRequest.BodyProcessor.*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -45,7 +45,7 @@ import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.StandardLocation;
|
||||
import javax.tools.ToolProvider;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import jdk.testlibrary.JDKToolFinder;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Arrays.asList;
|
||||
@ -55,8 +55,8 @@ import static java.util.Arrays.asList;
|
||||
* @bug 8064924
|
||||
* @modules jdk.compiler
|
||||
* @summary Basic test for URLStreamHandlerProvider
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @build jdk.testlibrary.JDKToolFinder
|
||||
* @compile Basic.java Child.java
|
||||
* @run main Basic
|
||||
*/
|
||||
|
@ -25,9 +25,7 @@
|
||||
* @bug 4313887 6873621 6979526 7006126 7020517
|
||||
* @summary Unit test for java.nio.file.FileStore
|
||||
* @key intermittent
|
||||
* @library ..
|
||||
* @library .. /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @library .. /test/lib
|
||||
* @run main Basic
|
||||
*/
|
||||
|
||||
@ -35,8 +33,8 @@ import java.nio.file.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
|
||||
public class Basic {
|
||||
|
@ -24,8 +24,7 @@
|
||||
/* @test
|
||||
* @bug 4313887 6838333 8132497
|
||||
* @summary Unit test for java.nio.file.FileSystem
|
||||
* @library .. /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @library .. /test/lib
|
||||
* @run main/othervm Basic
|
||||
*/
|
||||
|
||||
@ -41,7 +40,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.ProviderNotFoundException;
|
||||
import java.util.HashMap;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
/**
|
||||
* Simple sanity checks for java.nio.file.FileSystem
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2017, 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
|
||||
@ -28,8 +28,7 @@
|
||||
* "java.util.logging.FileHandler.maxLocks" which will be present in
|
||||
* "logging.properties" file with default value of 100. This property can be
|
||||
* overriden by specifying this property in the custom config file.
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @library /test/lib
|
||||
* @author rpatil
|
||||
* @run main/othervm FileHandlerMaxLocksTest
|
||||
*/
|
||||
@ -40,7 +39,7 @@ import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.FileHandler;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class FileHandlerMaxLocksTest {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2017, 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
|
||||
@ -24,8 +24,7 @@
|
||||
/* @test
|
||||
* @bug 8038491
|
||||
* @summary Crash in ZipFile.read() when ZipFileInputStream is shared between threads
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @library /test/lib
|
||||
* @run main MultiThreadedReadTest
|
||||
* @key randomness
|
||||
*/
|
||||
@ -38,7 +37,7 @@ import java.util.Random;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class MultiThreadedReadTest extends Thread {
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2017, 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
|
||||
@ -24,15 +24,14 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6374379
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @library /test/lib
|
||||
* @summary Verify that we can read zip file names > 255 chars long
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.jar.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.Stack;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class ReadLongZipFileName {
|
||||
private static String entryName = "testFile.txt";;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -24,8 +24,7 @@
|
||||
/* @test
|
||||
* @bug 6907252
|
||||
* @summary ZipFileInputStream Not Thread-Safe
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.*
|
||||
* @library /test/lib
|
||||
* @run main ZipEntryFreeTest
|
||||
*/
|
||||
|
||||
@ -35,7 +34,7 @@ import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.zip.*;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class ZipEntryFreeTest extends Thread {
|
||||
|
||||
|
@ -25,9 +25,8 @@
|
||||
* @test
|
||||
* @bug 8163798
|
||||
* @summary basic tests for multi-release jar versioned streams
|
||||
* @library /lib/testlibrary
|
||||
* @library /test/lib
|
||||
* @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @run testng TestVersionedStream
|
||||
*/
|
||||
|
||||
@ -57,7 +56,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class TestVersionedStream {
|
||||
private final Path userdir;
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8170859
|
||||
* @summary Basic test for incubator modules in jmods and images
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @key intermittent
|
||||
* @modules jdk.compiler jdk.jartool jdk.jlink
|
||||
* @build CompilerUtils
|
||||
@ -39,14 +39,13 @@ import java.io.PrintStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -1,230 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.testlibrary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryNotEmptyException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* Common library for various test file utility functions.
|
||||
*/
|
||||
public final class FileUtils {
|
||||
|
||||
private static final boolean isWindows =
|
||||
System.getProperty("os.name").startsWith("Windows");
|
||||
private static final int RETRY_DELETE_MILLIS = isWindows ? 500 : 0;
|
||||
private static final int MAX_RETRY_DELETE_TIMES = isWindows ? 15 : 0;
|
||||
|
||||
/**
|
||||
* Deletes a file, retrying if necessary.
|
||||
*
|
||||
* @param path the file to delete
|
||||
*
|
||||
* @throws NoSuchFileException
|
||||
* if the file does not exist (optional specific exception)
|
||||
* @throws DirectoryNotEmptyException
|
||||
* if the file is a directory and could not otherwise be deleted
|
||||
* because the directory is not empty (optional specific exception)
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
*/
|
||||
public static void deleteFileWithRetry(Path path)
|
||||
throws IOException
|
||||
{
|
||||
try {
|
||||
deleteFileWithRetry0(path);
|
||||
} catch (InterruptedException x) {
|
||||
throw new IOException("Interrupted while deleting.", x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a file, retrying if necessary.
|
||||
* No exception thrown if file doesn't exist.
|
||||
*
|
||||
* @param path the file to delete
|
||||
*
|
||||
* @throws NoSuchFileException
|
||||
* if the file does not exist (optional specific exception)
|
||||
* @throws DirectoryNotEmptyException
|
||||
* if the file is a directory and could not otherwise be deleted
|
||||
* because the directory is not empty (optional specific exception)
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
*/
|
||||
public static void deleteFileIfExistsWithRetry(Path path)
|
||||
throws IOException
|
||||
{
|
||||
try {
|
||||
if(Files.exists(path))
|
||||
deleteFileWithRetry0(path);
|
||||
} catch (InterruptedException x) {
|
||||
throw new IOException("Interrupted while deleting.", x);
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteFileWithRetry0(Path path)
|
||||
throws IOException, InterruptedException
|
||||
{
|
||||
int times = 0;
|
||||
IOException ioe = null;
|
||||
while (true) {
|
||||
try {
|
||||
Files.delete(path);
|
||||
while (Files.exists(path)) {
|
||||
times++;
|
||||
if (times > MAX_RETRY_DELETE_TIMES)
|
||||
throw new IOException("File still exists after " + times + " waits.");
|
||||
Thread.sleep(RETRY_DELETE_MILLIS);
|
||||
}
|
||||
break;
|
||||
} catch (NoSuchFileException | DirectoryNotEmptyException x) {
|
||||
throw x;
|
||||
} catch (IOException x) {
|
||||
// Backoff/retry in case another process is accessing the file
|
||||
times++;
|
||||
if (ioe == null)
|
||||
ioe = x;
|
||||
else
|
||||
ioe.addSuppressed(x);
|
||||
|
||||
if (times > MAX_RETRY_DELETE_TIMES)
|
||||
throw ioe;
|
||||
Thread.sleep(RETRY_DELETE_MILLIS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a directory and its subdirectories, retrying if necessary.
|
||||
*
|
||||
* @param dir the directory to delete
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs. Any such exceptions are caught
|
||||
* internally. If only one is caught, then it is re-thrown.
|
||||
* If more than one exception is caught, then the second and
|
||||
* following exceptions are added as suppressed exceptions of the
|
||||
* first one caught, which is then re-thrown.
|
||||
*/
|
||||
public static void deleteFileTreeWithRetry(Path dir)
|
||||
throws IOException
|
||||
{
|
||||
IOException ioe = null;
|
||||
final List<IOException> excs = deleteFileTreeUnchecked(dir);
|
||||
if (!excs.isEmpty()) {
|
||||
ioe = excs.remove(0);
|
||||
for (IOException x : excs)
|
||||
ioe.addSuppressed(x);
|
||||
}
|
||||
if (ioe != null)
|
||||
throw ioe;
|
||||
}
|
||||
|
||||
public static List<IOException> deleteFileTreeUnchecked(Path dir) {
|
||||
final List<IOException> excs = new ArrayList<>();
|
||||
try {
|
||||
java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
try {
|
||||
deleteFileWithRetry0(file);
|
||||
} catch (IOException x) {
|
||||
excs.add(x);
|
||||
} catch (InterruptedException x) {
|
||||
excs.add(new IOException("Interrupted while deleting.", x));
|
||||
return FileVisitResult.TERMINATE;
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
|
||||
try {
|
||||
deleteFileWithRetry0(dir);
|
||||
} catch (IOException x) {
|
||||
excs.add(x);
|
||||
} catch (InterruptedException x) {
|
||||
excs.add(new IOException("Interrupted while deleting.", x));
|
||||
return FileVisitResult.TERMINATE;
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
@Override
|
||||
public FileVisitResult visitFileFailed(Path file, IOException exc) {
|
||||
excs.add(exc);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
} catch (IOException x) {
|
||||
excs.add(x);
|
||||
}
|
||||
return excs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether all file systems are accessible. This is performed
|
||||
* by checking free disk space on all mounted file systems via a
|
||||
* separate, spawned process. File systems are considered to be
|
||||
* accessible if this process completes successfully before a given
|
||||
* fixed duration has elapsed.
|
||||
*
|
||||
* @implNote On Unix this executes the {@code df} command in a separate
|
||||
* process and on Windows always returns {@code true}.
|
||||
*/
|
||||
public static boolean areFileSystemsAccessible() throws IOException {
|
||||
boolean areFileSystemsAccessible = true;
|
||||
if (!isWindows) {
|
||||
// try to check whether 'df' hangs
|
||||
System.out.println("\n--- df output ---");
|
||||
System.out.flush();
|
||||
Process proc = new ProcessBuilder("df").inheritIO().start();
|
||||
try {
|
||||
proc.waitFor(90, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
try {
|
||||
int exitValue = proc.exitValue();
|
||||
if (exitValue != 0) {
|
||||
System.err.printf("df process exited with %d != 0%n",
|
||||
exitValue);
|
||||
areFileSystemsAccessible = false;
|
||||
}
|
||||
} catch (IllegalThreadStateException ignored) {
|
||||
System.err.println("df command apparently hung");
|
||||
areFileSystemsAccessible = false;
|
||||
}
|
||||
}
|
||||
return areFileSystemsAccessible;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2017, 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
|
||||
@ -28,9 +28,8 @@
|
||||
* options with/without a --release option. Some input files are
|
||||
* duplicates that sometimes cause exceptions and other times do not,
|
||||
* demonstrating identical behavior to JDK 8 jar tool.
|
||||
* @library /lib/testlibrary
|
||||
* @library /test/lib
|
||||
* @modules jdk.jartool
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @run testng InputFilesTest
|
||||
*/
|
||||
|
||||
@ -51,7 +50,7 @@ import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class InputFilesTest {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2017, 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,9 +27,8 @@
|
||||
* @summary test that both old style command line options and new gnu style
|
||||
* command line options work with the --release option whether or
|
||||
* not the --release option is preceded by a file name.
|
||||
* @library /lib/testlibrary
|
||||
* @library /test/lib
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @run testng ReleaseBeforeFiles
|
||||
*/
|
||||
|
||||
@ -46,7 +45,7 @@ import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class ReleaseBeforeFiles {
|
||||
private Runnable onCompletion;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -35,7 +35,7 @@ import java.util.jar.JarInputStream;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import jdk.testlibrary.JDKToolFinder;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
@ -49,8 +49,8 @@ import static org.testng.Assert.assertTrue;
|
||||
/*
|
||||
* @test
|
||||
* @bug 8170952
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @build jdk.testlibrary.JDKToolFinder
|
||||
* @run testng CLICompatibility
|
||||
* @summary Basic test for compatibility of CLI options
|
||||
*/
|
||||
|
@ -29,8 +29,7 @@
|
||||
* @modules java.base/jdk.internal.module
|
||||
* jdk.compiler
|
||||
* jdk.jartool
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @library /test/lib
|
||||
* @run testng Basic
|
||||
*/
|
||||
|
||||
@ -57,7 +56,7 @@ import java.util.stream.Stream;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import jdk.internal.module.ModuleInfoExtender;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class Basic {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
|
@ -25,7 +25,6 @@ import java.io.*;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.jar.JarEntry;
|
||||
@ -36,7 +35,7 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import jdk.testlibrary.JDKToolFinder;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@ -48,10 +47,10 @@ import static java.lang.System.out;
|
||||
/*
|
||||
* @test
|
||||
* @bug 8167328 8171830 8165640 8174248 8176772
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler
|
||||
* jdk.jartool
|
||||
* @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
|
||||
* @build jdk.testlibrary.JDKToolFinder
|
||||
* @compile Basic.java
|
||||
* @run testng Basic
|
||||
* @summary Tests for plain Modular jars & Multi-Release Modular jars
|
||||
|
@ -24,18 +24,16 @@
|
||||
/*
|
||||
* @test
|
||||
* @summary Tests for API validator.
|
||||
* @library /test/lib /lib/testlibrary
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* jdk.compiler
|
||||
* jdk.jartool
|
||||
* @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @build MRTestBase
|
||||
* @run testng/timeout=1200 ApiValidatorTest
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@ -421,4 +419,5 @@ public class ApiValidatorTest extends MRTestBase {
|
||||
|
||||
javac(classes, sourceFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,19 +23,17 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @library /test/lib /lib/testlibrary
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* jdk.compiler
|
||||
* jdk.jartool
|
||||
* @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @build MRTestBase
|
||||
* @run testng Basic
|
||||
*/
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2017, 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
|
||||
@ -29,7 +29,7 @@ import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import static jdk.testlibrary.ProcessTools.*;
|
||||
|
||||
|
||||
@ -39,9 +39,9 @@ import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler jdk.jlink
|
||||
* @build CompiledVersionTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
|
||||
* @build CompiledVersionTest CompilerUtils jdk.testlibrary.ProcessTools
|
||||
* @run testng CompiledVersionTest
|
||||
*/
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -33,7 +32,7 @@ import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
import static jdk.testlibrary.ProcessTools.*;
|
||||
|
||||
@ -44,11 +43,11 @@ import static org.testng.Assert.*;
|
||||
/**
|
||||
* @test
|
||||
* @bug 8142968 8173381 8174740
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler jdk.jlink
|
||||
* @modules java.base/jdk.internal.module
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @build ModuleTargetHelper UserModuleTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
|
||||
* @build ModuleTargetHelper UserModuleTest CompilerUtils jdk.testlibrary.ProcessTools
|
||||
* @run testng UserModuleTest
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -23,10 +23,10 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler
|
||||
* jdk.jlink
|
||||
* @build jdk.testlibrary.FileUtils CompilerUtils
|
||||
* @build CompilerUtils
|
||||
* @run testng JmodNegativeTest
|
||||
* @summary Negative tests for jmod
|
||||
*/
|
||||
@ -41,7 +41,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2017, 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
|
||||
@ -25,10 +25,10 @@
|
||||
* @test
|
||||
* @bug 8142968 8166568 8166286 8170618 8168149
|
||||
* @summary Basic test for jmod
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler
|
||||
* jdk.jlink
|
||||
* @build jdk.testlibrary.FileUtils CompilerUtils
|
||||
* @build CompilerUtils
|
||||
* @run testng/othervm -Djava.io.tmpdir=. JmodTest
|
||||
*/
|
||||
|
||||
@ -40,9 +40,8 @@ import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -24,16 +24,16 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 8167063
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @library /test/lib
|
||||
* @run main LauncherMessageTest
|
||||
* @summary LauncherHelper should not throw JNI error for LinkageError
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
|
||||
public class LauncherMessageTest {
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8157068 8177844
|
||||
* @summary Patch java.base and user module with ModuleHashes attribute
|
||||
* @library /lib/testlibrary
|
||||
* @library /lib/testlibrary /test/lib
|
||||
* @modules jdk.compiler
|
||||
* @build CompilerUtils
|
||||
* @run testng PatchSystemModules
|
||||
@ -39,7 +39,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import jdk.test.lib.util.FileUtils;
|
||||
import jdk.testlibrary.JDKToolFinder;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
Loading…
Reference in New Issue
Block a user