Skip to content

Commit 1c5796c

Browse files
author
eugenp
committed
java tests cleanup work
1 parent 1020ce2 commit 1c5796c

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

core-java/src/test/java/org/baeldung/java/CoreJavaIoIntegrationTest.java renamed to core-java/src/test/java/org/baeldung/java/JavaIoIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.google.common.base.Charsets;
1515
import com.google.common.io.Files;
1616

17-
public class CoreJavaIoIntegrationTest {
17+
public class JavaIoIntegrationTest {
1818
protected final Logger logger = LoggerFactory.getLogger(getClass());
1919

2020
// tests - iterate lines in a file

core-java/src/test/java/org/baeldung/java/CoreJavaRandomUnitTest.java renamed to core-java/src/test/java/org/baeldung/java/JavaRandomUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.apache.commons.math3.random.RandomDataGenerator;
88
import org.junit.Test;
99

10-
public class CoreJavaRandomUnitTest {
10+
public class JavaRandomUnitTest {
1111

1212
// tests - random long
1313

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.baeldung.java;
2+
3+
import java.util.Date;
4+
import java.util.Timer;
5+
import java.util.TimerTask;
6+
7+
import org.junit.Test;
8+
9+
public class JavaTimerUnitTest {
10+
11+
// tests
12+
13+
@Test
14+
public void givenUsingTimer_whenSchedulingTaskOnce_thenCorrect() throws InterruptedException {
15+
final TimerTask timerTask = new TimerTask() {
16+
@Override
17+
public void run() {
18+
System.out.println("Task performed on " + new Date() + "\n" + "Thread's name: " + Thread.currentThread().getName());
19+
}
20+
};
21+
22+
final Timer timer = new Timer("Timer");
23+
final long delay = 1000L;
24+
timer.schedule(timerTask, delay);
25+
26+
Thread.sleep(delay * 2);
27+
timer.cancel();
28+
}
29+
30+
}

0 commit comments

Comments
 (0)