java tests cleanup work

This commit is contained in:
eugenp 2014-11-02 01:19:58 +02:00
parent 1020ce2389
commit 1c5796c83c
3 changed files with 32 additions and 2 deletions

View File

@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
public class CoreJavaIoIntegrationTest {
public class JavaIoIntegrationTest {
protected final Logger logger = LoggerFactory.getLogger(getClass());
// tests - iterate lines in a file

View File

@ -7,7 +7,7 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.math3.random.RandomDataGenerator;
import org.junit.Test;
public class CoreJavaRandomUnitTest {
public class JavaRandomUnitTest {
// tests - random long

View File

@ -0,0 +1,30 @@
package org.baeldung.java;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.junit.Test;
public class JavaTimerUnitTest {
// tests
@Test
public void givenUsingTimer_whenSchedulingTaskOnce_thenCorrect() throws InterruptedException {
final TimerTask timerTask = new TimerTask() {
@Override
public void run() {
System.out.println("Task performed on " + new Date() + "\n" + "Thread's name: " + Thread.currentThread().getName());
}
};
final Timer timer = new Timer("Timer");
final long delay = 1000L;
timer.schedule(timerTask, delay);
Thread.sleep(delay * 2);
timer.cancel();
}
}