diff test/serviceability/ParserTest.java @ 6202:5a1f452f8f90

7178703: Fix handling of quoted arguments and better error messages in dcmd Reviewed-by: coleenp, mgronlun, rbackman
author sla
date Thu, 28 Jun 2012 11:37:28 +0200
parents 51612f0c0a79
children 1b0dc9f87e75
line wrap: on
line diff
--- a/test/serviceability/ParserTest.java	Wed Jul 04 15:55:45 2012 -0400
+++ b/test/serviceability/ParserTest.java	Thu Jun 28 11:37:28 2012 +0200
@@ -20,6 +20,7 @@
         testNanoTime();
         testJLong();
         testBool();
+        testQuotes();
         testMemorySize();
     }
 
@@ -95,6 +96,33 @@
         parse(name, "false", "", args);
     }
 
+    public void testQuotes() throws Exception {
+        String name = "name";
+        DiagnosticCommand arg1 = new DiagnosticCommand(name,
+                "desc", DiagnosticArgumentType.STRING,
+                false, null);
+        DiagnosticCommand arg2 = new DiagnosticCommand("arg",
+                "desc", DiagnosticArgumentType.STRING,
+                false, null);
+        DiagnosticCommand[] args = {arg1, arg2};
+
+        // try with a quoted value
+        parse(name, "Recording 1", name + "=\"Recording 1\"", args);
+        // try with a quoted argument
+        parse(name, "myrec", "\"" + name + "\"" + "=myrec", args);
+        // try with both a quoted value and a quoted argument
+        parse(name, "Recording 1", "\"" + name + "\"" + "=\"Recording 1\"", args);
+
+        // now the same thing but with other arguments after
+
+        // try with a quoted value
+        parse(name, "Recording 1", name + "=\"Recording 1\",arg=value", args);
+        // try with a quoted argument
+        parse(name, "myrec", "\"" + name + "\"" + "=myrec,arg=value", args);
+        // try with both a quoted value and a quoted argument
+        parse(name, "Recording 1", "\"" + name + "\"" + "=\"Recording 1\",arg=value", args);
+    }
+
     public void testMemorySize() throws Exception {
         String name = "name";
         String defaultValue = "1024";