Esempio n. 1
0
 @Test
 public void toggleDefaultWithPattern() {
   OptionsAndArgs o = opts("bla");
   assertNull(o.getPid());
   Pattern pat = o.getProcessPattern();
   assertEquals(pat.pattern(), "bla");
   assertEquals(o.getCommand(), "toggle");
 }
Esempio n. 2
0
 @Test
 public void simple() {
   OptionsAndArgs o =
       opts("--host", "localhost", "start", "12", "--password=bla", "-u", "roland", "--quiet");
   assertEquals(o.getCommand(), "start");
   assertTrue(o.isQuiet());
   assertFalse(o.isVerbose());
   assertEquals(o.getPid(), "12");
   assertNull(o.getProcessPattern());
   String args = o.toAgentArg();
   assertTrue(args.matches(".*host=localhost.*"));
   assertTrue(args.matches(".*user=roland.*"));
   assertTrue(args.matches(".*password=bla.*"));
   Map<String, String> opts = new HashMap<String, String>();
   for (String s : args.split(",")) {
     String[] p = s.split("=");
     assertEquals(p.length, 2);
     opts.put(p[0], p[1]);
   }
   assertEquals(opts.size(), 3);
   assertEquals(opts.get("host"), "localhost");
   assertEquals(opts.get("user"), "roland");
   assertEquals(opts.get("password"), "bla");
 }