| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.nio.charset.Charset; |
| | | |
| | | public class TestJob extends AbstractJob { |
| | | private Logger log = LoggerFactory.getLogger(TestJob.class); |
| | |
| | | PumpStreamHandler streamHandler = new PumpStreamHandler(new LogOutputStream() { |
| | | @Override |
| | | protected void processLine(String line, int level) { |
| | | log.info(line); |
| | | //log.info(line); |
| | | try { |
| | | outputStream.write(line.getBytes()); |
| | | outputStream.write("\n".getBytes()); |
| | |
| | | }, new LogOutputStream() { |
| | | @Override |
| | | protected void processLine(String line, int logLevel) { |
| | | log.error(line); |
| | | //log.error(line); |
| | | try { |
| | | errorOutputStream.write(line.getBytes()); |
| | | errorOutputStream.write("\n".getBytes()); |
| | |
| | | try { |
| | | executor.execute(cmdLine); |
| | | } catch (Exception ex) { |
| | | log.error("Error while executing script: " + ex.getMessage(), ex); |
| | | failed(); |
| | | if (failOn < 0) { |
| | | log.error("Error while executing script: " + ex.getMessage(), ex); |
| | | } |
| | | } |
| | | log.info(outputStream.toString(Charset.forName("UTF-8"))); |
| | | log.error(errorOutputStream.toString(Charset.forName("UTF-8"))); |
| | | //log.info(outputStream.toString(Charset.forName("UTF-8"))); |
| | | //log.error(errorOutputStream.toString(Charset.forName("UTF-8"))); |
| | | } |
| | | } |