Class AppClientWrapper
- java.lang.Object
-
- org.jboss.as.arquillian.container.managed.AppClientWrapper
-
- All Implemented Interfaces:
AutoCloseable
public class AppClientWrapper extends Object implements AutoCloseable
A wrapper for an application client process. Allows interacting with the application client process.- Author:
- Dominik Pospisil
, Stuart Douglas, James R. Perkins
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAppClientWrapper(ManagedContainerConfiguration config, org.jboss.logging.Logger log)Creates a new application client wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Kills the application client.List<String>readAll(long timeout)Consumes all available output from application client using the output queue filled by the process standard out reader thread.voidrun()Starts the application client in a new process and creates two thread to read the process output (stdout) and error streams (stderr).booleanwaitForExit(long timeout, TimeUnit unit)If the application client has started, causes the current thread to wait, if necessary, until the application client terminates or the specified wait has been reached.
-
-
-
Constructor Detail
-
AppClientWrapper
protected AppClientWrapper(ManagedContainerConfiguration config, org.jboss.logging.Logger log)
Creates a new application client wrapper.- Parameters:
config- the configuration for the containerlog- the logger to use
-
-
Method Detail
-
waitForExit
public boolean waitForExit(long timeout, TimeUnit unit) throws InterruptedExceptionIf the application client has started, causes the current thread to wait, if necessary, until the application client terminates or the specified wait has been reached.If the application client has not started a value of
falseis returned and an error message logged indicating the application client has not started.If the application client has started and the process has terminated, this method returns
trueimmediately.- Parameters:
timeout- the maximum time to waitunit- the time unit of thetimeoutargument- Returns:
trueif the application client process has exited andfalseif the waiting time elapsed before the process has exited- Throws:
InterruptedException- if the current thread is interrupted while waitingNullPointerException- if unit is null- See Also:
Process.waitFor(long, TimeUnit)
-
readAll
public List<String> readAll(long timeout)
Consumes all available output from application client using the output queue filled by the process standard out reader thread.- Parameters:
timeout- number of milliseconds to wait for each subsequent line- Returns:
- list of application client output lines
-
run
public void run() throws IOExceptionStarts the application client in a new process and creates two thread to read the process output (stdout) and error streams (stderr).- Throws:
IOException- if there is a failure to start the application client process
-
close
public void close()
Kills the application client.- Specified by:
closein interfaceAutoCloseable
-
-