Exemple #1
0
  /**
   * Tests if the execution configuration can be created.
   *
   * @throws Exception thrown on errors
   */
  public void testArgsWithConsumer() throws Exception {
    // look up the component factory
    final IComponentFactory factory = lookup(IComponentFactory.class);
    // create the execution config
    final MavenSession session = this.createSimpleSession("exec/empty-pom");
    final IPhpExecutableConfiguration execConfig =
        factory.lookup(IPhpExecutableConfiguration.class, IComponentFactory.EMPTY_CONFIG, session);

    final File envTestPhp = new File(session.getCurrentProject().getBasedir(), "args-test.php");

    // assert that the environment variable is mapped correctly
    final IPhpExecutable exec = execConfig.getPhpExecutable();
    assertEquals(
        0,
        exec.execute(
            "\"" + envTestPhp.getAbsolutePath() + "\" JUNIT_ARG_TEST",
            envTestPhp,
            new StreamConsumer() {

              @Override
              public void consumeLine(String line) {
                // does nothing
              }
            }));
  }
Exemple #2
0
  /**
   * Tests if the execution configuration can be created.
   *
   * @throws Exception thrown on errors
   */
  public void testCodeArgs() throws Exception {
    // look up the component factory
    final IComponentFactory factory = lookup(IComponentFactory.class);
    // create the execution config
    final MavenSession session = this.createSimpleSession("exec/empty-pom");
    final IPhpExecutableConfiguration execConfig =
        factory.lookup(IPhpExecutableConfiguration.class, IComponentFactory.EMPTY_CONFIG, session);

    // assert that the environment variable is mapped correctly
    final IPhpExecutable exec = execConfig.getPhpExecutable();
    final String output = exec.executeCode("", "echo $argv[1];", "JUNIT_ARG_TEST");
    assertEquals("JUNIT_ARG_TEST\n", output);
  }