AbstractCliTestCase (Griffon 0.9.5-rc2)
Date: 2012-03-09

Overview | Package | Class | Deprecated | Index | Help
| Griffon 0.9.5-rc2
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD

## griffon.test
[Groovy] Class AbstractCliTestCase

    java.lang.Object
      GroovyTestCase
          griffon.test.AbstractCliTestCase

    abstract class AbstractCliTestCase
    extends GroovyTestCase

This abstract test case makes it easy to run a Griffon command and query its output. It's currently configured via a set of system properties:

- `griffon.home` - location of Griffon distribution to test
- `griffon.version` - version of Griffon we're testing
- `griffon.cli.work.dir` - location of the test case's working directory

Authors:
  Peter Ledbrook (Grails 1.1)

Field Summary
`private String` | `commandOutput`
`private Condition` | `condition`
`private String` | `griffonHome`
`private String` | `griffonVersion`
`private Lock` | `lock`
`private Process` | `process`
`private boolean` | `streamsProcessed`
`private File` | `workDir`

Property Summary
`File` | `outputDir`
`long` | `timeout`

Constructor Summary
`AbstractCliTestCase()`

Method Summary
`void` | `enterInput(String input)` Allows you to provide user input for any commands that require it.
`protected void` | `execute(List command)` Executes a Griffon command.
`String` | `getOutput()` Returns the process output as a string.
`File` | `getWorkDir()` Returns the working directory for the current command.
`void` | `setOutput(String output)`
`void` | `setWorkDir(File dir)`
`protected void` | `signalDone()` Signals any threads waiting on `condition` to inform them that the process output stream has been read.
`protected void` | `verifyHeader()` Checks that the output of the current command starts with the expected header, which includes the Griffon version and the location of GRIFFON_HOME.
`int` | `waitForProcess()` Waits for the current command to finish executing.

Field Detail

### commandOutput

    private String commandOutput

### condition

    private final Condition condition

### griffonHome

    private String griffonHome

### griffonVersion

    private String griffonVersion

### lock

    private final Lock lock

### process

    private Process process

### streamsProcessed

    private boolean streamsProcessed

### workDir

    private File workDir

Property Detail

### outputDir

    File outputDir

### timeout

    long timeout

Constructor Detail

### AbstractCliTestCase

    AbstractCliTestCase()

Method Detail

### enterInput

    void enterInput(String input)

  Allows you to provide user input for any commands that require it. In other words, you can run commands in interactive mode. For example, you could pass "app1" as the `input` parameter when running the "create-app" command.

### execute

    protected void execute(List command)

  Executes a Griffon command. The path to the Griffon script is inserted at the front, so the first element of `command` should be the name of the Griffon command you want to start, e.g. "help" or "run-app".
  Parameters:
    `a` - list of command arguments (minus the Griffon script/executable).

### getOutput

    String getOutput()

  Returns the process output as a string.

### getWorkDir

    File getWorkDir()

  Returns the working directory for the current command. This may be the base working directory or a project.

### setOutput

    void setOutput(String output)

### setWorkDir

    void setWorkDir(File dir)

### signalDone

    protected void signalDone()

  Signals any threads waiting on `condition` to inform them that the process output stream has been read. Should only be used by this class (not sub-classes). It's protected so that it can be called from the reader thread closure (some strange Groovy behaviour).

### verifyHeader

    protected final void verifyHeader()

  Checks that the output of the current command starts with the expected header, which includes the Griffon version and the location of GRIFFON_HOME.

### waitForProcess

    int waitForProcess()

  Waits for the current command to finish executing. It returns the exit code from the external process. It also dumps the process output into the "cli-tests/output" directory to aid debugging.

Groovy Documentation