8183505: Update langtools tests to allow for unique test classes directory

Reviewed-by: alanb
This commit is contained in:
Jonathan Gibbons 2017-07-05 14:36:54 -07:00
parent 95784b44db
commit 86f7b05126
4 changed files with 39 additions and 11 deletions

View File

@ -31,6 +31,7 @@
* @run main T8147801
*/
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@ -42,6 +43,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.stream.Stream;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.FieldDoc;
@ -143,13 +145,18 @@ public class T8147801 {
}
void initJar() throws IOException {
Path testClasses = Paths.get(System.getProperty("test.classes"));
String testClassPath = System.getProperty("test.class.path", "");
Path jarsrc = Stream.of(testClassPath.split(File.pathSeparator))
.map(Paths::get)
.filter(e -> e.endsWith("jarsrc"))
.findAny()
.orElseThrow(() -> new InternalError("jarsrc not found"));
jarPath = Paths.get("lib.jar");
try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(jarPath))) {
String[] classNames = {"Lib1.class", "Lib2.class"};
for (String cn : classNames) {
out.putNextEntry(new JarEntry("lib/" + cn));
Path libClass = testClasses.resolve("jarsrc").resolve("lib").resolve(cn);
Path libClass = jarsrc.resolve("lib").resolve(cn);
out.write(Files.readAllBytes(libClass));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -37,6 +37,7 @@ package jdk.jdeprscan;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
@ -48,6 +49,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.sun.tools.jdeprscan.Main;
@ -63,8 +65,11 @@ public class TestLoad {
@Test
public void test1() throws IOException, UnsupportedEncodingException {
String testclasses = System.getProperty("test.classes");
String deprcases = testclasses + "/../../../cases";
String testClassPath = System.getProperty("test.class.path", "");
String deprcases = Stream.of(testClassPath.split(File.pathSeparator))
.filter(e -> e.endsWith("cases"))
.findAny()
.orElseThrow(() -> new InternalError("cases not found"));
boolean rval;
System.out.println("test.src = " + System.getProperty("test.src"));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -40,6 +40,7 @@ import com.sun.tools.jdeprscan.Main;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
@ -50,6 +51,7 @@ import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.testng.Assert;
import org.testng.annotations.Test;
@ -65,9 +67,16 @@ public class TestScan {
@Test
public void testScanAgainstReferenceFile() throws IOException {
String testclasses = System.getProperty("test.classes");
String deprcases = testclasses + "/../../../cases";
String deprusage = testclasses + "/../../../usage";
String[] testClassPath = System.getProperty("test.class.path", "")
.split(File.pathSeparator);
String deprcases = Stream.of(testClassPath)
.filter(e -> e.endsWith("cases"))
.findAny()
.orElseThrow(() -> new InternalError("cases not found"));
String deprusage = Stream.of(testClassPath)
.filter(e -> e.endsWith("usage"))
.findAny()
.orElseThrow(() -> new InternalError("usage not found"));
Set<String> expected = loadExpected();
System.out.println("expected = " + expected);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,11 +36,13 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
public class MultiReleaseJar {
Path mrjar;
@ -50,7 +52,12 @@ public class MultiReleaseJar {
@BeforeClass
public void initialize() throws Exception {
mrjar = Paths.get(System.getProperty("test.classes", "."), "mrjar");
String testClassPath = System.getProperty("test.class.path", "");
mrjar = Stream.of(testClassPath.split(File.pathSeparator))
.map(Paths::get)
.filter(e -> e.endsWith("mrjar"))
.findAny()
.orElseThrow(() -> new InternalError("mrjar not found"));
testJdk = System.getProperty("test.jdk");
fileSep = System.getProperty("file.separator");
cmdPath = Paths.get(testJdk, "bin");