diff --git a/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java b/test/hotspot/jtreg/runtime/appcds/jigsaw/modulepath/AddModules.java index 0fbc5bdf3d8..2472eb619cb 100644 --- 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.Path; 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 index 8ac55234186..0ab0dfb86ff 100644 --- 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.Path; 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 index 06bb1410742..6f8a9efa967 100644 --- 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.Path; 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 index 2ceb64dc8df..d8c463e75b2 100644 --- 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 java.nio.file.Paths; 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 index eb10af62796..ccbcc99b066 100644 --- 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 java.util.Arrays; 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 index 990d7ed41d3..ac4f8a137e1 100644 --- 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.Path; 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 index e8a349b46e1..68f28701cdc 100644 --- a/test/jdk/com/sun/jdi/BadAgentPath.java +++ b/test/jdk/com/sun/jdi/BadAgentPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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 index 89e05e08c94..8e76b6314ec 100644 --- a/test/jdk/com/sun/jdi/BadHandshakeTest.java +++ b/test/jdk/com/sun/jdi/BadHandshakeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -37,12 +37,13 @@ import java.util.concurrent.TimeUnit; 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 index be3b8d8ffdc..7eb286bda6d 100644 --- a/test/jdk/com/sun/jdi/DoubleAgentTest.java +++ b/test/jdk/com/sun/jdi/DoubleAgentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -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 @@ import jdk.testlibrary.Utils; * @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 index 9a648f35b4d..3977891fe29 100644 --- a/test/jdk/com/sun/jdi/ExclusiveBind.java +++ b/test/jdk/com/sun/jdi/ExclusiveBind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -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.List; 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 index 2927dd32ead..df648da84d2 100644 --- a/test/jdk/com/sun/jdi/NoLaunchOptionTest.java +++ b/test/jdk/com/sun/jdi/NoLaunchOptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -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 @@ import jdk.testlibrary.ProcessTools; * @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 index 29a08909740..ea6647d1e9d 100644 --- a/test/jdk/com/sun/jdi/ProcessAttachTest.java +++ b/test/jdk/com/sun/jdi/ProcessAttachTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -25,7 +25,7 @@ import java.io.IOException; 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 @@ import com.sun.jdi.connect.IllegalConnectorArgumentsException; * @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 index 4ace70d4ea9..ff3a9ed83ba 100644 --- a/test/jdk/com/sun/jdi/RunToExit.java +++ b/test/jdk/com/sun/jdi/RunToExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -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.List; 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 index 346dcca8923..98b32063c74 100644 --- a/test/jdk/com/sun/jdi/SuspendNoFlagTest.java +++ b/test/jdk/com/sun/jdi/SuspendNoFlagTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -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 index 9b67b1749d9..dc3061fb620 100644 --- a/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java +++ b/test/jdk/com/sun/jdi/cds/CDSBreakpointTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 index 8d95e4bf128..8723107233a 100644 --- a/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java +++ b/test/jdk/com/sun/jdi/cds/CDSDeleteAllBkptsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 index b170fd8a1da..d47a5ffdf2b 100644 --- a/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java +++ b/test/jdk/com/sun/jdi/cds/CDSFieldWatchpoints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 index f935b37c660..7d757eeab22 100644 --- a/test/jdk/com/sun/jdi/cds/CDSJDITest.java +++ b/test/jdk/com/sun/jdi/cds/CDSJDITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index e1199716207..08d57fdaba6 100644 --- 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.InputStream; 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 index ac8e4f9c2a9..06d2ed487d9 100644 --- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java +++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -29,7 +29,7 @@ import java.lang.management.*; 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 index 930b69333ee..8d942e5081c 100644 --- 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 com.sun.management.OperatingSystemMXBean; 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 index 2a25bbd9e17..836f7378f26 100644 --- 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.List; 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 index f0be773d2b8..909619707ee 100644 --- 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.VirtualMachine; 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 index 581881c93b0..a81bed051c5 100644 --- 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 index dadc6fc981e..136bd158f0b 100644 --- a/test/jdk/com/sun/tools/attach/RunnerUtil.java +++ b/test/jdk/com/sun/tools/attach/RunnerUtil.java @@ -27,7 +27,7 @@ import java.nio.file.Files; 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 index 2afb9b7c279..403c0b3669c 100644 --- a/test/jdk/com/sun/tools/attach/StartManagementAgent.java +++ b/test/jdk/com/sun/tools/attach/StartManagementAgent.java @@ -46,7 +46,7 @@ import jdk.testlibrary.Utils; * 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 index 99bb2d00690..03554339fb9 100644 --- a/test/jdk/com/sun/tools/attach/TempDirTest.java +++ b/test/jdk/com/sun/tools/attach/TempDirTest.java @@ -30,8 +30,8 @@ import java.util.List; 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 index 74aeda92932..0519e1483f0 100644 --- a/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java +++ b/test/jdk/java/io/BufferedInputStream/LargeCopyWithMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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.BufferedInputStream; 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 index ad14b3969c8..218aaeb5252 100644 --- a/test/jdk/java/lang/Class/forName/modules/TestDriver.java +++ b/test/jdk/java/lang/Class/forName/modules/TestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -31,7 +31,7 @@ import java.util.stream.Stream; 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 @@ import static org.testng.Assert.assertTrue; * @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 index 0e031957a15..ebb8b29818e 100644 --- a/test/jdk/java/lang/Class/getResource/ResourcesTest.java +++ b/test/jdk/java/lang/Class/getResource/ResourcesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 @@ import static org.testng.Assert.*; /** * @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 index a0357b4c21a..d5cedde55a8 100644 --- a/test/jdk/java/lang/ClassLoader/EndorsedDirs.java +++ b/test/jdk/java/lang/ClassLoader/EndorsedDirs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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 index 0b80bcdf110..a5308c531a2 100644 --- a/test/jdk/java/lang/ClassLoader/ExtDirs.java +++ b/test/jdk/java/lang/ClassLoader/ExtDirs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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 index 1308c3e7ae0..e827c911027 100644 --- a/test/jdk/java/lang/ClassLoader/GetDotResource.java +++ b/test/jdk/java/lang/ClassLoader/GetDotResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -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.io.IOException; 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 index 56152b5907f..25967bca620 100644 --- a/test/jdk/java/lang/ClassLoader/GetSystemPackage.java +++ b/test/jdk/java/lang/ClassLoader/GetSystemPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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.Attributes; 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 index cfac73a7cb6..430a3e5a8ad 100644 --- a/test/jdk/java/lang/ClassLoader/getResource/GetResource.java +++ b/test/jdk/java/lang/ClassLoader/getResource/GetResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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.Collectors; 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 index da56df06291..3797820fb13 100644 --- a/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java +++ b/test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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.nio.file.Paths; 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 index ddc9d71baf3..6daa8a0bc25 100644 --- a/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java +++ b/test/jdk/java/lang/ClassLoader/getResource/modules/ResourcesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 @@ import static org.testng.Assert.*; /** * @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 index 38033ed1e15..5524ff8809e 100644 --- a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java +++ b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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.Collections; 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 index eb600f93736..60c08735da7 100644 --- a/test/jdk/java/lang/ModuleTests/access/AccessTest.java +++ b/test/jdk/java/lang/ModuleTests/access/AccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -27,7 +27,7 @@ import java.util.Arrays; 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 @@ import static org.testng.Assert.*; /** * @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 index 51488ab4558..4a4751ee61d 100644 --- a/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java +++ b/test/jdk/java/lang/Runtime/shutdown/ShutdownInterruptedMain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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 index 0eb0b2bdc46..f1b352f7cb1 100644 --- a/test/jdk/java/lang/StackWalker/CallerFromMain.java +++ b/test/jdk/java/lang/StackWalker/CallerFromMain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 index 912d0c21f21..b1bb6d7a6fa 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/Base.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/Base.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -35,7 +35,7 @@ import java.util.stream.Stream; 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 index 3f2437b24f6..08bd4dd92e0 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 19e10e97d22..2b3bd182f7e 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 804b1f3dcfb..939b4a031b1 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index ee6f62e377e..6f4a16a3465 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 881aaa077ba..5ae4d0be885 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 9b9878d5e46..00f3a053604 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index e5cf8751f67..95d546988bf 100644 --- a/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 6faad256e83..dcfea43f617 100644 --- 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 index 3b1b985020c..6d6b7614315 100644 --- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java +++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThread.java @@ -1,6 +1,6 @@ /* * Copyright 2014 Goldman Sachs. - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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 index 2bf3e6fd687..7dca12ebe45 100644 --- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java +++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java @@ -1,6 +1,6 @@ /* * Copyright 2014 Goldman Sachs. - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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 index a59b6b77ced..81e7d303823 100644 --- a/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java +++ b/test/jdk/java/lang/instrument/PremainClass/NoPremainAgentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 @@ import jdk.testlibrary.Utils; * @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 index e717bce7076..4ff0e9245bb 100644 --- a/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java +++ b/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 @@ import jdk.testlibrary.Utils; * @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 index 3423f7c646a..4f32f3c0254 100644 --- a/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java +++ b/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 @@ import jdk.testlibrary.Utils; * @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 index 1fc82d7e802..7a401874b89 100644 --- a/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java +++ b/test/jdk/java/lang/instrument/executableJAR/ExecJarWithAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 java.util.stream.Stream; 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 index 78c5e615330..9eb3cff391b 100644 --- a/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java +++ b/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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 @@ import static jdk.testlibrary.ProcessTools.*; 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 index 2348b51cc68..dd3afacc6ee 100644 --- 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.*; 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 index 24761131484..28fd7bd4491 100644 --- a/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java +++ b/test/jdk/java/lang/management/MemoryMXBean/RunUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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 index e1b22781ad3..de03e433b3d 100644 --- a/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java +++ b/test/jdk/java/lang/reflect/Proxy/ProxyClassAccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -30,7 +30,7 @@ import java.util.Arrays; 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 @@ import static org.testng.Assert.*; /** * @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 index 9623f919ea5..fd4b266f128 100644 --- a/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java +++ b/test/jdk/java/lang/reflect/Proxy/ProxyLayerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -30,7 +30,7 @@ import java.nio.file.Paths; 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 @@ import static org.testng.Assert.*; /** * @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 index 8dd08e1315e..aada3f9875b 100644 --- a/test/jdk/java/lang/reflect/Proxy/ProxyTest.java +++ b/test/jdk/java/lang/reflect/Proxy/ProxyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -27,7 +27,7 @@ import java.util.Arrays; 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 @@ import static org.testng.Assert.*; /** * @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 index f7cfd0de3ff..263557e93fe 100644 --- a/test/jdk/java/nio/file/spi/SetDefaultProvider.java +++ b/test/jdk/java/nio/file/spi/SetDefaultProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -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.Path; 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 index 08fa2cdc4c3..6fcf9a4753e 100644 --- a/test/jdk/java/rmi/module/ModuleTest.java +++ b/test/jdk/java/rmi/module/ModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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 index 265e52ae981..0260ad14118 100644 --- 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 index 5d2da442df2..a330a57a101 100644 --- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java +++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -26,7 +26,7 @@ import java.io.IOException; 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 @@ import java.util.List; * @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 index f9016287c9b..ebf646b2912 100644 --- a/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java +++ b/test/jdk/java/security/KeyStore/PKCS12/KeytoolWriteP12Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -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 @@ import static java.lang.System.out; * @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 index 1bd2a5c2346..ece59d6bcc5 100644 --- a/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java +++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataEmptyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -40,6 +40,7 @@ import static java.lang.System.out; * @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 index e9d7119caf5..ff779a68307 100644 --- a/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java +++ b/test/jdk/java/security/KeyStore/PKCS12/MetadataStoreLoadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -44,6 +44,7 @@ import java.util.HashSet; * @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 index f2cdc6ea574..deb8f973250 100644 --- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java +++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertAPITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -43,6 +43,7 @@ import static java.lang.System.out; * 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 index 9575a888d93..677225498f0 100644 --- a/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java +++ b/test/jdk/java/security/KeyStore/PKCS12/StoreTrustedCertKeytool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -30,7 +30,7 @@ import java.security.KeyStoreException; 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 @@ import static java.lang.System.out; * @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 index 3716ac11829..1c0e88dc329 100644 --- a/test/jdk/java/security/KeyStore/PKCS12/Utils.java +++ b/test/jdk/java/security/KeyStore/PKCS12/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -32,8 +32,8 @@ import java.security.NoSuchAlgorithmException; 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 index c851f6d5c3f..30cfdb0a226 100644 --- a/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java +++ b/test/jdk/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -26,14 +26,14 @@ import java.io.File; 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 index 715a96c4e1d..76d14f6a95d 100644 --- a/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java +++ b/test/jdk/java/security/Policy/SignedJar/SignedJarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -28,13 +28,13 @@ import java.security.AccessControlException; 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 index 103ea817fea..3cee0867747 100644 --- 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.Arrays; 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 index 102655bec44..905fc9a79c8 100644 --- 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 index 576b55d5cda..5f654b99938 100644 --- a/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java +++ b/test/jdk/java/util/ResourceBundle/modules/cache/CacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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 index e0e76ff42de..914ebf6bbf0 100644 --- a/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java +++ b/test/jdk/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 43e4abe4c9a..e85fd7d1933 100644 --- a/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java +++ b/test/jdk/java/util/ResourceBundle/modules/security/TestPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -27,7 +27,7 @@ import java.util.Arrays; 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 @@ import static org.testng.Assert.*; /** * @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 index 394e23dac19..10a01c70a62 100644 --- a/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java +++ b/test/jdk/java/util/logging/TestLoggerWeakRefLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -26,7 +26,7 @@ import java.io.InputStream; 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 @@ import sun.tools.attach.HotSpotVirtualMachine; * @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 index 5167a21ee1d..af7b4c9b945 100644 --- a/test/jdk/java/util/logging/modules/GetResourceBundleTest.java +++ b/test/jdk/java/util/logging/modules/GetResourceBundleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -29,17 +29,17 @@ import org.testng.annotations.BeforeClass; 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 index b59980f53ec..68b86e50ece 100644 --- 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.ZipFile; 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 index 6630db062da..e1e8c7f5d53 100644 --- a/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java +++ b/test/jdk/javax/management/mxbean/MXBeanWeirdParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -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.SimpleType; 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 index 42165452147..b1fa4fcefd8 100644 --- a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java +++ b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.JMXConnector; 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 index e511ab0b454..12e17dc31ae 100644 --- a/test/jdk/javax/management/security/AuthorizationTest.java +++ b/test/jdk/javax/management/security/AuthorizationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -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.remote.JMXServiceURL; 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 index c9756d2896a..fc703849e6e 100644 --- a/test/jdk/javax/management/security/SecurityTest.java +++ b/test/jdk/javax/management/security/SecurityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -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 javax.rmi.ssl.SslRMIServerSocketFactory; 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 index 2718e7a4b33..e3a9abb4581 100644 --- a/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java +++ b/test/jdk/javax/security/auth/Subject/doAs/NestedActions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -41,7 +41,7 @@ import java.util.jar.JarOutputStream; 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 @@ import jdk.testlibrary.ProcessTools; * 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 index f45d9f7dd01..bcf3eda476d 100644 --- a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java +++ b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.Arrays; 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 index 42ab87ebf92..9f837f47abb 100644 --- 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 index 91aad2fd089..25ff746529b 100644 --- a/test/jdk/jdk/modules/incubator/DefaultImage.java +++ b/test/jdk/jdk/modules/incubator/DefaultImage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.BeforeTest; 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 index e569a175acc..b69c4022f13 100644 --- a/test/jdk/jdk/modules/incubator/ImageModules.java +++ b/test/jdk/jdk/modules/incubator/ImageModules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.DataProvider; 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 index 6d649e22429..254020273a8 100644 --- a/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java +++ b/test/jdk/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.Path; 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 index a0fe776408d..48d4b01ab6d 100644 --- a/test/jdk/jdk/modules/scenarios/container/ContainerTest.java +++ b/test/jdk/jdk/modules/scenarios/container/ContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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.Path; 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 index fb36288aeec..bf820b09d78 100644 --- a/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java +++ b/test/jdk/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.Arrays; 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 index 57c3db88303..123a3640538 100644 --- a/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java +++ b/test/jdk/lib/testlibrary/OutputAnalyzerReportingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index f8c31eed27f..7a252e62445 100644 --- a/test/jdk/lib/testlibrary/OutputAnalyzerTest.java +++ b/test/jdk/lib/testlibrary/OutputAnalyzerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 { @@ -150,17 +151,23 @@ public class OutputAnalyzerTest { // expected } - if (output.shouldMatchByLine(byLinePattern) != 1) { - throw new Exception("shouldMatchByLine() should find one line"); + try { + output.shouldMatchByLine(byLinePattern); + } catch (RuntimeException e) { + throw new Exception("shouldMatchByLine() failed", e); } + try { output.shouldMatchByLine(nonExistingPattern); throw new Exception("shouldMatchByLine() failed to throw exception"); } catch (RuntimeException e) { // expected } - if (output.stdoutShouldMatchByLine(stdoutByLinePattern) != 1) { - throw new Exception("stdoutShouldMatchByLine() should find one line"); + + try { + output.stdoutShouldMatchByLine(stdoutByLinePattern); + } catch (RuntimeException e) { + throw new Exception("stdoutShouldMatchByLine() failed", e); } // Should not match diff --git a/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java b/test/jdk/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java deleted file mode 100644 index 5c2c6b27f0a..00000000000 --- 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 index 9759f22b9e9..00000000000 --- 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 index 461977302ed..00000000000 --- 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 index 1107563738f..00000000000 --- 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 index ff487a1892e..fc3953f2e24 100644 --- a/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java +++ b/test/jdk/native_sanity/simplenativelauncher/ProgramTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 index c759c01c99a..3a1c425dfee 100644 --- a/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java +++ b/test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -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.Set; 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 @@ import sun.jvmstat.monitor.event.VmStatusChangeEvent; * @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 index f55d0c8b671..e54e8a7b9b2 100644 --- a/test/jdk/sun/management/jdp/DynamicLauncher.java +++ b/test/jdk/sun/management/jdp/DynamicLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index 2f407470c23..669d16150f9 100644 --- a/test/jdk/sun/management/jdp/JdpDefaultsTest.java +++ b/test/jdk/sun/management/jdp/JdpDefaultsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index b5d04d5bace..ece4581d13a 100644 --- a/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java +++ b/test/jdk/sun/management/jdp/JdpJmxRemoteDynamicPortTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 2f50e8416ef..7b1fcbcf81d 100644 --- a/test/jdk/sun/management/jdp/JdpOffTest.java +++ b/test/jdk/sun/management/jdp/JdpOffTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index f628e54df00..148a9293802 100644 --- a/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java +++ b/test/jdk/sun/management/jdp/JdpSpecificAddressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index fb82f0d8738..628ce68ed93 100644 --- a/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java +++ b/test/jdk/sun/management/jdp/PortAlreadyInUseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index 9302b632e1c..4a755808e5d 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index 8f4b5537f0c..880edd756b0 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -35,19 +35,18 @@ import java.util.Set; 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 index a4e44370221..6899c014b9f 100644 --- 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.List; 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 @@ import jdk.testlibrary.ProcessTools; * @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 index 909fedd4b3b..734790ea4ad 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -27,7 +27,7 @@ import java.util.ArrayList; 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 @@ import jdk.testlibrary.Utils; * 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 index 1aeaeb7c3ec..f19e9286859 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 @@ import java.util.regex.Pattern; * @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 index 90c2e27d071..9afc6865b1b 100644 --- a/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java +++ b/test/jdk/sun/management/jmxremote/startstop/JMXStartStopTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -44,7 +44,7 @@ import javax.management.*; 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 @@ import jdk.internal.agent.ConnectorAddressLink; * 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 index 14298f8e568..214523d2ab6 100644 --- a/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java +++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusPerfCountersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -32,7 +32,7 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** @@ -43,6 +43,7 @@ import jdk.testlibrary.ProcessTools; * 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 index ddc951bf081..d3f66418c7c 100644 --- a/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java +++ b/test/jdk/sun/management/jmxremote/startstop/JMXStatusTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -29,7 +29,7 @@ import java.util.regex.Pattern; import org.testng.annotations.*; import static org.testng.Assert.*; -import jdk.testlibrary.ProcessTools; +import jdk.test.lib.process.ProcessTools; /** * @test @@ -39,6 +39,7 @@ import jdk.testlibrary.ProcessTools; * 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 index 5a139bff815..01e875be146 100644 --- a/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java +++ b/test/jdk/sun/management/jmxremote/startstop/ManagementAgentJcmd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -34,7 +34,7 @@ import jdk.internal.agent.Agent; 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 index 208fcd84db6..861a1ee89e1 100644 --- a/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java +++ b/test/jdk/sun/security/krb5/auto/tools/KinitConfPlusProps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 index 369c8f97542..039bbefc180 100644 --- 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.KeyStore; 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 index d948b41218e..bfd84ad2303 100644 --- 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.SSLServerSocketFactory; 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.KeyStore; 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 index 79d9f1ad267..58d4b9da075 100644 --- a/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java +++ b/test/jdk/sun/security/tools/jarsigner/TsacertOptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index 0ab562593cb..2bde829c6a1 100644 --- a/test/jdk/sun/security/tools/jarsigner/Warning.java +++ b/test/jdk/sun/security/tools/jarsigner/Warning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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 index cea6a5f7e10..539b77969d9 100644 --- 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 index 819711e6374..39b20181a7c 100644 --- 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 index 8c3ea810c02..4cdb1376972 100644 --- a/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java +++ b/test/jdk/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -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 index bbf44babd61..d9135d53945 100644 --- 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 index d95ee2593a5..ac95cb6f797 100644 --- 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 @@ import java.nio.file.Paths; * @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 index 1a66cf03a1e..2d8ce4a7dec 100644 --- 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 index 780fd6359de..b30ed3b3395 100644 --- 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 index 53e00ab186b..efa3baa09a9 100644 --- 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 index 9d18707da5d..da4e212f165 100644 --- 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 index e94274935b4..d25984fec01 100644 --- 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 index 5cab7cb35fd..81f5c43aebc 100644 --- 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 index 9d5f59c7f11..7091afde88d 100644 --- 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 index 9ac994d96a9..ed2eec105c2 100644 --- 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 index e11d2cbb0d6..93846ed2da8 100644 --- 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 index c48624d3259..e43653c5446 100644 --- 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 @@ import jdk.testlibrary.Utils; * requests to a specific JVM process. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* * @run main TestJcmdDefaults @@ -90,12 +90,9 @@ public class TestJcmdDefaults { * 24428 com.sun.javatest.regtest.MainWrapper /tmp/jtreg/jtreg-workdir/classes/sun/tools/jcmd/TestJcmdDefaults.jta * * @param output The generated output from the jcmd. - * @throws Exception */ - private static void matchListedProcesses(OutputAnalyzer output) throws Exception { - int matchedCount = output.shouldMatchByLine(JCMD_LIST_REGEX); - assertGreaterThan(matchedCount , 0, - "Found no lines matching pattern: " + JCMD_LIST_REGEX); + private static void matchListedProcesses(OutputAnalyzer output) { + output.shouldMatchByLine(JCMD_LIST_REGEX); } private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException { diff --git a/test/jdk/sun/tools/jcmd/TestJcmdSanity.java b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java index 6fdaddfa7d1..88711f3ce73 100644 --- a/test/jdk/sun/tools/jcmd/TestJcmdSanity.java +++ b/test/jdk/sun/tools/jcmd/TestJcmdSanity.java @@ -30,8 +30,8 @@ import java.nio.file.Path; 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 @@ import jdk.testlibrary.Utils; * command requests to the current java process. * * @library /lib/testlibrary + * @library /test/lib * * @build jdk.testlibrary.* * @run main/othervm -XX:+UsePerfData TestJcmdSanity @@ -134,12 +135,10 @@ public class TestJcmdSanity { * @param output The generated output from the jcmd. * @throws Exception */ - private static void matchJcmdCommands(OutputAnalyzer output) throws Exception { - int matchedCount = output.shouldMatchByLine(JCMD_COMMAND_REGEX, + private static void matchJcmdCommands(OutputAnalyzer output) { + output.shouldMatchByLine(JCMD_COMMAND_REGEX, "help", JCMD_COMMAND_REGEX); - assertGreaterThan(matchedCount , 0, - "Found no lines matching pattern: " + JCMD_COMMAND_REGEX); } /** @@ -154,11 +153,9 @@ public class TestJcmdSanity { * @param output The generated output from the PerfCounter.print command. * @throws Exception */ - private static void matchPerfCounters(OutputAnalyzer output) throws Exception { - int matchedCount = output.shouldMatchByLineFrom(PERF_COUNTER_REGEX, + private static void matchPerfCounters(OutputAnalyzer output) { + output.shouldMatchByLineFrom(PERF_COUNTER_REGEX, PERF_COUNTER_REGEX); - assertGreaterThan(matchedCount , 0, - "Found no lines matching pattern: " + PERF_COUNTER_REGEX); } private static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException { diff --git a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java index 9309488cd66..49f102774d1 100644 --- a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java +++ b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java @@ -40,12 +40,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Arrays; import java.util.Optional; -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; import jdk.test.lib.apps.LingeredApp; import jdk.test.lib.Platform; +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.Utils; public class BasicLauncherTest { diff --git a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java index 1a86947ec7d..8ab956ad8f6 100644 --- a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java +++ b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java @@ -38,12 +38,13 @@ import java.io.IOException; 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 index c612652f46b..d9865d26184 100644 --- a/test/jdk/sun/tools/jinfo/BasicJInfoTest.java +++ b/test/jdk/sun/tools/jinfo/BasicJInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -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 index c0432deded8..bbfa8ef0f41 100644 --- a/test/jdk/sun/tools/jmap/BasicJMapTest.java +++ b/test/jdk/sun/tools/jmap/BasicJMapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -28,9 +28,9 @@ import java.io.File; 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 index be9ad0733d5..5d671e02851 100644 --- a/test/jdk/sun/tools/jps/JpsHelper.java +++ b/test/jdk/sun/tools/jps/JpsHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -35,11 +35,11 @@ import java.util.ArrayList; 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 @@ -184,10 +184,9 @@ public final class JpsHelper { * 35417 Main * 31103 org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar */ - public static void verifyJpsOutput(OutputAnalyzer output, String regex) throws Exception { + public static void verifyJpsOutput(OutputAnalyzer output, String regex) { output.shouldHaveExitValue(0); - int matchedCount = output.stdoutShouldMatchByLine(regex); - assertGreaterThan(matchedCount , 0, "Found no lines matching pattern: " + regex); + output.stdoutShouldMatchByLine(regex); output.stderrShouldNotMatch("[E|e]xception"); output.stderrShouldNotMatch("[E|e]rror"); } diff --git a/test/jdk/sun/tools/jps/TestJpsSanity.java b/test/jdk/sun/tools/jps/TestJpsSanity.java index 2f2eb4d81b0..dda4eff0f19 100644 --- 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 index 997876a54c5..7435f6dc296 100644 --- a/test/jdk/sun/tools/jstack/BasicJStackTest.java +++ b/test/jdk/sun/tools/jstack/BasicJStackTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -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 index ed9b7c6770d..bf47c911448 100644 --- a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java +++ b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java @@ -28,11 +28,11 @@ import java.util.stream.Collectors; 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 index e3e017e6f29..da4bf09fff9 100644 --- a/test/jdk/sun/tools/jstat/JStatInterval.java +++ b/test/jdk/sun/tools/jstat/JStatInterval.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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 index 7dbc119f929..76db74019aa 100644 --- a/test/jdk/sun/tools/jstatd/JstatdTest.java +++ b/test/jdk/sun/tools/jstatd/JstatdTest.java @@ -32,8 +32,8 @@ import jdk.test.lib.thread.ProcessThread; 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 @@ public final class JstatdTest { } // 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 index e053f43304a..3ee83b4dc18 100644 --- 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 index c508eba0cfc..fce9a0ac347 100644 --- a/test/jdk/tools/jimage/JImageToolTest.java +++ b/test/jdk/tools/jimage/JImageToolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.nio.file.Paths; 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 index 2530184be49..ec4176afeb0 100644 --- a/test/jdk/tools/jlink/basic/AllModulePath.java +++ b/test/jdk/tools/jlink/basic/AllModulePath.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.stream.Stream; 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 index 94499f231ec..b3eb5745ab1 100644 --- a/test/jdk/tools/jlink/basic/BasicTest.java +++ b/test/jdk/tools/jlink/basic/BasicTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.List; 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 index c165e044fdf..02f8bfd52d2 100644 --- a/test/jdk/tools/jlink/bindservices/BindServices.java +++ b/test/jdk/tools/jlink/bindservices/BindServices.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -34,7 +34,7 @@ import java.util.stream.Collectors; 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 @@ import static org.testng.Assert.*; /** * @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 index ca0584f2b93..69c4bab9ec7 100644 --- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java +++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -31,7 +31,7 @@ import java.util.stream.Stream; 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 @@ import static org.testng.Assert.*; /** * @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 index 55507adb392..a4c25e0aff6 100644 --- a/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java +++ b/test/jdk/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -35,7 +35,7 @@ import java.util.stream.Stream; 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 @@ import static org.testng.Assert.*; * @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 index 3102d91336b..e970b95a542 100644 --- a/test/jdk/tools/launcher/InfoStreams.java +++ b/test/jdk/tools/launcher/InfoStreams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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 index a74248df05b..92a8a7b238c 100644 --- 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.nio.file.Paths; 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 index b01283dfdd7..bd717d81a02 100644 --- a/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java +++ b/test/jdk/tools/launcher/modules/addexports/AddExportsTestWarningError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.Arrays; 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 index f28188699cc..178c3fd9997 100644 --- 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.nio.file.Paths; 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 index ee9a9884631..5f02530e3dc 100644 --- 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.Path; 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 index 09a1360b3e9..3acf36413ee 100644 --- a/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java +++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.Path; 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 index d1c69378acf..91ee067051e 100644 --- a/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java +++ b/test/jdk/tools/launcher/modules/addreads/AddReadsTestWarningError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.Arrays; 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 index 91629f659db..5ec05da1e82 100644 --- a/test/jdk/tools/launcher/modules/basic/BasicTest.java +++ b/test/jdk/tools/launcher/modules/basic/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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.nio.file.Paths; 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 index dd3a9837939..28ab860a689 100644 --- a/test/jdk/tools/launcher/modules/basic/InitErrors.java +++ b/test/jdk/tools/launcher/modules/basic/InitErrors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index cd26a99a196..0526c881d8a 100644 --- a/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java +++ b/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -29,24 +29,27 @@ import java.util.ArrayList; 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 @@ public class JavaClassPathTest { } 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 index 330bb5ef9ca..19716cba6c7 100644 --- a/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java +++ b/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 2c4e7e1219e..9e4aed85040 100644 --- a/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java +++ b/test/jdk/tools/launcher/modules/dryrun/DryRunTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.nio.file.Paths; 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 index 9fde69d5a89..c561eae039a 100644 --- 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.jar.Manifest; 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 index d697067b1f9..0841402ca9a 100644 --- a/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java +++ b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -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.Path; 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 index 38be89358a8..9171d886158 100644 --- a/test/jdk/tools/launcher/modules/listmods/ListModsTest.java +++ b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.Path; 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 index 5f35ca6b90a..b2b268b0ab2 100644 --- a/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java +++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -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.Collectors; 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 index 6bf6b97fb62..dde8f4d6749 100644 --- a/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java +++ b/test/jdk/tools/launcher/modules/patch/basic/PatchTestWarningError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -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.Collectors; 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 index 29acb1f77a4..aed9f61090f 100644 --- a/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java +++ b/test/jdk/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -47,7 +47,7 @@ import jdk.testlibrary.JDKToolFinder; 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 index d6eaedc693b..547a0edae1b 100644 --- a/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java +++ b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -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 index 8c69958ea5d..5da3cfe783b 100644 --- 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.io.IOException; 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 index 7bff8b5c60f..8ea3324b4df 100644 --- a/test/lib/jdk/test/lib/apps/LingeredApp.java +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java @@ -146,7 +146,7 @@ public class LingeredApp { 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 index e8c5791f487..880d1d7d16c 100644 --- a/test/lib/jdk/test/lib/dcmd/CommandExecutor.java +++ b/test/lib/jdk/test/lib/dcmd/CommandExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -34,7 +34,7 @@ public abstract class CommandExecutor { * 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 @@ public abstract class CommandExecutor { * * @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 index 6da75e8da5f..53fd28ace6f 100644 --- 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 @@ import java.util.regex.Pattern; 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 @@ public final class OutputAnalyzer { * @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 @@ public final class OutputAnalyzer { * @param buf String buffer to analyze */ public OutputAnalyzer(String buf) { - this(buf, buf); + buffer = OutputBuffer.of(buf, buf); } /** @@ -67,9 +63,7 @@ public final class OutputAnalyzer { * @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); } /** @@ -78,11 +72,12 @@ public final class OutputAnalyzer { * @throws RuntimeException * If stdout was not empty */ - public void stdoutShouldBeEmpty() { + public OutputAnalyzer stdoutShouldBeEmpty() { if (!getStdout().isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stdout was not empty"); } + return this; } /** @@ -91,11 +86,12 @@ public final class OutputAnalyzer { * @throws RuntimeException * If stderr was not empty */ - public void stderrShouldBeEmpty() { + public OutputAnalyzer stderrShouldBeEmpty() { if (!getStderr().isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stderr was not empty"); } + return this; } /** @@ -105,11 +101,12 @@ public final class OutputAnalyzer { * @throws RuntimeException * If stderr was not empty */ - public void stderrShouldBeEmptyIgnoreVMWarnings() { + public OutputAnalyzer stderrShouldBeEmptyIgnoreVMWarnings() { if (!getStderr().replaceAll(jvmwarningmsg + "\\R", "").isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stderr was not empty"); } + return this; } /** @@ -118,11 +115,12 @@ public final class OutputAnalyzer { * @throws RuntimeException * If stdout was empty */ - public void stdoutShouldNotBeEmpty() { + public OutputAnalyzer stdoutShouldNotBeEmpty() { if (getStdout().isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stdout was empty"); } + return this; } /** @@ -131,11 +129,12 @@ public final class OutputAnalyzer { * @throws RuntimeException * If stderr was empty */ - public void stderrShouldNotBeEmpty() { + public OutputAnalyzer stderrShouldNotBeEmpty() { if (getStderr().isEmpty()) { reportDiagnosticSummary(); throw new RuntimeException("stderr was empty"); } + return this; } /** @@ -145,6 +144,8 @@ public final class OutputAnalyzer { * @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 +160,7 @@ public final class OutputAnalyzer { * @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 +175,7 @@ public final class OutputAnalyzer { * @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 +186,12 @@ public final class OutputAnalyzer { /** * 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 +209,8 @@ public final class OutputAnalyzer { * @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 +225,11 @@ public final class OutputAnalyzer { /** * 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 +240,11 @@ public final class OutputAnalyzer { /** * 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 +256,18 @@ public final class OutputAnalyzer { * 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 +277,15 @@ public final class OutputAnalyzer { * 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 +299,7 @@ public final class OutputAnalyzer { * @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,22 +313,27 @@ public final class OutputAnalyzer { * 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(); + 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); + + String stderr = getStderr(); + 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 +341,15 @@ public final class OutputAnalyzer { * 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 +359,15 @@ public final class OutputAnalyzer { * 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,16 +377,19 @@ public final class OutputAnalyzer { * 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) { + Pattern pattern = Pattern.compile(regexp, Pattern.MULTILINE); + String stderr = getStderr(); + Matcher stderrMatcher = pattern.matcher(stderr); if (stderrMatcher.find()) { return stderrMatcher.group(group); } + String stdout = getStdout(); + Matcher stdoutMatcher = pattern.matcher(stdout); if (stdoutMatcher.find()) { return stdoutMatcher.group(group); } @@ -425,8 +448,8 @@ public final class OutputAnalyzer { */ 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 +481,7 @@ public final class OutputAnalyzer { * @return Content of the output buffer */ public String getOutput() { - return stdout + stderr; + return getStdout() + getStderr(); } /** @@ -467,7 +490,7 @@ public final class OutputAnalyzer { * @return Content of the stdout buffer */ public String getStdout() { - return stdout; + return buffer.getStdout(); } /** @@ -476,7 +499,7 @@ public final class OutputAnalyzer { * @return Content of the stderr buffer */ public String getStderr() { - return stderr; + return buffer.getStderr(); } /** @@ -485,7 +508,7 @@ public final class OutputAnalyzer { * @return Process exit value */ public int getExitValue() { - return exitValue; + return buffer.getExitValue(); } /** @@ -499,7 +522,7 @@ public final class OutputAnalyzer { } private List asLines(String buffer) { - return Arrays.asList(buffer.split("(\\r\\n|\\n|\\r)")); + return Arrays.asList(buffer.split("\\R")); } @@ -512,6 +535,8 @@ public final class OutputAnalyzer { * @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 +556,7 @@ public final class OutputAnalyzer { * @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 +573,118 @@ public final class OutputAnalyzer { * @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 OutputAnalyzer shouldMatchByLine(String pattern) { + return shouldMatchByLine(null, null, pattern); + } + + /** + * @see #stdoutShouldMatchByLine(String, String, String) + */ + public OutputAnalyzer stdoutShouldMatchByLine(String pattern) { + return stdoutShouldMatchByLine(null, null, pattern); + } + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public OutputAnalyzer shouldMatchByLineFrom(String from, String pattern) { + return shouldMatchByLine(from, null, pattern); + } + + /** + * @see #shouldMatchByLine(String, String, String) + */ + public OutputAnalyzer 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 + */ + public OutputAnalyzer 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 + */ + public OutputAnalyzer stdoutShouldMatchByLine(String from, String to, String pattern) { + return shouldMatchByLine(getStdout(), from, to, pattern); + } + + private OutputAnalyzer 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); + Asserts.assertFalse(subList.isEmpty(), "There are no lines to check"); + + subList.stream() + .filter(Pattern.compile(pattern).asPredicate().negate()) + .findAny() + .ifPresent(line -> Asserts.assertTrue(false, + "The line '" + line + "' does not match pattern '" + pattern + "'")); + + return this; + } + + /** + * Check if there is a line matching {@code regexp} and return its index + * + * @param regexp Matching pattern + * @return Index of first matching line + */ + private int indexOf(List lines, String regexp) { + Pattern pattern = Pattern.compile(regexp); + for (int i = 0; i < lines.size(); i++) { + if (pattern.matcher(lines.get(i)).matches()) { + return i; + } + } + return -1; } } diff --git a/test/lib/jdk/test/lib/process/OutputBuffer.java b/test/lib/jdk/test/lib/process/OutputBuffer.java index a41e8436ba0..49d887f9995 100644 --- a/test/lib/jdk/test/lib/process/OutputBuffer.java +++ b/test/lib/jdk/test/lib/process/OutputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,20 +23,19 @@ package jdk.test.lib.process; -public class OutputBuffer { - private final String stdout; - private final String stderr; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +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 +43,105 @@ public class OutputBuffer { * * @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 static class StreamTask { + private final ByteArrayOutputStream buffer; + private final Future future; + + private StreamTask(InputStream stream) { + this.buffer = new ByteArrayOutputStream(); + this.future = new StreamPumper(stream, buffer).process(); + } + + public String get() { + try { + future.get(); + return buffer.toString(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new OutputBufferException(e); + } catch (ExecutionException | CancellationException e) { + throw new OutputBufferException(e); + } + } + } + + private final StreamTask outTask; + private final StreamTask errTask; + private final Process p; + + private LazyOutputBuffer(Process p) { + this.p = p; + outTask = new StreamTask(p.getInputStream()); + errTask = new StreamTask(p.getErrorStream()); + } + + @Override + public String getStdout() { + return outTask.get(); + } + + @Override + public String getStderr() { + return errTask.get(); + } + + @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; + } + + @Override + public String getStdout() { + return stdout; + } + + @Override + 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 index 66bd7736f82..33a7939f586 100644 --- 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; @@ -64,50 +63,6 @@ public final class ProcessTools { private ProcessTools() { } - /** - * 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 @@ -392,11 +347,29 @@ public final class ProcessTools { * @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); + } + } + output = new OutputAnalyzer(p); p.waitFor(); diff --git a/test/lib/jdk/test/lib/process/StreamPumper.java b/test/lib/jdk/test/lib/process/StreamPumper.java index 8dd7f0cf0ec..7920d69bdf1 100644 --- a/test/lib/jdk/test/lib/process/StreamPumper.java +++ b/test/lib/jdk/test/lib/process/StreamPumper.java @@ -41,14 +41,14 @@ public final class StreamPumper implements Runnable { /** * Pump will be called by the StreamPumper to process the incoming data */ - abstract public static class Pump { + public abstract static class Pump { abstract void register(StreamPumper d); } /** * OutputStream -> Pump adapter */ - final public static class StreamPump extends Pump { + public final static class StreamPump extends Pump { private final OutputStream out; public StreamPump(OutputStream out) { this.out = out; @@ -63,13 +63,13 @@ public final class StreamPumper implements Runnable { /** * Used to process the incoming data line-by-line */ - abstract public static class LinePump extends Pump { + public abstract static class LinePump extends Pump { @Override final void register(StreamPumper sp) { sp.addLineProcessor(this); } - abstract protected void processLine(String line); + protected abstract void processLine(String line); } private final InputStream in; @@ -77,7 +77,6 @@ public final class StreamPumper implements Runnable { 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; @@ -108,7 +107,7 @@ public final class StreamPumper implements Runnable { int linelen = 0; while ((len = is.read(buf)) > 0 && !Thread.interrupted()) { - for(OutputStream out : outStreams) { + for (OutputStream out : outStreams) { out.write(buf, 0, len); } if (!linePumps.isEmpty()) { @@ -125,9 +124,7 @@ public final class StreamPumper implements Runnable { if (linelen > 0) { lineBos.flush(); final String line = lineBos.toString(); - linePumps.stream().forEach((lp) -> { - lp.processLine(line); - }); + linePumps.forEach((lp) -> lp.processLine(line)); lineBos.reset(); linelen = 0; } @@ -149,7 +146,7 @@ public final class StreamPumper implements Runnable { } catch (IOException e) { e.printStackTrace(); } finally { - for(OutputStream out : outStreams) { + for (OutputStream out : outStreams) { try { out.flush(); } catch (IOException e) {} @@ -168,30 +165,26 @@ public final class StreamPumper implements Runnable { linePumps.add(lp); } - final public StreamPumper addPump(Pump ... pump) { + public final StreamPumper addPump(Pump ... pump) { if (processing.get()) { throw new IllegalStateException("Can not modify pumper while " + "processing is in progress"); } - for(Pump p : pump) { + for (Pump p : pump) { p.register(this); } return this; } - final public Future process() { + public final 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(); - } - }); + FutureTask result = new FutureTask<>(this, null); + Thread t = new Thread(result); t.setDaemon(true); t.start(); - return processingTask; + return result; } }