Package test.command

Examples of test.command.TestInvocationContext


      "out.print(\"abc\");" +
      "}" +
      "}");

    //
    Assert.assertEquals("abc", new TestInvocationContext().execute(clazz));
  }
View Full Code Here


      "return str;" +
      "}" +
      "}");

    //
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.execute(clazz, "-s", "abc");
    assertEquals(Arrays.asList("abc"), ctx.getProducedItems());
    try {
      new TestInvocationContext().execute(clazz);
      fail();
    }
    catch (CommandException e) {
      assertInstance(SyntaxException.class, e.getCause());
    }
View Full Code Here

      "return str;" +
      "}" +
      "}");

    //
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.execute(clazz, "b");
    assertEquals(Arrays.asList("b"), ctx.getProducedItems());
  }
View Full Code Here

      "return 'foo';" +
      "}" +
      "}");

    //
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.execute(clazz);
    assertEquals(Arrays.asList("foo"), ctx.getProducedItems());
  }
View Full Code Here

      "return bar;" +
      "}" +
      "}");

    //
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.getSession().put("bar", "bar_value");

    // Execute directly
    ctx.execute(clazz);
    assertEquals(Arrays.asList("bar_value"), ctx.getProducedItems());
  }
View Full Code Here

      "return bar();" +
      "}" +
      "}");

    //
    TestInvocationContext ctx = new TestInvocationContext();
    Closure closure = (Closure)shell.evaluate("{ -> return 'from_closure'; }");
    ctx.getSession().put("bar", closure);

    // Execute directly
    ctx.execute(clazz);
    assertEquals(Arrays.asList("from_closure"), ctx.getProducedItems());
  }
View Full Code Here

      "return arguments;\n" +
      "}\n" +
      "}\n");

    // Execute directly
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.execute(clazz, "'foo'");
    assertEquals(Arrays.<Object>asList(Arrays.asList("foo")), ctx.getProducedItems());
  }
View Full Code Here

      "return arguments;\n" +
      "}\n" +
      "}\n");

    // Execute directly
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.execute(clazz, "'foo'");
    assertEquals(Arrays.<Object>asList(Arrays.asList("'foo'")), ctx.getProducedItems());
  }
View Full Code Here

    assertEquals(Arrays.<Object>asList(Arrays.asList("'foo'")), ctx.getProducedItems());
  }

  public void testContextAccessInScript() throws Exception {
    Class<? extends GroovyScriptCommand> clazz = loader.parseClass("System.out.println('bar:' + bar) ; return bar;");
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.getSession().put("bar", "bar_value");
    ctx.execute2(clazz);
    assertEquals(Arrays.asList("bar_value"), ctx.getProducedItems());
  }
View Full Code Here

    assertEquals(Arrays.asList("bar_value"), ctx.getProducedItems());
  }

  public void testArgumentAccessInScript() throws Exception {
    Class<? extends GroovyScriptCommand>  clazz = loader.parseClass("return args[0];");
    TestInvocationContext ctx = new TestInvocationContext();
    ctx.execute2(clazz, "arg_value");
    assertEquals(Arrays.asList("arg_value"), ctx.getProducedItems());
  }
View Full Code Here

TOP

Related Classes of test.command.TestInvocationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.