Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2015-05-21 15:03:03 -0400
committerFlorian Waibel2015-05-21 15:03:03 -0400
commit5558934d830ed63c22667753f78571776dfb8bef (patch)
tree577cb8506509c6697fe1ec205df50535ebd70a12
parentd4ae09e1d4014888ca18c5e510541ba5eea78a0c (diff)
downloadorg.eclipse.virgo.medic-5558934d830ed63c22667753f78571776dfb8bef.tar.gz
org.eclipse.virgo.medic-5558934d830ed63c22667753f78571776dfb8bef.tar.xz
org.eclipse.virgo.medic-5558934d830ed63c22667753f78571776dfb8bef.zip
Code cleanup in JUnit tests
-rw-r--r--org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/summary/SummaryDumpContributorTests.java17
-rw-r--r--org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/impl/config/DictionaryUtilsTests.java14
2 files changed, 13 insertions, 18 deletions
diff --git a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/summary/SummaryDumpContributorTests.java b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/summary/SummaryDumpContributorTests.java
index 2312692..664da21 100644
--- a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/summary/SummaryDumpContributorTests.java
+++ b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/summary/SummaryDumpContributorTests.java
@@ -79,16 +79,13 @@ public class SummaryDumpContributorTests {
}
private void assertDumpContents(File dumpFile, long timestamp, String cause, Throwable... throwables) throws IOException {
- BufferedReader input = new BufferedReader(new FileReader(dumpFile));
-
- List<String> lines = new ArrayList<String>();
-
- String line;
-
- while ((line = input.readLine()) != null) {
- lines.add(line);
- }
-
+ List<String> lines = new ArrayList<String>();
+ try (BufferedReader input = new BufferedReader(new FileReader(dumpFile))) {
+ String line;
+ while ((line = input.readLine()) != null) {
+ lines.add(line);
+ }
+ }
assertDatePresent(lines, timestamp);
assertTimePresent(lines, timestamp);
assertCausePresent(lines, cause);
diff --git a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/impl/config/DictionaryUtilsTests.java b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/impl/config/DictionaryUtilsTests.java
index 32fa55a..3fac321 100644
--- a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/impl/config/DictionaryUtilsTests.java
+++ b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/impl/config/DictionaryUtilsTests.java
@@ -20,14 +20,12 @@ import java.util.Hashtable;
import org.eclipse.virgo.medic.impl.config.DictionaryUtils;
import org.junit.Test;
-
-@SuppressWarnings("unchecked")
public class DictionaryUtilsTests {
@Test
public void emptyMerge() {
- Dictionary primary = new Hashtable();
- Dictionary secondary = new Hashtable();
+ Dictionary<Object, Object> primary = new Hashtable<Object, Object>();
+ Dictionary<Object, Object> secondary = new Hashtable<Object, Object>();
DictionaryUtils.merge(primary, secondary);
assertTrue(primary.isEmpty());
@@ -35,9 +33,9 @@ public class DictionaryUtilsTests {
@Test
public void mergeWithoutClash() {
- Dictionary primary = new Hashtable();
+ Dictionary<Object, Object> primary = new Hashtable<Object, Object>();
primary.put("b", "c");
- Dictionary secondary = new Hashtable();
+ Dictionary<Object, Object> secondary = new Hashtable<Object, Object>();
secondary.put("a", "b");
DictionaryUtils.merge(primary, secondary);
@@ -47,9 +45,9 @@ public class DictionaryUtilsTests {
@Test
public void mergeWithClash() {
- Dictionary primary = new Hashtable();
+ Dictionary<Object, Object> primary = new Hashtable<Object, Object>();
primary.put("b", "c");
- Dictionary secondary = new Hashtable();
+ Dictionary<Object, Object> secondary = new Hashtable<Object, Object>();
secondary.put("b", "b");
DictionaryUtils.merge(primary, secondary);

Back to the top