# HG changeset patch # User iignatyev # Date 1536109775 25200 # Tue Sep 04 18:09:35 2018 -0700 # Node ID 34e3a50bf68be3ecd86501960b0d28b6fdfcec20 # Parent e9177e7749e7c4e363bb48be0bbb9c49d090126e [mq]: 8210112 diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java --- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java +++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java @@ -25,7 +25,7 @@ /** * @test * @requires vm.cds - * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds + * @library /test/lib /test/hotspot/jtreg/runtime/appcds * @modules jdk.compiler * jdk.jartool/sun.tools.jar * jdk.jlink @@ -39,7 +39,6 @@ import java.nio.file.Paths; import jdk.test.lib.process.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; public class AddModules { diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java --- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java +++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddOpens.java @@ -25,7 +25,7 @@ /** * @test * @requires vm.cds - * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds + * @library /test/lib /test/hotspot/jtreg/runtime/appcds * @modules jdk.compiler * jdk.jartool/sun.tools.jar * jdk.jlink @@ -39,7 +39,6 @@ import java.nio.file.Paths; import jdk.test.lib.process.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; public class AddOpens { diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddReads.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddReads.java --- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddReads.java +++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddReads.java @@ -39,7 +39,6 @@ import java.nio.file.Paths; import jdk.test.lib.process.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; import jdk.testlibrary.Asserts; public class AddReads { diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java --- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java +++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ExportModule.java @@ -40,7 +40,6 @@ import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; import jdk.testlibrary.Asserts; public class ExportModule { diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java --- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java +++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/MainModuleOnly.java @@ -25,7 +25,7 @@ /** * @test * @requires vm.cds - * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds + * @library /test/lib /test/hotspot/jtreg/runtime/appcds * @modules jdk.compiler * jdk.jartool/sun.tools.jar * jdk.jlink @@ -41,7 +41,6 @@ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; -import jdk.testlibrary.ProcessTools; public class MainModuleOnly { diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java --- a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java +++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/ModulePathAndCP.java @@ -25,7 +25,7 @@ /** * @test * @requires vm.cds - * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/appcds + * @library /test/lib /test/hotspot/jtreg/runtime/appcds * @modules jdk.compiler * jdk.jartool/sun.tools.jar * jdk.jlink @@ -40,7 +40,6 @@ import java.nio.file.Paths; import jdk.test.lib.process.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; public class ModulePathAndCP { diff --git a/test/jdk/com/sun/jdi/BadAgentPath.java b/test/jdk/com/sun/jdi/BadAgentPath.java --- a/test/jdk/com/sun/jdi/BadAgentPath.java +++ b/test/jdk/com/sun/jdi/BadAgentPath.java @@ -21,18 +21,16 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.Utils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* @test * @bug 8147456 * @summary Check that providing a non-existing -agentpath gives a proper error. * @author Sharath Ballal * - * @library /lib/testlibrary + * @library /test/lib * @modules java.management - * @build jdk.testlibrary.* * @build BadAgentPath * @run driver BadAgentPath */ diff --git a/test/jdk/com/sun/jdi/BadHandshakeTest.java b/test/jdk/com/sun/jdi/BadHandshakeTest.java --- a/test/jdk/com/sun/jdi/BadHandshakeTest.java +++ b/test/jdk/com/sun/jdi/BadHandshakeTest.java @@ -37,12 +37,13 @@ import java.util.concurrent.atomic.AtomicBoolean; import jdk.testlibrary.Utils; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /* @test * @bug 6306165 6432567 * @summary Check that a bad handshake doesn't cause a debuggee to abort * @library /lib/testlibrary + * @library /test/lib * * @modules java.management * jdk.jdi diff --git a/test/jdk/com/sun/jdi/DoubleAgentTest.java b/test/jdk/com/sun/jdi/DoubleAgentTest.java --- a/test/jdk/com/sun/jdi/DoubleAgentTest.java +++ b/test/jdk/com/sun/jdi/DoubleAgentTest.java @@ -21,8 +21,8 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; /* @test @@ -30,6 +30,7 @@ * @summary Check that multiple -agentlib statements in command line fails * * @library /lib/testlibrary + * @library /test/lib * @modules java.management * @build jdk.testlibrary.* * @build DoubleAgentTest Exit0 diff --git a/test/jdk/com/sun/jdi/ExclusiveBind.java b/test/jdk/com/sun/jdi/ExclusiveBind.java --- a/test/jdk/com/sun/jdi/ExclusiveBind.java +++ b/test/jdk/com/sun/jdi/ExclusiveBind.java @@ -26,6 +26,7 @@ * @summary Test that more than one debuggee cannot bind to same port * at the same time. * @library /lib/testlibrary + * @library /test/lib * * @modules java.management * jdk.jdi @@ -44,7 +45,7 @@ import java.util.Iterator; import java.util.concurrent.TimeUnit; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; public class ExclusiveBind { diff --git a/test/jdk/com/sun/jdi/NoLaunchOptionTest.java b/test/jdk/com/sun/jdi/NoLaunchOptionTest.java --- a/test/jdk/com/sun/jdi/NoLaunchOptionTest.java +++ b/test/jdk/com/sun/jdi/NoLaunchOptionTest.java @@ -22,8 +22,8 @@ */ import static jdk.testlibrary.Asserts.assertFalse; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* * @test NoLaunchOptionTest.java @@ -32,6 +32,7 @@ * @author Tim Bell * * @library /lib/testlibrary + * @library /test/lib * * @run compile -g NoLaunchOptionTest.java * @build jdk.testlibrary.* VMConnection diff --git a/test/jdk/com/sun/jdi/ProcessAttachTest.java b/test/jdk/com/sun/jdi/ProcessAttachTest.java --- a/test/jdk/com/sun/jdi/ProcessAttachTest.java +++ b/test/jdk/com/sun/jdi/ProcessAttachTest.java @@ -25,7 +25,7 @@ import java.io.InputStream; import java.util.Map; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import com.sun.jdi.Bootstrap; import com.sun.jdi.VirtualMachine; @@ -39,6 +39,7 @@ * @summary Unit test for ProcessAttachingConnector * * @library /lib/testlibrary + * @library /test/lib * @modules java.management * jdk.jdi * @build jdk.testlibrary.* ProcessAttachTest diff --git a/test/jdk/com/sun/jdi/RunToExit.java b/test/jdk/com/sun/jdi/RunToExit.java --- a/test/jdk/com/sun/jdi/RunToExit.java +++ b/test/jdk/com/sun/jdi/RunToExit.java @@ -24,10 +24,10 @@ /* @test * @bug 4997445 * @summary Test that with server=y, when VM runs to System.exit() no error happens - * @library /lib/testlibrary + * @library /test/lib * @modules java.management * jdk.jdi - * @build jdk.testlibrary.* VMConnection RunToExit Exit0 + * @build VMConnection RunToExit Exit0 * @run driver RunToExit */ import java.net.ServerSocket; @@ -42,7 +42,7 @@ import java.util.Iterator; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; public class RunToExit { diff --git a/test/jdk/com/sun/jdi/SuspendNoFlagTest.java b/test/jdk/com/sun/jdi/SuspendNoFlagTest.java --- a/test/jdk/com/sun/jdi/SuspendNoFlagTest.java +++ b/test/jdk/com/sun/jdi/SuspendNoFlagTest.java @@ -21,15 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* @test * @bug 4914611 * @summary Test for JDWP: -agentlib:jdwp=suspend=n hanging - * @library /lib/testlibrary + * @library /test/lib * @modules java.management - * @build jdk.testlibrary.* * @compile -g HelloWorld.java * @run driver SuspendNoFlagTest */ diff --git a/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java b/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java --- a/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java +++ b/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java @@ -29,9 +29,8 @@ * @modules jdk.jdi * java.management * jdk.jartool/sun.tools.jar - * @library /lib/testlibrary + * @library /test/lib * @library .. - * @build jdk.testlibrary.* * @build TestScaffold VMConnection TargetListener TargetAdapter * @build CDSJDITest * @run compile -g ../BreakpointTest.java diff --git a/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java b/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java --- a/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java +++ b/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java @@ -29,9 +29,8 @@ * @modules jdk.jdi * java.management * jdk.jartool/sun.tools.jar - * @library /lib/testlibrary + * @library /test/lib * @library .. - * @build jdk.testlibrary.* * @build TestScaffold VMConnection TargetListener TargetAdapter * @build CDSJDITest * @run compile -g ../DeleteAllBkptsTest.java diff --git a/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java b/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java --- a/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java +++ b/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java @@ -29,9 +29,8 @@ * @modules jdk.jdi * java.management * jdk.jartool/sun.tools.jar - * @library /lib/testlibrary + * @library /test/lib * @library .. - * @build jdk.testlibrary.* * @build TestScaffold VMConnection TargetListener TargetAdapter * @build CDSJDITest * @run compile -g ../FieldWatchpoints.java diff --git a/test/jdk/com/sun/jdi/cds/CDSJDITest.java b/test/jdk/com/sun/jdi/cds/CDSJDITest.java --- a/test/jdk/com/sun/jdi/cds/CDSJDITest.java +++ b/test/jdk/com/sun/jdi/cds/CDSJDITest.java @@ -25,8 +25,8 @@ * Helper superclass for launching JDI tests out of the CDS archive. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import java.io.*; import java.util.ArrayList; diff --git a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java --- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java +++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -27,10 +27,9 @@ * @author Staffan Larsen * @comment Graal does not support CMS * @requires !vm.graal.enabled - * @library /lib/testlibrary + * @library /test/lib * @modules jdk.attach/sun.tools.attach * jdk.management - * @build jdk.testlibrary.* * @run main CheckOrigin */ @@ -44,7 +43,7 @@ import java.io.PrintWriter; import java.lang.management.ManagementFactory; import java.util.Map; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import sun.tools.attach.HotSpotVirtualMachine; public class CheckOrigin { diff --git a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java --- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java +++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java @@ -29,7 +29,7 @@ import java.util.List; import jdk.test.lib.hprof.HprofParser; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import com.sun.management.HotSpotDiagnosticMXBean; diff --git a/test/jdk/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java b/test/jdk/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java --- a/test/jdk/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java +++ b/test/jdk/com/sun/management/OperatingSystemMXBean/TestTotalSwap.java @@ -28,10 +28,8 @@ * @author Steve Bohne * @author Jaroslav Bachorik * - * @library /lib/testlibrary * @library /test/lib * - * @build TestTotalSwap jdk.testlibrary.* * @run main TestTotalSwap */ @@ -57,8 +55,8 @@ import java.lang.management.*; import jdk.test.lib.Platform; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; public class TestTotalSwap { diff --git a/test/jdk/com/sun/tools/attach/BasicTests.java b/test/jdk/com/sun/tools/attach/BasicTests.java --- a/test/jdk/com/sun/tools/attach/BasicTests.java +++ b/test/jdk/com/sun/tools/attach/BasicTests.java @@ -29,8 +29,8 @@ import java.util.Properties; import jdk.test.lib.thread.ProcessThread; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import com.sun.tools.attach.AgentInitializationException; import com.sun.tools.attach.AgentLoadException; diff --git a/test/jdk/com/sun/tools/attach/PermissionTest.java b/test/jdk/com/sun/tools/attach/PermissionTest.java --- a/test/jdk/com/sun/tools/attach/PermissionTest.java +++ b/test/jdk/com/sun/tools/attach/PermissionTest.java @@ -25,8 +25,8 @@ import com.sun.tools.attach.AttachNotSupportedException; import java.io.File; import jdk.test.lib.thread.ProcessThread; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* * @test diff --git a/test/jdk/com/sun/tools/attach/ProviderTest.java b/test/jdk/com/sun/tools/attach/ProviderTest.java --- a/test/jdk/com/sun/tools/attach/ProviderTest.java +++ b/test/jdk/com/sun/tools/attach/ProviderTest.java @@ -22,9 +22,8 @@ */ import java.io.File; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import com.sun.tools.attach.VirtualMachine; import com.sun.tools.attach.spi.AttachProvider; diff --git a/test/jdk/com/sun/tools/attach/RunnerUtil.java b/test/jdk/com/sun/tools/attach/RunnerUtil.java --- a/test/jdk/com/sun/tools/attach/RunnerUtil.java +++ b/test/jdk/com/sun/tools/attach/RunnerUtil.java @@ -27,7 +27,7 @@ import java.util.Arrays; import jdk.test.lib.thread.ProcessThread; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; /* diff --git a/test/jdk/com/sun/tools/attach/StartManagementAgent.java b/test/jdk/com/sun/tools/attach/StartManagementAgent.java --- a/test/jdk/com/sun/tools/attach/StartManagementAgent.java +++ b/test/jdk/com/sun/tools/attach/StartManagementAgent.java @@ -46,7 +46,7 @@ * jdk.attach * jdk.jartool/sun.tools.jar * - * @run build Application SimpleProvider jdk.testlibrary.* + * @run build jdk.testlibrary.* Application SimpleProvider jdk.testlibrary.* * @run main/timeout=300 StartManagementAgent */ diff --git a/test/jdk/com/sun/tools/attach/TempDirTest.java b/test/jdk/com/sun/tools/attach/TempDirTest.java --- a/test/jdk/com/sun/tools/attach/TempDirTest.java +++ b/test/jdk/com/sun/tools/attach/TempDirTest.java @@ -30,8 +30,8 @@ import java.io.File; import jdk.test.lib.thread.ProcessThread; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* * @test diff --git a/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java b/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java --- a/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java +++ b/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java @@ -25,8 +25,7 @@ * @bug 7129312 * @summary BufferedInputStream calculates negative array size with large * streams and mark - * @library /lib/testlibrary - * @build jdk.testlibrary.* + * @library /test/lib * @run main/othervm LargeCopyWithMark */ @@ -34,7 +33,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; public class LargeCopyWithMark { diff --git a/test/jdk/java/lang/Class/forName/modules/TestDriver.java b/test/jdk/java/lang/Class/forName/modules/TestDriver.java --- a/test/jdk/java/lang/Class/forName/modules/TestDriver.java +++ b/test/jdk/java/lang/Class/forName/modules/TestDriver.java @@ -31,7 +31,7 @@ import jdk.test.lib.util.FileUtils; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -41,12 +41,12 @@ * @test * @bug 8087335 * @summary Tests for Class.forName(Module,String) - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * @build jdk.test.lib.Platform * jdk.test.lib.util.FileUtils * jdk.test.lib.compiler.CompilerUtils - * jdk.testlibrary.ProcessTools + * jdk.test.lib.process.ProcessTools * TestDriver TestMain TestLayer * @run testng TestDriver */ diff --git a/test/jdk/java/lang/Class/getResource/ResourcesTest.java b/test/jdk/java/lang/Class/getResource/ResourcesTest.java --- a/test/jdk/java/lang/Class/getResource/ResourcesTest.java +++ b/test/jdk/java/lang/Class/getResource/ResourcesTest.java @@ -24,7 +24,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import jdk.test.lib.compiler.CompilerUtils; import org.testng.annotations.BeforeTest; @@ -33,9 +33,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils * @run testng ResourcesTest * @summary Driver for basic test of Class getResource and getResourceAsStream */ diff --git a/test/jdk/java/lang/ClassLoader/EndorsedDirs.java b/test/jdk/java/lang/ClassLoader/EndorsedDirs.java --- a/test/jdk/java/lang/ClassLoader/EndorsedDirs.java +++ b/test/jdk/java/lang/ClassLoader/EndorsedDirs.java @@ -24,11 +24,11 @@ /* * @test * @bug 8060206 8067366 - * @library /lib/testlibrary + * @library /test/lib * @summary Endorsed standards and override mechanism is removed */ -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import java.util.stream.Stream; diff --git a/test/jdk/java/lang/ClassLoader/ExtDirs.java b/test/jdk/java/lang/ClassLoader/ExtDirs.java --- a/test/jdk/java/lang/ClassLoader/ExtDirs.java +++ b/test/jdk/java/lang/ClassLoader/ExtDirs.java @@ -24,11 +24,11 @@ /* * @test * @bug 8060206 8067366 - * @library /lib/testlibrary + * @library /test/lib * @summary Extension mechanism is removed */ -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import java.lang.Integer; import java.util.stream.Stream; diff --git a/test/jdk/java/lang/ClassLoader/GetDotResource.java b/test/jdk/java/lang/ClassLoader/GetDotResource.java --- a/test/jdk/java/lang/ClassLoader/GetDotResource.java +++ b/test/jdk/java/lang/ClassLoader/GetDotResource.java @@ -26,8 +26,7 @@ * @bug 4273031 * @summary ClassLoader.getResouce() should be able to * find resources with leading "." in their names - * @library /lib/testlibrary - * @build jdk.testlibrary.* + * @library /test/lib * @run main GetDotResource */ @@ -37,7 +36,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; public class GetDotResource { diff --git a/test/jdk/java/lang/ClassLoader/GetSystemPackage.java b/test/jdk/java/lang/ClassLoader/GetSystemPackage.java --- a/test/jdk/java/lang/ClassLoader/GetSystemPackage.java +++ b/test/jdk/java/lang/ClassLoader/GetSystemPackage.java @@ -24,8 +24,8 @@ /* * @test * @bug 8060130 - * @library /lib/testlibrary - * @build package2.Class2 GetSystemPackage jdk.testlibrary.* + * @library /test/lib + * @build package2.Class2 GetSystemPackage * @summary Test if getSystemPackage() return consistent values for cases * where a manifest is provided or not and ensure only jars on * bootclasspath gets resolved via Package.getSystemPackage @@ -41,7 +41,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; public class GetSystemPackage { diff --git a/test/jdk/java/lang/ClassLoader/getResource/GetResource.java b/test/jdk/java/lang/ClassLoader/getResource/GetResource.java --- a/test/jdk/java/lang/ClassLoader/getResource/GetResource.java +++ b/test/jdk/java/lang/ClassLoader/getResource/GetResource.java @@ -25,7 +25,8 @@ * @test * @bug 6760902 * @library /lib/testlibrary - * @build jdk.testlibrary.ProcessTools + * @library /test/lib + * @build jdk.test.lib.process.ProcessTools * @run testng GetResource * @summary Empty path on bootclasspath is not default to current working * directory for both class lookup and resource lookup whereas @@ -45,7 +46,7 @@ import java.util.stream.Stream; import jdk.testlibrary.JDKToolFinder; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; diff --git a/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java b/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java --- a/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java +++ b/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java @@ -23,8 +23,8 @@ /** * @test - * @library /lib/testlibrary - * @build Driver Main JarUtils jdk.testlibrary.ProcessTools + * @library /lib/testlibrary /test/lib + * @build Driver Main JarUtils * @run main Driver * @summary Test ClassLoader.getResourceXXX to locate resources in an automatic * module @@ -38,7 +38,7 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * The driver creates a JAR file containing p/Foo.class, p/foo.properties, diff --git a/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java b/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java --- a/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java +++ b/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java @@ -24,7 +24,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import jdk.test.lib.compiler.CompilerUtils; import org.testng.annotations.BeforeTest; @@ -34,9 +34,9 @@ /** * @test * @bug 8087335 - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils * @run testng ResourcesTest * @summary Driver for basic test of ClassLoader getResource and getResourceAsStream */ diff --git a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java --- a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java +++ b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java @@ -27,6 +27,7 @@ * @summary Different types of ClassLoader running with(out) SecurityManager and * (in)valid security policy file. * @library /lib/testlibrary + * @library /test/lib * @modules java.base/jdk.internal.module * @build JarUtils * @build TestClassLoader TestClient @@ -49,7 +50,7 @@ import java.util.LinkedList; import java.util.List; import jdk.internal.module.ModuleInfoWriter; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; public class ClassLoaderTest { diff --git a/test/jdk/java/lang/ModuleTests/access/AccessTest.java b/test/jdk/java/lang/ModuleTests/access/AccessTest.java --- a/test/jdk/java/lang/ModuleTests/access/AccessTest.java +++ b/test/jdk/java/lang/ModuleTests/access/AccessTest.java @@ -27,7 +27,7 @@ import java.util.List; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -35,9 +35,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build AccessTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build AccessTest jdk.test.lib.compiler.CompilerUtils * @run testng AccessTest * @summary Driver for test that checks access to access to types in * exported and non-exported packages. diff --git a/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java b/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java --- a/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java +++ b/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java @@ -24,16 +24,15 @@ /* * @test * @bug 8154017 - * @library /lib/testlibrary - * @build jdk.testlibrary.* + * @library /test/lib * @summary Shutdown hooks are racing against shutdown sequence, if System.exit()-calling thread is interrupted * @run main ShutdownInterruptedMain exec */ -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.createJavaProcessBuilder; -import static jdk.testlibrary.ProcessTools.executeProcess; +import jdk.test.lib.process.OutputAnalyzer; +import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder; +import static jdk.test.lib.process.ProcessTools.executeProcess; public class ShutdownInterruptedMain { diff --git a/test/jdk/java/lang/StackWalker/CallerFromMain.java b/test/jdk/java/lang/StackWalker/CallerFromMain.java --- a/test/jdk/java/lang/StackWalker/CallerFromMain.java +++ b/test/jdk/java/lang/StackWalker/CallerFromMain.java @@ -24,14 +24,13 @@ /* * @test * @bug 8140450 - * @library /lib/testlibrary - * @build jdk.testlibrary.* + * @library /test/lib * @summary Test if the getCallerClass method returns empty optional * @run main CallerFromMain exec */ -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; public class CallerFromMain { diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/Base.java b/test/jdk/java/lang/System/LoggerFinder/modules/Base.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/Base.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/Base.java @@ -35,7 +35,7 @@ import jdk.testlibrary.JDKToolFinder; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.executeCommand; +import static jdk.test.lib.process.ProcessTools.executeCommand; /* * Base class for tests. diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java @@ -23,19 +23,6 @@ * questions. */ -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import jdk.testlibrary.JDKToolFinder; - -import static jdk.testlibrary.ProcessTools.executeCommand; - /* * @test * @modules jdk.compiler diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java @@ -23,19 +23,6 @@ * questions. */ -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import jdk.testlibrary.JDKToolFinder; - -import static jdk.testlibrary.ProcessTools.executeCommand; - /* * @test * @modules java.logging diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java b/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java @@ -23,19 +23,6 @@ * questions. */ -import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import jdk.testlibrary.JDKToolFinder; - -import static jdk.testlibrary.ProcessTools.executeCommand; - /* * @test * @modules jdk.compiler diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java @@ -24,17 +24,6 @@ */ import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import jdk.testlibrary.JDKToolFinder; - -import static jdk.testlibrary.ProcessTools.executeCommand; /* * @test diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java @@ -24,17 +24,6 @@ */ import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import jdk.testlibrary.JDKToolFinder; - -import static jdk.testlibrary.ProcessTools.executeCommand; /* * @test diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java @@ -24,17 +24,6 @@ */ import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import jdk.testlibrary.JDKToolFinder; - -import static jdk.testlibrary.ProcessTools.executeCommand; /* * @test diff --git a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java --- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java @@ -24,17 +24,6 @@ */ import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import jdk.testlibrary.JDKToolFinder; - -import static jdk.testlibrary.ProcessTools.executeCommand; /* * @test diff --git a/test/jdk/java/lang/System/OsVersionTest.java b/test/jdk/java/lang/System/OsVersionTest.java --- a/test/jdk/java/lang/System/OsVersionTest.java +++ b/test/jdk/java/lang/System/OsVersionTest.java @@ -22,16 +22,15 @@ */ import jdk.test.lib.Platform; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* * @test * @bug 8132374 * @summary Check that the value of the os.version property is equal * to the value of the corresponding OS provided tools. - * @library /lib/testlibrary /test/lib - * @build jdk.test.lib.Platform + * @library /test/lib * @run main OsVersionTest * @author Volker Simonis */ diff --git a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java --- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java +++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java @@ -24,11 +24,11 @@ /* @test * @bug 7142035 * @summary Assert in java.lang.instrument agents during shutdown when classloading occurs after shutdown - * @library /lib/testlibrary + * @library /test/lib * * @modules java.instrument * java.management - * @build jdk.testlibrary.* DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread + * @build DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread * @run shell ../MakeJAR3.sh DummyAgent * @run main/timeout=240 TestDaemonThreadLauncher * diff --git a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java --- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java +++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java @@ -23,8 +23,8 @@ */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; public class TestDaemonThreadLauncher { public static void main(String args[]) throws Exception { diff --git a/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java b/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java --- a/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java +++ b/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java @@ -21,8 +21,8 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; /* @@ -30,6 +30,7 @@ * @bug 6289149 * @summary test when the agent's class is missing the premain() function. * @library /lib/testlibrary + * @library /test/lib * @modules java.management * java.instrument * @run build jdk.testlibrary.* DummyMain diff --git a/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java b/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java --- a/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java +++ b/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java @@ -21,8 +21,8 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; /* @@ -30,6 +30,7 @@ * @bug 5055293 * @summary Test non ascii characters in the Premain-Class attribute. * @library /lib/testlibrary + * @library /test/lib * @modules java.management * @run build jdk.testlibrary.* DummyMain * @run main PremainClassTest diff --git a/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java b/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java --- a/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java +++ b/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java @@ -21,8 +21,8 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; /* @@ -30,6 +30,7 @@ * @bug 6289149 * @summary test when the agent's class has a zero arg premain() function. * @library /lib/testlibrary + * @library /test/lib * @modules java.management * java.instrument * @run build jdk.testlibrary.* DummyMain diff --git a/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java b/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java --- a/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java +++ b/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java @@ -24,6 +24,7 @@ /** * @test * @library /lib/testlibrary + * @library /test/lib * @build ExecJarWithAgent Main Agent AgentHelper JarUtils jdk.testlibrary.* * @run testng ExecJarWithAgent * @summary Test starting agents in executable JAR files @@ -38,8 +39,8 @@ import org.testng.annotations.Test; import static org.testng.Assert.*; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; @Test public class ExecJarWithAgent { diff --git a/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java b/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java --- a/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java +++ b/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java @@ -24,14 +24,18 @@ /** * @test * @bug 8169909 - * @library src /lib/testlibrary + * @library src /test/lib * @build test/* * @run shell AppendToClassPathModuleTest.sh * @run main AppendToClassPathModuleTest */ +import jdk.test.lib.JDKToolFinder; + import java.util.Map; -import static jdk.testlibrary.ProcessTools.*; +import java.util.stream.Stream; + +import static jdk.test.lib.process.ProcessTools.*; /** * Launch a modular test with no class path and no CLASSPATH set. @@ -41,14 +45,17 @@ public class AppendToClassPathModuleTest { public static void main(String... args) throws Throwable { String modulepath = System.getProperty("test.module.path"); - ProcessBuilder pb = - createJavaProcessBuilder("-javaagent:Agent.jar", - "--module-path", modulepath, - "-m", "test/jdk.test.Main"); - // remove CLASSPATH environment variable + // can't use ProcessTools.createJavaProcessBuilder as it always adds -cp + ProcessBuilder pb = new ProcessBuilder( + JDKToolFinder.getTestJDKTool("java"), + "-javaagent:Agent.jar", + "--module-path", modulepath, + "-m", "test/jdk.test.Main"); + Map env = pb.environment(); - String value = env.remove("CLASSPATH"); + // remove CLASSPATH environment variable + env.remove("CLASSPATH"); int exitCode = executeCommand(pb).getExitValue(); if (exitCode != 0) { diff --git a/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest.java b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest.java --- a/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest.java +++ b/test/jdk/java/lang/management/MemoryMXBean/LowMemoryTest.java @@ -45,7 +45,7 @@ import java.util.concurrent.Phaser; import javax.management.*; import javax.management.openmbean.CompositeData; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolFinder; import jdk.testlibrary.Utils; diff --git a/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java b/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java --- a/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java +++ b/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java @@ -28,9 +28,9 @@ import java.util.List; import java.util.ArrayList; import java.util.Arrays; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; -import jdk.testlibrary.ProcessTools; import jdk.testlibrary.JDKToolFinder; public class RunUtil { diff --git a/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java b/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java --- a/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java +++ b/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java @@ -30,7 +30,7 @@ import java.util.List; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -38,9 +38,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build ProxyClassAccessTest q.NP jdk.testlibrary.* + * @build ProxyClassAccessTest q.NP * jdk.test.lib.compiler.CompilerUtils * @run testng ProxyClassAccessTest * @summary Driver for testing proxy class doesn't have access to diff --git a/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java b/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java --- a/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java +++ b/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java @@ -30,7 +30,7 @@ import java.util.Arrays; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -38,9 +38,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build ProxyTest jdk.testlibrary.ProcessTools + * @build ProxyTest jdk.test.lib.process.ProcessTools * jdk.test.lib.compiler.CompilerUtils * @run testng ProxyLayerTest * @summary Test proxies to implement interfaces in a layer diff --git a/test/jdk/java/lang/reflect/Proxy/ProxyTest.java b/test/jdk/java/lang/reflect/Proxy/ProxyTest.java --- a/test/jdk/java/lang/reflect/Proxy/ProxyTest.java +++ b/test/jdk/java/lang/reflect/Proxy/ProxyTest.java @@ -27,7 +27,7 @@ import java.util.List; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -35,9 +35,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build ProxyTest q.U jdk.testlibrary.* + * @build ProxyTest q.U * jdk.test.lib.compiler.CompilerUtils * @run testng ProxyTest * @summary Driver for testing proxies accessing interfaces in named modules diff --git a/test/jdk/java/nio/file/spi/SetDefaultProvider.java b/test/jdk/java/nio/file/spi/SetDefaultProvider.java --- a/test/jdk/java/nio/file/spi/SetDefaultProvider.java +++ b/test/jdk/java/nio/file/spi/SetDefaultProvider.java @@ -24,8 +24,8 @@ /** * @test * @modules jdk.jartool - * @library /lib/testlibrary - * @build SetDefaultProvider TestProvider m/* jdk.testlibrary.ProcessTools + * @library /test/lib + * @build SetDefaultProvider TestProvider m/* jdk.test.lib.process.ProcessTools * @run testng/othervm SetDefaultProvider * @summary Runs tests with -Djava.nio.file.spi.DefaultFileSystemProvider set on * the command line to override the default file system provider @@ -38,7 +38,7 @@ import java.nio.file.Paths; import java.util.spi.ToolProvider; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/java/rmi/module/ModuleTest.java b/test/jdk/java/rmi/module/ModuleTest.java --- a/test/jdk/java/rmi/module/ModuleTest.java +++ b/test/jdk/java/rmi/module/ModuleTest.java @@ -24,13 +24,13 @@ /** * @test * @library /lib/testlibrary /test/lib - * @build jdk.testlibrary.ProcessTools + * @build jdk.test.lib.process.ProcessTools * ModuleTest jdk.test.lib.compiler.CompilerUtils JarUtils * @run testng ModuleTest * @summary Basic tests for using rmi in module world */ -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; diff --git a/test/jdk/java/security/AccessController/DoPrivAccompliceTest.java b/test/jdk/java/security/AccessController/DoPrivAccompliceTest.java --- a/test/jdk/java/security/AccessController/DoPrivAccompliceTest.java +++ b/test/jdk/java/security/AccessController/DoPrivAccompliceTest.java @@ -23,7 +23,6 @@ * questions. */ -import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; diff --git a/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java b/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java --- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java +++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java @@ -26,7 +26,7 @@ import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.Base64; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import static java.lang.System.out; import java.nio.file.Paths; import java.util.List; @@ -37,6 +37,7 @@ * @summary Test for PKCS12 keystore list , export commands. Refer README for * keystore files information * @library /lib/testlibrary ../ + * @library /test/lib * @run main KeytoolReaderP12Test */ public class KeytoolReaderP12Test { diff --git a/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java b/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java --- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java +++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java @@ -24,7 +24,7 @@ */ import java.io.File; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import static java.lang.System.out; /** @@ -32,6 +32,7 @@ * @bug 8048830 * @summary Tests for creating pkcs12 keystore with various algorithms * @library /lib/testlibrary ../ + * @library /test/lib * @run main KeytoolWriteP12Test */ public class KeytoolWriteP12Test { diff --git a/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java b/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java --- a/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java +++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java @@ -40,6 +40,7 @@ * @bug 8048830 * @summary Entry's attribute set should be empty * @library /lib/testlibrary ../ + * @library /test/lib * @run main MetadataEmptyTest */ public class MetadataEmptyTest { diff --git a/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java b/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java --- a/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java +++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java @@ -44,6 +44,7 @@ * @bug 8048830 * @summary Test store metadata attributes to PKCS12 keystore. * @library /lib/testlibrary ../ + * @library /test/lib * @run main MetadataStoreLoadTest */ public class MetadataStoreLoadTest { diff --git a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java --- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java +++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java @@ -43,6 +43,7 @@ * trusted certificate Check import errors (must be not errors) & check keystore * content after import * @library /lib/testlibrary ../ + * @library /test/lib * @run main StoreTrustedCertAPITest */ public class StoreTrustedCertAPITest { diff --git a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java --- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java +++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java @@ -30,7 +30,7 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import static java.lang.System.out; /** @@ -39,6 +39,7 @@ * @summary Tests keytool command imports certificate , list keystore, print * certificate and import password help. * @library /lib/testlibrary ../ + * @library /test/lib * @run main StoreTrustedCertKeytool */ public class StoreTrustedCertKeytool { diff --git a/test/jdk/java/security/KeyStore/PKCS12/Utils.java b/test/jdk/java/security/KeyStore/PKCS12/Utils.java --- a/test/jdk/java/security/KeyStore/PKCS12/Utils.java +++ b/test/jdk/java/security/KeyStore/PKCS12/Utils.java @@ -32,8 +32,8 @@ import java.security.cert.CertificateException; import java.util.Arrays; import java.util.List; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; import jdk.testlibrary.JDKToolFinder; import static java.lang.System.out; import java.util.ArrayList; diff --git a/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java b/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java --- a/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java +++ b/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java @@ -26,14 +26,14 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.security.AccessController; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8050402 * @summary Check policy is extensible with user defined permissions - * @library /lib/testlibrary /test/lib + * @library /test/lib * @build jdk.test.lib.util.JarUtils * @compile TVJar/TVPermission.java * @run main ExtensiblePolicyWithJarTest diff --git a/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java b/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java --- a/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java +++ b/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java @@ -28,13 +28,13 @@ import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * @test * @bug 8048360 * @summary test policy entry with signedBy alias - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm SignedJarTest */ public class SignedJarTest { diff --git a/test/jdk/java/util/Arrays/TimSortStackSize2.java b/test/jdk/java/util/Arrays/TimSortStackSize2.java --- a/test/jdk/java/util/Arrays/TimSortStackSize2.java +++ b/test/jdk/java/util/Arrays/TimSortStackSize2.java @@ -26,10 +26,9 @@ * @bug 8072909 * @summary Test TimSort stack size on big arrays * @key intermittent - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules java.management * java.base/jdk.internal - * @build jdk.testlibrary.* * @build TimSortStackSize2 * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission @@ -41,9 +40,8 @@ import java.util.List; import java.util.function.Consumer; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.Utils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import sun.hotspot.WhiteBox; public class TimSortStackSize2 { diff --git a/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java --- a/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java +++ b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java @@ -23,15 +23,15 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @bug 8189134 * @summary Tests the system properties * @modules jdk.localedata - * @build DefaultLocaleTest jdk.testlibrary.* + * @build DefaultLocaleTest * @run testng/othervm SystemPropertyTests */ -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import static org.testng.Assert.assertTrue; import java.util.Locale; diff --git a/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java b/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java --- a/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java +++ b/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java @@ -24,19 +24,17 @@ /** * @test * @bug 8170772 - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build CacheTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build CacheTest jdk.test.lib.compiler.CompilerUtils * @run testng CacheTest */ -import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import jdk.test.lib.compiler.CompilerUtils; import org.testng.annotations.BeforeTest; diff --git a/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java b/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java --- a/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java +++ b/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java @@ -24,17 +24,17 @@ /* * @test * @bug 8177980 - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * @build jdk.test.lib.compiler.CompilerUtils - * jdk.testlibrary.ProcessTools CaseInsensitiveNameClash + * jdk.test.lib.process.ProcessTools CaseInsensitiveNameClash * @run testng CaseInsensitiveNameClash */ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.test.lib.compiler.CompilerUtils; import org.testng.annotations.BeforeTest; diff --git a/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java b/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java --- a/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java +++ b/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java @@ -27,7 +27,7 @@ import java.util.List; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.executeTestJava; +import static jdk.test.lib.process.ProcessTools.executeTestJava; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -35,9 +35,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build TestPermission jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build TestPermission jdk.test.lib.compiler.CompilerUtils * @run testng TestPermission * @summary Driver for testing ResourceBundle::getBundle(String, Module) */ diff --git a/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java b/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java --- a/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java +++ b/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java @@ -26,7 +26,7 @@ import java.io.InputStreamReader; import static jdk.testlibrary.Asserts.assertGreaterThan; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import com.sun.tools.attach.AttachNotSupportedException; import com.sun.tools.attach.VirtualMachine; @@ -38,9 +38,10 @@ * @bug 6942989 * @summary Check for WeakReference leak in Logger and anonymous Logger objects * @library /lib/testlibrary + * @library /test/lib * @modules jdk.attach/sun.tools.attach * java.logging - * @build jdk.testlibrary.ProcessTools + * @build jdk.test.lib.process.ProcessTools * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak Logger * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak AnonymousLogger */ diff --git a/test/jdk/java/util/logging/modules/GetResourceBundleTest.java b/test/jdk/java/util/logging/modules/GetResourceBundleTest.java --- a/test/jdk/java/util/logging/modules/GetResourceBundleTest.java +++ b/test/jdk/java/util/logging/modules/GetResourceBundleTest.java @@ -29,17 +29,17 @@ import org.testng.annotations.Test; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import jdk.test.lib.compiler.CompilerUtils; import static org.testng.Assert.*; /** * @test * @bug 8129126 8136802 8137316 8137317 8136804 8139350 - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * java.logging - * @build GetResourceBundleTest jdk.testlibrary.ProcessTools + * @build GetResourceBundleTest jdk.test.lib.process.ProcessTools * jdk.test.lib.compiler.CompilerUtils * @run testng GetResourceBundleTest * @summary Tests Logger.getLogger + logger.getResourceBundle in an named/unnamed module, diff --git a/test/jdk/java/util/zip/EntryCount64k.java b/test/jdk/java/util/zip/EntryCount64k.java --- a/test/jdk/java/util/zip/EntryCount64k.java +++ b/test/jdk/java/util/zip/EntryCount64k.java @@ -24,7 +24,7 @@ /** * @test * @summary Test java.util.zip behavior with ~64k entries - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm EntryCount64k * @run main/othervm -Djdk.util.zip.inhibitZip64=true EntryCount64k * @run main/othervm -Djdk.util.zip.inhibitZip64=false EntryCount64k @@ -44,8 +44,8 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; public class EntryCount64k { public static class Main { diff --git a/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java b/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java --- a/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java +++ b/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java @@ -29,6 +29,7 @@ * @author Olivier Lagneau * @modules java.management.rmi * @library /lib/testlibrary + * @library /test/lib * @compile Basic.java * @run main/othervm/timeout=300 -DDEBUG_STANDARD MXBeanWeirdParamTest */ @@ -58,7 +59,7 @@ import javax.management.openmbean.TabularDataSupport; import javax.management.openmbean.TabularType; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolFinder; public class MXBeanWeirdParamTest { diff --git a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java --- a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java +++ b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java @@ -25,6 +25,7 @@ * @test * @bug 8159377 * @library /lib/testlibrary + * @library /test/lib * @summary Tests ObjectFilter on default agent * @author Harsha Wardhana B * @modules java.management @@ -54,7 +55,7 @@ import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; public class DefaultAgentFilterTest { diff --git a/test/jdk/javax/management/security/AuthorizationTest.java b/test/jdk/javax/management/security/AuthorizationTest.java --- a/test/jdk/javax/management/security/AuthorizationTest.java +++ b/test/jdk/javax/management/security/AuthorizationTest.java @@ -28,6 +28,7 @@ * @author Olivier Lagneau * @modules java.management.rmi * @library /lib/testlibrary + * @library /test/lib * @compile Simple.java * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username2 -Dpassword=password2 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedSetException -expectedInvokeException @@ -64,7 +65,7 @@ import javax.management.Attribute ; import javax.management.ObjectName ; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolFinder; public class AuthorizationTest { diff --git a/test/jdk/javax/management/security/SecurityTest.java b/test/jdk/javax/management/security/SecurityTest.java --- a/test/jdk/javax/management/security/SecurityTest.java +++ b/test/jdk/javax/management/security/SecurityTest.java @@ -28,6 +28,7 @@ * @author Olivier Lagneau * @modules java.management.rmi * @library /lib/testlibrary + * @library /test/lib * @compile MBS_Light.java ServerDelegate.java TestSampleLoginModule.java * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=SQE_username -Dpassword=SQE_password SecurityTest -server -mapType x.password.file -client -mapType credentials * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=UNKNOWN_username -Dpassword=SQE_password SecurityTest -server -mapType x.password.file -client -mapType credentials -expectedThrowable java.lang.SecurityException @@ -80,7 +81,7 @@ import java.security.Security; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolFinder; public class SecurityTest { diff --git a/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java b/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java --- a/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java +++ b/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java @@ -41,7 +41,7 @@ import java.util.jar.Manifest; import javax.security.auth.Subject; import javax.security.auth.x500.X500Principal; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * @test @@ -50,7 +50,7 @@ * in case of nested Subject.doAs() invocations * when one of protection domains doesn't have permissions * - * @library /lib/testlibrary + * @library /test/lib * * @run main NestedActions jar NestedActionsACE.jar * NestedActionsACE.class Utils.class diff --git a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java --- a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java +++ b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java @@ -24,7 +24,7 @@ /** * @test * @summary Basic test of VM::getRuntimeArguments - * @library /lib/testlibrary + * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.zipfs * @run testng RuntimeArguments @@ -34,7 +34,7 @@ import java.util.List; import java.util.stream.Stream; import jdk.internal.misc.VM; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.testng.Assert.*; diff --git a/test/jdk/jdk/modules/etc/DefaultModules.java b/test/jdk/jdk/modules/etc/DefaultModules.java --- a/test/jdk/jdk/modules/etc/DefaultModules.java +++ b/test/jdk/jdk/modules/etc/DefaultModules.java @@ -27,7 +27,7 @@ * @modules jdk.compiler * jdk.jlink * jdk.zipfs - * @library src /lib/testlibrary + * @library src /test/lib * @build java.json/* * @run main DefaultModules * @summary Test that all modules that export an API are in the set of modules @@ -37,13 +37,9 @@ import java.io.PrintStream; import java.nio.file.Files; import java.nio.file.Path; -import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleFinder; -import java.lang.module.ModuleReference; import java.util.spi.ToolProvider; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /** * This test compiles and runs the following tests on the class path: diff --git a/test/jdk/jdk/modules/incubator/DefaultImage.java b/test/jdk/jdk/modules/incubator/DefaultImage.java --- a/test/jdk/jdk/modules/incubator/DefaultImage.java +++ b/test/jdk/jdk/modules/incubator/DefaultImage.java @@ -25,7 +25,7 @@ * @test * @bug 8170859 * @summary Ensure no incubator modules are resolved by default in the image - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * @build jdk.test.lib.compiler.CompilerUtils * @run testng DefaultImage @@ -47,7 +47,7 @@ import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; -import static jdk.testlibrary.ProcessTools.executeCommand; +import static jdk.test.lib.process.ProcessTools.executeCommand; import static org.testng.Assert.*; @Test diff --git a/test/jdk/jdk/modules/incubator/ImageModules.java b/test/jdk/jdk/modules/incubator/ImageModules.java --- a/test/jdk/jdk/modules/incubator/ImageModules.java +++ b/test/jdk/jdk/modules/incubator/ImageModules.java @@ -25,7 +25,7 @@ * @test * @bug 8170859 * @summary Basic test for incubator modules in jmods and images - * @library /lib/testlibrary /test/lib + * @library /test/lib * @key intermittent * @modules jdk.compiler jdk.jartool jdk.jlink * @build jdk.test.lib.Platform @@ -54,7 +54,7 @@ import org.testng.annotations.Test; import static java.nio.charset.StandardCharsets.UTF_8; -import static jdk.testlibrary.ProcessTools.executeCommand; +import static jdk.test.lib.process.ProcessTools.executeCommand; import static org.testng.Assert.*; public class ImageModules { diff --git a/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java b/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java --- a/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java +++ b/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java @@ -28,7 +28,7 @@ * java.scripting * jdk.zipfs * @build RunWithAutomaticModules jdk.test.lib.compiler.CompilerUtils JarUtils - * jdk.testlibrary.ProcessTools + * jdk.test.lib.process.ProcessTools * @run testng RunWithAutomaticModules * @summary Runs tests that make use of automatic modules */ @@ -38,7 +38,7 @@ import java.nio.file.Paths; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.Test; import static org.testng.Assert.*; diff --git a/test/jdk/jdk/modules/scenarios/container/ContainerTest.java b/test/jdk/jdk/modules/scenarios/container/ContainerTest.java --- a/test/jdk/jdk/modules/scenarios/container/ContainerTest.java +++ b/test/jdk/jdk/modules/scenarios/container/ContainerTest.java @@ -23,12 +23,12 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.jartool/sun.tools.jar * jdk.compiler * jdk.zipfs * java.se - * @build ContainerTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build ContainerTest jdk.test.lib.compiler.CompilerUtils * @run testng ContainerTest * @summary Starts a simple container that uses dynamic configurations * and launches two applications in the same VM @@ -39,7 +39,7 @@ import java.nio.file.Paths; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java b/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java --- a/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java +++ b/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java @@ -23,9 +23,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build OverlappingPackagesTest jdk.testlibrary.* + * @build OverlappingPackagesTest * jdk.test.lib.compiler.CompilerUtils * @run testng OverlappingPackagesTest * @summary Basic test to ensure that startup fails if two or more modules @@ -38,7 +38,7 @@ import java.util.List; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java b/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java --- a/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java +++ b/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java @@ -21,18 +21,18 @@ * questions. */ -package jdk.testlibrary; - /* * @test * @summary Test the OutputAnalyzer reporting functionality, * such as printing additional diagnostic info * (exit code, stdout, stderr, command line, etc.) * @modules java.management - * @build jdk.testlibrary.* - * @run main jdk.testlibrary.OutputAnalyzerReportingTest + * @library /test/lib + * @run main OutputAnalyzerReportingTest */ +import jdk.test.lib.process.OutputAnalyzer; + import java.io.ByteArrayOutputStream; import java.io.PrintStream; diff --git a/test/jdk/lib/testlibrary/OutputAnalyzerTest.java b/test/jdk/lib/testlibrary/OutputAnalyzerTest.java --- a/test/jdk/lib/testlibrary/OutputAnalyzerTest.java +++ b/test/jdk/lib/testlibrary/OutputAnalyzerTest.java @@ -20,16 +20,17 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.testlibrary; /* * @test * @summary Test the OutputAnalyzer utility class * @modules java.management - * @build jdk.testlibrary.* - * @run main jdk.testlibrary.OutputAnalyzerTest + * @library /test/lib + * @run main OutputAnalyzerTest */ +import jdk.test.lib.process.OutputAnalyzer; + public class OutputAnalyzerTest { public static void main(String args[]) throws Exception { diff --git a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java b/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java deleted file mode 100644 --- a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java +++ /dev/null @@ -1,577 +0,0 @@ -/* - * Copyright (c) 2013, 2018, 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 static jdk.testlibrary.Asserts.*; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.PrintStream; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - - -/** - * Utility class for verifying output and exit value from a {@code Process}. - * - * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/jdk/test/lib/process} - * - */ -@Deprecated -public final class OutputAnalyzer { - private final OutputBuffer output; - private final String stdout; - private final String stderr; - private final int exitValue; // useless now. output contains exit value. - - /** - * Create an OutputAnalyzer, a utility class for verifying output and exit - * value from a Process. - *

