Tag Results
4 posts tagged java
4 posts tagged java
You can easily (JUnit-) test if something has been written via System.out.println by poiting out to a ByteArrayOutputStream:
private final ByteArrayOutputStream output = new ByteArrayOutputStream();
private final String logMessage = "testtestTEST";
@Before
public void setUp() {
System.setOut(new PrintStream(this.output));
}
@After
public void tearDown() {
System.setOut(null);
}
/**
* Test of info method, of class Log. - Debug mode enabled.
*/
@Test
public void testInfoInDebug() {
Main.debugMode = true;
Log.info(this.logMessage);
assertTrue(output.toString().contains(this.logMessage));
}
The guide has moved here: https://github.com/Graylog2/graylog2-server/wiki/Installing
The most important difference between the User Datagram Protocol (UDP) and TCP which you always have to keep in mind is: UDP communication is never reliable. While TCP guarantees that the packages you send will arrive the destination, will still be in the correct order and are not damaged, UDP packages are just fired out and you have no feedback what happened to them on their journey around the world. Remember: Network communication is never reliable. Routers on the way can fail, drop your packets, you can run out of TTL, your package can be corrupted, timeouts, … In short: use TCP if you want to make sure that your packages arrive at the destination as you sent them or you want to at least find out if they did not.
You just read about the biggest disadvantage of UDP and ask why anybody would ever want to use it?! There are a few situations in which UDP may be the better choice:
JMX provides an easy way to monitor your Java applications. In this guide I’ll show you how to use it to monitor values from inside your application. To learn what else you can do with JMX, take a look at the Java Management Extension article on Wikipedia.
The values to monitor are represented by MBean objects. Your MBeans will be organized by the MBeanServer.
Creating the MBeanServer will be our first step: