Ejemplo n.º 1
0
  @Test
  public void testJavaBuilderWithObjectInstance()
      throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    final List<Object> methodArgs = new ArrayList<Object>();
    methodArgs.add(new TestContext());

    MockBuilder builder =
        new MockBuilder() {
          @Override
          public void configure() {
            java(new EchoAction()).methodArgs(methodArgs).method("execute");
          }
        };

    builder.run(null, null);

    Assert.assertEquals(builder.testCase().getActions().size(), 1);
    Assert.assertEquals(builder.testCase().getActions().get(0).getClass(), JavaAction.class);

    JavaAction action = ((JavaAction) builder.testCase().getActions().get(0));
    Assert.assertEquals(action.getName(), JavaAction.class.getSimpleName());

    Assert.assertNull(action.getClassName());
    Assert.assertNotNull(action.getInstance());
    Assert.assertEquals(action.getMethodName(), "execute");
    Assert.assertEquals(action.getMethodArgs().size(), 1);
  }
Ejemplo n.º 2
0
  @Test
  public void testJavaBuilderWithClassName()
      throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    final List<Object> constructorArgs = new ArrayList<Object>();
    constructorArgs.add(5);
    constructorArgs.add(7);

    final List<Object> methodArgs = new ArrayList<Object>();
    methodArgs.add(4);

    MockBuilder builder =
        new MockBuilder() {
          @Override
          public void configure() {
            java("com.consol.citrus.dsl.util.JavaTest")
                .constructorArgs(constructorArgs)
                .methodArgs(methodArgs)
                .method("add");
          }
        };

    builder.run(null, null);

    Assert.assertEquals(builder.testCase().getActions().size(), 1);
    Assert.assertEquals(builder.testCase().getActions().get(0).getClass(), JavaAction.class);

    JavaAction action = ((JavaAction) builder.testCase().getActions().get(0));
    Assert.assertEquals(action.getName(), JavaAction.class.getSimpleName());

    Assert.assertEquals(action.getClassName(), "com.consol.citrus.dsl.util.JavaTest");
    Assert.assertNull(action.getInstance());
    Assert.assertEquals(action.getMethodName(), "add");
    Assert.assertEquals(action.getMethodArgs().size(), 1);
  }