| | @@ -0,0 +1,65 @@ |
| 1 | +package org.tanukisoftware.wrapper.test; |
| 2 | + |
| 3 | +/* |
| 4 | + * Copyright (c) 1999, 2012 Tanuki Software, Ltd. |
| 5 | + * http://www.tanukisoftware.com |
| 6 | + * All rights reserved. |
| 7 | + * |
| 8 | + * This software is the proprietary information of Tanuki Software. |
| 9 | + * You shall use it only in accordance with the terms of the |
| 10 | + * license agreement you entered into with Tanuki Software. |
| 11 | + * http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html |
| 12 | + */ |
| 13 | + |
| 14 | +/** |
| 15 | + * |
| 16 | + * |
| 17 | + * @author Leif Mortenson <leif@tanukisoftware.com> |
| 18 | + */ |
| 19 | +public class LogStdoutStderr { |
| 20 | + private static int m_lineNum = 1; |
| 21 | + private static int m_outLineNum = 1; |
| 22 | + private static int m_errLineNum = 1; |
| 23 | + |
| 24 | + /*--------------------------------------------------------------- |
| 25 | + * Static Methods |
| 26 | + *-------------------------------------------------------------*/ |
| 27 | + private static void logOut( String message ) |
| 28 | + { |
| 29 | + System.out.println( "All:" + (m_lineNum++) + " Out:" + (m_outLineNum++) + " " + message ); |
| 30 | + } |
| 31 | + private static void logErr( String message ) |
| 32 | + { |
| 33 | + System.err.println( "All:" + (m_lineNum++) + " Err:" + (m_errLineNum++) + " " + message ); |
| 34 | + } |
| 35 | + |
| 36 | + /*--------------------------------------------------------------- |
| 37 | + * Main Method |
| 38 | + *-------------------------------------------------------------*/ |
| 39 | + public static void main(String[] args) { |
| 40 | + System.out.println( Main.getRes().getString( "Logs several lines of output to stdout and stderr." ) ); |
| 41 | + System.out.println( Main.getRes().getString( "Make sure that all of the line numbers are in order and that they show up in the right places." ) ); |
| 42 | + |
| 43 | + logOut( "Test Output" ); |
| 44 | + logErr( "Test Error" ); |
| 45 | + |
| 46 | + for ( int i = 0; i < 100; i++ ) |
| 47 | + { |
| 48 | + logOut( "Loop #" + i ); |
| 49 | + logErr( "Loop #" + i ); |
| 50 | + } |
| 51 | + |
| 52 | + StringBuffer sb = new StringBuffer(); |
| 53 | + for ( int i = 0; i < 100; i++ ) |
| 54 | + { |
| 55 | + sb.append( "abcdefghijklmnopqrstuvwxyz" ); |
| 56 | + |
| 57 | + logOut( "Loop #" + i + " " + sb.toString() ); |
| 58 | + logErr( "Loop #" + i + " " + sb.toString() ); |
| 59 | + } |
| 60 | + |
| 61 | + logOut( "All done." ); |
| 62 | + logErr( "All done." ); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| | @@ -248,6 +248,34 @@ |
| 248 | 248 | wrapper.debug=TRUE]]></replacevalue> |
| 249 | 249 | </replace> |
| 250 | 250 | |
| 251 | + <!-- Log StdOutStdErr Test --> |
| 252 | + <delete file="${test.dir}/logstdoutstderr.conf"/> |
| 253 | + <filter token="app.name" value="logstdoutstderr"/> |
| 254 | + <filter token="app.long.name" value="Log stdout stderr Case" /> |
| 255 | + <copy file="${test.dir}/template.conf" |
| 256 | + tofile="${test.dir}/logstdoutstderr.conf" |
| 257 | + filtering="on"/> |
| 258 | + <replace file="${test.dir}/logstdoutstderr.conf" |
| 259 | + token="wrapper.app.parameter.1=<YourMainClass>" |
| 260 | + value="wrapper.app.parameter.1=org.tanukisoftware.wrapper.test.LogStdoutStderr" /> |
| 261 | + |
| 262 | + <!-- Log StdOutStdErrDetached Test --> |
| 263 | + <delete file="${test.dir}/logstdoutstderrdetached.conf"/> |
| 264 | + <filter token="app.name" value="logstdoutstderrdetached"/> |
| 265 | + <filter token="app.long.name" value="Log Stdout Stderr Detached Case" /> |
| 266 | + <copy file="${test.dir}/template.conf" |
| 267 | + tofile="${test.dir}/logstdoutstderrdetached.conf" |
| 268 | + filtering="on"/> |
| 269 | + <replace file="${test.dir}/logstdoutstderrdetached.conf"> |
| 270 | + <replacetoken><![CDATA[wrapper.app.parameter.1=<YourMainClass>]]></replacetoken> |
| 271 | + <replacevalue><![CDATA[wrapper.app.parameter.1=org.tanukisoftware.wrapper.test.LogStdoutStderr |
| 272 | +wrapper.app.parameter.1=true |
| 273 | + |
| 274 | +wrapper.jvm_detach_started=TRUE |
| 275 | +wrapper.java.outfile=../logs/java.stdout.log |
| 276 | +wrapper.java.errfile=../logs/java.stderr.log]]></replacevalue> |
| 277 | + </replace> |
| 278 | + |
| 251 | 279 | <!-- Loaded GC Output Test --> |
| 252 | 280 | <delete file="${test.dir}/loadedgcoutput.conf"/> |
| 253 | 281 | <filter token="app.name" value="loadedgcoutput"/> |
| | @@ -715,6 +743,31 @@ |
| 715 | 743 | token='set _WRAPPER_CONF_DEFAULT=../conf/wrapper.conf' |
| 716 | 744 | value='set _WRAPPER_CONF_DEFAULT=../test/loadedlogoutput.conf' /> |
| 717 | 745 | |
| 746 | + <!-- Log StdOutStdErr Test --> |
| 747 | + <delete file="${test.dir}/TestLogStdoutStderr.bat"/> |
| 748 | + <copy file="${src.dir}/bin/App.bat.in" |
| 749 | + tofile="${test.dir}/TestLogStdoutStderr.bat" |
| 750 | + filtering="on"/> |
| 751 | + <replace file="${test.dir}/TestLogStdoutStderr.bat" |
| 752 | + token='set _WRAPPER_BASE=wrapper' |
| 753 | + value='set _WRAPPER_BASE=..\bin\wrapper' /> |
| 754 | + <replace file="${test.dir}/TestLogStdoutStderr.bat" |
| 755 | + token='set _WRAPPER_CONF_DEFAULT=../conf/wrapper.conf' |
| 756 | + value='set _WRAPPER_CONF_DEFAULT=../test/logstdoutstderr.conf' /> |
| 757 | + |
| 758 | + |
| 759 | + <!-- Log StdOutStdErrDetached Test --> |
| 760 | + <delete file="${test.dir}/TestLogStdoutStderrDetached.bat"/> |
| 761 | + <copy file="${src.dir}/bin/App.bat.in" |
| 762 | + tofile="${test.dir}/TestLogStdoutStderrDetached.bat" |
| 763 | + filtering="on"/> |
| 764 | + <replace file="${test.dir}/TestLogStdoutStderrDetached.bat" |
| 765 | + token='set _WRAPPER_BASE=wrapper' |
| 766 | + value='set _WRAPPER_BASE=..\bin\wrapper' /> |
| 767 | + <replace file="${test.dir}/TestLogStdoutStderrDetached.bat" |
| 768 | + token='set _WRAPPER_CONF_DEFAULT=../conf/wrapper.conf' |
| 769 | + value='set _WRAPPER_CONF_DEFAULT=../test/logstdoutstderrdetached.conf' /> |
| 770 | + |
| 718 | 771 | <!-- Loaded GC Output Test --> |
| 719 | 772 | <delete file="${test.dir}/TestLoadedGCOutput.bat"/> |
| 720 | 773 | <copy file="${src.dir}/bin/App.bat.in" |
| | @@ -1078,6 +1131,22 @@ |
| 1078 | 1131 | filtering="on"/> |
| 1079 | 1132 | <chmod file="${test.dir}/loadedlogoutput" perm="+x"/> |
| 1080 | 1133 | |
| 1134 | + <!-- Log StdOutStdErr Test --> |
| 1135 | + <filter token="app.name" value="logstdoutstderr"/> |
| 1136 | + <filter token="app.long.name" value="Log StdOutStdErr Case" /> |
| 1137 | + <copy file="${test.dir}/temp.script.in" |
| 1138 | + tofile="${test.dir}/logstdoutstderr" |
| 1139 | + filtering="on"/> |
| 1140 | + <chmod file="${test.dir}/logstdoutstderr" perm="+x"/> |
| 1141 | + |
| 1142 | + <!-- Log StdOutStdErrDetached Test --> |
| 1143 | + <filter token="app.name" value="logstdoutstderrdetached"/> |
| 1144 | + <filter token="app.long.name" value="Log StdOutStdErrDetached Case" /> |
| 1145 | + <copy file="${test.dir}/temp.script.in" |
| 1146 | + tofile="${test.dir}/logstdoutstderrdetached" |
| 1147 | + filtering="on"/> |
| 1148 | + <chmod file="${test.dir}/logstdoutstderrdetached" perm="+x"/> |
| 1149 | + |
| 1081 | 1150 | <!-- Loaded GC Output Test --> |
| 1082 | 1151 | <filter token="app.name" value="loadedgcoutput"/> |
| 1083 | 1152 | <filter token="app.long.name" value="Loaded GC Output Case" /> |