Package org.tanukisoftware.wrapper.test
Class TestUtils
- java.lang.Object
-
- org.tanukisoftware.wrapper.test.TestUtils
-
public class TestUtils extends java.lang.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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
sleep(long ms)
Sleep for the specified time without any exceptions.static void
writeTextFile(java.io.File file, java.lang.String text)
Writes the specified text to a file.static void
writeTextFile(java.io.File file, java.lang.String text, java.lang.String encoding, boolean append)
Writes the specified text to a file.static void
writeWrapperCommand(java.lang.String command)
Writes a command to the Wrapper command file.static void
writeWrapperTestCommand(java.lang.String command)
Writes a test command to the Wrapper command file.
-
-
-
Method Detail
-
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(java.io.File file, java.lang.String text, java.lang.String encoding, boolean append) throws java.io.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:
java.io.IOException
- If there are any problems writing to the file.
-
writeTextFile
public static void writeTextFile(java.io.File file, java.lang.String text) throws java.io.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:
java.io.IOException
- If there are any problems writing to the file.
-
writeWrapperCommand
public static void writeWrapperCommand(java.lang.String command) throws java.io.IOException, java.lang.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:
java.io.IOException
- If there are any problems writing to the file.java.lang.IllegalStateException
- If the wrapper.commandfile property has not been defined.
-
writeWrapperTestCommand
public static void writeWrapperTestCommand(java.lang.String command) throws java.io.IOException, java.lang.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:
java.io.IOException
- If there are any problems writing to the file.java.lang.IllegalStateException
- If the wrapper.commandfile property has not been defined or the wrapper.command.enable_tests property has not been set to true.
-
-