< prev index next >
core/tests/org.openjdk.jmc.common.test/src/test/java/org/openjdk/jmc/common/test/MCTestCase.java
Print this page
*** 77,88 ****
* Asserts that with respect to all bits in the mask, a long is equal to the given value. If it
* is not an AssertionFailedError is thrown with the given message.
*/
static public void assertMaskedEquals(String message, long expected, long actual, long mask) {
if (((expected ^ actual) & mask) != 0) {
! Assert.fail(((message != null) ? message + ' ' : "") //$NON-NLS-1$
! + "masked with " + hex(mask) + " expected:<" + hex(expected) + "> was not:<" + hex(actual) + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
/**
* Asserts that with respect to all bits in the mask, a long is equal to the given value.
--- 77,88 ----
* Asserts that with respect to all bits in the mask, a long is equal to the given value. If it
* is not an AssertionFailedError is thrown with the given message.
*/
static public void assertMaskedEquals(String message, long expected, long actual, long mask) {
if (((expected ^ actual) & mask) != 0) {
! Assert.fail(((message != null) ? message + ' ' : "")
! + "masked with " + hex(mask) + " expected:<" + hex(expected) + "> was not:<" + hex(actual) + ">");
}
}
/**
* Asserts that with respect to all bits in the mask, a long is equal to the given value.
*** 90,110 ****
static public void assertMaskedEquals(long expected, long actual, long mask) {
assertMaskedEquals(null, expected, actual, mask);
}
protected static String hex(long val) {
! return "0x" + Long.toHexString(val); //$NON-NLS-1$
}
/**
* Asserts that a {@link Comparable} is within the given (inclusive) range. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertBetween(String message, T min, T max, T actual) {
if ((min.compareTo(actual) > 0) || (max.compareTo(actual) < 0)) {
! Assert.fail(((message != null) ? message + ' ' : "") //$NON-NLS-1$
! + "expected in:[" + min + ", " + max + "] was not:<" + actual + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
/**
* Asserts that a {@link Comparable} is within the given (inclusive) range.
--- 90,110 ----
static public void assertMaskedEquals(long expected, long actual, long mask) {
assertMaskedEquals(null, expected, actual, mask);
}
protected static String hex(long val) {
! return "0x" + Long.toHexString(val);
}
/**
* Asserts that a {@link Comparable} is within the given (inclusive) range. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertBetween(String message, T min, T max, T actual) {
if ((min.compareTo(actual) > 0) || (max.compareTo(actual) < 0)) {
! Assert.fail(((message != null) ? message + ' ' : "")
! + "expected in:[" + min + ", " + max + "] was not:<" + actual + ">");
}
}
/**
* Asserts that a {@link Comparable} is within the given (inclusive) range.
*** 117,128 ****
* Asserts that a {@link Comparable} is less or equal than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertMax(String message, T max, T actual) {
if (max.compareTo(actual) < 0) {
! Assert.fail(((message != null) ? message + ' ' : "") //$NON-NLS-1$
! + "expected max:<" + max + "> was not:<" + actual + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
/**
* Asserts that a {@link Comparable} is less or equal than the given value.
--- 117,128 ----
* Asserts that a {@link Comparable} is less or equal than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertMax(String message, T max, T actual) {
if (max.compareTo(actual) < 0) {
! Assert.fail(((message != null) ? message + ' ' : "")
! + "expected max:<" + max + "> was not:<" + actual + ">");
}
}
/**
* Asserts that a {@link Comparable} is less or equal than the given value.
*** 135,146 ****
* Asserts that a {@link Comparable} is greater or equal than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertMin(String message, T min, T actual) {
if (min.compareTo(actual) > 0) {
! Assert.fail(((message != null) ? message + ' ' : "") //$NON-NLS-1$
! + "expected min:<" + min + "> was not:<" + actual + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
/**
* Asserts that a {@link Comparable} is greater or equal than the given value.
--- 135,146 ----
* Asserts that a {@link Comparable} is greater or equal than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertMin(String message, T min, T actual) {
if (min.compareTo(actual) > 0) {
! Assert.fail(((message != null) ? message + ' ' : "")
! + "expected min:<" + min + "> was not:<" + actual + ">");
}
}
/**
* Asserts that a {@link Comparable} is greater or equal than the given value.
*** 153,164 ****
* Asserts that a {@link Comparable} is less than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertLessThan(String message, T greaterVal, T actual) {
if (greaterVal.compareTo(actual) <= 0) {
! Assert.fail(((message != null) ? message + ' ' : "") //$NON-NLS-1$
! + "expected less than:<" + greaterVal + "> was not:<" + actual + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
/**
* Asserts that a {@link Comparable} is less than the given value.
--- 153,164 ----
* Asserts that a {@link Comparable} is less than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<T>> void assertLessThan(String message, T greaterVal, T actual) {
if (greaterVal.compareTo(actual) <= 0) {
! Assert.fail(((message != null) ? message + ' ' : "")
! + "expected less than:<" + greaterVal + "> was not:<" + actual + ">");
}
}
/**
* Asserts that a {@link Comparable} is less than the given value.
*** 171,182 ****
* Asserts that a {@link Comparable} is greater than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<? super T>> void assertGreaterThan(String message, T lesserVal, T actual) {
if (lesserVal.compareTo(actual) >= 0) {
! Assert.fail(((message != null) ? message + ' ' : "") //$NON-NLS-1$
! + "expected greater than:<" + lesserVal + "> was not:<" + actual + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
/**
* Asserts that a {@link Comparable} is greater than the given value.
--- 171,182 ----
* Asserts that a {@link Comparable} is greater than the given value. If it is not an
* AssertionFailedError is thrown with the given message.
*/
static public <T extends Comparable<? super T>> void assertGreaterThan(String message, T lesserVal, T actual) {
if (lesserVal.compareTo(actual) >= 0) {
! Assert.fail(((message != null) ? message + ' ' : "")
! + "expected greater than:<" + lesserVal + "> was not:<" + actual + ">");
}
}
/**
* Asserts that a {@link Comparable} is greater than the given value.
*** 198,236 ****
throw new AssertionError(sb.toString(), e);
}
}
protected void skipIfEarlierThan8u0() {
! Assume.assumeTrue("This feature is only valid on JDK8u0 or later.", //$NON-NLS-1$
(getClientVersion().compareTo(JVMVersion.JDK8)) >= 0);
}
protected void skipIfEarlierThan7u40() {
! Assume.assumeTrue("This feature is only valid on JDK7u40 or later.", //$NON-NLS-1$
(getClientVersion().compareTo(JVMVersion.JDK7u40)) >= 0);
}
protected void skipIfEarlierThan7u4() {
! Assume.assumeTrue("This feature is only valid on JDK7u4 or later.", //$NON-NLS-1$
(getClientVersion().compareTo(JVMVersion.JDK7u4)) >= 0);
}
protected void skipIfEarlierThan7u0() {
! Assume.assumeTrue("This feature is only valid on JDK7u0 or later.", //$NON-NLS-1$
(getClientVersion().compareTo(JVMVersion.JDK7)) >= 0);
}
// This enum needs to be in the proper order.
private enum JVMVersion {
ANY, UNKNOWN, JRockit, JDK6, JDK7, JDK7u4, JDK7u40, JDK8
}
private JVMVersion getClientVersion() {
! if (JavaVMVersionToolkit.isJRockitJVMName(System.getProperty("java.vm.name"))) { //$NON-NLS-1$
return JVMVersion.JRockit;
! } else if (JavaVMVersionToolkit.isHotspotJVMName(System.getProperty("java.vm.name"))) { //$NON-NLS-1$
! JavaVersion javaVersion = new JavaVersion(System.getProperty("java.version")); //$NON-NLS-1$
if (javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_8)) {
return JVMVersion.JDK8;
} else if (javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_7_U_40)) {
return JVMVersion.JDK7u40;
} else if (javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_7_U_4)) {
--- 198,236 ----
throw new AssertionError(sb.toString(), e);
}
}
protected void skipIfEarlierThan8u0() {
! Assume.assumeTrue("This feature is only valid on JDK8u0 or later.",
(getClientVersion().compareTo(JVMVersion.JDK8)) >= 0);
}
protected void skipIfEarlierThan7u40() {
! Assume.assumeTrue("This feature is only valid on JDK7u40 or later.",
(getClientVersion().compareTo(JVMVersion.JDK7u40)) >= 0);
}
protected void skipIfEarlierThan7u4() {
! Assume.assumeTrue("This feature is only valid on JDK7u4 or later.",
(getClientVersion().compareTo(JVMVersion.JDK7u4)) >= 0);
}
protected void skipIfEarlierThan7u0() {
! Assume.assumeTrue("This feature is only valid on JDK7u0 or later.",
(getClientVersion().compareTo(JVMVersion.JDK7)) >= 0);
}
// This enum needs to be in the proper order.
private enum JVMVersion {
ANY, UNKNOWN, JRockit, JDK6, JDK7, JDK7u4, JDK7u40, JDK8
}
private JVMVersion getClientVersion() {
! if (JavaVMVersionToolkit.isJRockitJVMName(System.getProperty("java.vm.name"))) {
return JVMVersion.JRockit;
! } else if (JavaVMVersionToolkit.isHotspotJVMName(System.getProperty("java.vm.name"))) {
! JavaVersion javaVersion = new JavaVersion(System.getProperty("java.version"));
if (javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_8)) {
return JVMVersion.JDK8;
} else if (javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_7_U_40)) {
return JVMVersion.JDK7u40;
} else if (javaVersion.isGreaterOrEqualThan(JavaVersionSupport.JDK_7_U_4)) {
< prev index next >