- * OutputAnalyzer should never be instantiated directly - - * use {@linkplain ProcessTools#executeProcess(ProcessBuilder)} instead - * - * @param process - * Process to analyze - * @throws IOException - * If an I/O error occurs. - */ - OutputAnalyzer(Process process) throws IOException { - output = new OutputBuffer(process); - exitValue = -1; - this.stdout = null; - this.stderr = null; - } - - /** - * Create an OutputAnalyzer, a utility class for verifying output. - * - * @param buf - * String buffer to analyze - */ - OutputAnalyzer(String buf) { - this(buf, buf); - } - - /** - * Create an OutputAnalyzer, a utility class for verifying output - * - * @param stdout - * stdout buffer to analyze - * @param stderr - * stderr buffer to analyze - */ - OutputAnalyzer(String stdout, String stderr) { - this.output = null; - this.stdout = stdout; - this.stderr = stderr; - exitValue = -1; - } - - /** - * Verify that the stdout and stderr contents of output buffer contains the - * string - * - * @param expectedString - * String that buffer should contain - * @throws RuntimeException - * If the string was not found - */ - public OutputAnalyzer shouldContain(String expectedString) { - if (!getStdout().contains(expectedString) - && !getStderr().contains(expectedString)) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + expectedString - + "' missing from stdout/stderr \n"); - } - return this; - } - - /** - * Verify that the stdout contents of output buffer contains the string - * - * @param expectedString - * String that buffer should contain - * @throws RuntimeException - * If the string was not found - */ - public OutputAnalyzer stdoutShouldContain(String expectedString) { - if (!getStdout().contains(expectedString)) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + expectedString - + "' missing from stdout \n"); - } - return this; - } - - /** - * Verify that the stderr contents of output buffer contains the string - * - * @param expectedString - * String that buffer should contain - * @throws RuntimeException - * If the string was not found - */ - public OutputAnalyzer stderrShouldContain(String expectedString) { - if (!getStderr().contains(expectedString)) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + expectedString - + "' missing from stderr \n"); - } - return this; - } - - /** - * Verify that the stdout and stderr contents of output buffer does not - * contain the string - * - * @param notExpectedString - * String that the buffer should not contain - * @throws RuntimeException - * If the string was found - */ - public OutputAnalyzer shouldNotContain(String notExpectedString) { - if (getStdout().contains(notExpectedString)) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + notExpectedString - + "' found in stdout \n"); - } - if (getStderr().contains(notExpectedString)) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + notExpectedString - + "' found in stderr \n"); - } - return this; - } - - /** - * Verify that the stdout contents of output buffer does not contain the - * string - * - * @param notExpectedString - * String that the buffer should not contain - * @throws RuntimeException - * If the string was found - */ - public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) { - if (getStdout().contains(notExpectedString)) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + notExpectedString - + "' found in stdout \n"); - } - return this; - } - - /** - * Verify that the stderr contents of output buffer does not contain the - * string - * - * @param notExpectedString - * String that the buffer should not contain - * @throws RuntimeException - * If the string was found - */ - public OutputAnalyzer stderrShouldNotContain(String notExpectedString) { - if (getStderr().contains(notExpectedString)) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + notExpectedString - + "' found in stderr \n"); - } - return this; - } - - /** - * Verify that the stdout and stderr contents of output buffer matches the - * pattern - * - * @param pattern - * @throws RuntimeException - * If the pattern was not found - */ - public OutputAnalyzer shouldMatch(String pattern) { - Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE) - .matcher(getStdout()); - Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE) - .matcher(getStderr()); - if (!stdoutMatcher.find() && !stderrMatcher.find()) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern - + "' missing from stdout/stderr \n"); - } - return this; - } - - /** - * Verify that the stdout contents of output buffer matches the pattern - * - * @param pattern - * @throws RuntimeException - * If the pattern was not found - */ - public OutputAnalyzer stdoutShouldMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher( - getStdout()); - if (!matcher.find()) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern - + "' missing from stdout \n"); - } - return this; - } - - /** - * Verify that the stderr contents of output buffer matches the pattern - * - * @param pattern - * @throws RuntimeException - * If the pattern was not found - */ - public OutputAnalyzer stderrShouldMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher( - getStderr()); - if (!matcher.find()) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern - + "' missing from stderr \n"); - } - return this; - } - - /** - * Verify that the stdout and stderr contents of output buffer does not - * match the pattern - * - * @param pattern - * @throws RuntimeException - * If the pattern was found - */ - public OutputAnalyzer shouldNotMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher( - getStdout()); - if (matcher.find()) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + "' found in stdout: '" - + matcher.group() + "' \n"); - } - matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(getStderr()); - if (matcher.find()) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + "' found in stderr: '" - + matcher.group() + "' \n"); - } - return this; - } - - /** - * Verify that the stdout contents of output buffer does not match the - * pattern - * - * @param pattern - * @throws RuntimeException - * If the pattern was found - */ - public OutputAnalyzer stdoutShouldNotMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher( - getStdout()); - if (matcher.find()) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + "' found in stdout \n"); - } - return this; - } - - /** - * Verify that the stderr contents of output buffer does not match the - * pattern - * - * @param pattern - * @throws RuntimeException - * If the pattern was found - */ - public OutputAnalyzer stderrShouldNotMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher( - getStderr()); - if (matcher.find()) { - reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + "' found in stderr \n"); - } - return this; - } - - /** - * Get the captured group of the first string matching the pattern. stderr - * is searched before stdout. - * - * @param pattern - * The multi-line pattern to match - * @param group - * The group to capture - * @return The matched string or null if no match was found - */ - public String firstMatch(String pattern, int group) { - Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE) - .matcher(getStderr()); - Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE) - .matcher(getStdout()); - if (stderrMatcher.find()) { - return stderrMatcher.group(group); - } - if (stdoutMatcher.find()) { - return stdoutMatcher.group(group); - } - return null; - } - - /** - * Get the first string matching the pattern. stderr is searched before - * stdout. - * - * @param pattern - * The multi-line pattern to match - * @return The matched string or null if no match was found - */ - public String firstMatch(String pattern) { - return firstMatch(pattern, 0); - } - - /** - * Verify the exit value of the process - * - * @param expectedExitValue - * Expected exit value from process - * @throws RuntimeException - * If the exit value from the process did not match the expected - * value - */ - public OutputAnalyzer shouldHaveExitValue(int expectedExitValue) { - if (getExitValue() != expectedExitValue) { - reportDiagnosticSummary(); - throw new RuntimeException("Expected to get exit value of [" - + expectedExitValue + "]\n"); - } - return this; - } - - /** - * Report summary that will help to diagnose the problem Currently includes: - * - standard input produced by the process under test - standard output - - * exit code Note: the command line is printed by the ProcessTools - */ - private OutputAnalyzer reportDiagnosticSummary() { - String msg = " stdout: [" + getStdout() + "];\n" + " stderr: [" + getStderr() - + "]\n" + " exitValue = " + getExitValue() + "\n"; - - System.err.println(msg); - return this; - } - - /** - * Get the contents of the output buffer (stdout and stderr) - * - * @return Content of the output buffer - */ - public String getOutput() { - return getStdout() + getStderr(); - } - - /** - * Get the contents of the stdout buffer - * - * @return Content of the stdout buffer - */ - public String getStdout() { - return output == null ? stdout : output.getStdout(); - } - - /** - * Get the contents of the stderr buffer - * - * @return Content of the stderr buffer - */ - public String getStderr() { - return output == null ? stderr : output.getStderr(); - } - - /** - * Get the process exit value - * - * @return Process exit value - */ - public int getExitValue() { - return output == null ? exitValue : output.getExitValue(); - } - - - /** - * Print the stdout buffer to the given {@code PrintStream}. - * - * @return this OutputAnalyzer - */ - public OutputAnalyzer outputTo(PrintStream out) { - out.println(getStdout()); - return this; - } - - /** - * Print the stderr buffer to the given {@code PrintStream}. - * - * @return this OutputAnalyzer - */ - public OutputAnalyzer errorTo(PrintStream out) { - out.println(getStderr()); - return this; - } - - - /** - * Get the contents of the output buffer (stdout and stderr) - * as a list of strings. Output will be split at new-lines as - * recognized by java.io.BufferedReader.readLine(). - * - * @return Contents of the output buffer as list of strings - */ - public List asLines() { - return asLines(getOutput()); - } - - private List asLines(String buffer) { - return new BufferedReader(new StringReader(buffer)) - .lines().collect(Collectors.toList()); - } - - /** - * Check if there is a line matching {@code pattern} and return its index - * - * @param pattern Matching pattern - * @return Index of first matching line - */ - private int indexOf(List lines, String pattern) { - for (int i = 0; i < lines.size(); i++) { - if (lines.get(i).matches(pattern)) { - return i; - } - } - return -1; - } - - /** - * @see #shouldMatchByLine(String, String, String) - */ - public int shouldMatchByLine(String pattern) { - return shouldMatchByLine(null, null, pattern); - } - - /** - * @see #stdoutShouldMatchByLine(String, String, String) - */ - public int stdoutShouldMatchByLine(String pattern) { - return stdoutShouldMatchByLine(null, null, pattern); - } - - /** - * @see #shouldMatchByLine(String, String, String) - */ - public int shouldMatchByLineFrom(String from, String pattern) { - return shouldMatchByLine(from, null, pattern); - } - - /** - * @see #shouldMatchByLine(String, String, String) - */ - public int shouldMatchByLineTo(String to, String pattern) { - return shouldMatchByLine(null, to, pattern); - } - - /** - * Verify that the stdout and stderr contents of output buffer match the - * {@code pattern} line by line. The whole output could be matched or - * just a subset of it. - * - * @param from - * The line from where output will be matched. - * Set {@code from} to null for matching from the first line. - * @param to - * The line until where output will be matched. - * Set {@code to} to null for matching until the last line. - * @param pattern - * Matching pattern - * @return Count of lines which match the {@code pattern} - */ - public int shouldMatchByLine(String from, String to, String pattern) { - return shouldMatchByLine(getOutput(), from, to, pattern); - } - - /** - * Verify that the stdout contents of output buffer matches the - * {@code pattern} line by line. The whole stdout could be matched or - * just a subset of it. - * - * @param from - * The line from where stdout will be matched. - * Set {@code from} to null for matching from the first line. - * @param to - * The line until where stdout will be matched. - * Set {@code to} to null for matching until the last line. - * @param pattern - * Matching pattern - * @return Count of lines which match the {@code pattern} - */ - public int stdoutShouldMatchByLine(String from, String to, String pattern) { - return shouldMatchByLine(getStdout(), from, to, pattern); - } - - private int shouldMatchByLine(String buffer, String from, String to, String pattern) { - List lines = asLines(buffer); - - int fromIndex = 0; - if (from != null) { - fromIndex = indexOf(lines, from); - assertGreaterThan(fromIndex, -1, - "The line/pattern '" + from + "' from where the output should match can not be found"); - } - - int toIndex = lines.size(); - if (to != null) { - toIndex = indexOf(lines, to); - assertGreaterThan(toIndex, -1, - "The line/pattern '" + to + "' until where the output should match can not be found"); - } - - List subList = lines.subList(fromIndex, toIndex); - int matchedCount = 0; - for (String line : subList) { - assertTrue(line.matches(pattern), - "The line '" + line + "' does not match pattern '" + pattern + "'"); - matchedCount++; - } - - return matchedCount; - } - -} diff --git a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputBuffer.java b/test/jdk/lib/testlibrary/jdk/testlibrary/OutputBuffer.java deleted file mode 100644 --- a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputBuffer.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2013, 2016, 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.ByteArrayOutputStream; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -/** - * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/jdk/test/lib/process} - */ -@Deprecated -class OutputBuffer { - private static class OutputBufferException extends RuntimeException { - private static final long serialVersionUID = 8528687792643129571L; - - public OutputBufferException(Throwable cause) { - super(cause); - } - } - - private final Process p; - private final Future outTask; - private final Future errTask; - private final ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream(); - private final ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream(); - - /** - * Create an OutputBuffer, a class for storing and managing stdout and - * stderr results separately - * - * @param stdout - * stdout result - * @param stderr - * stderr result - */ - OutputBuffer(Process p) { - this.p = p; - StreamPumper outPumper = new StreamPumper(p.getInputStream(), - stdoutBuffer); - StreamPumper errPumper = new StreamPumper(p.getErrorStream(), - stderrBuffer); - - outTask = outPumper.process(); - errTask = errPumper.process(); - } - - /** - * Returns the stdout result - * - * @return stdout result - */ - public String getStdout() { - try { - outTask.get(); - return stdoutBuffer.toString(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new OutputBufferException(e); - } catch (ExecutionException | CancellationException e) { - throw new OutputBufferException(e); - } - } - - /** - * Returns the stderr result - * - * @return stderr result - */ - public String getStderr() { - try { - errTask.get(); - return stderrBuffer.toString(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new OutputBufferException(e); - } catch (ExecutionException | CancellationException e) { - throw new OutputBufferException(e); - } - } - - public int getExitValue() { - try { - return p.waitFor(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new OutputBufferException(e); - } - } -} diff --git a/test/jdk/lib/testlibrary/jdk/testlibrary/ProcessTools.java b/test/jdk/lib/testlibrary/jdk/testlibrary/ProcessTools.java deleted file mode 100644 --- a/test/jdk/lib/testlibrary/jdk/testlibrary/ProcessTools.java +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Copyright (c) 2013, 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.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.concurrent.CountDownLatch; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.function.Predicate; -import java.util.function.Consumer; -import java.util.stream.Collectors; - - -/** - * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/jdk/test/lib/process} - */ -@Deprecated -public final class ProcessTools { - private static final class LineForwarder extends StreamPumper.LinePump { - private final PrintStream ps; - private final String prefix; - LineForwarder(String prefix, PrintStream os) { - this.ps = os; - this.prefix = prefix; - } - @Override - protected void processLine(String line) { - ps.println("[" + prefix + "] " + line); - } - } - - private ProcessTools() { - } - - /** - *

Starts a process from its builder.

- * The default redirects of STDOUT and STDERR are started - * @param name The process name - * @param processBuilder The process builder - * @return Returns the initialized process - * @throws IOException - */ - public static Process startProcess(String name, - ProcessBuilder processBuilder) - throws IOException { - return startProcess(name, processBuilder, (Consumer)null); - } - - /** - *

Starts a process from its builder.

- * The default redirects of STDOUT and STDERR are started - *

It is possible to monitor the in-streams via the provided {@code consumer} - * @param name The process name - * @param consumer {@linkplain Consumer} instance to process the in-streams - * @param processBuilder The process builder - * @return Returns the initialized process - * @throws IOException - */ - @SuppressWarnings("overloads") - public static Process startProcess(String name, - ProcessBuilder processBuilder, - Consumer consumer) - throws IOException { - try { - return startProcess(name, processBuilder, consumer, null, -1, TimeUnit.NANOSECONDS); - } catch (InterruptedException | TimeoutException e) { - // will never happen - throw new RuntimeException(e); - } - } - - /** - *

Starts a process from its builder.

- * The default redirects of STDOUT and STDERR are started - *

- * It is possible to wait for the process to get to a warmed-up state - * via {@linkplain Predicate} condition on the STDOUT - *

- * @param name The process name - * @param processBuilder The process builder - * @param linePredicate The {@linkplain Predicate} to use on the STDOUT - * Used to determine the moment the target app is - * properly warmed-up. - * It can be null - in that case the warmup is skipped. - * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever - * @param unit The timeout {@linkplain TimeUnit} - * @return Returns the initialized {@linkplain Process} - * @throws IOException - * @throws InterruptedException - * @throws TimeoutException - */ - public static Process startProcess(String name, - ProcessBuilder processBuilder, - final Predicate linePredicate, - long timeout, - TimeUnit unit) - throws IOException, InterruptedException, TimeoutException { - return startProcess(name, processBuilder, null, linePredicate, timeout, unit); - } - - /** - *

Starts a process from its builder.

- * The default redirects of STDOUT and STDERR are started - *

- * It is possible to wait for the process to get to a warmed-up state - * via {@linkplain Predicate} condition on the STDOUT and monitor the - * in-streams via the provided {@linkplain Consumer} - *

- * @param name The process name - * @param processBuilder The process builder - * @param lineConsumer The {@linkplain Consumer} the lines will be forwarded to - * @param linePredicate The {@linkplain Predicate} to use on the STDOUT - * Used to determine the moment the target app is - * properly warmed-up. - * It can be null - in that case the warmup is skipped. - * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever - * @param unit The timeout {@linkplain TimeUnit} - * @return Returns the initialized {@linkplain Process} - * @throws IOException - * @throws InterruptedException - * @throws TimeoutException - */ - public static Process startProcess(String name, - ProcessBuilder processBuilder, - final Consumer lineConsumer, - final Predicate linePredicate, - long timeout, - TimeUnit unit) - throws IOException, InterruptedException, TimeoutException { - System.out.println("["+name+"]:" + processBuilder.command().stream().collect(Collectors.joining(" "))); - Process p = processBuilder.start(); - StreamPumper stdout = new StreamPumper(p.getInputStream()); - StreamPumper stderr = new StreamPumper(p.getErrorStream()); - - stdout.addPump(new LineForwarder(name, System.out)); - stderr.addPump(new LineForwarder(name, System.err)); - if (lineConsumer != null) { - StreamPumper.LinePump pump = new StreamPumper.LinePump() { - @Override - protected void processLine(String line) { - lineConsumer.accept(line); - } - }; - stdout.addPump(pump); - stderr.addPump(pump); - } - - - CountDownLatch latch = new CountDownLatch(1); - if (linePredicate != null) { - StreamPumper.LinePump pump = new StreamPumper.LinePump() { - @Override - protected void processLine(String line) { - if (latch.getCount() > 0 && linePredicate.test(line)) { - latch.countDown(); - } - } - }; - stdout.addPump(pump); - stderr.addPump(pump); - } else { - latch.countDown(); - } - final Future stdoutTask = stdout.process(); - final Future stderrTask = stderr.process(); - - try { - if (timeout > -1) { - if (timeout == 0) { - latch.await(); - } else { - if (!latch.await(Utils.adjustTimeout(timeout), unit)) { - throw new TimeoutException(); - } - } - } - } catch (TimeoutException | InterruptedException e) { - System.err.println("Failed to start a process (thread dump follows)"); - for(Map.Entry s : Thread.getAllStackTraces().entrySet()) { - printStack(s.getKey(), s.getValue()); - } - - if (p.isAlive()) { - p.destroyForcibly(); - } - - stdoutTask.cancel(true); - stderrTask.cancel(true); - throw e; - } - - return new ProcessImpl(p, stdoutTask, stderrTask); - } - - /** - *

Starts a process from its builder.

- * The default redirects of STDOUT and STDERR are started - *

- * It is possible to wait for the process to get to a warmed-up state - * via {@linkplain Predicate} condition on the STDOUT. The warm-up will - * wait indefinitely. - *

- * @param name The process name - * @param processBuilder The process builder - * @param linePredicate The {@linkplain Predicate} to use on the STDOUT - * Used to determine the moment the target app is - * properly warmed-up. - * It can be null - in that case the warmup is skipped. - * @return Returns the initialized {@linkplain Process} - * @throws IOException - * @throws InterruptedException - * @throws TimeoutException - */ - @SuppressWarnings("overloads") - public static Process startProcess(String name, - ProcessBuilder processBuilder, - final Predicate linePredicate) - throws IOException, InterruptedException, TimeoutException { - return startProcess(name, processBuilder, linePredicate, 0, TimeUnit.SECONDS); - } - - /** - * Get the process id of the current running Java process - * - * @return Process id - */ - public static long getProcessId() { - return ProcessHandle.current().pid(); - } - - /** - * Create ProcessBuilder using the java launcher from the jdk to be tested, - * and with any platform specific arguments prepended. - * - * @param command Arguments to pass to the java command. - * @return The ProcessBuilder instance representing the java command. - */ - public static ProcessBuilder createJavaProcessBuilder(String... command) { - return createJavaProcessBuilder(false, command); - } - - /** - * Create ProcessBuilder using the java launcher from the jdk to be tested, - * and with any platform specific arguments prepended. - * - * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts - * to the java arguments. - * @param command Arguments to pass to the java command. - * @return The ProcessBuilder instance representing the java command. - */ - public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) { - String javapath = JDKToolFinder.getJDKTool("java"); - - ArrayList args = new ArrayList<>(); - args.add(javapath); - - if (addTestVmAndJavaOptions) { - // -cp is needed to make sure the same classpath is used whether the test is - // run in AgentVM mode or OtherVM mode. It was added to the hotspot version - // of this API as part of 8077608. However, for the jdk version it is only - // added when addTestVmAndJavaOptions is true in order to minimize - // disruption to existing JDK tests, which have yet to be tested with -cp - // being added. At some point -cp should always be added to be consistent - // with what the hotspot version does. - args.add("-cp"); - args.add(System.getProperty("java.class.path")); - Collections.addAll(args, Utils.getTestJavaOpts()); - } - - Collections.addAll(args, command); - - // Reporting - StringBuilder cmdLine = new StringBuilder(); - for (String cmd : args) - cmdLine.append(cmd).append(' '); - System.out.println("Command line: [" + cmdLine.toString() + "]"); - - return new ProcessBuilder(args.toArray(new String[args.size()])); - } - - private static void printStack(Thread t, StackTraceElement[] stack) { - System.out.println("\t" + t + - " stack: (length = " + stack.length + ")"); - if (t != null) { - for (StackTraceElement stack1 : stack) { - System.out.println("\t" + stack1); - } - System.out.println(); - } - } - - /** - * Executes a test java process, waits for it to finish and returns the process output. - * The default options from jtreg, test.vm.opts and test.java.opts, are added. - * The java from the test.jdk is used to execute the command. - * - * The command line will be like: - * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds - * - * The java process will have exited before this method returns. - * - * @param cmds User specifed arguments. - * @return The output from the process. - */ - public static OutputAnalyzer executeTestJava(String... options) throws Exception { - ProcessBuilder pb = createJavaProcessBuilder(Utils.addTestJavaOpts(options)); - return executeProcess(pb); - } - - /** - * @deprecated Use executeTestJava instead - */ - public static OutputAnalyzer executeTestJvm(String... options) throws Exception { - return executeTestJava(options); - } - - /** - * Executes a process, waits for it to finish and returns the process output. - * The process will have exited before this method returns. - * @param pb The ProcessBuilder to execute. - * @return The {@linkplain OutputAnalyzer} instance wrapping the process. - */ - public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception { - return executeProcess(pb, null); - } - - /** - * Executes a process, pipe some text into its STDIN, waits for it - * to finish and returns the process output. The process will have exited - * before this method returns. - * @param pb The ProcessBuilder to execute. - * @param input The text to pipe into STDIN. Can be null. - * @return The {@linkplain OutputAnalyzer} instance wrapping the process. - */ - public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input) - throws Exception { - OutputAnalyzer output = null; - Process p = null; - boolean failed = false; - try { - p = pb.start(); - if (input != null) { - try (OutputStream os = p.getOutputStream(); - PrintStream ps = new PrintStream(os)) { - ps.print(input); - ps.flush(); - } - } - output = new OutputAnalyzer(p); - p.waitFor(); - - return output; - } catch (Throwable t) { - if (p != null) { - p.destroyForcibly().waitFor(); - } - - failed = true; - System.out.println("executeProcess() failed: " + t); - throw t; - } finally { - if (failed) { - System.err.println(getProcessLog(pb, output)); - } - } - } - - /** - * Executes a process, waits for it to finish and returns the process output. - * - * The process will have exited before this method returns. - * - * @param cmds The command line to execute. - * @return The output from the process. - */ - public static OutputAnalyzer executeProcess(String... cmds) throws Exception { - return executeProcess(new ProcessBuilder(cmds)); - } - - /** - * Used to log command line, stdout, stderr and exit code from an executed process. - * @param pb The executed process. - * @param output The output from the process. - */ - public static String getProcessLog(ProcessBuilder pb, OutputAnalyzer output) { - String stderr = output == null ? "null" : output.getStderr(); - String stdout = output == null ? "null" : output.getStdout(); - String exitValue = output == null ? "null": Integer.toString(output.getExitValue()); - StringBuilder logMsg = new StringBuilder(); - final String nl = System.getProperty("line.separator"); - logMsg.append("--- ProcessLog ---" + nl); - logMsg.append("cmd: " + getCommandLine(pb) + nl); - logMsg.append("exitvalue: " + exitValue + nl); - logMsg.append("stderr: " + stderr + nl); - logMsg.append("stdout: " + stdout + nl); - - return logMsg.toString(); - } - - /** - * @return The full command line for the ProcessBuilder. - */ - public static String getCommandLine(ProcessBuilder pb) { - if (pb == null) { - return "null"; - } - StringBuilder cmd = new StringBuilder(); - for (String s : pb.command()) { - cmd.append(s).append(" "); - } - return cmd.toString().trim(); - } - - /** - * Executes a process, waits for it to finish, prints the process output - * to stdout, and returns the process output. - * - * The process will have exited before this method returns. - * - * @param cmds The command line to execute. - * @return The {@linkplain OutputAnalyzer} instance wrapping the process. - */ - public static OutputAnalyzer executeCommand(String... cmds) - throws Throwable { - String cmdLine = Arrays.stream(cmds).collect(Collectors.joining(" ")); - System.out.println("Command line: [" + cmdLine + "]"); - OutputAnalyzer analyzer = ProcessTools.executeProcess(cmds); - System.out.println(analyzer.getOutput()); - return analyzer; - } - - /** - * Executes a process, waits for it to finish, prints the process output - * to stdout and returns the process output. - * - * The process will have exited before this method returns. - * - * @param pb The ProcessBuilder to execute. - * @return The {@linkplain OutputAnalyzer} instance wrapping the process. - */ - public static OutputAnalyzer executeCommand(ProcessBuilder pb) - throws Throwable { - String cmdLine = pb.command().stream().collect(Collectors.joining(" ")); - System.out.println("Command line: [" + cmdLine + "]"); - OutputAnalyzer analyzer = ProcessTools.executeProcess(pb); - System.out.println(analyzer.getOutput()); - return analyzer; - } - - private static class ProcessImpl extends Process { - - private final Process p; - private final Future stdoutTask; - private final Future stderrTask; - - public ProcessImpl(Process p, Future stdoutTask, Future stderrTask) { - this.p = p; - this.stdoutTask = stdoutTask; - this.stderrTask = stderrTask; - } - - @Override - public OutputStream getOutputStream() { - return p.getOutputStream(); - } - - @Override - public InputStream getInputStream() { - return p.getInputStream(); - } - - @Override - public InputStream getErrorStream() { - return p.getErrorStream(); - } - - @Override - public int waitFor() throws InterruptedException { - int rslt = p.waitFor(); - waitForStreams(); - return rslt; - } - - @Override - public int exitValue() { - return p.exitValue(); - } - - @Override - public void destroy() { - p.destroy(); - } - - @Override - public long pid() { - return p.pid(); - } - - @Override - public boolean isAlive() { - return p.isAlive(); - } - - @Override - public Process destroyForcibly() { - return p.destroyForcibly(); - } - - @Override - public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException { - boolean rslt = p.waitFor(timeout, unit); - if (rslt) { - waitForStreams(); - } - return rslt; - } - - private void waitForStreams() throws InterruptedException { - try { - stdoutTask.get(); - } catch (ExecutionException e) { - } - try { - stderrTask.get(); - } catch (ExecutionException e) { - } - } - } -} diff --git a/test/jdk/lib/testlibrary/jdk/testlibrary/StreamPumper.java b/test/jdk/lib/testlibrary/jdk/testlibrary/StreamPumper.java deleted file mode 100644 --- a/test/jdk/lib/testlibrary/jdk/testlibrary/StreamPumper.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2013, 2016, 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.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * @deprecated This class is deprecated. Use the one from - * {@code /test/lib/jdk/test/lib/process} - */ -@Deprecated -public final class StreamPumper implements Runnable { - - private static final int BUF_SIZE = 256; - - /** - * Pump will be called by the StreamPumper to process the incoming data - */ - abstract public static class Pump { - abstract void register(StreamPumper d); - } - - /** - * OutputStream -> Pump adapter - */ - final public static class StreamPump extends Pump { - private final OutputStream out; - public StreamPump(OutputStream out) { - this.out = out; - } - - @Override - void register(StreamPumper sp) { - sp.addOutputStream(out); - } - } - - /** - * Used to process the incoming data line-by-line - */ - abstract public static class LinePump extends Pump { - @Override - final void register(StreamPumper sp) { - sp.addLineProcessor(this); - } - - abstract protected void processLine(String line); - } - - private final InputStream in; - private final Set outStreams = new HashSet<>(); - private final Set linePumps = new HashSet<>(); - - private final AtomicBoolean processing = new AtomicBoolean(false); - private final FutureTask processingTask = new FutureTask<>(this, null); - - public StreamPumper(InputStream in) { - this.in = in; - } - - /** - * Create a StreamPumper that reads from in and writes to out. - * - * @param in - * The stream to read from. - * @param out - * The stream to write to. - */ - public StreamPumper(InputStream in, OutputStream out) { - this(in); - this.addOutputStream(out); - } - - /** - * Implements Thread.run(). Continuously read from {@code in} and write to - * {@code out} until {@code in} has reached end of stream. Abort on - * interruption. Abort on IOExceptions. - */ - @Override - public void run() { - try (BufferedInputStream is = new BufferedInputStream(in)) { - ByteArrayOutputStream lineBos = new ByteArrayOutputStream(); - byte[] buf = new byte[BUF_SIZE]; - int len = 0; - int linelen = 0; - - while ((len = is.read(buf)) > 0 && !Thread.interrupted()) { - for(OutputStream out : outStreams) { - out.write(buf, 0, len); - } - if (!linePumps.isEmpty()) { - int i = 0; - int lastcrlf = -1; - while (i < len) { - if (buf[i] == '\n' || buf[i] == '\r') { - int bufLinelen = i - lastcrlf - 1; - if (bufLinelen > 0) { - lineBos.write(buf, lastcrlf + 1, bufLinelen); - } - linelen += bufLinelen; - - if (linelen > 0) { - lineBos.flush(); - final String line = lineBos.toString(); - linePumps.stream().forEach((lp) -> { - lp.processLine(line); - }); - lineBos.reset(); - linelen = 0; - } - lastcrlf = i; - } - - i++; - } - if (lastcrlf == -1) { - lineBos.write(buf, 0, len); - linelen += len; - } else if (lastcrlf < len - 1) { - lineBos.write(buf, lastcrlf + 1, len - lastcrlf - 1); - linelen += len - lastcrlf - 1; - } - } - } - - } catch (IOException e) { - e.printStackTrace(); - } finally { - for(OutputStream out : outStreams) { - try { - out.flush(); - } catch (IOException e) {} - } - try { - in.close(); - } catch (IOException e) {} - } - } - - final void addOutputStream(OutputStream out) { - outStreams.add(out); - } - - final void addLineProcessor(LinePump lp) { - linePumps.add(lp); - } - - final public StreamPumper addPump(Pump ... pump) { - if (processing.get()) { - throw new IllegalStateException("Can not modify pumper while " + - "processing is in progress"); - } - for(Pump p : pump) { - p.register(this); - } - return this; - } - - final public Future process() { - if (!processing.compareAndSet(false, true)) { - throw new IllegalStateException("Can not re-run the processing"); - } - Thread t = new Thread(new Runnable() { - @Override - public void run() { - processingTask.run(); - } - }); - t.setDaemon(true); - t.start(); - - return processingTask; - } -} diff --git a/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java b/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java --- a/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java +++ b/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java @@ -23,14 +23,14 @@ /* * @test - * @library /lib/testlibrary - * @build jdk.testlibrary.OutputAnalyzer + * @library /test/lib + * @build jdk.test.lib.process.OutputAnalyzer * @build ProgramTest * @run main/native ProgramTest */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; public class ProgramTest { public static void main(String... args) throws Exception { diff --git a/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java b/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java --- a/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java +++ b/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java @@ -21,7 +21,6 @@ * questions. */ -import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; @@ -34,8 +33,8 @@ import java.util.UUID; import java.util.concurrent.Semaphore; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import sun.jvmstat.monitor.MonitorException; import sun.jvmstat.monitor.MonitoredHost; import sun.jvmstat.monitor.MonitoredVm; @@ -66,11 +65,10 @@ * @test * @bug 4990825 * @summary attach to external but local JVM processes - * @library /lib/testlibrary + * @library /test/lib * @modules java.management * jdk.internal.jvmstat/sun.jvmstat.monitor * jdk.internal.jvmstat/sun.jvmstat.monitor.event - * @build jdk.testlibrary.* * @run main/othervm MonitorVmStartTerminate */ public final class MonitorVmStartTerminate { diff --git a/test/jdk/sun/management/jdp/DynamicLauncher.java b/test/jdk/sun/management/jdp/DynamicLauncher.java --- a/test/jdk/sun/management/jdp/DynamicLauncher.java +++ b/test/jdk/sun/management/jdp/DynamicLauncher.java @@ -22,8 +22,8 @@ */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; import java.util.UUID; diff --git a/test/jdk/sun/management/jdp/JdpDefaultsTest.java b/test/jdk/sun/management/jdp/JdpDefaultsTest.java --- a/test/jdk/sun/management/jdp/JdpDefaultsTest.java +++ b/test/jdk/sun/management/jdp/JdpDefaultsTest.java @@ -32,6 +32,7 @@ * @summary Assert that we can read JDP packets from a multicast socket connection, on default IP and port. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher * @run main/othervm JdpDefaultsTest diff --git a/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java b/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java --- a/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java +++ b/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java @@ -28,6 +28,7 @@ * when VM is started with jmxremote.port=0. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpJmxRemoteDynamicPortTestCase DynamicLauncher * @run main/othervm JdpJmxRemoteDynamicPortTest diff --git a/test/jdk/sun/management/jdp/JdpOffTest.java b/test/jdk/sun/management/jdp/JdpOffTest.java --- a/test/jdk/sun/management/jdp/JdpOffTest.java +++ b/test/jdk/sun/management/jdp/JdpOffTest.java @@ -33,6 +33,7 @@ * @summary Assert that no JDP packets are sent to the default address and port. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOffTestCase DynamicLauncher * @run main/othervm JdpOffTest diff --git a/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java b/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java --- a/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java +++ b/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java @@ -32,6 +32,7 @@ * @summary Assert that we can read JDP packets from a multicast socket connection, on specific IP and port. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher * @run main/othervm JdpSpecificAddressTest diff --git a/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java b/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java --- a/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java +++ b/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java @@ -22,7 +22,7 @@ */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.testlibrary.Utils; import java.io.IOException; diff --git a/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java --- a/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java @@ -21,8 +21,8 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Platform; import java.io.BufferedWriter; diff --git a/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java --- a/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -35,19 +35,18 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * @test * @bug 6434402 8004926 * @author Jaroslav Bachorik * - * @library /lib/testlibrary + * @library /test/lib * @modules java.management * jdk.attach * jdk.management.agent/jdk.internal.agent * - * @build jdk.testlibrary.* * @build TestManager TestApplication CustomLauncherTest * @run main/othervm CustomLauncherTest */ diff --git a/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java b/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java --- a/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/JMXInterfaceBindingTest.java @@ -30,7 +30,7 @@ import java.util.stream.Collectors; import jdk.test.lib.thread.ProcessThread; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * NOTE: @@ -48,11 +48,10 @@ * @summary Test JMX agent host address binding. Same ports but different * interfaces to bind to (using plain sockets and SSL sockets). * - * @library /lib/testlibrary * @library /test/lib * @modules java.management.rmi * - * @build jdk.testlibrary.* JMXAgentInterfaceBinding + * @build JMXAgentInterfaceBinding * @run main/timeout=5 JMXInterfaceBindingTest */ public class JMXInterfaceBindingTest { diff --git a/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java b/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java --- a/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicReference; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; /** @@ -39,6 +39,7 @@ * both agent properties and jvmstat buffer. * * @library /lib/testlibrary + * @library /test/lib * @modules java.management * jdk.attach * jdk.management.agent/jdk.internal.agent diff --git a/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java b/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java --- a/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java @@ -21,8 +21,8 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; import java.io.BufferedReader; @@ -44,6 +44,7 @@ * @author Luis-Miguel Alventosa, Taras Ledkov * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* RmiRegistrySslTestApp * @run main/timeout=300 RmiRegistrySslTest diff --git a/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java b/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java --- a/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java +++ b/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java @@ -44,7 +44,7 @@ import javax.management.remote.*; import javax.net.ssl.SSLHandshakeException; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; import jdk.internal.agent.Agent; import jdk.internal.agent.AgentConfigurationError; @@ -58,6 +58,7 @@ * achieves the desired results * * @library /lib/testlibrary + * @library /test/lib * @modules java.management * java.rmi * jdk.management.agent/jdk.internal.agent diff --git a/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java b/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java --- a/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java +++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java @@ -32,7 +32,7 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** @@ -43,6 +43,7 @@ * in the related performance counters. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* PortAllocator TestApp ManagementAgentJcmd * @run testng/othervm -XX:+UsePerfData JMXStatusPerfCountersTest diff --git a/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java b/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java --- a/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java +++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java @@ -29,7 +29,7 @@ import org.testng.annotations.*; import static org.testng.Assert.*; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * @test @@ -39,6 +39,7 @@ * The test asserts that the expected text is being printed. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* PortAllocator TestApp ManagementAgentJcmd * JMXStatusTest JMXStatus1Test JMXStatus2Test diff --git a/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java b/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java --- a/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java +++ b/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java @@ -34,7 +34,7 @@ import jdk.internal.agent.AgentConfigurationError; import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * A helper class for issuing ManagementAgent.* diagnostic commands and capturing diff --git a/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java b/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java --- a/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java +++ b/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java @@ -24,15 +24,15 @@ import java.io.File; import java.util.HashMap; import java.util.Map; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; /* * @test * @bug 6857795 8075299 * @summary Checks if kinit uses both krb5 conf file and system properties * @requires os.family == "windows" - * @library /lib/testlibrary + * @library /test/lib * @library /sun/security/krb5/auto * @run main/othervm KinitConfPlusProps */ diff --git a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java --- a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java +++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java @@ -25,6 +25,7 @@ * @test * @bug 8164879 * @library /lib/testlibrary ../../ + * @library /test/lib * @summary Verify AES/GCM's limits set in the jdk.tls.keyLimits property * start a new handshake sequence to renegotiate the symmetric key with an * SSLSocket connection. This test verifies the handshake method was called @@ -53,9 +54,9 @@ import java.security.SecureRandom; import java.util.Arrays; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; import jdk.testlibrary.Utils; -import jdk.testlibrary.OutputAnalyzer; public class SSLEngineKeyLimit { diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java @@ -25,6 +25,7 @@ * @test * @bug 8164879 * @library /lib/testlibrary ../../ + * @library /test/lib * @modules java.base/sun.security.util * @summary Verify AES/GCM's limits set in the jdk.tls.keyLimits property * @run main SSLSocketKeyLimit 0 server AES/GCM/NoPadding keyupdate 1000000 @@ -47,8 +48,6 @@ import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManagerFactory; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; import java.io.OutputStream; @@ -57,9 +56,9 @@ import java.security.SecureRandom; import java.util.Arrays; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; -import jdk.testlibrary.OutputAnalyzer; import sun.security.util.HexDumpEncoder; public class SSLSocketKeyLimit { diff --git a/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java b/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java --- a/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java +++ b/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java @@ -21,7 +21,7 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** diff --git a/test/jdk/sun/security/tools/jarsigner/Warning.java b/test/jdk/sun/security/tools/jarsigner/Warning.java --- a/test/jdk/sun/security/tools/jarsigner/Warning.java +++ b/test/jdk/sun/security/tools/jarsigner/Warning.java @@ -23,8 +23,8 @@ import jdk.testlibrary.JDKToolLauncher; import jdk.test.lib.util.JarUtils; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import java.nio.file.Files; import java.nio.file.Paths; diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for aliasNotInStore warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main AliasNotInStoreTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for badExtendedKeyUsage warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main BadExtendedKeyUsageTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for badKeyUsage warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @ignore until 8026393 is fixed * @build jdk.test.lib.util.JarUtils * @run main BadKeyUsageTest diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for badNetscapeCertType warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main BadNetscapeCertTypeTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java @@ -21,7 +21,7 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; import java.nio.file.Files; @@ -31,7 +31,7 @@ * @test * @bug 8024302 8026037 * @summary Test for chainNotValidated warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main ChainNotValidatedTest ca2yes * @run main ChainNotValidatedTest ca2no diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for hasExpiredCert warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main HasExpiredCertTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for hasExpiringCert warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main HasExpiringCertTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for hasUnsignedEntry warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main HasUnsignedEntryTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Checks if jarsigner prints appropriate warnings - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main MultipleWarningsTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/NoTimestampTest.java @@ -23,14 +23,14 @@ import java.util.Date; import java.util.Locale; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 8196213 * @summary Checks warnings if -tsa and -tsacert options are not specified - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main NoTimestampTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for notSignedByAlias warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main NotSignedByAliasTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java b/test/jdk/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java @@ -21,14 +21,14 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.util.JarUtils; /** * @test * @bug 8024302 8026037 * @summary Test for notYetValidCert warning - * @library /lib/testlibrary /test/lib ../ + * @library /test/lib ../ * @build jdk.test.lib.util.JarUtils * @run main NotYetValidCertTest */ diff --git a/test/jdk/sun/security/tools/jarsigner/warnings/Test.java b/test/jdk/sun/security/tools/jarsigner/warnings/Test.java --- a/test/jdk/sun/security/tools/jarsigner/warnings/Test.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/Test.java @@ -21,8 +21,8 @@ * questions. */ -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import java.util.ArrayList; import java.util.Arrays; diff --git a/test/jdk/sun/tools/jcmd/JcmdBase.java b/test/jdk/sun/tools/jcmd/JcmdBase.java --- a/test/jdk/sun/tools/jcmd/JcmdBase.java +++ b/test/jdk/sun/tools/jcmd/JcmdBase.java @@ -23,8 +23,8 @@ import java.util.Arrays; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolLauncher; /** diff --git a/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java b/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java --- a/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java +++ b/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java @@ -23,14 +23,13 @@ import static jdk.testlibrary.Asserts.*; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.testlibrary.Utils; /* @@ -40,6 +39,7 @@ * requests to a specific JVM process. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* * @run main TestJcmdDefaults diff --git a/test/jdk/sun/tools/jcmd/TestJcmdSanity.java b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java --- a/test/jdk/sun/tools/jcmd/TestJcmdSanity.java +++ b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java @@ -30,8 +30,8 @@ import java.nio.file.Paths; import java.util.List; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; /* @@ -41,6 +41,7 @@ * command requests to the current java process. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* * @run main/othervm -XX:+UsePerfData TestJcmdSanity diff --git a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java --- a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java +++ b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java @@ -40,12 +40,12 @@ import java.util.List; import java.util.Arrays; import java.util.Optional; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.apps.LingeredApp; +import jdk.test.lib.Platform; import jdk.testlibrary.JDKToolLauncher; import jdk.testlibrary.Utils; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; -import jdk.test.lib.apps.LingeredApp; -import jdk.test.lib.Platform; public class BasicLauncherTest { diff --git a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java --- a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java +++ b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java @@ -38,12 +38,13 @@ import java.io.File; import java.util.List; import java.util.Arrays; -import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.test.lib.apps.LingeredApp; import jdk.test.lib.Platform; import jdk.test.lib.hprof.parser.HprofReader; +import jdk.testlibrary.JDKToolLauncher; public class HeapDumpTest { diff --git a/test/jdk/sun/tools/jinfo/BasicJInfoTest.java b/test/jdk/sun/tools/jinfo/BasicJInfoTest.java --- a/test/jdk/sun/tools/jinfo/BasicJInfoTest.java +++ b/test/jdk/sun/tools/jinfo/BasicJInfoTest.java @@ -23,14 +23,15 @@ import java.util.Arrays; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; /* * @test * @summary Unit test for jinfo utility * @library /lib/testlibrary + * @library /test/lib * @build jdk.testlibrary.* * @run main BasicJInfoTest */ diff --git a/test/jdk/sun/tools/jmap/BasicJMapTest.java b/test/jdk/sun/tools/jmap/BasicJMapTest.java --- a/test/jdk/sun/tools/jmap/BasicJMapTest.java +++ b/test/jdk/sun/tools/jmap/BasicJMapTest.java @@ -28,9 +28,9 @@ import java.util.Arrays; import jdk.test.lib.hprof.HprofParser; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; /* * @test diff --git a/test/jdk/sun/tools/jps/JpsHelper.java b/test/jdk/sun/tools/jps/JpsHelper.java --- a/test/jdk/sun/tools/jps/JpsHelper.java +++ b/test/jdk/sun/tools/jps/JpsHelper.java @@ -35,11 +35,11 @@ import java.util.Arrays; import java.util.List; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Asserts; import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; import jdk.testlibrary.Utils; -import jdk.testlibrary.ProcessTools; /** * The helper class for running jps utility and verifying output from it diff --git a/test/jdk/sun/tools/jps/TestJpsSanity.java b/test/jdk/sun/tools/jps/TestJpsSanity.java --- a/test/jdk/sun/tools/jps/TestJpsSanity.java +++ b/test/jdk/sun/tools/jps/TestJpsSanity.java @@ -22,7 +22,7 @@ */ import jdk.testlibrary.Asserts; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.apps.LingeredApp; /* diff --git a/test/jdk/sun/tools/jstack/BasicJStackTest.java b/test/jdk/sun/tools/jstack/BasicJStackTest.java --- a/test/jdk/sun/tools/jstack/BasicJStackTest.java +++ b/test/jdk/sun/tools/jstack/BasicJStackTest.java @@ -23,14 +23,15 @@ import java.util.Arrays; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; /* * @test * @summary Unit test for jstack utility * @library /lib/testlibrary + * @library /test/lib * @build jdk.testlibrary.* * @run main BasicJStackTest */ diff --git a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java --- a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java +++ b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java @@ -28,11 +28,11 @@ import jdk.test.lib.apps.LingeredApp; import jdk.test.lib.apps.LingeredAppWithDeadlock; import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.Utils; import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; /** * @test diff --git a/test/jdk/sun/tools/jstat/JStatInterval.java b/test/jdk/sun/tools/jstat/JStatInterval.java --- a/test/jdk/sun/tools/jstat/JStatInterval.java +++ b/test/jdk/sun/tools/jstat/JStatInterval.java @@ -25,6 +25,7 @@ * @test * @bug 8035668 * @library /lib/testlibrary + * @library /test/lib * @summary Test checks case when target application finishes execution and jstat didn't complete work. jstat is started with interval = 100 (jstat -compiler 100) and monitored application finishes after 500ms. This shouldn't cause crash or hang in target application or in jstat. @@ -33,7 +34,7 @@ * @run main JStatInterval */ -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import jdk.testlibrary.JDKToolLauncher; import java.util.concurrent.TimeUnit; diff --git a/test/jdk/sun/tools/jstatd/JstatdTest.java b/test/jdk/sun/tools/jstatd/JstatdTest.java --- a/test/jdk/sun/tools/jstatd/JstatdTest.java +++ b/test/jdk/sun/tools/jstatd/JstatdTest.java @@ -32,8 +32,8 @@ import static jdk.testlibrary.Asserts.*; import jdk.testlibrary.JDKToolLauncher; import jdk.testlibrary.Utils; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /** * The base class for tests of jstatd. @@ -328,7 +328,7 @@ } // Verify output from jstatd - jdk.test.lib.process.OutputAnalyzer output = jstatdThread.getOutput(); + OutputAnalyzer output = jstatdThread.getOutput(); assertTrue(output.getOutput().isEmpty(), "jstatd should get an empty output, got: " + Utils.NEW_LINE + output.getOutput()); diff --git a/test/jdk/sun/tools/jstatd/TestJstatdUsage.java b/test/jdk/sun/tools/jstatd/TestJstatdUsage.java --- a/test/jdk/sun/tools/jstatd/TestJstatdUsage.java +++ b/test/jdk/sun/tools/jstatd/TestJstatdUsage.java @@ -22,8 +22,8 @@ */ import jdk.testlibrary.JDKToolLauncher; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; /* * @test diff --git a/test/jdk/tools/jimage/JImageToolTest.java b/test/jdk/tools/jimage/JImageToolTest.java --- a/test/jdk/tools/jimage/JImageToolTest.java +++ b/test/jdk/tools/jimage/JImageToolTest.java @@ -22,8 +22,8 @@ */ /* * @test - * @library /lib/testlibrary - * @build jdk.testlibrary.ProcessTools + * @library /test/lib + * @build jdk.test.lib.process.ProcessTools * @summary Test to check if jimage tool exists and is working * @run main/timeout=360 JImageToolTest */ @@ -34,7 +34,7 @@ import java.util.ArrayList; import java.util.Arrays; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * Basic test for jimage tool. diff --git a/test/jdk/tools/jlink/basic/AllModulePath.java b/test/jdk/tools/jlink/basic/AllModulePath.java --- a/test/jdk/tools/jlink/basic/AllModulePath.java +++ b/test/jdk/tools/jlink/basic/AllModulePath.java @@ -24,10 +24,10 @@ /* * @test * @summary jlink test of --add-module ALL-MODULE-PATH - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build jdk.testlibrary.ProcessTools - * jdk.testlibrary.OutputAnalyzer + * @build jdk.test.lib.process.ProcessTools + * jdk.test.lib.process.OutputAnalyzer * jdk.test.lib.compiler.CompilerUtils * @run testng AllModulePath */ @@ -49,7 +49,7 @@ import java.util.spi.ToolProvider; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/test/jdk/tools/jlink/basic/BasicTest.java b/test/jdk/tools/jlink/basic/BasicTest.java --- a/test/jdk/tools/jlink/basic/BasicTest.java +++ b/test/jdk/tools/jlink/basic/BasicTest.java @@ -29,8 +29,8 @@ * @modules java.base/jdk.internal.module * jdk.jlink * jdk.compiler - * @build jdk.testlibrary.ProcessTools - * jdk.testlibrary.OutputAnalyzer + * @build jdk.test.lib.process.ProcessTools + * jdk.test.lib.process.OutputAnalyzer * JarUtils jdk.test.lib.compiler.CompilerUtils * @run main BasicTest */ @@ -46,8 +46,8 @@ import java.util.spi.ToolProvider; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; public class BasicTest { static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod") diff --git a/test/jdk/tools/jlink/bindservices/BindServices.java b/test/jdk/tools/jlink/bindservices/BindServices.java --- a/test/jdk/tools/jlink/bindservices/BindServices.java +++ b/test/jdk/tools/jlink/bindservices/BindServices.java @@ -34,7 +34,7 @@ import java.util.stream.Stream; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -43,9 +43,9 @@ /** * @test * @bug 8174826 - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler jdk.jlink - * @build BindServices jdk.testlibrary.ProcessTools + * @build BindServices jdk.test.lib.process.ProcessTools * jdk.test.lib.compiler.CompilerUtils * @run testng BindServices */ diff --git a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java --- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java +++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java @@ -31,7 +31,7 @@ import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.util.FileUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; @@ -40,12 +40,12 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler jdk.jlink * @build jdk.test.lib.compiler.CompilerUtils * jdk.test.lib.util.FileUtils * jdk.test.lib.Platform - * CompiledVersionTest jdk.testlibrary.ProcessTools + * CompiledVersionTest jdk.test.lib.process.ProcessTools * @run testng CompiledVersionTest */ diff --git a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java --- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java +++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java @@ -35,7 +35,7 @@ import jdk.test.lib.compiler.CompilerUtils; import jdk.test.lib.util.FileUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -51,7 +51,7 @@ * @build jdk.test.lib.compiler.CompilerUtils * jdk.test.lib.util.FileUtils * jdk.test.lib.Platform - * ModuleTargetHelper UserModuleTest jdk.testlibrary.ProcessTools + * ModuleTargetHelper UserModuleTest jdk.test.lib.process.ProcessTools * @run testng UserModuleTest */ diff --git a/test/jdk/tools/launcher/InfoStreams.java b/test/jdk/tools/launcher/InfoStreams.java --- a/test/jdk/tools/launcher/InfoStreams.java +++ b/test/jdk/tools/launcher/InfoStreams.java @@ -23,15 +23,14 @@ /** * @test - * @library /lib/testlibrary - * @build InfoStreams jdk.testlibrary.ProcessTools + * @library /test/lib + * @build InfoStreams jdk.test.lib.process.ProcessTools * @run main InfoStreams * @summary Test that informational options use the correct streams */ -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; - +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; public class InfoStreams { diff --git a/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java b/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java --- a/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java +++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTest.java @@ -23,9 +23,9 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler - * @build AddExportsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build AddExportsTest jdk.test.lib.compiler.CompilerUtils * @run testng AddExportsTest * @summary Basic tests for java --add-exports */ @@ -35,8 +35,8 @@ import java.util.stream.Stream; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.*; +import jdk.test.lib.process.OutputAnalyzer; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; diff --git a/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java b/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java --- a/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java +++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java @@ -25,11 +25,10 @@ * @test * @bug 8168836 * @summary Basic argument validation for --add-exports - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * @build jdk.test.lib.compiler.ModuleInfoMaker * jdk.test.lib.compiler.CompilerUtils - * jdk.testlibrary.* * @run testng AddExportsTestWarningError */ @@ -42,8 +41,8 @@ import java.util.stream.Stream; import jdk.test.lib.compiler.ModuleInfoMaker; -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.*; +import jdk.test.lib.process.OutputAnalyzer; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; diff --git a/test/jdk/tools/launcher/modules/addexports/manifest/AddExportsAndOpensInManifest.java b/test/jdk/tools/launcher/modules/addexports/manifest/AddExportsAndOpensInManifest.java --- a/test/jdk/tools/launcher/modules/addexports/manifest/AddExportsAndOpensInManifest.java +++ b/test/jdk/tools/launcher/modules/addexports/manifest/AddExportsAndOpensInManifest.java @@ -24,6 +24,7 @@ /** * @test * @library /lib/testlibrary + * @library /test/lib * @modules jdk.compiler * @build AddExportsAndOpensInManifest Test2 JarUtils jdk.testlibrary.* * @compile --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED Test1.java @@ -39,8 +40,8 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; -import jdk.testlibrary.OutputAnalyzer; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/addmods/AddModsTest.java b/test/jdk/tools/launcher/modules/addmods/AddModsTest.java --- a/test/jdk/tools/launcher/modules/addmods/AddModsTest.java +++ b/test/jdk/tools/launcher/modules/addmods/AddModsTest.java @@ -23,10 +23,10 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.jlink/jdk.tools.jmod * jdk.compiler - * @build AddModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build AddModsTest jdk.test.lib.compiler.CompilerUtils * @run testng AddModsTest * @summary Basic test for java --add-modules */ @@ -36,7 +36,7 @@ import java.nio.file.Paths; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java b/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java --- a/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java +++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java @@ -25,7 +25,7 @@ * @test * @library /lib/testlibrary /test/lib * @modules jdk.compiler - * @build AddReadsTest JarUtils jdk.testlibrary.* + * @build AddReadsTest JarUtils * jdk.test.lib.compiler.CompilerUtils * @run testng AddReadsTest * @summary Basic tests for java --add-reads @@ -35,8 +35,8 @@ import java.nio.file.Paths; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.*; +import jdk.test.lib.process.OutputAnalyzer; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; diff --git a/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java b/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java --- a/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java +++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java @@ -25,11 +25,10 @@ * @test * @bug 8168836 * @summary Basic argument validation for --add-reads - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * @build jdk.test.lib.compiler.ModuleInfoMaker * @build jdk.test.lib.compiler.CompilerUtils - * @build jdk.testlibrary.* * @build AddReadsTestWarningError * @run testng AddReadsTestWarningError */ @@ -43,8 +42,8 @@ import java.util.stream.Stream; import jdk.test.lib.compiler.ModuleInfoMaker; -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.*; +import jdk.test.lib.process.OutputAnalyzer; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; diff --git a/test/jdk/tools/launcher/modules/basic/BasicTest.java b/test/jdk/tools/launcher/modules/basic/BasicTest.java --- a/test/jdk/tools/launcher/modules/basic/BasicTest.java +++ b/test/jdk/tools/launcher/modules/basic/BasicTest.java @@ -23,11 +23,11 @@ /** * @test - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * jdk.jartool * jdk.jlink - * @build BasicTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build BasicTest jdk.test.lib.compiler.CompilerUtils * @run testng BasicTest * @summary Basic test of starting an application as a module */ @@ -39,7 +39,7 @@ import java.util.spi.ToolProvider; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/basic/InitErrors.java b/test/jdk/tools/launcher/modules/basic/InitErrors.java --- a/test/jdk/tools/launcher/modules/basic/InitErrors.java +++ b/test/jdk/tools/launcher/modules/basic/InitErrors.java @@ -23,8 +23,8 @@ /** * @test - * @library /lib/testlibrary - * @build InitErrors jdk.testlibrary.* + * @library /test/lib + * @build InitErrors * @run testng InitErrors * @summary Basic test to ensure that module system initialization errors * go the right stream and with the right level of verbosity @@ -32,8 +32,8 @@ import java.util.Arrays; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; import org.testng.annotations.Test; import static org.testng.Assert.*; diff --git a/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java b/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java --- a/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java +++ b/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java @@ -29,24 +29,27 @@ import java.util.List; import java.util.Map; import java.util.spi.ToolProvider; +import java.util.stream.Stream; +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.Platform; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.OutputAnalyzer; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.testng.Assert.assertTrue; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; /** * @test * @bug 8168205 * @summary Test the default class path if -Djava.class.path is set - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * jdk.jartool - * @build jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build jdk.test.lib.compiler.CompilerUtils * @run testng JavaClassPathTest */ @@ -197,28 +200,27 @@ } private OutputAnalyzer execute(List options) throws Throwable { - ProcessBuilder pb = createJavaProcessBuilder( - options.stream() - .map(this::autoQuote) - .toArray(String[]::new) + // can't use ProcessTools.createJavaProcessBuilder as it always adds -cp + ProcessBuilder pb = new ProcessBuilder( + Stream.concat(Stream.of(JDKToolFinder.getTestJDKTool("java")), + options.stream() + .map(this::autoQuote)) + .toArray(String[]::new) ); Map env = pb.environment(); // remove CLASSPATH environment variable - String value = env.remove("CLASSPATH"); + env.remove("CLASSPATH"); return executeCommand(pb) .outputTo(System.out) .errorTo(System.out); } - private static final boolean IS_WINDOWS - = System.getProperty("os.name").startsWith("Windows"); - /* * Autoquote empty string argument on Windows */ private String autoQuote(String arg) { - if (IS_WINDOWS && arg.isEmpty()) { + if (Platform.isWindows() && arg.isEmpty()) { return "\"\""; } return arg; diff --git a/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java b/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java --- a/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java +++ b/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java @@ -24,13 +24,13 @@ /** * @test * @modules java.xml - * @library /lib/testlibrary - * @build DescribeModuleTest jdk.testlibrary.* + * @library /test/lib + * @build DescribeModuleTest * @run testng DescribeModuleTest * @summary Basic test for java --describe-module */ -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.Test; import static org.testng.Assert.*; diff --git a/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java b/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java --- a/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java +++ b/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java @@ -24,10 +24,10 @@ /** * @test * @bug 8159596 - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules jdk.compiler * jdk.jartool - * @build DryRunTest jdk.testlibrary.ProcessTools + * @build DryRunTest jdk.test.lib.process.ProcessTools * jdk.test.lib.compiler.CompilerUtils * @run testng DryRunTest * @summary Test java --dry-run @@ -41,7 +41,7 @@ import java.util.spi.ToolProvider; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java b/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java --- a/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java +++ b/test/jdk/tools/launcher/modules/illegalaccess/IllegalAccessTest.java @@ -29,7 +29,6 @@ * @library /test/lib /lib/testlibrary modules * @build IllegalAccessTest TryAccess JarUtils * jdk.test.lib.compiler.CompilerUtils - * jdk.testlibrary.* * @build m/* * @run testng/othervm/timeout=180 IllegalAccessTest * @summary Basic test for java --illegal-access=$VALUE @@ -45,8 +44,8 @@ import java.util.stream.Stream; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java --- a/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java +++ b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java @@ -24,9 +24,9 @@ /** * @test * @requires !vm.graal.enabled - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules java.desktop java.logging jdk.compiler - * @build LimitModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build LimitModsTest jdk.test.lib.compiler.CompilerUtils * @run testng LimitModsTest * @summary Basic tests for java --limit-modules */ @@ -35,7 +35,7 @@ import java.nio.file.Paths; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/listmods/ListModsTest.java b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java --- a/test/jdk/tools/launcher/modules/listmods/ListModsTest.java +++ b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java @@ -24,9 +24,9 @@ /** * @test * @requires !vm.graal.enabled - * @library /lib/testlibrary /test/lib + * @library /test/lib * @modules java.se - * @build ListModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.* + * @build ListModsTest jdk.test.lib.compiler.CompilerUtils * @run testng ListModsTest * @summary Basic test for java --list-modules */ @@ -35,8 +35,8 @@ import java.nio.file.Paths; import jdk.test.lib.compiler.CompilerUtils; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java b/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java --- a/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java +++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java @@ -26,7 +26,7 @@ * @library /lib/testlibrary /test/lib * @modules jdk.compiler * jdk.naming.dns - * @build PatchTest JarUtils jdk.testlibrary.* + * @build PatchTest JarUtils * jdk.test.lib.compiler.CompilerUtils * @run testng PatchTest * @summary Basic test for --patch-module @@ -40,7 +40,7 @@ import java.util.stream.Stream; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; diff --git a/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java b/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java --- a/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java +++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java @@ -27,7 +27,7 @@ * @summary Basic argument validation for --patch-module * @library /lib/testlibrary /test/lib * @modules jdk.compiler - * @build PatchTestWarningError JarUtils jdk.testlibrary.* + * @build PatchTestWarningError JarUtils * jdk.test.lib.compiler.CompilerUtils * @run testng PatchTestWarningError */ @@ -40,7 +40,7 @@ import java.util.stream.Stream; import jdk.test.lib.compiler.CompilerUtils; -import static jdk.testlibrary.ProcessTools.*; +import static jdk.test.lib.process.ProcessTools.*; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; diff --git a/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java b/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java --- a/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java +++ b/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java @@ -47,7 +47,7 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import static jdk.testlibrary.ProcessTools.executeCommand; +import static jdk.test.lib.process.ProcessTools.executeCommand; import static org.testng.Assert.*; public class PatchSystemModules { diff --git a/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java --- a/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java +++ b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java @@ -25,13 +25,13 @@ * @test * @requires !vm.graal.enabled * @modules jdk.jdeps jdk.zipfs - * @library /lib/testlibrary - * @build ShowModuleResolutionTest jdk.testlibrary.* + * @library /test/lib + * @build ShowModuleResolutionTest * @run testng ShowModuleResolutionTest * @summary Basic test for java --show-module-resolution */ -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; import org.testng.annotations.Test; import static org.testng.Assert.*; diff --git a/test/jdk/tools/launcher/modules/validate/ValidateModulesTest.java b/test/jdk/tools/launcher/modules/validate/ValidateModulesTest.java --- a/test/jdk/tools/launcher/modules/validate/ValidateModulesTest.java +++ b/test/jdk/tools/launcher/modules/validate/ValidateModulesTest.java @@ -25,8 +25,8 @@ * @test * @bug 8178380 8194937 * @modules java.xml - * @library src /lib/testlibrary - * @build ValidateModulesTest hello/* JarUtils jdk.testlibrary.* + * @library src /lib/testlibrary /test/lib + * @build ValidateModulesTest hello/* JarUtils * @run testng ValidateModulesTest * @summary Basic test for java --validate-modules */ @@ -36,8 +36,8 @@ import java.nio.file.Files; import java.nio.file.Path; -import jdk.testlibrary.ProcessTools; -import jdk.testlibrary.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; import org.testng.annotations.Test; import static org.testng.Assert.*; diff --git a/test/lib/jdk/test/lib/apps/LingeredApp.java b/test/lib/jdk/test/lib/apps/LingeredApp.java --- a/test/lib/jdk/test/lib/apps/LingeredApp.java +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java @@ -146,7 +146,7 @@ throw new RuntimeException("Process is still alive. Can't get its output."); } if (output == null) { - output = new OutputBuffer(stdoutBuffer.toString(), stderrBuffer.toString()); + output = OutputBuffer.of(stdoutBuffer.toString(), stderrBuffer.toString()); } return output; } diff --git a/test/lib/jdk/test/lib/dcmd/CommandExecutor.java b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java --- a/test/lib/jdk/test/lib/dcmd/CommandExecutor.java +++ b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java @@ -34,7 +34,7 @@ * Execute a diagnostic command * * @param cmd The diagnostic command to execute - * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command + * @return an {@link jdk.test.lib.process.OutputAnalyzer} encapsulating the output of the command * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the * Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in * stderr, regardless of the specific executor used. @@ -48,7 +48,7 @@ * * @param cmd The diagnostic command to execute * @param silent Do not print the command output - * @return an {@link jdk.testlibrary.OutputAnalyzer} encapsulating the output of the command + * @return an {@link jdk.test.lib.process.OutputAnalyzer} encapsulating the output of the command * @throws CommandExecutorException if there is an exception on the "calling side" while trying to execute the * Diagnostic Command. Exceptions thrown on the remote side are available as textual representations in * stderr, regardless of the specific executor used. diff --git a/test/lib/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java --- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java +++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java @@ -23,6 +23,8 @@ package jdk.test.lib.process; +import jdk.test.lib.Asserts; + import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; @@ -33,10 +35,7 @@ public final class OutputAnalyzer { - private final String stdout; - private final String stderr; - private final int exitValue; - + private final OutputBuffer buffer; /** * Create an OutputAnalyzer, a utility class for verifying output and exit * value from a Process @@ -45,10 +44,7 @@ * @throws IOException If an I/O error occurs. */ public OutputAnalyzer(Process process) throws IOException { - OutputBuffer output = ProcessTools.getOutput(process); - exitValue = process.exitValue(); - this.stdout = output.getStdout(); - this.stderr = output.getStderr(); + buffer = OutputBuffer.of(process); } /** @@ -57,7 +53,7 @@ * @param buf String buffer to analyze */ public OutputAnalyzer(String buf) { - this(buf, buf); + buffer = OutputBuffer.of(buf, buf); } /** @@ -67,9 +63,7 @@ * @param stderr stderr buffer to analyze */ public OutputAnalyzer(String stdout, String stderr) { - this.stdout = stdout; - this.stderr = stderr; - exitValue = -1; + buffer = OutputBuffer.of(stdout, stderr); } /** @@ -145,6 +139,8 @@ * @throws RuntimeException If the string was not found */ public OutputAnalyzer shouldContain(String expectedString) { + String stdout = getStdout(); + String stderr = getStderr(); if (!stdout.contains(expectedString) && !stderr.contains(expectedString)) { reportDiagnosticSummary(); throw new RuntimeException("'" + expectedString + "' missing from stdout/stderr \n"); @@ -159,6 +155,7 @@ * @throws RuntimeException If the string was not found */ public OutputAnalyzer stdoutShouldContain(String expectedString) { + String stdout = getStdout(); if (!stdout.contains(expectedString)) { reportDiagnosticSummary(); throw new RuntimeException("'" + expectedString + "' missing from stdout \n"); @@ -173,6 +170,7 @@ * @throws RuntimeException If the string was not found */ public OutputAnalyzer stderrShouldContain(String expectedString) { + String stderr = getStderr(); if (!stderr.contains(expectedString)) { reportDiagnosticSummary(); throw new RuntimeException("'" + expectedString + "' missing from stderr \n"); @@ -183,10 +181,12 @@ /** * Verify that the stdout and stderr contents of output buffer does not contain the string * - * @param expectedString String that the buffer should not contain + * @param notExpectedString String that the buffer should not contain * @throws RuntimeException If the string was found */ public OutputAnalyzer shouldNotContain(String notExpectedString) { + String stdout = getStdout(); + String stderr = getStderr(); if (stdout.contains(notExpectedString)) { reportDiagnosticSummary(); throw new RuntimeException("'" + notExpectedString + "' found in stdout \n"); @@ -204,6 +204,8 @@ * @throws RuntimeException If the stdout and stderr are not empty */ public OutputAnalyzer shouldBeEmpty() { + String stdout = getStdout(); + String stderr = getStderr(); if (!stdout.isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stdout was not empty"); @@ -218,10 +220,11 @@ /** * Verify that the stdout contents of output buffer does not contain the string * - * @param expectedString String that the buffer should not contain + * @param notExpectedString String that the buffer should not contain * @throws RuntimeException If the string was found */ public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) { + String stdout = getStdout(); if (stdout.contains(notExpectedString)) { reportDiagnosticSummary(); throw new RuntimeException("'" + notExpectedString + "' found in stdout \n"); @@ -232,10 +235,11 @@ /** * Verify that the stderr contents of output buffer does not contain the string * - * @param expectedString String that the buffer should not contain + * @param notExpectedString String that the buffer should not contain * @throws RuntimeException If the string was found */ public OutputAnalyzer stderrShouldNotContain(String notExpectedString) { + String stderr = getStderr(); if (stderr.contains(notExpectedString)) { reportDiagnosticSummary(); throw new RuntimeException("'" + notExpectedString + "' found in stderr \n"); @@ -247,15 +251,18 @@ * Verify that the stdout and stderr contents of output buffer matches * the pattern * - * @param pattern + * @param regexp * @throws RuntimeException If the pattern was not found */ - public OutputAnalyzer shouldMatch(String pattern) { - Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); - Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); + public OutputAnalyzer shouldMatch(String regexp) { + String stdout = getStdout(); + String stderr = getStderr(); + Pattern pattern = Pattern.compile(regexp, Pattern.MULTILINE); + Matcher stdoutMatcher = pattern.matcher(stdout); + Matcher stderrMatcher = pattern.matcher(stderr); if (!stdoutMatcher.find() && !stderrMatcher.find()) { reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + throw new RuntimeException("'" + regexp + "' missing from stdout/stderr \n"); } return this; @@ -265,14 +272,15 @@ * Verify that the stdout contents of output buffer matches the * pattern * - * @param pattern + * @param regexp * @throws RuntimeException If the pattern was not found */ - public OutputAnalyzer stdoutShouldMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); + public OutputAnalyzer stdoutShouldMatch(String regexp) { + String stdout = getStdout(); + Matcher matcher = Pattern.compile(regexp, Pattern.MULTILINE).matcher(stdout); if (!matcher.find()) { reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + throw new RuntimeException("'" + regexp + "' missing from stdout \n"); } return this; @@ -286,7 +294,7 @@ * @throws RuntimeException If the pattern was not found */ public OutputAnalyzer stderrShouldMatch(String pattern) { - + String stderr = getStderr(); Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); if (!matcher.find()) { reportDiagnosticSummary(); @@ -300,20 +308,23 @@ * Verify that the stdout and stderr contents of output buffer does not * match the pattern * - * @param pattern + * @param regexp * @throws RuntimeException If the pattern was found */ - public OutputAnalyzer shouldNotMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); + public OutputAnalyzer shouldNotMatch(String regexp) { + String stdout = getStdout(); + String stderr = getStderr(); + Pattern pattern = Pattern.compile(regexp, Pattern.MULTILINE); + Matcher matcher = pattern.matcher(stdout); if (matcher.find()) { reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + throw new RuntimeException("'" + regexp + "' found in stdout: '" + matcher.group() + "' \n"); } - matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); + matcher = pattern.matcher(stderr); if (matcher.find()) { reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + throw new RuntimeException("'" + regexp + "' found in stderr: '" + matcher.group() + "' \n"); } return this; @@ -323,14 +334,15 @@ * Verify that the stdout contents of output buffer does not match the * pattern * - * @param pattern + * @param regexp * @throws RuntimeException If the pattern was found */ - public OutputAnalyzer stdoutShouldNotMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); + public OutputAnalyzer stdoutShouldNotMatch(String regexp) { + String stdout = getStdout(); + Matcher matcher = Pattern.compile(regexp, Pattern.MULTILINE).matcher(stdout); if (matcher.find()) { reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + throw new RuntimeException("'" + regexp + "' found in stdout \n"); } return this; @@ -340,14 +352,15 @@ * Verify that the stderr contents of output buffer does not match the * pattern * - * @param pattern + * @param regexp * @throws RuntimeException If the pattern was found */ - public OutputAnalyzer stderrShouldNotMatch(String pattern) { - Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); + public OutputAnalyzer stderrShouldNotMatch(String regexp) { + String stderr = getStderr(); + Matcher matcher = Pattern.compile(regexp, Pattern.MULTILINE).matcher(stderr); if (matcher.find()) { reportDiagnosticSummary(); - throw new RuntimeException("'" + pattern + throw new RuntimeException("'" + regexp + "' found in stderr \n"); } return this; @@ -357,13 +370,16 @@ * Get the captured group of the first string matching the pattern. * stderr is searched before stdout. * - * @param pattern The multi-line pattern to match + * @param regexp The multi-line pattern to match * @param group The group to capture * @return The matched string or null if no match was found */ - public String firstMatch(String pattern, int group) { - Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); - Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout); + public String firstMatch(String regexp, int group) { + String stdout = getStdout(); + String stderr = getStderr(); + Pattern pattern = Pattern.compile(regexp, Pattern.MULTILINE); + Matcher stderrMatcher = pattern.matcher(stderr); + Matcher stdoutMatcher = pattern.matcher(stdout); if (stderrMatcher.find()) { return stderrMatcher.group(group); } @@ -425,8 +441,8 @@ */ public void reportDiagnosticSummary() { String msg = - " stdout: [" + stdout + "];\n" + - " stderr: [" + stderr + "]\n" + + " stdout: [" + getStdout() + "];\n" + + " stderr: [" + getStderr() + "]\n" + " exitValue = " + getExitValue() + "\n"; System.err.println(msg); @@ -458,7 +474,7 @@ * @return Content of the output buffer */ public String getOutput() { - return stdout + stderr; + return getStdout() + getStderr(); } /** @@ -467,7 +483,7 @@ * @return Content of the stdout buffer */ public String getStdout() { - return stdout; + return buffer.getStdout(); } /** @@ -476,7 +492,7 @@ * @return Content of the stderr buffer */ public String getStderr() { - return stderr; + return buffer.getStderr(); } /** @@ -485,7 +501,7 @@ * @return Process exit value */ public int getExitValue() { - return exitValue; + return buffer.getExitValue(); } /** @@ -512,6 +528,8 @@ * @throws RuntimeException If the stdout and stderr are not empty */ public OutputAnalyzer shouldBeEmptyIgnoreVMWarnings() { + String stdout = getStdout(); + String stderr = getStderr(); if (!stdout.isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stdout was not empty"); @@ -531,7 +549,7 @@ * @throws RuntimeException If the pattern was not found */ public OutputAnalyzer stderrShouldMatchIgnoreVMWarnings(String pattern) { - String stderr = this.stderr.replaceAll(jvmwarningmsg + "\\R", ""); + String stderr = getStderr().replaceAll(jvmwarningmsg + "\\R", ""); Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); if (!matcher.find()) { reportDiagnosticSummary(); @@ -548,10 +566,119 @@ * @return Contents of the output buffer as list of strings */ public List asLinesWithoutVMWarnings() { - return Arrays.asList(getOutput().split("\\R")) - .stream() - .filter(Pattern.compile(jvmwarningmsg).asPredicate().negate()) - .collect(Collectors.toList()); + return Arrays.stream(getOutput().split("\\R")) + .filter(Pattern.compile(jvmwarningmsg).asPredicate().negate()) + .collect(Collectors.toList()); + } + + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public int shouldMatchByLine(String pattern) { + return shouldMatchByLine(null, null, pattern); + } + + /** + * @see #stdoutShouldMatchByLine(String, String, String) + */ + public int stdoutShouldMatchByLine(String pattern) { + return stdoutShouldMatchByLine(null, null, pattern); + } + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public int shouldMatchByLineFrom(String from, String pattern) { + return shouldMatchByLine(from, null, pattern); + } + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public int shouldMatchByLineTo(String to, String pattern) { + return shouldMatchByLine(null, to, pattern); + } + + /** + * Verify that the stdout and stderr contents of output buffer match the + * {@code pattern} line by line. The whole output could be matched or + * just a subset of it. + * + * @param from + * The line from where output will be matched. + * Set {@code from} to null for matching from the first line. + * @param to + * The line until where output will be matched. + * Set {@code to} to null for matching until the last line. + * @param pattern + * Matching pattern + * @return Count of lines which match the {@code pattern} + */ + public int shouldMatchByLine(String from, String to, String pattern) { + return shouldMatchByLine(getOutput(), from, to, pattern); + } + + /** + * Verify that the stdout contents of output buffer matches the + * {@code pattern} line by line. The whole stdout could be matched or + * just a subset of it. + * + * @param from + * The line from where stdout will be matched. + * Set {@code from} to null for matching from the first line. + * @param to + * The line until where stdout will be matched. + * Set {@code to} to null for matching until the last line. + * @param pattern + * Matching pattern + * @return Count of lines which match the {@code pattern} + */ + public int stdoutShouldMatchByLine(String from, String to, String pattern) { + return shouldMatchByLine(getStdout(), from, to, pattern); + } + + private int shouldMatchByLine(String buffer, String from, String to, String pattern) { + List lines = asLines(buffer); + + int fromIndex = 0; + if (from != null) { + fromIndex = indexOf(lines, from); + Asserts.assertGreaterThan(fromIndex, -1, + "The line/pattern '" + from + "' from where the output should match can not be found"); + } + + int toIndex = lines.size(); + if (to != null) { + toIndex = indexOf(lines, to); + Asserts.assertGreaterThan(toIndex, -1, + "The line/pattern '" + to + "' until where the output should match can not be found"); + } + + List subList = lines.subList(fromIndex, toIndex); + int matchedCount = 0; + for (String line : subList) { + Asserts.assertTrue(line.matches(pattern), + "The line '" + line + "' does not match pattern '" + pattern + "'"); + matchedCount++; + } + + return matchedCount; + } + + /** + * Check if there is a line matching {@code pattern} and return its index + * + * @param pattern Matching pattern + * @return Index of first matching line + */ + private int indexOf(List lines, String pattern) { + for (int i = 0; i < lines.size(); i++) { + if (lines.get(i).matches(pattern)) { + return i; + } + } + return -1; } } diff --git a/test/lib/jdk/test/lib/process/OutputBuffer.java b/test/lib/jdk/test/lib/process/OutputBuffer.java --- a/test/lib/jdk/test/lib/process/OutputBuffer.java +++ b/test/lib/jdk/test/lib/process/OutputBuffer.java @@ -23,20 +23,18 @@ package jdk.test.lib.process; -public class OutputBuffer { - private final String stdout; - private final String stderr; +import java.io.ByteArrayOutputStream; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; - /** - * Create an OutputBuffer, a class for storing and managing stdout and stderr - * results separately - * - * @param stdout stdout result - * @param stderr stderr result - */ - public OutputBuffer(String stdout, String stderr) { - this.stdout = stdout; - this.stderr = stderr; +public interface OutputBuffer { + public static class OutputBufferException extends RuntimeException { + private static final long serialVersionUID = 8528687792643129571L; + + public OutputBufferException(Throwable cause) { + super(cause); + } } /** @@ -44,16 +42,103 @@ * * @return stdout result */ - public String getStdout() { - return stdout; - } - + public String getStdout(); /** * Returns the stderr result * * @return stderr result */ - public String getStderr() { - return stderr; + public String getStderr(); + public int getExitValue(); + + public static OutputBuffer of(Process p) { + return new LazyOutputBuffer(p); + } + + public static OutputBuffer of(String stdout, String stderr, int exitValue) { + return new EagerOutputBuffer(stdout, stderr, exitValue); + } + + public static OutputBuffer of(String stdout, String stderr) { + return of(stdout, stderr, -1); + } + + class LazyOutputBuffer implements OutputBuffer { + private final ByteArrayOutputStream stderrBuffer; + private final ByteArrayOutputStream stdoutBuffer; + private final Future outTask; + private final Future errTask; + private final Process p; + + private LazyOutputBuffer(Process p) { + this.p = p; + stderrBuffer = new ByteArrayOutputStream(); + stdoutBuffer = new ByteArrayOutputStream(); + outTask = new StreamPumper(p.getInputStream(), + stdoutBuffer).process(); + errTask = new StreamPumper(p.getErrorStream(), + stderrBuffer).process(); + } + + @Override + public String getStdout() { + try { + outTask.get(); + return stdoutBuffer.toString(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new OutputBufferException(e); + } catch (ExecutionException | CancellationException e) { + throw new OutputBufferException(e); + } + } + + @Override + public String getStderr() { + try { + errTask.get(); + return stderrBuffer.toString(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new OutputBufferException(e); + } catch (ExecutionException | CancellationException e) { + throw new OutputBufferException(e); + } + } + + @Override + public int getExitValue() { + try { + return p.waitFor(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new OutputBufferException(e); + } + } + } + + class EagerOutputBuffer implements OutputBuffer { + private final String stdout; + private final String stderr; + private final int exitValue; + + private EagerOutputBuffer(String stdout, String stderr, int exitValue) { + this.stdout = stdout; + this.stderr = stderr; + this.exitValue = exitValue; + } + + public String getStdout() { + return stdout; + } + + public String getStderr() { + return stderr; + } + + @Override + public int getExitValue() { + return exitValue; + } } } diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -23,7 +23,6 @@ package jdk.test.lib.process; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -65,50 +64,6 @@ } /** - * Pumps stdout and stderr from running the process into a String. - * - * @param processBuilder ProcessBuilder to run. - * @return Output from process. - * @throws IOException If an I/O error occurs. - */ - public static OutputBuffer getOutput(ProcessBuilder processBuilder) throws IOException { - return getOutput(privilegedStart(processBuilder)); - } - - /** - * Pumps stdout and stderr the running process into a String. - * - * @param process Process to pump. - * @return Output from process. - * @throws IOException If an I/O error occurs. - */ - public static OutputBuffer getOutput(Process process) throws IOException { - ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream(); - ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream(); - StreamPumper outPumper = new StreamPumper(process.getInputStream(), stdoutBuffer); - StreamPumper errPumper = new StreamPumper(process.getErrorStream(), stderrBuffer); - Thread outPumperThread = new Thread(outPumper); - Thread errPumperThread = new Thread(errPumper); - - outPumperThread.setDaemon(true); - errPumperThread.setDaemon(true); - - outPumperThread.start(); - errPumperThread.start(); - - try { - process.waitFor(); - outPumperThread.join(); - errPumperThread.join(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return null; - } - - return new OutputBuffer(stdoutBuffer.toString(), stderrBuffer.toString()); - } - - /** *

Starts a process from its builder.

* The default redirects of STDOUT and STDERR are started * @param name The process name @@ -392,11 +347,32 @@ * @return The {@linkplain OutputAnalyzer} instance wrapping the process. */ public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception { + return executeProcess(pb, null); + } + + /** + * Executes a process, pipe some text into its STDIN, waits for it + * to finish and returns the process output. The process will have exited + * before this method returns. + * @param pb The ProcessBuilder to execute. + * @param input The text to pipe into STDIN. Can be null. + * @return The {@linkplain OutputAnalyzer} instance wrapping the process. + */ + public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input) throws Exception { + + OutputAnalyzer output = null; Process p = null; boolean failed = false; try { p = privilegedStart(pb); + if (input != null) { + try (PrintStream ps = new PrintStream(p.getOutputStream())) { + ps.print(input); + ps.flush(); + } + } + output = new OutputAnalyzer(p); p.waitFor();