diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-04-30 15:12:24 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-04-30 15:12:24 +0200 |
commit | b2ce89c7d12d0b77d7aaf273c8f4c0516ded7bd5 (patch) | |
tree | f37f50633caa356d64ddb7b7e2cc6571661e2394 /vdslib | |
parent | 2b18385e21151985edb7a9d0a85daa2332daa4a5 (diff) |
Remove usage of junit.framework
Diffstat (limited to 'vdslib')
3 files changed, 32 insertions, 22 deletions
diff --git a/vdslib/src/test/java/com/yahoo/vdslib/BucketDistributionTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/BucketDistributionTestCase.java index 0982a49bee1..5e1d811ade1 100644 --- a/vdslib/src/test/java/com/yahoo/vdslib/BucketDistributionTestCase.java +++ b/vdslib/src/test/java/com/yahoo/vdslib/BucketDistributionTestCase.java @@ -2,18 +2,22 @@ package com.yahoo.vdslib; import com.yahoo.document.BucketId; +import org.junit.Test; import java.util.Random; +import static org.junit.Assert.assertEquals; + /** - * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + * @author Simon Thoresen */ -public class BucketDistributionTestCase extends junit.framework.TestCase { +public class BucketDistributionTestCase { private static final int NUM_COLUMNS = 16; private static final int MIN_BUCKETBITS = 4; private static final int MAX_BUCKETBITS = 9; + @Test public void printExpected() { System.out.println(" int[][] expected = new int[][] {"); for (int numBucketBits = MIN_BUCKETBITS; numBucketBits <= MAX_BUCKETBITS; ++numBucketBits) { @@ -38,6 +42,7 @@ public class BucketDistributionTestCase extends junit.framework.TestCase { System.out.println(" };"); } + @Test public void testDistribution() { int[][] expected = new int[][] { new int[] { @@ -90,6 +95,7 @@ public class BucketDistributionTestCase extends junit.framework.TestCase { } } + @Test public void testNumBucketBits() { Random rnd = new Random(); @@ -108,4 +114,5 @@ public class BucketDistributionTestCase extends junit.framework.TestCase { assertEquals(0, bd.getColumn(new BucketId(32, (rnd.nextLong() << 16) & i))); } } + } diff --git a/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java index 62429f7c300..eaf9e576a5b 100644 --- a/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java +++ b/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java @@ -3,21 +3,23 @@ package com.yahoo.vdslib; import com.yahoo.document.*; import com.yahoo.document.datatypes.FloatFieldValue; -import com.yahoo.document.datatypes.IntegerFieldValue; import com.yahoo.document.datatypes.StringFieldValue; import com.yahoo.document.serialization.DocumentSerializer; import com.yahoo.document.serialization.DocumentSerializerFactory; import com.yahoo.document.update.FieldUpdate; +import org.junit.Test; -import java.io.EOFException; -import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.IOException; import java.util.ArrayList; import java.util.List; -public class DocumentListTestCase extends junit.framework.TestCase { +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +public class DocumentListTestCase { + + @Test @SuppressWarnings("deprecation") public void testSelfSerializationAndWriteJavaFile() throws Exception { DocumentTypeManager docMan = new DocumentTypeManager(); @@ -34,7 +36,7 @@ public class DocumentListTestCase extends junit.framework.TestCase { DocumentUpdate docUp = new DocumentUpdate(docMan.getDocumentType("benchmark"), new DocumentId("userdoc:foo:99999999:4")); docUp.addFieldUpdate(FieldUpdate.createAssign(docUp.getType().getField("bodystring"), new StringFieldValue("ballooooo"))); - List<Entry> entries = new ArrayList<Entry>(); + List<Entry> entries = new ArrayList<>(); entries.add(Entry.create(put1)); entries.add(Entry.create(doc2)); entries.add(Entry.create(put3)); @@ -92,6 +94,7 @@ public class DocumentListTestCase extends junit.framework.TestCase { assertEquals(new StringFieldValue("ballooooo"),((DocumentUpdate) entry4.getDocumentOperation()).getFieldUpdate(0).getValueUpdate(0).getValue()); } + @Test public void testContains() { DocumentTypeManager manager = new DocumentTypeManager(); DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg"); @@ -119,17 +122,17 @@ public class DocumentListTestCase extends junit.framework.TestCase { DocumentList documentList2 = DocumentList.create(entries2); - assert(documentList.containsAll(documentList2)); + assertTrue(documentList.containsAll(documentList2)); Long t = put4.getDocument().getLastModified(); put4.getDocument().setLastModified(13L); - assert(!documentList.containsAll(documentList2)); + assertTrue(!documentList.containsAll(documentList2)); put4.getDocument().setLastModified(t); assert(documentList.containsAll(documentList2)); entries.remove(2); - assert(!documentList.containsAll(documentList2)); - + assertTrue(!documentList.containsAll(documentList2)); } + } diff --git a/vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java index 0f650185d69..ccce2ffcbb7 100644 --- a/vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java +++ b/vdslib/src/test/java/com/yahoo/vdslib/EntryTestCase.java @@ -1,17 +1,20 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vdslib; -import com.yahoo.document.Document; import com.yahoo.document.DocumentPut; import com.yahoo.document.DocumentType; import com.yahoo.document.DocumentTypeManager; import com.yahoo.document.DocumentTypeManagerConfigurer; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; /** * @author banino */ -public class EntryTestCase extends junit.framework.TestCase{ +public class EntryTestCase { + @Test public void testEquals() { DocumentTypeManager manager = new DocumentTypeManager(); DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg"); @@ -22,13 +25,13 @@ public class EntryTestCase extends junit.framework.TestCase{ Entry entry1 = Entry.create(put1); Entry entry2 = Entry.create(put1); - assert(entry1.equals(entry2)); + assertTrue(entry1.equals(entry2)); Entry entry3 = Entry.create(put2); - assert(!entry1.equals(entry3)); - + assertTrue(!entry1.equals(entry3)); } + @Test public void testHashCode() { DocumentTypeManager manager = new DocumentTypeManager(); DocumentTypeManagerConfigurer.configure(manager, "file:src/test/files/documentmanager.cfg"); @@ -39,13 +42,10 @@ public class EntryTestCase extends junit.framework.TestCase{ Entry entry1 = Entry.create(put1); Entry entry2 = Entry.create(put1); - assert(entry1.hashCode() == entry2.hashCode()); + assertTrue(entry1.hashCode() == entry2.hashCode()); Entry entry3 = Entry.create(put2); - assert(entry1.hashCode() != entry3.hashCode()); - + assertTrue(entry1.hashCode() != entry3.hashCode()); } - - } |