コード例 #1
0
  @Test
  public void shouldCreateBeanshellControlMarkerLessCodeLineFromMultiLineScript() throws Exception {
    // given
    final String scriptLine = "#% beforeEach:\n print(\"foo\");";
    final Integer colPos = Integer.valueOf(0);
    final Map<Integer, String> line =
        ImmutableMap.<Integer, String>builder().put(colPos, scriptLine).build();

    // when
    final AbstractCodeLine codeLine = factory.createCodeLineFromLine(line);

    // then
    assertThat(codeLine).isNotNull();
    assertThat(codeLine.getExecutableCode()).isEqualTo("print(\"foo\");");
    assertThat(codeLine).isInstanceOf(AbstractScriptingEngineCodeLine.class);
    assertThat(((AbstractScriptingEngineCodeLine) codeLine).getScriptingEngineName())
        .isEqualTo("bsh");
    assertThat(codeLine.getMarker()).isEqualTo("beforeEach:");
  }
コード例 #2
0
  @Test
  public void
      shouldCreateBeanshellCodeLineWith_if_ControlMarkerFromNewScriptDefinitionUsingFileExtensionAsEngineName()
          throws Exception {
    // given
    final String scriptLine = "#%bsh% if: print(\"foo\");";
    final Integer colPos = Integer.valueOf(0);
    final Map<Integer, String> line =
        ImmutableMap.<Integer, String>builder().put(colPos, scriptLine).build();

    // when
    final AbstractCodeLine codeLine = factory.createCodeLineFromLine(line);

    // then
    assertThat(codeLine).isNotNull();
    assertThat(codeLine.getExecutableCode()).isEqualTo("print(\"foo\");");
    assertThat(codeLine).isInstanceOf(AbstractScriptingEngineCodeLine.class);
    assertThat(((AbstractScriptingEngineCodeLine) codeLine).getScriptingEngineName())
        .isEqualTo("bsh");
    assertThat(codeLine.getMarker()).isEqualTo("if:");
  }