Path: blob/master/test/jdk/java/net/URLConnection/6212146/TestDriver.java
41153 views
/*1* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 621214626* @summary URLConnection.connect() fails on JAR Entry it creates27* file handler leak28* @library /test/lib29* @build jdk.test.lib.Utils30* jdk.test.lib.Asserts31* jdk.test.lib.JDKToolFinder32* jdk.test.lib.JDKToolLauncher33* jdk.test.lib.Platform34* jdk.test.lib.process.*35* Test36* @run main/othervm TestDriver37*/3839import jdk.test.lib.JDKToolFinder;40import jdk.test.lib.process.ProcessTools;4142import java.io.IOException;43import java.nio.file.Files;44import java.nio.file.Path;45import java.nio.file.Paths;4647import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;4849public class TestDriver {50private static final String BASE_DIR = System.getProperty("user.dir")51+ "/jars/";52private static final String ARCHIVE_NAME = "test.jar";53private static final String CMD_ULIMIT = "ulimit -n 300;";5455public static void main(String[] args)56throws Throwable {57setup(BASE_DIR);58String testCMD = CMD_ULIMIT + JDKToolFinder.getTestJDKTool("java")59+ " Test " + BASE_DIR + " " + ARCHIVE_NAME;60boolean isWindows = System.getProperty("os.name").startsWith("Windows");61if (isWindows) {62testCMD = testCMD.replace("\\", "/");63}64ProcessTools.executeCommand("sh", "-c", testCMD)65.outputTo(System.out)66.errorTo(System.err)67.shouldHaveExitValue(0);68}6970private static void setup(String baseDir) throws IOException {71Path testJar = Paths.get(System.getProperty("test.src"), ARCHIVE_NAME);72Path targetDir = Paths.get(baseDir);73Files.createDirectories(targetDir);74Files.copy(testJar, targetDir.resolve(ARCHIVE_NAME), REPLACE_EXISTING);75}76}777879