mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
Merge
Reviewed-by: dcubed
This commit is contained in:
commit
17295b1bb0
30 changed files with 650 additions and 150 deletions
|
@ -1354,11 +1354,29 @@ bool SystemDictionaryShared::check_for_exclusion(InstanceKlass* k, DumpTimeShare
|
||||||
return info->is_excluded();
|
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) {
|
bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) {
|
||||||
if (k->is_in_error_state()) {
|
if (k->is_in_error_state()) {
|
||||||
return warn_excluded(k, "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");
|
return warn_excluded(k, "Has been redefined");
|
||||||
}
|
}
|
||||||
if (!k->is_hidden() && k->shared_classpath_index() < 0 && is_builtin(k)) {
|
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 is_registered_lambda_proxy_class(InstanceKlass* ik);
|
||||||
static bool warn_excluded(InstanceKlass* k, const char* reason);
|
static bool warn_excluded(InstanceKlass* k, const char* reason);
|
||||||
static bool check_for_exclusion_impl(InstanceKlass* k);
|
static bool check_for_exclusion_impl(InstanceKlass* k);
|
||||||
|
static bool has_been_redefined(InstanceKlass* k);
|
||||||
|
|
||||||
static bool _dump_in_progress;
|
static bool _dump_in_progress;
|
||||||
DEBUG_ONLY(static bool _no_class_loading_should_happen;)
|
DEBUG_ONLY(static bool _no_class_loading_should_happen;)
|
||||||
|
|
|
@ -435,6 +435,7 @@ final class CipherCore {
|
||||||
|
|
||||||
byte[] keyBytes = getKeyBytes(key);
|
byte[] keyBytes = getKeyBytes(key);
|
||||||
byte[] ivBytes = null;
|
byte[] ivBytes = null;
|
||||||
|
try {
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
if (params instanceof IvParameterSpec) {
|
if (params instanceof IvParameterSpec) {
|
||||||
ivBytes = ((IvParameterSpec) params).getIV();
|
ivBytes = ((IvParameterSpec) params).getIV();
|
||||||
|
@ -479,6 +480,9 @@ final class CipherCore {
|
||||||
|
|
||||||
String algorithm = key.getAlgorithm();
|
String algorithm = key.getAlgorithm();
|
||||||
cipher.init(decrypting, algorithm, keyBytes, ivBytes);
|
cipher.init(decrypting, algorithm, keyBytes, ivBytes);
|
||||||
|
} finally {
|
||||||
|
Arrays.fill(keyBytes, (byte)0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(int opmode, Key key, AlgorithmParameters params,
|
void init(int opmode, Key key, AlgorithmParameters params,
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
package com.sun.crypto.provider;
|
package com.sun.crypto.provider;
|
||||||
|
|
||||||
|
import jdk.internal.access.SharedSecrets;
|
||||||
|
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
|
@ -48,24 +50,18 @@ import javax.crypto.spec.SecretKeySpec;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final class ConstructKeys {
|
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,
|
private static final PublicKey constructPublicKey(byte[] encodedKey,
|
||||||
String encodedKeyAlgorithm)
|
int ofs, int len, String encodedKeyAlgorithm)
|
||||||
throws InvalidKeyException, NoSuchAlgorithmException {
|
throws InvalidKeyException, NoSuchAlgorithmException {
|
||||||
PublicKey key = null;
|
PublicKey key = null;
|
||||||
|
byte[] keyBytes = (ofs == 0 && encodedKey.length == len)
|
||||||
|
? encodedKey : Arrays.copyOfRange(encodedKey, ofs, ofs + len);
|
||||||
|
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
|
||||||
try {
|
try {
|
||||||
KeyFactory keyFactory =
|
KeyFactory keyFactory =
|
||||||
KeyFactory.getInstance(encodedKeyAlgorithm,
|
KeyFactory.getInstance(encodedKeyAlgorithm,
|
||||||
SunJCE.getInstance());
|
SunJCE.getInstance());
|
||||||
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey);
|
|
||||||
key = keyFactory.generatePublic(keySpec);
|
key = keyFactory.generatePublic(keySpec);
|
||||||
} catch (NoSuchAlgorithmException nsae) {
|
} catch (NoSuchAlgorithmException nsae) {
|
||||||
// Try to see whether there is another
|
// Try to see whether there is another
|
||||||
|
@ -73,8 +69,6 @@ final class ConstructKeys {
|
||||||
try {
|
try {
|
||||||
KeyFactory keyFactory =
|
KeyFactory keyFactory =
|
||||||
KeyFactory.getInstance(encodedKeyAlgorithm);
|
KeyFactory.getInstance(encodedKeyAlgorithm);
|
||||||
X509EncodedKeySpec keySpec =
|
|
||||||
new X509EncodedKeySpec(encodedKey);
|
|
||||||
key = keyFactory.generatePublic(keySpec);
|
key = keyFactory.generatePublic(keySpec);
|
||||||
} catch (NoSuchAlgorithmException nsae2) {
|
} catch (NoSuchAlgorithmException nsae2) {
|
||||||
throw new NoSuchAlgorithmException("No installed providers " +
|
throw new NoSuchAlgorithmException("No installed providers " +
|
||||||
|
@ -97,25 +91,17 @@ final class ConstructKeys {
|
||||||
return key;
|
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,
|
private static final PrivateKey constructPrivateKey(byte[] encodedKey,
|
||||||
String encodedKeyAlgorithm)
|
int ofs, int len, String encodedKeyAlgorithm)
|
||||||
throws InvalidKeyException, NoSuchAlgorithmException {
|
throws InvalidKeyException, NoSuchAlgorithmException {
|
||||||
PrivateKey key = null;
|
PrivateKey key = null;
|
||||||
|
byte[] keyBytes = (ofs == 0 && encodedKey.length == len)
|
||||||
|
? encodedKey : Arrays.copyOfRange(encodedKey, ofs, ofs + len);
|
||||||
|
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
|
||||||
try {
|
try {
|
||||||
KeyFactory keyFactory =
|
KeyFactory keyFactory =
|
||||||
KeyFactory.getInstance(encodedKeyAlgorithm,
|
KeyFactory.getInstance(encodedKeyAlgorithm,
|
||||||
SunJCE.getInstance());
|
SunJCE.getInstance());
|
||||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey);
|
|
||||||
return keyFactory.generatePrivate(keySpec);
|
return keyFactory.generatePrivate(keySpec);
|
||||||
} catch (NoSuchAlgorithmException nsae) {
|
} catch (NoSuchAlgorithmException nsae) {
|
||||||
// Try to see whether there is another
|
// Try to see whether there is another
|
||||||
|
@ -123,8 +109,6 @@ final class ConstructKeys {
|
||||||
try {
|
try {
|
||||||
KeyFactory keyFactory =
|
KeyFactory keyFactory =
|
||||||
KeyFactory.getInstance(encodedKeyAlgorithm);
|
KeyFactory.getInstance(encodedKeyAlgorithm);
|
||||||
PKCS8EncodedKeySpec keySpec =
|
|
||||||
new PKCS8EncodedKeySpec(encodedKey);
|
|
||||||
key = keyFactory.generatePrivate(keySpec);
|
key = keyFactory.generatePrivate(keySpec);
|
||||||
} catch (NoSuchAlgorithmException nsae2) {
|
} catch (NoSuchAlgorithmException nsae2) {
|
||||||
throw new NoSuchAlgorithmException("No installed providers " +
|
throw new NoSuchAlgorithmException("No installed providers " +
|
||||||
|
@ -142,20 +126,16 @@ final class ConstructKeys {
|
||||||
new InvalidKeyException("Cannot construct private key");
|
new InvalidKeyException("Cannot construct private key");
|
||||||
ike.initCause(ikse);
|
ike.initCause(ikse);
|
||||||
throw ike;
|
throw ike;
|
||||||
|
} finally {
|
||||||
|
SharedSecrets.getJavaSecuritySpecAccess().clearEncodedKeySpec(keySpec);
|
||||||
|
if (keyBytes != encodedKey) {
|
||||||
|
Arrays.fill(keyBytes, (byte)0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
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,
|
private static final SecretKey constructSecretKey(byte[] encodedKey,
|
||||||
int ofs, int len, String encodedKeyAlgorithm) {
|
int ofs, int len, String encodedKeyAlgorithm) {
|
||||||
return (new SecretKeySpec(encodedKey, ofs, len, 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,
|
static final Key constructKey(byte[] encoding, int ofs, int len,
|
||||||
String keyAlgorithm, int keyType)
|
String keyAlgorithm, int keyType)
|
||||||
throws InvalidKeyException, NoSuchAlgorithmException {
|
throws InvalidKeyException, NoSuchAlgorithmException {
|
||||||
switch (keyType) {
|
return switch (keyType) {
|
||||||
case Cipher.SECRET_KEY:
|
case Cipher.SECRET_KEY -> ConstructKeys.constructSecretKey(
|
||||||
try {
|
encoding, ofs, len, keyAlgorithm);
|
||||||
return ConstructKeys.constructSecretKey(encoding, ofs, len,
|
case Cipher.PRIVATE_KEY -> ConstructKeys.constructPrivateKey(
|
||||||
keyAlgorithm);
|
encoding, ofs, len, keyAlgorithm);
|
||||||
} finally {
|
case Cipher.PUBLIC_KEY -> ConstructKeys.constructPublicKey(
|
||||||
Arrays.fill(encoding, ofs, len, (byte)0);
|
encoding, ofs, len, keyAlgorithm);
|
||||||
}
|
default -> throw new NoSuchAlgorithmException("Unsupported key type");
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,13 @@ abstract class GaloisCounterMode extends CipherSpi {
|
||||||
reInit = false;
|
reInit = false;
|
||||||
|
|
||||||
// always encrypt mode for embedded cipher
|
// always encrypt mode for embedded cipher
|
||||||
|
try {
|
||||||
blockCipher.init(false, key.getAlgorithm(), keyValue);
|
blockCipher.init(false, key.getAlgorithm(), keyValue);
|
||||||
|
} finally {
|
||||||
|
if (!encryption) {
|
||||||
|
Arrays.fill(keyValue, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -124,6 +124,7 @@ class KWUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.arraycopy(buffer, 0, icvOut, 0, SEMI_BLKSIZE);
|
System.arraycopy(buffer, 0, icvOut, 0, SEMI_BLKSIZE);
|
||||||
|
Arrays.fill(buffer, (byte)0);
|
||||||
return inLen - SEMI_BLKSIZE;
|
return inLen - SEMI_BLKSIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,7 +472,11 @@ abstract class KeyWrapCipher extends CipherSpi {
|
||||||
int outLen = engineDoFinal(in, inOfs, inLen, out, 0);
|
int outLen = engineDoFinal(in, inOfs, inLen, out, 0);
|
||||||
|
|
||||||
if (outLen < estOutLen) {
|
if (outLen < estOutLen) {
|
||||||
|
try {
|
||||||
return Arrays.copyOf(out, outLen);
|
return Arrays.copyOf(out, outLen);
|
||||||
|
} finally {
|
||||||
|
Arrays.fill(out, (byte)0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -529,6 +533,9 @@ abstract class KeyWrapCipher extends CipherSpi {
|
||||||
return outLen;
|
return outLen;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
if (dataBuf != null) {
|
||||||
|
Arrays.fill(dataBuf, (byte)0);
|
||||||
|
}
|
||||||
dataBuf = null;
|
dataBuf = null;
|
||||||
dataIdx = 0;
|
dataIdx = 0;
|
||||||
}
|
}
|
||||||
|
@ -559,8 +566,14 @@ abstract class KeyWrapCipher extends CipherSpi {
|
||||||
len += inLen;
|
len += inLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (opmode == Cipher.ENCRYPT_MODE?
|
try {
|
||||||
|
return (opmode == Cipher.ENCRYPT_MODE ?
|
||||||
helperEncrypt(out, len) : helperDecrypt(out, len));
|
helperEncrypt(out, len) : helperDecrypt(out, len));
|
||||||
|
} finally {
|
||||||
|
if (dataBuf != null && dataBuf != out) {
|
||||||
|
Arrays.fill(dataBuf, (byte)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper routine for in-place encryption.
|
// helper routine for in-place encryption.
|
||||||
|
|
|
@ -70,6 +70,7 @@ environment=\
|
||||||
users.current users.logged users.last \
|
users.current users.logged users.last \
|
||||||
disk \
|
disk \
|
||||||
env \
|
env \
|
||||||
|
ulimit \
|
||||||
system.dmesg system.sysctl \
|
system.dmesg system.sysctl \
|
||||||
process.top process.ps \
|
process.top process.ps \
|
||||||
memory.free memory.vmstat.default memory.vmstat.statistics \
|
memory.free memory.vmstat.default memory.vmstat.statistics \
|
||||||
|
@ -91,6 +92,10 @@ disk.args=-h
|
||||||
|
|
||||||
env.app=env
|
env.app=env
|
||||||
|
|
||||||
|
ulimit.app=bash
|
||||||
|
ulimit.args=-c\0ulimit -a
|
||||||
|
ulimit.args.delimiter=\0
|
||||||
|
|
||||||
system.dmesg.app=dmesg
|
system.dmesg.app=dmesg
|
||||||
system.sysctl.app=sysctl
|
system.sysctl.app=sysctl
|
||||||
system.sysctl.args=-a
|
system.sysctl.args=-a
|
||||||
|
|
|
@ -78,6 +78,7 @@ environment=\
|
||||||
users.current users.logged users.last \
|
users.current users.logged users.last \
|
||||||
disk \
|
disk \
|
||||||
env \
|
env \
|
||||||
|
ulimit \
|
||||||
system.dmesg system.sysctl \
|
system.dmesg system.sysctl \
|
||||||
process.ps process.top \
|
process.ps process.top \
|
||||||
memory.vmstat \
|
memory.vmstat \
|
||||||
|
@ -98,6 +99,10 @@ disk.args=-h
|
||||||
|
|
||||||
env.app=env
|
env.app=env
|
||||||
|
|
||||||
|
ulimit.app=bash
|
||||||
|
ulimit.args=-c\0ulimit -a
|
||||||
|
ulimit.args.delimiter=\0
|
||||||
|
|
||||||
system.dmesg.app=dmesg
|
system.dmesg.app=dmesg
|
||||||
system.sysctl.app=sysctl
|
system.sysctl.app=sysctl
|
||||||
system.sysctl.args=-a
|
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.
|
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
#
|
#
|
||||||
# This code is free software; you can redistribute it and/or modify it
|
# This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -66,6 +66,7 @@ environment=\
|
||||||
users.current users.logged \
|
users.current users.logged \
|
||||||
disk \
|
disk \
|
||||||
env \
|
env \
|
||||||
|
ulimit \
|
||||||
system.events.system system.events.application system.os \
|
system.events.system system.events.application system.os \
|
||||||
process.top process.ps process.tasklist \
|
process.top process.ps process.tasklist \
|
||||||
memory.free memory.vmstat.default memory.vmstat.statistics \
|
memory.free memory.vmstat.default memory.vmstat.statistics \
|
||||||
|
@ -84,6 +85,10 @@ disk.args=-h
|
||||||
|
|
||||||
env.app=env
|
env.app=env
|
||||||
|
|
||||||
|
ulimit.app=bash
|
||||||
|
ulimit.args=-c\0ulimit -a
|
||||||
|
ulimit.args.delimiter=\0
|
||||||
|
|
||||||
system.events.app=powershell
|
system.events.app=powershell
|
||||||
system.events.delimiter=\0
|
system.events.delimiter=\0
|
||||||
system.events.system.args=-NoLogo\0-Command\0Get-EventLog System -After (Get-Date).AddDays(-1) | Format-List
|
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/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java 8224150 generic-all
|
||||||
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all
|
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all
|
||||||
serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-x64
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.management
|
* java.management
|
||||||
* @run main TestLargePagesFlags
|
* @run driver TestLargePagesFlags
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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: " +
|
System.out.println("Final command line: " +
|
||||||
ProcessTools.getCommandLine(pb));
|
ProcessTools.getCommandLine(pb));
|
||||||
OutputAnalyzer output = ProcessTools.executeProcess(pb);
|
OutputAnalyzer output = ProcessTools.executeProcess(pb);
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
output.shouldContain(SUCCESS_STRING);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -47,6 +47,7 @@ public class TestUseCpuAllocPath {
|
||||||
"-version");
|
"-version");
|
||||||
|
|
||||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
output.shouldHaveExitValue(0);
|
||||||
output.shouldContain(SUCCESS_STRING);
|
output.shouldContain(SUCCESS_STRING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.StandardSocketOptions;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.AsynchronousServerSocketChannel;
|
import java.nio.channels.AsynchronousServerSocketChannel;
|
||||||
import java.nio.channels.AsynchronousSocketChannel;
|
import java.nio.channels.AsynchronousSocketChannel;
|
||||||
|
@ -267,7 +268,7 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
// give time for socket buffer to fill up.
|
// give time for socket buffer to fill up.
|
||||||
Thread.sleep(5*1000);
|
awaitNoFurtherWrites(bytesWritten);
|
||||||
|
|
||||||
assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is acquired by");
|
assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is acquired by");
|
||||||
assertTrue(scope.isAlive());
|
assertTrue(scope.isAlive());
|
||||||
|
@ -279,15 +280,40 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest {
|
||||||
// in turn unlock the scope and allow it to be closed.
|
// in turn unlock the scope and allow it to be closed.
|
||||||
readNBytes(asc2, bytesWritten.get());
|
readNBytes(asc2, bytesWritten.get());
|
||||||
assertTrue(scope.isAlive());
|
assertTrue(scope.isAlive());
|
||||||
out.println("outstanding writes: " + outstandingWriteOps.get());
|
awaitOutstandingWrites(outstandingWriteOps);
|
||||||
while (outstandingWriteOps.get() > 0 ) {
|
|
||||||
out.println("spinning");
|
|
||||||
Thread.onSpinWait();
|
|
||||||
}
|
|
||||||
handler.await();
|
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. */
|
/** Completion handler that exposes conveniences to assert results. */
|
||||||
static class TestHandler<V extends Number> implements CompletionHandler<V, Void> {
|
static class TestHandler<V extends Number> implements CompletionHandler<V, Void> {
|
||||||
volatile V result;
|
volatile V result;
|
||||||
|
@ -357,11 +383,27 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest {
|
||||||
AsynchronousSocketChannel asc)
|
AsynchronousSocketChannel asc)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
setBufferSized(assc, asc);
|
||||||
assc.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
|
assc.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
|
||||||
asc.connect(assc.getLocalAddress()).get();
|
asc.connect(assc.getLocalAddress()).get();
|
||||||
return assc.accept().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
|
/** Tolerate the additional level of IOException wrapping of unchecked exceptions
|
||||||
* On Windows, when completing the completion handler with a failure. */
|
* On Windows, when completing the completion handler with a failure. */
|
||||||
static Throwable tolerateIOEOnWindows(Throwable t) {
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 com.sun.net.httpserver.HttpsServer;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -50,6 +52,7 @@ import java.net.http.HttpResponse.BodyHandler;
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -63,6 +66,7 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
import java.util.concurrent.SubmissionPublisher;
|
import java.util.concurrent.SubmissionPublisher;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -138,17 +142,37 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters {
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
if (FAILURES.isEmpty()) return;
|
||||||
|
@ -385,6 +409,7 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters {
|
||||||
boolean async, Set<Where> whereValues)
|
boolean async, Set<Where> whereValues)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
out.printf("%n%s%s%n", now(), name);
|
out.printf("%n%s%s%n", now(), name);
|
||||||
try {
|
try {
|
||||||
testThrowing(uri, sameClient, publishers, finisher, thrower, async, whereValues);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -43,6 +43,8 @@
|
||||||
|
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -68,6 +70,7 @@ import java.net.http.HttpResponse.BodySubscriber;
|
||||||
import java.net.http.HttpResponse.PushPromiseHandler;
|
import java.net.http.HttpResponse.PushPromiseHandler;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
@ -79,6 +82,7 @@ import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -151,17 +155,37 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
if (FAILURES.isEmpty()) return;
|
||||||
|
@ -360,6 +384,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters
|
||||||
Finisher finisher, Thrower thrower)
|
Finisher finisher, Thrower thrower)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
out.printf("%n%s%s%n", now(), name);
|
out.printf("%n%s%s%n", now(), name);
|
||||||
try {
|
try {
|
||||||
testThrowing(uri, sameClient, handlers, finisher, thrower);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 com.sun.net.httpserver.HttpsServer;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -52,6 +54,7 @@ import java.net.http.HttpResponse.BodyHandlers;
|
||||||
import java.net.http.HttpResponse.BodySubscriber;
|
import java.net.http.HttpResponse.BodySubscriber;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
@ -62,6 +65,7 @@ import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
@ -137,17 +141,37 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
if (FAILURES.isEmpty()) return;
|
||||||
|
@ -379,6 +403,7 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters
|
||||||
boolean async, EnumSet<Where> excludes)
|
boolean async, EnumSet<Where> excludes)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
out.printf("%n%s%s%n", now(), name);
|
out.printf("%n%s%s%n", now(), name);
|
||||||
try {
|
try {
|
||||||
testThrowing(uri, sameClient, handlers, finisher, thrower, async, excludes);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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;
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -63,6 +64,7 @@ import java.util.concurrent.Flow.Subscription;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -76,6 +78,8 @@ import com.sun.net.httpserver.HttpsServer;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -151,17 +155,36 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
if (FAILURES.isEmpty()) return;
|
||||||
|
@ -446,6 +469,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
|
|
||||||
@Test(dataProvider = "sparseContent") // checks that NPE is thrown
|
@Test(dataProvider = "sparseContent") // checks that NPE is thrown
|
||||||
public void testNullPointerException(String description, String[] content) {
|
public void testNullPointerException(String description, String[] content) {
|
||||||
|
checkSkip();
|
||||||
BodyPublisher[] publishers = publishers(content);
|
BodyPublisher[] publishers = publishers(content);
|
||||||
Assert.assertThrows(NullPointerException.class, () -> BodyPublishers.concat(publishers));
|
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
|
// Verifies that an empty array creates a "noBody" publisher
|
||||||
@Test
|
@Test
|
||||||
public void testEmpty() {
|
public void testEmpty() {
|
||||||
|
checkSkip();
|
||||||
BodyPublisher publisher = BodyPublishers.concat();
|
BodyPublisher publisher = BodyPublishers.concat();
|
||||||
RequestSubscriber subscriber = new RequestSubscriber();
|
RequestSubscriber subscriber = new RequestSubscriber();
|
||||||
assertEquals(publisher.contentLength(), 0);
|
assertEquals(publisher.contentLength(), 0);
|
||||||
|
@ -466,6 +491,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
// verifies that error emitted by upstream publishers are propagated downstream.
|
// verifies that error emitted by upstream publishers are propagated downstream.
|
||||||
@Test(dataProvider = "sparseContent") // nulls are replaced with error publisher
|
@Test(dataProvider = "sparseContent") // nulls are replaced with error publisher
|
||||||
public void testOnError(String description, String[] content) {
|
public void testOnError(String description, String[] content) {
|
||||||
|
checkSkip();
|
||||||
final RequestSubscriber subscriber = new RequestSubscriber();
|
final RequestSubscriber subscriber = new RequestSubscriber();
|
||||||
final PublishWithError errorPublisher;
|
final PublishWithError errorPublisher;
|
||||||
final BodyPublisher[] publishers;
|
final BodyPublisher[] publishers;
|
||||||
|
@ -521,6 +547,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
// the length should be known.
|
// the length should be known.
|
||||||
@Test(dataProvider = "sparseContent") // nulls are replaced with unknown length
|
@Test(dataProvider = "sparseContent") // nulls are replaced with unknown length
|
||||||
public void testUnknownContentLength(String description, String[] content) {
|
public void testUnknownContentLength(String description, String[] content) {
|
||||||
|
checkSkip();
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
content = BODIES.toArray(String[]::new);
|
content = BODIES.toArray(String[]::new);
|
||||||
description = "BODIES (known length)";
|
description = "BODIES (known length)";
|
||||||
|
@ -561,6 +588,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
|
|
||||||
@Test(dataProvider = "negativeRequests")
|
@Test(dataProvider = "negativeRequests")
|
||||||
public void testNegativeRequest(long n) {
|
public void testNegativeRequest(long n) {
|
||||||
|
checkSkip();
|
||||||
assert n <= 0 : "test for negative request called with n > 0 : " + n;
|
assert n <= 0 : "test for negative request called with n > 0 : " + n;
|
||||||
BodyPublisher[] publishers = ContentLengthPublisher.of(List.of(1L, 2L, 3L));
|
BodyPublisher[] publishers = ContentLengthPublisher.of(List.of(1L, 2L, 3L));
|
||||||
BodyPublisher publisher = BodyPublishers.concat(publishers);
|
BodyPublisher publisher = BodyPublishers.concat(publishers);
|
||||||
|
@ -584,6 +612,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPositiveRequests() {
|
public void testPositiveRequests() {
|
||||||
|
checkSkip();
|
||||||
// A composite array of publishers
|
// A composite array of publishers
|
||||||
BodyPublisher[] publishers = Stream.of(
|
BodyPublisher[] publishers = Stream.of(
|
||||||
Stream.of(ofStrings("Lorem", " ", "ipsum", " ")),
|
Stream.of(ofStrings("Lorem", " ", "ipsum", " ")),
|
||||||
|
@ -626,6 +655,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
|
|
||||||
@Test(dataProvider = "contentLengths")
|
@Test(dataProvider = "contentLengths")
|
||||||
public void testContentLength(long expected, List<Long> lengths) {
|
public void testContentLength(long expected, List<Long> lengths) {
|
||||||
|
checkSkip();
|
||||||
BodyPublisher[] publishers = ContentLengthPublisher.of(lengths);
|
BodyPublisher[] publishers = ContentLengthPublisher.of(lengths);
|
||||||
BodyPublisher aggregate = BodyPublishers.concat(publishers);
|
BodyPublisher aggregate = BodyPublishers.concat(publishers);
|
||||||
assertEquals(aggregate.contentLength(), expected,
|
assertEquals(aggregate.contentLength(), expected,
|
||||||
|
@ -636,6 +666,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
// publishers are no longer subscribed etc...
|
// publishers are no longer subscribed etc...
|
||||||
@Test
|
@Test
|
||||||
public void testCancel() {
|
public void testCancel() {
|
||||||
|
checkSkip();
|
||||||
BodyPublisher[] publishers = BODIES.stream()
|
BodyPublisher[] publishers = BODIES.stream()
|
||||||
.map(BodyPublishers::ofString)
|
.map(BodyPublishers::ofString)
|
||||||
.toArray(BodyPublisher[]::new);
|
.toArray(BodyPublisher[]::new);
|
||||||
|
@ -695,6 +726,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
// Verifies that cancelling the subscription is propagated downstream
|
// Verifies that cancelling the subscription is propagated downstream
|
||||||
@Test
|
@Test
|
||||||
public void testCancelSubscription() {
|
public void testCancelSubscription() {
|
||||||
|
checkSkip();
|
||||||
PublishWithError upstream = new PublishWithError(BODIES, BODIES.size(),
|
PublishWithError upstream = new PublishWithError(BODIES, BODIES.size(),
|
||||||
() -> new AssertionError("should not come here"));
|
() -> new AssertionError("should not come here"));
|
||||||
BodyPublisher publisher = BodyPublishers.concat(upstream);
|
BodyPublisher publisher = BodyPublishers.concat(upstream);
|
||||||
|
@ -756,6 +788,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters {
|
||||||
|
|
||||||
@Test(dataProvider = "variants")
|
@Test(dataProvider = "variants")
|
||||||
public void test(String uri, boolean sameClient) throws Exception {
|
public void test(String uri, boolean sameClient) throws Exception {
|
||||||
|
checkSkip();
|
||||||
System.out.println("Request to " + uri);
|
System.out.println("Request to " + uri);
|
||||||
|
|
||||||
HttpClient client = newHttpClient(sameClient);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.RandomFactory;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -65,6 +67,7 @@ import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.net.http.HttpResponse.BodyHandler;
|
import java.net.http.HttpResponse.BodyHandler;
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -77,6 +80,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@ -149,16 +153,34 @@ public class CancelRequestTest implements HttpServerAdapters {
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
|
var failed = context.getFailedTests().getAllResults().stream()
|
||||||
|
.collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable));
|
||||||
|
FAILURES.putAll(failed);
|
||||||
try {
|
try {
|
||||||
out.printf("%n%sCreated %d servers and %d clients%n",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
|
@ -275,6 +297,7 @@ public class CancelRequestTest implements HttpServerAdapters {
|
||||||
@Test(dataProvider = "asyncurls")
|
@Test(dataProvider = "asyncurls")
|
||||||
public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning)
|
public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
checkSkip();
|
||||||
HttpClient client = null;
|
HttpClient client = null;
|
||||||
uri = uri + "/get";
|
uri = uri + "/get";
|
||||||
out.printf("%n%s testGetSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning);
|
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")
|
@Test(dataProvider = "asyncurls")
|
||||||
public void testPostSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning)
|
public void testPostSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
checkSkip();
|
||||||
uri = uri + "/post";
|
uri = uri + "/post";
|
||||||
HttpClient client = null;
|
HttpClient client = null;
|
||||||
out.printf("%n%s testPostSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning);
|
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")
|
@Test(dataProvider = "urls")
|
||||||
public void testPostInterrupt(String uri, boolean sameClient)
|
public void testPostInterrupt(String uri, boolean sameClient)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
checkSkip();
|
||||||
HttpClient client = null;
|
HttpClient client = null;
|
||||||
out.printf("%n%s testPostInterrupt(%s, %b)%n", now(), uri, sameClient);
|
out.printf("%n%s testPostInterrupt(%s, %b)%n", now(), uri, sameClient);
|
||||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 com.sun.net.httpserver.HttpsServer;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -72,6 +74,7 @@ import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -80,6 +83,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static java.lang.System.err;
|
import static java.lang.System.err;
|
||||||
import static java.lang.System.out;
|
import static java.lang.System.out;
|
||||||
|
@ -148,17 +152,37 @@ public class ForbiddenHeadTest implements HttpServerAdapters {
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
if (FAILURES.isEmpty()) return;
|
||||||
|
@ -219,6 +243,7 @@ public class ForbiddenHeadTest implements HttpServerAdapters {
|
||||||
|
|
||||||
@Test(dataProvider = "all")
|
@Test(dataProvider = "all")
|
||||||
void test(String uriString, int code, boolean async, HttpClient client) throws Throwable {
|
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",
|
var name = String.format("test(%s, %d, %s, %s)", uriString, code, async ? "async" : "sync",
|
||||||
client.authenticator().isPresent() ? "authClient" : "noAuthClient");
|
client.authenticator().isPresent() ? "authClient" : "noAuthClient");
|
||||||
out.printf("%n---- starting %s ----%n", name);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -72,6 +73,7 @@ import java.util.concurrent.Flow.Subscription;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -85,6 +87,8 @@ import com.sun.net.httpserver.HttpsServer;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -162,17 +166,36 @@ public class ISO_8859_1_Test implements HttpServerAdapters {
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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 com.sun.net.httpserver.HttpsServer;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -70,6 +72,7 @@ import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -78,6 +81,8 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
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.err;
|
||||||
import static java.lang.System.out;
|
import static java.lang.System.out;
|
||||||
|
@ -148,10 +153,25 @@ public class ProxySelectorTest implements HttpServerAdapters {
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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() {
|
static final void printFailedTests() {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
if (FAILURES.isEmpty()) return;
|
||||||
|
@ -210,6 +235,7 @@ public class ProxySelectorTest implements HttpServerAdapters {
|
||||||
void test(Schemes scheme, HttpClient.Version version, String uri, boolean async)
|
void test(Schemes scheme, HttpClient.Version version, String uri, boolean async)
|
||||||
throws Throwable
|
throws Throwable
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
var name = String.format("test(%s, %s, %s)", scheme, version, async);
|
var name = String.format("test(%s, %s, %s)", scheme, version, async);
|
||||||
out.printf("%n---- starting %s ----%n", name);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.net.http.HttpResponse.BodyHandlers;
|
import java.net.http.HttpResponse.BodyHandlers;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
|
import org.testng.ITestResult;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -123,17 +129,36 @@ public class Response204V2Test implements HttpServerAdapters {
|
||||||
return Boolean.getBoolean("jdk.internal.httpclient.debug");
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) {
|
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
|
@AfterClass
|
||||||
static final void printFailedTests() {
|
static final void printFailedTests(ITestContext context) {
|
||||||
out.println("\n=========================");
|
out.println("\n=========================");
|
||||||
try {
|
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",
|
out.printf("%n%sCreated %d servers and %d clients%n",
|
||||||
now(), serverCount.get(), clientCount.get());
|
now(), serverCount.get(), clientCount.get());
|
||||||
if (FAILURES.isEmpty()) return;
|
if (FAILURES.isEmpty()) return;
|
||||||
|
@ -220,6 +245,7 @@ public class Response204V2Test implements HttpServerAdapters {
|
||||||
|
|
||||||
@Test(dataProvider = "variants")
|
@Test(dataProvider = "variants")
|
||||||
public void test(String uri, boolean sameClient) throws Exception {
|
public void test(String uri, boolean sameClient) throws Exception {
|
||||||
|
checkSkip();
|
||||||
System.out.println("Request to " + uri);
|
System.out.println("Request to " + uri);
|
||||||
|
|
||||||
HttpClient client = newHttpClient(sameClient);
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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.Executors;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.test.lib.net.SimpleSSLContext;
|
import jdk.test.lib.net.SimpleSSLContext;
|
||||||
import org.testng.ITestContext;
|
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.BeforeMethod;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
|
@ -107,10 +112,44 @@ public class ShortResponseBody {
|
||||||
};
|
};
|
||||||
final ExecutorService service = Executors.newCachedThreadPool(factory);
|
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
|
@BeforeMethod
|
||||||
void beforeMethod(ITestContext context) {
|
void beforeMethod(ITestContext context) {
|
||||||
if (context.getFailedTests().size() > 0) {
|
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)
|
void testSynchronousGET(String url, String expectedMsg, boolean sameClient)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
out.print("---\n");
|
out.print("---\n");
|
||||||
HttpClient client = null;
|
HttpClient client = null;
|
||||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||||
|
@ -253,6 +293,7 @@ public class ShortResponseBody {
|
||||||
void testAsynchronousGET(String url, String expectedMsg, boolean sameClient)
|
void testAsynchronousGET(String url, String expectedMsg, boolean sameClient)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
out.print("---\n");
|
out.print("---\n");
|
||||||
HttpClient client = null;
|
HttpClient client = null;
|
||||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||||
|
@ -335,6 +376,7 @@ public class ShortResponseBody {
|
||||||
void testSynchronousPOST(String url, String expectedMsg, boolean sameClient)
|
void testSynchronousPOST(String url, String expectedMsg, boolean sameClient)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
out.print("---\n");
|
out.print("---\n");
|
||||||
HttpClient client = null;
|
HttpClient client = null;
|
||||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||||
|
@ -368,6 +410,7 @@ public class ShortResponseBody {
|
||||||
void testAsynchronousPOST(String url, String expectedMsg, boolean sameClient)
|
void testAsynchronousPOST(String url, String expectedMsg, boolean sameClient)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
checkSkip();
|
||||||
out.print("---\n");
|
out.print("---\n");
|
||||||
HttpClient client = null;
|
HttpClient client = null;
|
||||||
for (int i=0; i< ITERATION_COUNT; i++) {
|
for (int i=0; i< ITERATION_COUNT; i++) {
|
||||||
|
|
|
@ -34,6 +34,13 @@
|
||||||
import jdk.test.lib.Asserts;
|
import jdk.test.lib.Asserts;
|
||||||
import sun.security.krb5.Config;
|
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 {
|
public class TestDynamicStore {
|
||||||
|
|
||||||
native static int actionInternal(char what, char whom);
|
native static int actionInternal(char what, char whom);
|
||||||
|
@ -59,7 +66,10 @@ public class TestDynamicStore {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.out.println("Fill in dynamic store");
|
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().get("libdefaults", "default_realm").equals("A.COM"));
|
||||||
Asserts.assertTrue(Config.getInstance().exists("domain_realm"));
|
Asserts.assertTrue(Config.getInstance().exists("domain_realm"));
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,9 @@ int addMapping(SCDynamicStoreRef store) {
|
||||||
|
|
||||||
int addAll(SCDynamicStoreRef store) {
|
int addAll(SCDynamicStoreRef store) {
|
||||||
NSArray *keys = [NSArray arrayWithObjects:@"A.COM", @"B.COM", nil];
|
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:
|
NSDictionary *k1 = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
@"kdc1.a.com", @"host", nil];
|
@"kdc1.a.com", @"host", nil];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue