< prev index next >

test/jdk/java/lang/ClassLoader/getResource/GetResource.java

Print this page
*** 1,7 ***
  /*
!  * 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
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2014, 2023, 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.

*** 38,15 ***
  import java.nio.file.Files;
  import java.nio.file.Path;
  import java.nio.file.Paths;
  import java.util.ArrayList;
  import java.util.List;
- import java.util.Map;
  import java.util.stream.Collectors;
  import java.util.stream.Stream;
  
- import jdk.test.lib.JDKToolFinder;
  import static jdk.test.lib.process.ProcessTools.*;
  
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.DataProvider;
  import org.testng.annotations.Test;
--- 38,13 ---

*** 142,29 ***
      }
  
      private void runTest(Path dir, List<String> options, String expected)
          throws Throwable
      {
-         String javapath = JDKToolFinder.getJDKTool("java");
- 
          List<String> cmdLine = new ArrayList<>();
-         cmdLine.add(javapath);
          options.forEach(cmdLine::add);
  
          cmdLine.add("GetResource");
          cmdLine.add(expected);
! 
!         System.out.println("Command line: " + cmdLine);
!         ProcessBuilder pb =
-             new ProcessBuilder(cmdLine.stream().toArray(String[]::new));
- 
-         // change working directory
-         pb.directory(dir.toFile());
- 
-         // remove CLASSPATH environment variable
-         Map<String,String> env = pb.environment();
-         String value = env.remove("CLASSPATH");
- 
          executeCommand(pb).shouldHaveExitValue(0);
      }
  
  }
--- 140,17 ---
      }
  
      private void runTest(Path dir, List<String> options, String expected)
          throws Throwable
      {
          List<String> cmdLine = new ArrayList<>();
          options.forEach(cmdLine::add);
  
          cmdLine.add("GetResource");
          cmdLine.add(expected);
!         ProcessBuilder pb = createTestJavaProcessBuilder(cmdLine);
!         pb.directory(dir.toFile()); // change working directory
!         pb.environment().remove("CLASSPATH"); // remove CLASSPATH environment variable
          executeCommand(pb).shouldHaveExitValue(0);
      }
  
  }
< prev index next >