suppress logs on tests
This commit is contained in:
@@ -10,9 +10,12 @@ import java.net.URISyntaxException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class Connection {
|
public abstract class Connection {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(Connection.class.getName());
|
||||||
|
|
||||||
final static int TIMEOUT = 7000;
|
final static int TIMEOUT = 7000;
|
||||||
final static int PORT = 3000;
|
final static int PORT = 3000;
|
||||||
|
|
||||||
@@ -23,7 +26,7 @@ public abstract class Connection {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void startServer() throws IOException, InterruptedException {
|
public void startServer() throws IOException, InterruptedException {
|
||||||
System.out.println("Starting server ...");
|
logger.fine("Starting server ...");
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
serverProcess = Runtime.getRuntime().exec(
|
serverProcess = Runtime.getRuntime().exec(
|
||||||
@@ -39,10 +42,10 @@ public abstract class Connection {
|
|||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
do {
|
do {
|
||||||
System.out.println("SERVER OUT: " + line);
|
logger.fine("SERVER OUT: " + line);
|
||||||
} while ((line = reader.readLine()) != null);
|
} while ((line = reader.readLine()) != null);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.warning(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -54,10 +57,10 @@ public abstract class Connection {
|
|||||||
String line;
|
String line;
|
||||||
try {
|
try {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
System.err.println("SERVER ERR: " + line);
|
logger.fine("SERVER ERR: " + line);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.warning(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -66,7 +69,7 @@ public abstract class Connection {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void stopServer() throws InterruptedException {
|
public void stopServer() throws InterruptedException {
|
||||||
System.out.println("Stopping server ...");
|
logger.fine("Stopping server ...");
|
||||||
serverProcess.destroy();
|
serverProcess.destroy();
|
||||||
serverOutput.cancel(false);
|
serverOutput.cancel(false);
|
||||||
serverError.cancel(false);
|
serverError.cancel(false);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.junit.runners.JUnit4;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
@@ -14,6 +15,8 @@ import static org.junit.Assert.assertThat;
|
|||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class ExecutionTest extends Connection {
|
public class ExecutionTest extends Connection {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(ExecutionTest.class.getName());
|
||||||
|
|
||||||
final static int TIMEOUT = 30 * 1000;
|
final static int TIMEOUT = 30 * 1000;
|
||||||
|
|
||||||
@Test(timeout = TIMEOUT)
|
@Test(timeout = TIMEOUT)
|
||||||
@@ -38,7 +41,7 @@ public class ExecutionTest extends Connection {
|
|||||||
new InputStreamReader(process.getInputStream()));
|
new InputStreamReader(process.getInputStream()));
|
||||||
String line;
|
String line;
|
||||||
while ((line = input.readLine()) != null) {
|
while ((line = input.readLine()) != null) {
|
||||||
System.out.println("EXEC OUT: " + line);
|
logger.fine("EXEC OUT: " + line);
|
||||||
}
|
}
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
assertThat(process.exitValue(), is(0));
|
assertThat(process.exitValue(), is(0));
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
|
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
|
||||||
.level = ALL
|
.level = ALL
|
||||||
|
|
||||||
java.util.logging.ConsoleHandler.level = FINE
|
java.util.logging.ConsoleHandler.level = INFO
|
||||||
|
|
||||||
java.util.logging.FileHandler.level = ALL
|
java.util.logging.FileHandler.level = ALL
|
||||||
java.util.logging.FileHandler.pattern = ./target/test.log
|
java.util.logging.FileHandler.pattern = ./target/test.log
|
||||||
|
|||||||
Reference in New Issue
Block a user