Beispiel #1
0
 @Test
 public void help() {
   OptionsAndArgs o = opts("--help", "--verbose");
   assertEquals(o.getCommand(), "help");
   assertFalse(o.isQuiet());
   assertTrue(o.isVerbose());
 }
Beispiel #2
0
 @Test
 public void defaultCommands() {
   OptionsAndArgs o = opts();
   assertEquals(o.getCommand(), "list");
   o = opts("12");
   assertEquals(o.getCommand(), "toggle");
 }
Beispiel #3
0
 @Test
 public void toggleDefaultWithPattern() {
   OptionsAndArgs o = opts("bla");
   assertNull(o.getPid());
   Pattern pat = o.getProcessPattern();
   assertEquals(pat.pattern(), "bla");
   assertEquals(o.getCommand(), "toggle");
 }
Beispiel #4
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");
 }
Beispiel #5
0
 @Test
 public void lookupJar() {
   OptionsAndArgs o = opts();
   assertEquals(o.getJarFileName(), "classes");
   assertNotNull(o.getJarFilePath(), "");
 }