Merge
Reviewed-by: dcubed
This commit is contained in:
commit
17295b1bb0
@ -1354,11 +1354,29 @@ bool SystemDictionaryShared::check_for_exclusion(InstanceKlass* k, DumpTimeShare
|
||||
return info->is_excluded();
|
||||
}
|
||||
|
||||
// Check if a class or any of its supertypes has been redefined.
|
||||
bool SystemDictionaryShared::has_been_redefined(InstanceKlass* k) {
|
||||
if (k->has_been_redefined()) {
|
||||
return true;
|
||||
}
|
||||
if (k->java_super() != NULL && has_been_redefined(k->java_super())) {
|
||||
return true;
|
||||
}
|
||||
Array<InstanceKlass*>* interfaces = k->local_interfaces();
|
||||
int len = interfaces->length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (has_been_redefined(interfaces->at(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
|
||||
if (k->is_in_error_state()) {
|
||||
return warn_excluded(k, "In error state");
|
||||
}
|
||||
if (k->has_been_redefined()) {
|
||||
if (has_been_redefined(k)) {
|
||||
return warn_excluded(k, "Has been redefined");
|
||||
}
|
||||
if (!k->is_hidden() && k->shared_classpath_index() < 0 && is_builtin(k)) {
|
||||
|
@ -232,6 +232,7 @@ private:
|
||||
static bool is_registered_lambda_proxy_class(InstanceKlass* ik);
|
||||
static bool warn_excluded(InstanceKlass* k, const char* reason);
|
||||
static bool check_for_exclusion_impl(InstanceKlass* k);
|
||||
static bool has_been_redefined(InstanceKlass* k);
|
||||
|
||||
static bool _dump_in_progress;
|
||||
DEBUG_ONLY(static bool _no_class_loading_should_happen;)
|
||||
|
@ -435,50 +435,54 @@ final class CipherCore {
|
||||
|
||||
byte[] keyBytes = getKeyBytes(key);
|
||||
byte[] ivBytes = null;
|
||||
if (params != null) {
|
||||
if (params instanceof IvParameterSpec) {
|
||||
ivBytes = ((IvParameterSpec) params).getIV();
|
||||
if ((ivBytes == null) || (ivBytes.length != blockSize)) {
|
||||
try {
|
||||
if (params != null) {
|
||||
if (params instanceof IvParameterSpec) {
|
||||
ivBytes = ((IvParameterSpec) params).getIV();
|
||||
if ((ivBytes == null) || (ivBytes.length != blockSize)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("Wrong IV length: must be " + blockSize +
|
||||
" bytes long");
|
||||
}
|
||||
} else if (params instanceof RC2ParameterSpec) {
|
||||
ivBytes = ((RC2ParameterSpec) params).getIV();
|
||||
if ((ivBytes != null) && (ivBytes.length != blockSize)) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("Wrong IV length: must be " + blockSize +
|
||||
" bytes long");
|
||||
}
|
||||
} else {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("Wrong IV length: must be " + blockSize +
|
||||
" bytes long");
|
||||
("Unsupported parameter: " + params);
|
||||
}
|
||||
} else if (params instanceof RC2ParameterSpec) {
|
||||
ivBytes = ((RC2ParameterSpec) params).getIV();
|
||||
if ((ivBytes != null) && (ivBytes.length != blockSize)) {
|
||||
}
|
||||
if (cipherMode == ECB_MODE) {
|
||||
if (ivBytes != null) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("Wrong IV length: must be " + blockSize +
|
||||
" bytes long");
|
||||
("ECB mode cannot use IV");
|
||||
}
|
||||
} else {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("Unsupported parameter: " + params);
|
||||
} else if (ivBytes == null) {
|
||||
if (decrypting) {
|
||||
throw new InvalidAlgorithmParameterException("Parameters "
|
||||
+ "missing");
|
||||
}
|
||||
|
||||
if (random == null) {
|
||||
random = SunJCE.getRandom();
|
||||
}
|
||||
|
||||
ivBytes = new byte[blockSize];
|
||||
random.nextBytes(ivBytes);
|
||||
}
|
||||
|
||||
buffered = 0;
|
||||
diffBlocksize = blockSize;
|
||||
|
||||
String algorithm = key.getAlgorithm();
|
||||
cipher.init(decrypting, algorithm, keyBytes, ivBytes);
|
||||
} finally {
|
||||
Arrays.fill(keyBytes, (byte)0);
|
||||
}
|
||||
if (cipherMode == ECB_MODE) {
|
||||
if (ivBytes != null) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("ECB mode cannot use IV");
|
||||
}
|
||||
} else if (ivBytes == null) {
|
||||
if (decrypting) {
|
||||
throw new InvalidAlgorithmParameterException("Parameters "
|
||||
+ "missing");
|
||||
}
|
||||
|
||||
if (random == null) {
|
||||
random = SunJCE.getRandom();
|
||||
}
|
||||
|
||||
ivBytes = new byte[blockSize];
|
||||
random.nextBytes(ivBytes);
|
||||
}
|
||||
|
||||
buffered = 0;
|
||||
diffBlocksize = blockSize;
|
||||
|
||||
String algorithm = key.getAlgorithm();
|
||||
cipher.init(decrypting, algorithm, keyBytes, ivBytes);
|
||||
}
|
||||
|
||||
void init(int opmode, Key key, AlgorithmParameters params,
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
package com.sun.crypto.provider;
|
||||
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
||||
import java.security.Key;
|
||||
import java.security.PublicKey;
|
||||
import java.security.PrivateKey;
|
||||
@ -48,24 +50,18 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
*/
|
||||
|
||||
final class ConstructKeys {
|
||||
/**
|
||||
* Construct a public key from its encoding.
|
||||
*
|
||||
* @param encodedKey the encoding of a public key.
|
||||
*
|
||||
* @param encodedKeyAlgorithm the algorithm the encodedKey is for.
|
||||
*
|
||||
* @return a public key constructed from the encodedKey.
|
||||
*/
|
||||
|
||||
private static final PublicKey constructPublicKey(byte[] encodedKey,
|
||||
String encodedKeyAlgorithm)
|
||||
int ofs, int len, String encodedKeyAlgorithm)
|
||||
throws InvalidKeyException, NoSuchAlgorithmException {
|
||||
PublicKey key = null;
|
||||
byte[] keyBytes = (ofs == 0 && encodedKey.length == len)
|
||||
? encodedKey : Arrays.copyOfRange(encodedKey, ofs, ofs + len);
|
||||
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
|
||||
try {
|
||||
KeyFactory keyFactory =
|
||||
KeyFactory.getInstance(encodedKeyAlgorithm,
|
||||
SunJCE.getInstance());
|
||||
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey);
|
||||
key = keyFactory.generatePublic(keySpec);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
// Try to see whether there is another
|
||||
@ -73,8 +69,6 @@ final class ConstructKeys {
|
||||
try {
|
||||
KeyFactory keyFactory =
|
||||
KeyFactory.getInstance(encodedKeyAlgorithm);
|
||||
X509EncodedKeySpec keySpec =
|
||||
new X509EncodedKeySpec(encodedKey);
|
||||
key = keyFactory.generatePublic(keySpec);
|
||||
} catch (NoSuchAlgorithmException nsae2) {
|
||||
throw new NoSuchAlgorithmException("No installed providers " +
|
||||
@ -97,25 +91,17 @@ final class ConstructKeys {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a private key from its encoding.
|
||||
*
|
||||
* @param encodedKey the encoding of a private key.
|
||||
*
|
||||
* @param encodedKeyAlgorithm the algorithm the wrapped key is for.
|
||||
*
|
||||
* @return a private key constructed from the encodedKey.
|
||||
*/
|
||||
private static final PrivateKey constructPrivateKey(byte[] encodedKey,
|
||||
String encodedKeyAlgorithm)
|
||||
int ofs, int len, String encodedKeyAlgorithm)
|
||||
throws InvalidKeyException, NoSuchAlgorithmException {
|
||||
PrivateKey key = null;
|
||||
|
||||
byte[] keyBytes = (ofs == 0 && encodedKey.length == len)
|
||||
? encodedKey : Arrays.copyOfRange(encodedKey, ofs, ofs + len);
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
|
||||
try {
|
||||
KeyFactory keyFactory =
|
||||
KeyFactory.getInstance(encodedKeyAlgorithm,
|
||||
SunJCE.getInstance());
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey);
|
||||
return keyFactory.generatePrivate(keySpec);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
// Try to see whether there is another
|
||||
@ -123,8 +109,6 @@ final class ConstructKeys {
|
||||
try {
|
||||
KeyFactory keyFactory =
|
||||
KeyFactory.getInstance(encodedKeyAlgorithm);
|
||||
PKCS8EncodedKeySpec keySpec =
|
||||
new PKCS8EncodedKeySpec(encodedKey);
|
||||
key = keyFactory.generatePrivate(keySpec);
|
||||
} catch (NoSuchAlgorithmException nsae2) {
|
||||
throw new NoSuchAlgorithmException("No installed providers " +
|
||||
@ -142,20 +126,16 @@ final class ConstructKeys {
|
||||
new InvalidKeyException("Cannot construct private key");
|
||||
ike.initCause(ikse);
|
||||
throw ike;
|
||||
} finally {
|
||||
SharedSecrets.getJavaSecuritySpecAccess().clearEncodedKeySpec(keySpec);
|
||||
if (keyBytes != encodedKey) {
|
||||
Arrays.fill(keyBytes, (byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a secret key from its encoding.
|
||||
*
|
||||
* @param encodedKey the encoding of a secret key.
|
||||
*
|
||||
* @param encodedKeyAlgorithm the algorithm the secret key is for.
|
||||
*
|
||||
* @return a secret key constructed from the encodedKey.
|
||||
*/
|
||||
private static final SecretKey constructSecretKey(byte[] encodedKey,
|
||||
int ofs, int len, String encodedKeyAlgorithm) {
|
||||
return (new SecretKeySpec(encodedKey, ofs, len, encodedKeyAlgorithm));
|
||||
@ -170,35 +150,14 @@ final class ConstructKeys {
|
||||
static final Key constructKey(byte[] encoding, int ofs, int len,
|
||||
String keyAlgorithm, int keyType)
|
||||
throws InvalidKeyException, NoSuchAlgorithmException {
|
||||
switch (keyType) {
|
||||
case Cipher.SECRET_KEY:
|
||||
try {
|
||||
return ConstructKeys.constructSecretKey(encoding, ofs, len,
|
||||
keyAlgorithm);
|
||||
} finally {
|
||||
Arrays.fill(encoding, ofs, len, (byte)0);
|
||||
}
|
||||
case Cipher.PRIVATE_KEY:
|
||||
byte[] encoding2 = encoding;
|
||||
try {
|
||||
if (ofs != 0 || len != encoding.length) {
|
||||
encoding2 = Arrays.copyOfRange(encoding, ofs, ofs + len);
|
||||
}
|
||||
return ConstructKeys.constructPrivateKey(encoding2,
|
||||
keyAlgorithm);
|
||||
} finally {
|
||||
Arrays.fill(encoding, ofs, len, (byte)0);
|
||||
if (encoding2 != encoding) {
|
||||
Arrays.fill(encoding2, (byte)0);
|
||||
}
|
||||
}
|
||||
case Cipher.PUBLIC_KEY:
|
||||
if (ofs != 0 || len != encoding.length) {
|
||||
encoding = Arrays.copyOfRange(encoding, ofs, ofs + len);
|
||||
}
|
||||
return ConstructKeys.constructPublicKey(encoding, keyAlgorithm);
|
||||
default:
|
||||
throw new NoSuchAlgorithmException("Unsupported key type");
|
||||
}
|
||||
return switch (keyType) {
|
||||
case Cipher.SECRET_KEY -> ConstructKeys.constructSecretKey(
|
||||
encoding, ofs, len, keyAlgorithm);
|
||||
case Cipher.PRIVATE_KEY -> ConstructKeys.constructPrivateKey(
|
||||
encoding, ofs, len, keyAlgorithm);
|
||||
case Cipher.PUBLIC_KEY -> ConstructKeys.constructPublicKey(
|
||||
encoding, ofs, len, keyAlgorithm);
|
||||
default -> throw new NoSuchAlgorithmException("Unsupported key type");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,13 @@ abstract class GaloisCounterMode extends CipherSpi {
|
||||
reInit = false;
|
||||
|
||||
// always encrypt mode for embedded cipher
|
||||
blockCipher.init(false, key.getAlgorithm(), keyValue);
|
||||
try {
|
||||
blockCipher.init(false, key.getAlgorithm(), keyValue);
|
||||
} finally {
|
||||
if (!encryption) {
|
||||
Arrays.fill(keyValue, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,6 +124,7 @@ class KWUtil {
|
||||
}
|
||||
}
|
||||
System.arraycopy(buffer, 0, icvOut, 0, SEMI_BLKSIZE);
|
||||
Arrays.fill(buffer, (byte)0);
|
||||
return inLen - SEMI_BLKSIZE;
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +472,11 @@ abstract class KeyWrapCipher extends CipherSpi {
|
||||
int outLen = engineDoFinal(in, inOfs, inLen, out, 0);
|
||||
|
||||
if (outLen < estOutLen) {
|
||||
return Arrays.copyOf(out, outLen);
|
||||
try {
|
||||
return Arrays.copyOf(out, outLen);
|
||||
} finally {
|
||||
Arrays.fill(out, (byte)0);
|
||||
}
|
||||
} else {
|
||||
return out;
|
||||
}
|
||||
@ -529,6 +533,9 @@ abstract class KeyWrapCipher extends CipherSpi {
|
||||
return outLen;
|
||||
}
|
||||
} finally {
|
||||
if (dataBuf != null) {
|
||||
Arrays.fill(dataBuf, (byte)0);
|
||||
}
|
||||
dataBuf = null;
|
||||
dataIdx = 0;
|
||||
}
|
||||
@ -559,8 +566,14 @@ abstract class KeyWrapCipher extends CipherSpi {
|
||||
len += inLen;
|
||||
}
|
||||
|
||||
return (opmode == Cipher.ENCRYPT_MODE?
|
||||
helperEncrypt(out, len) : helperDecrypt(out, len));
|
||||
try {
|
||||
return (opmode == Cipher.ENCRYPT_MODE ?
|
||||
helperEncrypt(out, len) : helperDecrypt(out, len));
|
||||
} finally {
|
||||
if (dataBuf != null && dataBuf != out) {
|
||||
Arrays.fill(dataBuf, (byte)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// helper routine for in-place encryption.
|
||||
|
@ -70,6 +70,7 @@ environment=\
|
||||
users.current users.logged users.last \
|
||||
disk \
|
||||
env \
|
||||
ulimit \
|
||||
system.dmesg system.sysctl \
|
||||
process.top process.ps \
|
||||
memory.free memory.vmstat.default memory.vmstat.statistics \
|
||||
@ -91,6 +92,10 @@ disk.args=-h
|
||||
|
||||
env.app=env
|
||||
|
||||
ulimit.app=bash
|
||||
ulimit.args=-c\0ulimit -a
|
||||
ulimit.args.delimiter=\0
|
||||
|
||||
system.dmesg.app=dmesg
|
||||
system.sysctl.app=sysctl
|
||||
system.sysctl.args=-a
|
||||
|
@ -78,6 +78,7 @@ environment=\
|
||||
users.current users.logged users.last \
|
||||
disk \
|
||||
env \
|
||||
ulimit \
|
||||
system.dmesg system.sysctl \
|
||||
process.ps process.top \
|
||||
memory.vmstat \
|
||||
@ -98,6 +99,10 @@ disk.args=-h
|
||||
|
||||
env.app=env
|
||||
|
||||
ulimit.app=bash
|
||||
ulimit.args=-c\0ulimit -a
|
||||
ulimit.args.delimiter=\0
|
||||
|
||||
system.dmesg.app=dmesg
|
||||
system.sysctl.app=sysctl
|
||||
system.sysctl.args=-a
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2015, 2021, 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
|
||||
@ -66,6 +66,7 @@ environment=\
|
||||
users.current users.logged \
|
||||
disk \
|
||||
env \
|
||||
ulimit \
|
||||
system.events.system system.events.application system.os \
|
||||
process.top process.ps process.tasklist \
|
||||
memory.free memory.vmstat.default memory.vmstat.statistics \
|
||||
@ -84,6 +85,10 @@ disk.args=-h
|
||||
|
||||
env.app=env
|
||||
|
||||
ulimit.app=bash
|
||||
ulimit.args=-c\0ulimit -a
|
||||
ulimit.args.delimiter=\0
|
||||
|
||||
system.events.app=powershell
|
||||
system.events.delimiter=\0
|
||||
system.events.system.args=-NoLogo\0-Command\0Get-EventLog System -After (Get-Date).AddDays(-1) | Format-List
|
||||
|
@ -114,6 +114,7 @@ serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java 8214
|
||||
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java 8224150 generic-all
|
||||
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all
|
||||
serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-x64
|
||||
serviceability/jvmti/CompiledMethodLoad/Zombie.java 8245877 linux-aarch64
|
||||
|
||||
#############################################################################
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8268470
|
||||
* @summary Test dynamic CDS with JFR recording.
|
||||
* Dynamic dump should skip the class such as jdk/jfr/events/FileReadEvent
|
||||
* if one of its super classes has been redefined during JFR startup.
|
||||
* @requires vm.cds
|
||||
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
|
||||
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
|
||||
* @build JFRDynamicCDSApp sun.hotspot.WhiteBox
|
||||
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar jfr_dynamic_cds_app.jar JFRDynamicCDSApp JFRDynamicCDSApp$StressEvent
|
||||
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. JFRDynamicCDS
|
||||
*/
|
||||
|
||||
import jdk.test.lib.helpers.ClassFileInstaller;
|
||||
|
||||
public class JFRDynamicCDS extends DynamicArchiveTestBase {
|
||||
public static void main(String[] args) throws Exception {
|
||||
runTest(JFRDynamicCDS::test);
|
||||
}
|
||||
|
||||
static void test() throws Exception {
|
||||
String topArchiveName = getNewArchiveName();
|
||||
String appJar = ClassFileInstaller.getJarPath("jfr_dynamic_cds_app.jar");
|
||||
String mainClass = "JFRDynamicCDSApp";
|
||||
dump(topArchiveName,
|
||||
"-Xlog:class+load,cds=debug",
|
||||
"-cp", appJar, mainClass)
|
||||
.assertNormalExit(output -> {
|
||||
output.shouldHaveExitValue(0)
|
||||
.shouldMatch("Skipping.jdk/jfr/events.*Has.been.redefined");
|
||||
});
|
||||
|
||||
run(topArchiveName,
|
||||
"-Xlog:class+load=info",
|
||||
"-cp", appJar, mainClass)
|
||||
.assertNormalExit(output -> {
|
||||
output.shouldHaveExitValue(0)
|
||||
.shouldMatch(".class.load. jdk.jfr.events.*source:.*jrt:/jdk.jfr")
|
||||
.shouldContain("[class,load] JFRDynamicCDSApp source: shared objects file (top)");
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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.
|
||||
*
|
||||
*/
|
||||
import java.nio.file.Paths;
|
||||
import jdk.jfr.Configuration;
|
||||
import jdk.jfr.Description;
|
||||
import jdk.jfr.Label;
|
||||
import jdk.jfr.Name;
|
||||
import jdk.jfr.Recording;
|
||||
import jdk.jfr.consumer.RecordingStream;
|
||||
|
||||
public class JFRDynamicCDSApp {
|
||||
public static void main(String args[]) throws Exception {
|
||||
RecordingStream rs = new RecordingStream();
|
||||
rs.enable("JFRDynamicCDS.StressEvent");
|
||||
rs.startAsync();
|
||||
|
||||
Recording recording = startRecording();
|
||||
loop();
|
||||
recording.stop();
|
||||
recording.close();
|
||||
|
||||
rs.close();
|
||||
}
|
||||
|
||||
static Recording startRecording() throws Exception {
|
||||
Configuration configuration = Configuration.getConfiguration("default");
|
||||
Recording recording = new Recording(configuration);
|
||||
|
||||
recording.setName("internal");
|
||||
recording.enable(StressEvent.class);
|
||||
recording.setDestination(Paths.get("JFRDynamicCDS.jfr"));
|
||||
recording.start();
|
||||
return recording;
|
||||
}
|
||||
|
||||
|
||||
static void loop() {
|
||||
for (int i=0; i<100; i++) {
|
||||
StressEvent event = new StressEvent();
|
||||
event.iteration = i;
|
||||
event.description = "Stressful Event, take it easy!";
|
||||
event.customClazz = StressEvent.class;
|
||||
event.value = i;
|
||||
event.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal StressEvent class.
|
||||
*/
|
||||
@Label("Stress Event")
|
||||
@Description("A duration event with 4 entries")
|
||||
@Name("JFRDynamicCDS.StressEvent")
|
||||
public static class StressEvent extends jdk.jfr.Event {
|
||||
public Class<?> customClazz;
|
||||
public String description;
|
||||
public int iteration;
|
||||
public double value;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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 @@
|
||||
* @library /test/lib
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* java.management
|
||||
* @run main TestLargePagesFlags
|
||||
* @run driver TestLargePagesFlags
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, 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
|
||||
@ -87,6 +87,7 @@ public class AvailableProcessors {
|
||||
System.out.println("Final command line: " +
|
||||
ProcessTools.getCommandLine(pb));
|
||||
OutputAnalyzer output = ProcessTools.executeProcess(pb);
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain(SUCCESS_STRING);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2021, 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,6 +47,7 @@ public class TestUseCpuAllocPath {
|
||||
"-version");
|
||||
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain(SUCCESS_STRING);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.StandardSocketOptions;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.AsynchronousServerSocketChannel;
|
||||
import java.nio.channels.AsynchronousSocketChannel;
|
||||
@ -267,7 +268,7 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest {
|
||||
}
|
||||
}));
|
||||
// give time for socket buffer to fill up.
|
||||
Thread.sleep(5*1000);
|
||||
awaitNoFurtherWrites(bytesWritten);
|
||||
|
||||
assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is acquired by");
|
||||
assertTrue(scope.isAlive());
|
||||
@ -279,15 +280,40 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest {
|
||||
// in turn unlock the scope and allow it to be closed.
|
||||
readNBytes(asc2, bytesWritten.get());
|
||||
assertTrue(scope.isAlive());
|
||||
out.println("outstanding writes: " + outstandingWriteOps.get());
|
||||
while (outstandingWriteOps.get() > 0 ) {
|
||||
out.println("spinning");
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
awaitOutstandingWrites(outstandingWriteOps);
|
||||
handler.await();
|
||||
}
|
||||
}
|
||||
|
||||
/** Waits for outstandingWriteOps to complete (become 0). */
|
||||
static void awaitOutstandingWrites(AtomicInteger outstandingWriteOps) {
|
||||
boolean initial = true;
|
||||
while (outstandingWriteOps.get() > 0 ) {
|
||||
if (initial) {
|
||||
out.print("awaiting outstanding writes");
|
||||
initial = false;
|
||||
}
|
||||
out.print(".");
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
out.println("outstanding writes: " + outstandingWriteOps.get());
|
||||
}
|
||||
|
||||
/** Waits, at most 20secs, for bytesWritten to stabilize. */
|
||||
static void awaitNoFurtherWrites(AtomicLong bytesWritten) throws Exception {
|
||||
int i;
|
||||
long prevN = 0;
|
||||
for (i=0; i<10; i++) {
|
||||
long n = bytesWritten.get();
|
||||
Thread.sleep(2 * 1000);
|
||||
if (bytesWritten.get() == n && prevN == n) {
|
||||
break;
|
||||
}
|
||||
prevN = n;
|
||||
}
|
||||
out.println("awaitNoFurtherWrites: i=" + i +" , bytesWritten=" + bytesWritten.get());
|
||||
}
|
||||
|
||||
/** Completion handler that exposes conveniences to assert results. */
|
||||
static class TestHandler<V extends Number> implements CompletionHandler<V, Void> {
|
||||
volatile V result;
|
||||
@ -357,11 +383,27 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest {
|
||||
AsynchronousSocketChannel asc)
|
||||
throws Exception
|
||||
{
|
||||
setBufferSized(assc, asc);
|
||||
assc.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
|
||||
asc.connect(assc.getLocalAddress()).get();
|
||||
return assc.accept().get();
|
||||
}
|
||||
|
||||
/** Sets the send/receive buffer sizes in an attempt/hint to limit the
|
||||
* accepted/connected socket buffer sizes. Actual buffer sizes in use will
|
||||
* likely be larger due to TCP auto-tuning, but the hint typically reduces
|
||||
* the overall scaled sizes. This is primarily to stabilize outstanding
|
||||
* write operations.
|
||||
*/
|
||||
static void setBufferSized(AsynchronousServerSocketChannel assc,
|
||||
AsynchronousSocketChannel asc)
|
||||
throws Exception
|
||||
{
|
||||
assc.setOption(StandardSocketOptions.SO_RCVBUF, 32 * 1024);
|
||||
asc.setOption(StandardSocketOptions.SO_SNDBUF, 32 * 1024);
|
||||
asc.setOption(StandardSocketOptions.SO_RCVBUF, 32 * 1024);
|
||||
}
|
||||
|
||||
/** Tolerate the additional level of IOException wrapping of unchecked exceptions
|
||||
* On Windows, when completing the completion handler with a failure. */
|
||||
static Throwable tolerateIOEOnWindows(Throwable t) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, 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,8 @@ import com.sun.net.httpserver.HttpsConfigurator;
|
||||
import com.sun.net.httpserver.HttpsServer;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -50,6 +52,7 @@ import java.net.http.HttpResponse.BodyHandler;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -63,6 +66,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Flow;
|
||||
import java.util.concurrent.SubmissionPublisher;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
@ -138,17 +142,37 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters {
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
// Exceptions should already have been added to FAILURES
|
||||
// var failed = context.getFailedTests().getAllResults().stream()
|
||||
// .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
// FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
@ -385,6 +409,7 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters {
|
||||
boolean async, Set<Where> whereValues)
|
||||
throws Exception
|
||||
{
|
||||
checkSkip();
|
||||
out.printf("%n%s%s%n", now(), name);
|
||||
try {
|
||||
testThrowing(uri, sameClient, publishers, finisher, thrower, async, whereValues);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, 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,8 @@
|
||||
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -68,6 +70,7 @@ import java.net.http.HttpResponse.BodySubscriber;
|
||||
import java.net.http.HttpResponse.PushPromiseHandler;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -79,6 +82,7 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Flow;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
@ -151,17 +155,37 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
// Exceptions should already have been added to FAILURES
|
||||
// var failed = context.getFailedTests().getAllResults().stream()
|
||||
// .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
// FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
@ -360,6 +384,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters
|
||||
Finisher finisher, Thrower thrower)
|
||||
throws Exception
|
||||
{
|
||||
checkSkip();
|
||||
out.printf("%n%s%s%n", now(), name);
|
||||
try {
|
||||
testThrowing(uri, sameClient, handlers, finisher, thrower);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, 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,8 @@ import com.sun.net.httpserver.HttpsConfigurator;
|
||||
import com.sun.net.httpserver.HttpsServer;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -52,6 +54,7 @@ import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.net.http.HttpResponse.BodySubscriber;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -62,6 +65,7 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Flow;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
@ -137,17 +141,37 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
// Exceptions should already have been added to FAILURES
|
||||
// var failed = context.getFailedTests().getAllResults().stream()
|
||||
// .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
// FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
@ -379,6 +403,7 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters
|
||||
boolean async, EnumSet<Where> excludes)
|
||||
throws Exception
|
||||
{
|
||||
checkSkip();
|
||||
out.printf("%n%s%s%n", now(), name);
|
||||
try {
|
||||
testThrowing(uri, sameClient, handlers, finisher, thrower, async, excludes);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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,6 +47,7 @@ import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -63,6 +64,7 @@ import java.util.concurrent.Flow.Subscription;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
@ -76,6 +78,8 @@ import com.sun.net.httpserver.HttpsServer;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.Assert;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -151,17 +155,36 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
var failed = context.getFailedTests().getAllResults().stream()
|
||||
.collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
@ -446,6 +469,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
|
||||
@Test(dataProvider = "sparseContent") // checks that NPE is thrown
|
||||
public void testNullPointerException(String description, String[] content) {
|
||||
checkSkip();
|
||||
BodyPublisher[] publishers = publishers(content);
|
||||
Assert.assertThrows(NullPointerException.class, () -> BodyPublishers.concat(publishers));
|
||||
}
|
||||
@ -453,6 +477,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
// Verifies that an empty array creates a "noBody" publisher
|
||||
@Test
|
||||
public void testEmpty() {
|
||||
checkSkip();
|
||||
BodyPublisher publisher = BodyPublishers.concat();
|
||||
RequestSubscriber subscriber = new RequestSubscriber();
|
||||
assertEquals(publisher.contentLength(), 0);
|
||||
@ -466,6 +491,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
// verifies that error emitted by upstream publishers are propagated downstream.
|
||||
@Test(dataProvider = "sparseContent") // nulls are replaced with error publisher
|
||||
public void testOnError(String description, String[] content) {
|
||||
checkSkip();
|
||||
final RequestSubscriber subscriber = new RequestSubscriber();
|
||||
final PublishWithError errorPublisher;
|
||||
final BodyPublisher[] publishers;
|
||||
@ -521,6 +547,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
// the length should be known.
|
||||
@Test(dataProvider = "sparseContent") // nulls are replaced with unknown length
|
||||
public void testUnknownContentLength(String description, String[] content) {
|
||||
checkSkip();
|
||||
if (content == null) {
|
||||
content = BODIES.toArray(String[]::new);
|
||||
description = "BODIES (known length)";
|
||||
@ -561,6 +588,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
|
||||
@Test(dataProvider = "negativeRequests")
|
||||
public void testNegativeRequest(long n) {
|
||||
checkSkip();
|
||||
assert n <= 0 : "test for negative request called with n > 0 : " + n;
|
||||
BodyPublisher[] publishers = ContentLengthPublisher.of(List.of(1L, 2L, 3L));
|
||||
BodyPublisher publisher = BodyPublishers.concat(publishers);
|
||||
@ -584,6 +612,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
|
||||
@Test
|
||||
public void testPositiveRequests() {
|
||||
checkSkip();
|
||||
// A composite array of publishers
|
||||
BodyPublisher[] publishers = Stream.of(
|
||||
Stream.of(ofStrings("Lorem", " ", "ipsum", " ")),
|
||||
@ -626,6 +655,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
|
||||
@Test(dataProvider = "contentLengths")
|
||||
public void testContentLength(long expected, List<Long> lengths) {
|
||||
checkSkip();
|
||||
BodyPublisher[] publishers = ContentLengthPublisher.of(lengths);
|
||||
BodyPublisher aggregate = BodyPublishers.concat(publishers);
|
||||
assertEquals(aggregate.contentLength(), expected,
|
||||
@ -636,6 +666,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
// publishers are no longer subscribed etc...
|
||||
@Test
|
||||
public void testCancel() {
|
||||
checkSkip();
|
||||
BodyPublisher[] publishers = BODIES.stream()
|
||||
.map(BodyPublishers::ofString)
|
||||
.toArray(BodyPublisher[]::new);
|
||||
@ -695,6 +726,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
// Verifies that cancelling the subscription is propagated downstream
|
||||
@Test
|
||||
public void testCancelSubscription() {
|
||||
checkSkip();
|
||||
PublishWithError upstream = new PublishWithError(BODIES, BODIES.size(),
|
||||
() -> new AssertionError("should not come here"));
|
||||
BodyPublisher publisher = BodyPublishers.concat(upstream);
|
||||
@ -756,6 +788,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||
|
||||
@Test(dataProvider = "variants")
|
||||
public void test(String uri, boolean sameClient) throws Exception {
|
||||
checkSkip();
|
||||
System.out.println("Request to " + uri);
|
||||
|
||||
HttpClient client = newHttpClient(sameClient);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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
|
||||
@ -45,6 +45,8 @@ import com.sun.net.httpserver.HttpsServer;
|
||||
import jdk.test.lib.RandomFactory;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -65,6 +67,7 @@ import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandler;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@ -77,6 +80,7 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -149,16 +153,34 @@ public class CancelRequestTest implements HttpServerAdapters {
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
var failed = context.getFailedTests().getAllResults().stream()
|
||||
.collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
FAILURES.putAll(failed);
|
||||
try {
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
@ -275,6 +297,7 @@ public class CancelRequestTest implements HttpServerAdapters {
|
||||
@Test(dataProvider = "asyncurls")
|
||||
public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning)
|
||||
throws Exception {
|
||||
checkSkip();
|
||||
HttpClient client = null;
|
||||
uri = uri + "/get";
|
||||
out.printf("%n%s testGetSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning);
|
||||
@ -360,6 +383,7 @@ public class CancelRequestTest implements HttpServerAdapters {
|
||||
@Test(dataProvider = "asyncurls")
|
||||
public void testPostSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning)
|
||||
throws Exception {
|
||||
checkSkip();
|
||||
uri = uri + "/post";
|
||||
HttpClient client = null;
|
||||
out.printf("%n%s testPostSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning);
|
||||
@ -463,6 +487,7 @@ public class CancelRequestTest implements HttpServerAdapters {
|
||||
@Test(dataProvider = "urls")
|
||||
public void testPostInterrupt(String uri, boolean sameClient)
|
||||
throws Exception {
|
||||
checkSkip();
|
||||
HttpClient client = null;
|
||||
out.printf("%n%s testPostInterrupt(%s, %b)%n", now(), uri, sameClient);
|
||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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
|
||||
@ -49,6 +49,8 @@ import com.sun.net.httpserver.HttpsConfigurator;
|
||||
import com.sun.net.httpserver.HttpsServer;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -72,6 +74,7 @@ import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -80,6 +83,7 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static java.lang.System.err;
|
||||
import static java.lang.System.out;
|
||||
@ -148,17 +152,37 @@ public class ForbiddenHeadTest implements HttpServerAdapters {
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
// Exceptions should already have been added to FAILURES
|
||||
// var failed = context.getFailedTests().getAllResults().stream()
|
||||
// .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
// FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
@ -219,6 +243,7 @@ public class ForbiddenHeadTest implements HttpServerAdapters {
|
||||
|
||||
@Test(dataProvider = "all")
|
||||
void test(String uriString, int code, boolean async, HttpClient client) throws Throwable {
|
||||
checkSkip();
|
||||
var name = String.format("test(%s, %d, %s, %s)", uriString, code, async ? "async" : "sync",
|
||||
client.authenticator().isPresent() ? "authClient" : "noAuthClient");
|
||||
out.printf("%n---- starting %s ----%n", name);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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
|
||||
@ -55,6 +55,7 @@ import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -72,6 +73,7 @@ import java.util.concurrent.Flow.Subscription;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
@ -85,6 +87,8 @@ import com.sun.net.httpserver.HttpsServer;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.Assert;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -162,17 +166,36 @@ public class ISO_8859_1_Test implements HttpServerAdapters {
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
var failed = context.getFailedTests().getAllResults().stream()
|
||||
.collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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
|
||||
@ -50,6 +50,8 @@ import com.sun.net.httpserver.HttpsConfigurator;
|
||||
import com.sun.net.httpserver.HttpsServer;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -70,6 +72,7 @@ import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -78,6 +81,8 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.lang.System.err;
|
||||
import static java.lang.System.out;
|
||||
@ -148,10 +153,25 @@ public class ProxySelectorTest implements HttpServerAdapters {
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,6 +179,11 @@ public class ProxySelectorTest implements HttpServerAdapters {
|
||||
static final void printFailedTests() {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
// Exceptions should already have been added to FAILURES
|
||||
// var failed = context.getFailedTests().getAllResults().stream()
|
||||
// .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
// FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
@ -210,6 +235,7 @@ public class ProxySelectorTest implements HttpServerAdapters {
|
||||
void test(Schemes scheme, HttpClient.Version version, String uri, boolean async)
|
||||
throws Throwable
|
||||
{
|
||||
checkSkip();
|
||||
var name = String.format("test(%s, %s, %s)", scheme, version, async);
|
||||
out.printf("%n---- starting %s ----%n", name);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, 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
|
||||
@ -48,14 +48,20 @@ import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -123,17 +129,36 @@ public class Response204V2Test implements HttpServerAdapters {
|
||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
||||
}
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests() {
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================");
|
||||
try {
|
||||
var failed = context.getFailedTests().getAllResults().stream()
|
||||
.collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
FAILURES.putAll(failed);
|
||||
|
||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||
now(), serverCount.get(), clientCount.get());
|
||||
if (FAILURES.isEmpty()) return;
|
||||
@ -220,6 +245,7 @@ public class Response204V2Test implements HttpServerAdapters {
|
||||
|
||||
@Test(dataProvider = "variants")
|
||||
public void test(String uri, boolean sameClient) throws Exception {
|
||||
checkSkip();
|
||||
System.out.println("Request to " + uri);
|
||||
|
||||
HttpClient client = newHttpClient(sameClient);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2021, 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
|
||||
@ -54,9 +54,14 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.ITestResult;
|
||||
import org.testng.SkipException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
@ -107,10 +112,44 @@ public class ShortResponseBody {
|
||||
};
|
||||
final ExecutorService service = Executors.newCachedThreadPool(factory);
|
||||
|
||||
final AtomicReference<SkipException> skiptests = new AtomicReference<>();
|
||||
void checkSkip() {
|
||||
var skip = skiptests.get();
|
||||
if (skip != null) throw skip;
|
||||
}
|
||||
static String name(ITestResult result) {
|
||||
var params = result.getParameters();
|
||||
return result.getName()
|
||||
+ (params == null ? "()" : Arrays.toString(result.getParameters()));
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
void beforeMethod(ITestContext context) {
|
||||
if (context.getFailedTests().size() > 0) {
|
||||
throw new RuntimeException("some tests failed");
|
||||
if (skiptests.get() == null) {
|
||||
SkipException skip = new SkipException("some tests failed");
|
||||
skip.setStackTrace(new StackTraceElement[0]);
|
||||
skiptests.compareAndSet(null, skip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
static final void printFailedTests(ITestContext context) {
|
||||
out.println("\n=========================\n");
|
||||
try {
|
||||
var FAILURES = context.getFailedTests().getAllResults().stream()
|
||||
.collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||
|
||||
if (FAILURES.isEmpty()) return;
|
||||
out.println("Failed tests: ");
|
||||
FAILURES.entrySet().forEach((e) -> {
|
||||
out.printf("\t%s: %s%n", e.getKey(), e.getValue());
|
||||
e.getValue().printStackTrace(out);
|
||||
e.getValue().printStackTrace();
|
||||
});
|
||||
} finally {
|
||||
out.println("\n=========================\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,6 +267,7 @@ public class ShortResponseBody {
|
||||
void testSynchronousGET(String url, String expectedMsg, boolean sameClient)
|
||||
throws Exception
|
||||
{
|
||||
checkSkip();
|
||||
out.print("---\n");
|
||||
HttpClient client = null;
|
||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||
@ -253,6 +293,7 @@ public class ShortResponseBody {
|
||||
void testAsynchronousGET(String url, String expectedMsg, boolean sameClient)
|
||||
throws Exception
|
||||
{
|
||||
checkSkip();
|
||||
out.print("---\n");
|
||||
HttpClient client = null;
|
||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||
@ -335,6 +376,7 @@ public class ShortResponseBody {
|
||||
void testSynchronousPOST(String url, String expectedMsg, boolean sameClient)
|
||||
throws Exception
|
||||
{
|
||||
checkSkip();
|
||||
out.print("---\n");
|
||||
HttpClient client = null;
|
||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||
@ -368,6 +410,7 @@ public class ShortResponseBody {
|
||||
void testAsynchronousPOST(String url, String expectedMsg, boolean sameClient)
|
||||
throws Exception
|
||||
{
|
||||
checkSkip();
|
||||
out.print("---\n");
|
||||
HttpClient client = null;
|
||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||
|
@ -34,6 +34,13 @@
|
||||
import jdk.test.lib.Asserts;
|
||||
import sun.security.krb5.Config;
|
||||
|
||||
// =================== Attention ===================
|
||||
// This test calls a native method implemented in libTestDynamicStore.m
|
||||
// to modify system-level Kerberos 5 settings stored in the dynamic store.
|
||||
// It must be launched by a user with enough privilege or with "sudo".
|
||||
// If launched with sudo, remember to remove the report and working
|
||||
// directories with sudo as well after executing the test.
|
||||
|
||||
public class TestDynamicStore {
|
||||
|
||||
native static int actionInternal(char what, char whom);
|
||||
@ -59,7 +66,10 @@ public class TestDynamicStore {
|
||||
|
||||
try {
|
||||
System.out.println("Fill in dynamic store");
|
||||
action('a', 'a');
|
||||
if (action('a', 'a') == 0) {
|
||||
throw new Exception("Cannot write native Kerberos settings. " +
|
||||
"Please make sure the test runs with enough privilege.");
|
||||
}
|
||||
Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM"));
|
||||
Asserts.assertTrue(Config.getInstance().exists("domain_realm"));
|
||||
|
||||
|
@ -62,7 +62,9 @@ int addMapping(SCDynamicStoreRef store) {
|
||||
|
||||
int addAll(SCDynamicStoreRef store) {
|
||||
NSArray *keys = [NSArray arrayWithObjects:@"A.COM", @"B.COM", nil];
|
||||
fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS, keys));
|
||||
Boolean b = SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS, keys);
|
||||
fprintf(stderr, "%d\n", b);
|
||||
if (!b) return 0;
|
||||
|
||||
NSDictionary *k1 = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"kdc1.a.com", @"host", nil];
|
||||
|
Loading…
x
Reference in New Issue
Block a user