1.1 --- a/test/gc/arguments/TestDynMinHeapFreeRatio.java Mon Jul 28 20:47:56 2014 +0200 1.2 +++ b/test/gc/arguments/TestDynMinHeapFreeRatio.java Tue May 20 18:25:14 2014 +0400 1.3 @@ -33,30 +33,52 @@ 1.4 * @run main/othervm -XX:MinHeapFreeRatio=51 -XX:MaxHeapFreeRatio=52 TestDynMinHeapFreeRatio 1.5 * @run main/othervm -XX:MinHeapFreeRatio=75 -XX:MaxHeapFreeRatio=100 TestDynMinHeapFreeRatio 1.6 */ 1.7 -import com.oracle.java.testlibrary.TestDynamicVMOption; 1.8 -import com.oracle.java.testlibrary.DynamicVMOptionChecker; 1.9 +import static com.oracle.java.testlibrary.Asserts.assertEQ; 1.10 +import static com.oracle.java.testlibrary.Asserts.assertFalse; 1.11 +import static com.oracle.java.testlibrary.Asserts.assertTrue; 1.12 +import com.oracle.java.testlibrary.DynamicVMOption; 1.13 1.14 -public class TestDynMinHeapFreeRatio extends TestDynamicVMOption { 1.15 - 1.16 - public static final String MinFreeRatioFlagName = "MinHeapFreeRatio"; 1.17 - public static final String MaxFreeRatioFlagName = "MaxHeapFreeRatio"; 1.18 - 1.19 - public TestDynMinHeapFreeRatio() { 1.20 - super(MinFreeRatioFlagName); 1.21 - } 1.22 - 1.23 - public void test() { 1.24 - int maxHeapFreeValue = DynamicVMOptionChecker.getIntValue(MaxFreeRatioFlagName); 1.25 - System.out.println(MaxFreeRatioFlagName + " = " + maxHeapFreeValue); 1.26 - 1.27 - testPercentageValues(); 1.28 - 1.29 - checkInvalidValue(Integer.toString(maxHeapFreeValue + 1)); 1.30 - checkValidValue(Integer.toString(maxHeapFreeValue)); 1.31 - checkValidValue("0"); 1.32 - } 1.33 +public class TestDynMinHeapFreeRatio { 1.34 1.35 public static void main(String args[]) throws Exception { 1.36 - new TestDynMinHeapFreeRatio().test(); 1.37 + 1.38 + // high boundary value 1.39 + int maxValue = DynamicVMOption.getInt("MaxHeapFreeRatio"); 1.40 + System.out.println("MaxHeapFreeRatio= " + maxValue); 1.41 + 1.42 + String badValues[] = { 1.43 + null, 1.44 + "", 1.45 + "not a number", 1.46 + "8.5", "-0.01", 1.47 + Integer.toString(Integer.MIN_VALUE), 1.48 + Integer.toString(Integer.MAX_VALUE), 1.49 + Integer.toString(maxValue + 1), 1.50 + "-1024", "-1", "101", "1997" 1.51 + }; 1.52 + 1.53 + String goodValues[] = { 1.54 + Integer.toString(maxValue), 1.55 + Integer.toString(maxValue - 1), 1.56 + Integer.toString(maxValue / 2), 1.57 + "0", "1" 1.58 + }; 1.59 + 1.60 + // option under test 1.61 + DynamicVMOption option = new DynamicVMOption("MinHeapFreeRatio"); 1.62 + 1.63 + assertTrue(option.isWriteable(), "Option " + option.name 1.64 + + " is expected to be writable"); 1.65 + 1.66 + for (String v : badValues) { 1.67 + assertFalse(option.isValidValue(v), 1.68 + "'" + v + "' is expected to be illegal for flag " + option.name); 1.69 + } 1.70 + 1.71 + for (String v : goodValues) { 1.72 + option.setValue(v); 1.73 + String newValue = option.getValue(); 1.74 + assertEQ(v, newValue); 1.75 + } 1.76 } 1.77 }