8205108: [testbug] Fix pattern matching in jstatd tests.
authorgoetz
Wed, 20 Jun 2018 11:12:58 +0200
changeset 50671 1637a4e50fc9
parent 50670 e810abb27deb
child 50672 35a87577b461
8205108: [testbug] Fix pattern matching in jstatd tests. Reviewed-by: stuefe, azeller
test/jdk/sun/tools/jstatd/JstatGCUtilParser.java
--- a/test/jdk/sun/tools/jstatd/JstatGCUtilParser.java	Wed Jun 20 06:51:39 2018 +0200
+++ b/test/jdk/sun/tools/jstatd/JstatGCUtilParser.java	Wed Jun 20 11:12:58 2018 +0200
@@ -25,16 +25,14 @@
 
 import jdk.testlibrary.Utils;
 import static jdk.testlibrary.Asserts.*;
+import java.text.NumberFormat;
 
 /**
  * The helper class for parsing following output from command 'jstat -gcutil':
  *
- *  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT
- *  100.00   0.00  64.68  13.17  73.39  33.46      2    0.003     1    0.156    0.158
- *  100.00   0.00  76.54  13.17  73.39  33.46      2    0.003     1    0.156    0.158
- *  100.00   0.00  83.49  13.17  73.39  33.46      2    0.003     1    0.156    0.158
- *  100.00   0.00  84.53  13.17  73.39  33.46      2    0.003     1    0.156    0.158
- *  100.00   0.00  85.57  13.17  73.39  33.46      2    0.003     1    0.156    0.158
+ *  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT    CGC    CGCT     GCT
+ *  0.00   0.00  86.67   0.00   -      -      0      0.000     0    0.000     0    0.000    0.000
+ *  0.00   0.00  86.67   0.00   -      -      0      0.000     0    0.000     0    0.000    0.000
  *
  *  It will be verified that numerical values have defined types and are reasonable,
  *  for example percentage should fit within 0-100 interval.
@@ -50,7 +48,7 @@
         S1(GcStatisticsType.PERCENTAGE),
         E(GcStatisticsType.PERCENTAGE),
         O(GcStatisticsType.PERCENTAGE),
-        M(GcStatisticsType.PERCENTAGE),
+        M(GcStatisticsType.PERCENTAGE_OR_DASH),
         CCS(GcStatisticsType.PERCENTAGE_OR_DASH),
         YGC(GcStatisticsType.INTEGER),
         YGCT(GcStatisticsType.DOUBLE),
@@ -97,18 +95,18 @@
                 GcStatisticsType type = values()[i].getType();
                 String value = valueArray[i].trim();
                 if (type.equals(GcStatisticsType.INTEGER)) {
-                    Integer.parseInt(value);
+                    NumberFormat.getInstance().parse(value).intValue();
                     break;
                 }
                 if (type.equals(GcStatisticsType.DOUBLE)) {
-                    Double.parseDouble(value);
+                    NumberFormat.getInstance().parse(value).doubleValue();
                     break;
                 }
                 if (type.equals(GcStatisticsType.PERCENTAGE_OR_DASH) &&
                         value.equals("-")) {
                     break;
                 }
-                double percentage = Double.parseDouble(value);
+                double percentage = NumberFormat.getInstance().parse(value).doubleValue();
                 assertTrue(0 <= percentage && percentage <= 100,
                         "Not a percentage: " + value);
             }