Package org.tanukisoftware.wrapper.test

# Class TestUtils

java.lang.Object
org.tanukisoftware.wrapper.test.TestUtils

public class TestUtils extends Object
This test is designed to make sure the Wrapper handles the case where the JVM is restarted while the Wrapper is blocking due to a long disk IO queue. Prior to 3.5.11, the Wrapper would sometimes exit before it noticed that the JVM had wanted to restart.

## Method Summary

Modifier and Type
Method
Description
`static void`
`sleep(long ms)`
Sleep for the specified time without any exceptions.
`static void`
`writeTextFile(File file, String text)`
Writes the specified text to a file.
`static void`
`writeTextFile(File file, String text, String encoding, boolean append)`
Writes the specified text to a file.
`static void`
`writeWrapperCommand(String command)`
Writes a command to the Wrapper command file.
`static void`
`writeWrapperTestCommand(String command)`
Writes a test command to the Wrapper command file.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### sleep

public static void sleep(long ms)
Sleep for the specified time without any exceptions.

Parameters:
  `ms` - Time to sleep.

### writeTextFile

public static void writeTextFile(File file, String text, String encoding, boolean append) throws IOException
Writes the specified text to a file. This method is not an efficient way to write multiple lines of text as the file is opened and closed each time this is called. It can be useful when it is necessary to quickly write out some text however.

Parameters:
  `file` - File to be written to.
  `text` - Text to be written to the file. May contain multiple lines. No additional line feeds will be written out so it is important to include them if needed.
  `encoding` - Encoding to use when writing the text. Null implies that the system default will be used.
  `append` - If true and the file already exists then the text will be appended to the end of the file. If false then a new file will always be created.
Throws:
  `IOException` - If there are any problems writing to the file.

### writeTextFile

public static void writeTextFile(File file, String text) throws IOException
Writes the specified text to a file.

Parameters:
  `file` - File to be written to.
  `text` - Text to be written to the file. May contain multiple lines. No additional line feeds will be written out so it is important to include them if needed.
Throws:
  `IOException` - If there are any problems writing to the file.

### writeWrapperCommand

public static void writeWrapperCommand(String command) throws IOException, IllegalStateException
Writes a command to the Wrapper command file. If the file already exists then a warning will be logged as the file will be overwritten. The Wrapper polls for the file at regular intervals and this can happen if two command are written in rapid succession. If two commands must be written then they should be written to the same file at the same time to avoid any synchronization problems between the Wrapper and this process.

Parameters:
  `command` - Command to write to the configured Wrapper command file.
Throws:
  `IOException` - If there are any problems writing to the file.
  `IllegalStateException` - If the wrapper.commandfile property has not been defined.

### writeWrapperTestCommand

public static void writeWrapperTestCommand(String command) throws IOException, IllegalStateException
Writes a test command to the Wrapper command file. If the file already exists then a warning will be logged as the file will be overwritten. The Wrapper polls for the file at regular intervals and this can happen if two command are written in rapid succession. If two commands must be written then they should be written to the same file at the same time to avoid any synchronization problems between the Wrapper and this process.

Parameters:
  `command` - Command to write to the configured Wrapper command file.
Throws:
  `IOException` - If there are any problems writing to the file.
  `IllegalStateException` - If the wrapper.commandfile property has not been defined or the wrapper.command.enable_tests property has not been set to true.