diff options
author | gjoranv <gjoranv@gmail.com> | 2018-04-26 15:11:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-26 15:11:23 +0200 |
commit | fd87f261cb57d26600b219c9362ed57fd61f6cbe (patch) | |
tree | 81856edd2519c307bf108a059930de139cf0b38b /vespajlib/src/test/java/com | |
parent | 551c41397831d21fddc8b41bf319ef4a26798d0d (diff) | |
parent | 2140d26246a005b53def955d0beac0b925d98875 (diff) |
Merge pull request #5720 from vespa-engine/gjoranv/java9-prep-03
Gjoranv/java9 prep 03
Diffstat (limited to 'vespajlib/src/test/java/com')
7 files changed, 19 insertions, 12 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java b/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java index 002b1de9147..6d9a6b6f422 100644 --- a/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/cache/CalcTestCase.java @@ -4,6 +4,8 @@ package com.yahoo.cache; import java.util.ArrayList; import java.util.List; +import static java.lang.Boolean.TRUE; + public class CalcTestCase extends junit.framework.TestCase { private SizeCalculator calc; @@ -26,7 +28,7 @@ public class CalcTestCase extends junit.framework.TestCase { } public void testBoolean() { - assertEquals(8+1, calc.sizeOf(new Boolean(true))); + assertEquals(8+1, calc.sizeOf(TRUE)); } public void testArrayPrimitive() { diff --git a/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java index 1dc8e5fa62e..4e8398a3ef5 100644 --- a/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/collections/ArraySetTestCase.java @@ -247,7 +247,9 @@ public final class ArraySetTestCase { @Test public void testSmallEmptySet() { final ArraySet<Integer> t = new ArraySet<>(3); - Integer a = new Integer(0), b = new Integer(1), c = new Integer(2); + Integer a = 0; + Integer b = 1; + Integer c = 2; t.add(a); t.add(b); t.add(c); diff --git a/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java index 6bf97baf985..2307b2cbca9 100644 --- a/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/collections/HashletTestCase.java @@ -87,10 +87,10 @@ public class HashletTestCase { Hashlet<String, Integer> h = new Hashlet<>(); h.put(A, 1); int indexOfA = h.getIndexOfKey(A); - assertEquals(new Integer(1), h.value(indexOfA)); + assertEquals(Integer.valueOf(1), h.value(indexOfA)); h.setValue(indexOfA, 2); - assertEquals(new Integer(2), h.value(indexOfA)); - assertEquals(new Integer(2), h.get(A)); + assertEquals(Integer.valueOf(2), h.value(indexOfA)); + assertEquals(Integer.valueOf(2), h.get(A)); } @Test @@ -171,7 +171,7 @@ public class HashletTestCase { String str = ("" + i + "_str_" + i); assertThat(hash.get(str), nullValue()); switch (i % 2) { - case 1: assertThat(hash.put(str, new Integer(i)), nullValue()); + case 1: assertThat(hash.put(str, i), nullValue()); } } assertThat(hash.size(), is(n / 2)); @@ -179,7 +179,7 @@ public class HashletTestCase { String str = ("" + i + "_str_" + i); switch (i % 2) { case 0: assertThat(hash.get(str), nullValue()); break; - case 1: assertThat(hash.get(str), is(new Integer(i))); break; + case 1: assertThat(hash.get(str), is(i)); break; } } } diff --git a/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java index e579a0cad23..98aaaf267e8 100644 --- a/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/collections/TinyIdentitySetTestCase.java @@ -247,7 +247,9 @@ public final class TinyIdentitySetTestCase { @Test public void testSmallEmptySet() { final TinyIdentitySet<Integer> t = new TinyIdentitySet<>(3); - Integer a = new Integer(0), b = new Integer(1), c = new Integer(2); + Integer a = 0; + Integer b = 1; + Integer c = 2; t.add(a); t.add(b); t.add(c); diff --git a/vespajlib/src/test/java/com/yahoo/compress/IntegerCompressorTest.java b/vespajlib/src/test/java/com/yahoo/compress/IntegerCompressorTest.java index 6676ecb6205..2c88080b879 100644 --- a/vespajlib/src/test/java/com/yahoo/compress/IntegerCompressorTest.java +++ b/vespajlib/src/test/java/com/yahoo/compress/IntegerCompressorTest.java @@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue; /** * Test that integers compresses correctly. * - * @author: baldersheim + * @author baldersheim */ public class IntegerCompressorTest { private void verifyPositiveNumber(int n, byte [] expected) { diff --git a/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java b/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java index 787260f2e20..88413f4975f 100644 --- a/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/concurrent/ExecutorsTestCase.java @@ -18,7 +18,7 @@ public class ExecutorsTestCase { static private class ThreadId extends ThreadLocal<Integer> { @Override protected Integer initialValue() { - return new Integer(threadCount.getAndIncrement()); + return threadCount.getAndIncrement(); } } static private ThreadId threadId = new ThreadId(); diff --git a/vespajlib/src/test/java/com/yahoo/text/Benchmark.java b/vespajlib/src/test/java/com/yahoo/text/Benchmark.java index 14eed6d80d4..9569adcf9f0 100644 --- a/vespajlib/src/test/java/com/yahoo/text/Benchmark.java +++ b/vespajlib/src/test/java/com/yahoo/text/Benchmark.java @@ -4,6 +4,7 @@ package com.yahoo.text; // import com.google.common.base.Preconditions; // import com.google.inject.Provider; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -27,8 +28,8 @@ class Benchmark { final Class<? extends Task> taskClass; public Task get() { try { - return taskClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + return taskClass.getDeclaredConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new RuntimeException(e); } } |