Skip to content

Commit fe4d04f

Browse files
authored
apacheGH-42002: [Java] Update Unit Tests for Vector Module (apache#42019)
### Rationale for this change Update package from JUnit 4(`org.junit`) to JUnit 5(`org.junit.jupiter`). ### What changes are included in this PR? - [x] Replacing `org.junit` with `org.junit.jupiter.api`. - [x] Updating `Assertions.assertXXX` to `assertXXX` using static imports. - [x] Updating annotations such as `@ Before`, `@ BeforeClass`, `@ After`, `@ AfterClass`. - `@ Before` -> `@ BeforeEach` - `@ BeforeClass` -> `@ BeforeAll` - `@ After` -> `@ AfterEach` - `@ AfterClass` -> `@ AfterAll` - `@ Test` -> `@ Test` with `org.junit.jupiter` - [x] Removing unused `@ Rule` Annotation - [x] Updating `Parameterized` test - [x] Doing self review ### Are these changes tested? Yes, existing tests have passed. ### Are there any user-facing changes? No. * GitHub Issue: apache#42002 Authored-by: Hyunseok Seo <[email protected]> Signed-off-by: David Li <[email protected]>
1 parent a045770 commit fe4d04f

File tree

69 files changed

+1191
-1144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1191
-1144
lines changed

java/vector/src/test/java/org/apache/arrow/vector/ITTestLargeVector.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
package org.apache.arrow.vector;
1919

20-
import static org.junit.Assert.assertArrayEquals;
21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

2424
import java.math.BigDecimal;
2525
import java.nio.charset.StandardCharsets;
@@ -28,7 +28,7 @@
2828
import org.apache.arrow.memory.BufferAllocator;
2929
import org.apache.arrow.memory.RootAllocator;
3030
import org.apache.arrow.vector.holders.NullableDecimalHolder;
31-
import org.junit.Test;
31+
import org.junit.jupiter.api.Test;
3232
import org.slf4j.Logger;
3333
import org.slf4j.LoggerFactory;
3434

java/vector/src/test/java/org/apache/arrow/vector/TestBitVector.java

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
package org.apache.arrow.vector;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertFalse;
22-
import static org.junit.Assert.assertSame;
23-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertSame;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
2424

2525
import java.util.stream.IntStream;
2626

@@ -29,22 +29,21 @@
2929
import org.apache.arrow.memory.util.hash.MurmurHasher;
3030
import org.apache.arrow.vector.testing.ValueVectorDataPopulator;
3131
import org.apache.arrow.vector.util.TransferPair;
32-
import org.junit.After;
33-
import org.junit.Assert;
34-
import org.junit.Before;
35-
import org.junit.Test;
32+
import org.junit.jupiter.api.AfterEach;
33+
import org.junit.jupiter.api.BeforeEach;
34+
import org.junit.jupiter.api.Test;
3635

3736
public class TestBitVector {
3837
private static final String EMPTY_SCHEMA_PATH = "";
3938

4039
private BufferAllocator allocator;
4140

42-
@Before
41+
@BeforeEach
4342
public void init() {
4443
allocator = new RootAllocator(Long.MAX_VALUE);
4544
}
4645

47-
@After
46+
@AfterEach
4847
public void terminate() throws Exception {
4948
allocator.close();
5049
}
@@ -124,8 +123,8 @@ public void testSplitAndTransfer() throws Exception {
124123
for (int i = 0; i < length; i++) {
125124
int actual = toVector.get(i);
126125
int expected = sourceVector.get(start + i);
127-
assertEquals("different data values not expected --> sourceVector index: " + (start + i) +
128-
" toVector index: " + i, expected, actual);
126+
assertEquals(expected, actual,
127+
"different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i);
129128
}
130129
}
131130
}
@@ -167,8 +166,8 @@ public void testSplitAndTransfer1() throws Exception {
167166
for (int i = 0; i < length; i++) {
168167
int actual = toVector.get(i);
169168
int expected = sourceVector.get(start + i);
170-
assertEquals("different data values not expected --> sourceVector index: " + (start + i) +
171-
" toVector index: " + i, expected, actual);
169+
assertEquals(expected, actual,
170+
"different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i);
172171
}
173172
}
174173
}
@@ -218,8 +217,8 @@ public void testSplitAndTransfer2() throws Exception {
218217
for (int i = 0; i < length; i++) {
219218
int actual = toVector.get(i);
220219
int expected = sourceVector.get(start + i);
221-
assertEquals("different data values not expected --> sourceVector index: " + (start + i) +
222-
" toVector index: " + i, expected, actual);
220+
assertEquals(expected, actual,
221+
"different data values not expected --> sourceVector index: " + (start + i) + " toVector index: " + i);
223222
}
224223
}
225224
}
@@ -241,9 +240,9 @@ public void testReallocAfterVectorTransfer1() {
241240

242241
for (int i = 0; i < valueCapacity; i++) {
243242
if ((i & 1) == 1) {
244-
assertEquals("unexpected cleared bit at index: " + i, 1, vector.get(i));
243+
assertEquals(1, vector.get(i), "unexpected cleared bit at index: " + i);
245244
} else {
246-
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
245+
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
247246
}
248247
}
249248

@@ -259,9 +258,9 @@ public void testReallocAfterVectorTransfer1() {
259258

260259
for (int i = 0; i < valueCapacity * 2; i++) {
261260
if (((i & 1) == 1) || (i == valueCapacity)) {
262-
assertEquals("unexpected cleared bit at index: " + i, 1, vector.get(i));
261+
assertEquals(1, vector.get(i), "unexpected cleared bit at index: " + i);
263262
} else {
264-
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
263+
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
265264
}
266265
}
267266

@@ -277,9 +276,9 @@ public void testReallocAfterVectorTransfer1() {
277276

278277
for (int i = 0; i < valueCapacity * 4; i++) {
279278
if (((i & 1) == 1) || (i == valueCapacity) || (i == valueCapacity * 2)) {
280-
assertEquals("unexpected cleared bit at index: " + i, 1, vector.get(i));
279+
assertEquals(1, vector.get(i), "unexpected cleared bit at index: " + i);
281280
} else {
282-
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
281+
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
283282
}
284283
}
285284

@@ -297,12 +296,12 @@ public void testReallocAfterVectorTransfer1() {
297296
if (i <= valueCapacity * 4) {
298297
if (((i & 1) == 1) || (i == valueCapacity) ||
299298
(i == valueCapacity * 2) || (i == valueCapacity * 4)) {
300-
assertEquals("unexpected cleared bit at index: " + i, 1, toVector.get(i));
299+
assertEquals(1, toVector.get(i), "unexpected cleared bit at index: " + i);
301300
} else {
302-
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
301+
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
303302
}
304303
} else {
305-
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
304+
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
306305
}
307306
}
308307

@@ -325,9 +324,9 @@ public void testReallocAfterVectorTransfer2() {
325324

326325
for (int i = 0; i < valueCapacity; i++) {
327326
if ((i & 1) == 1) {
328-
assertFalse("unexpected cleared bit at index: " + i, vector.isNull(i));
327+
assertFalse(vector.isNull(i), "unexpected cleared bit at index: " + i);
329328
} else {
330-
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
329+
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
331330
}
332331
}
333332

@@ -343,9 +342,9 @@ public void testReallocAfterVectorTransfer2() {
343342

344343
for (int i = 0; i < valueCapacity * 2; i++) {
345344
if (((i & 1) == 1) || (i == valueCapacity)) {
346-
assertFalse("unexpected cleared bit at index: " + i, vector.isNull(i));
345+
assertFalse(vector.isNull(i), "unexpected cleared bit at index: " + i);
347346
} else {
348-
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
347+
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
349348
}
350349
}
351350

@@ -361,9 +360,9 @@ public void testReallocAfterVectorTransfer2() {
361360

362361
for (int i = 0; i < valueCapacity * 4; i++) {
363362
if (((i & 1) == 1) || (i == valueCapacity) || (i == valueCapacity * 2)) {
364-
assertFalse("unexpected cleared bit at index: " + i, vector.isNull(i));
363+
assertFalse(vector.isNull(i), "unexpected cleared bit at index: " + i);
365364
} else {
366-
assertTrue("unexpected set bit at index: " + i, vector.isNull(i));
365+
assertTrue(vector.isNull(i), "unexpected set bit at index: " + i);
367366
}
368367
}
369368

@@ -381,12 +380,12 @@ public void testReallocAfterVectorTransfer2() {
381380
if (i <= valueCapacity * 4) {
382381
if (((i & 1) == 1) || (i == valueCapacity) ||
383382
(i == valueCapacity * 2) || (i == valueCapacity * 4)) {
384-
assertFalse("unexpected cleared bit at index: " + i, toVector.isNull(i));
383+
assertFalse(toVector.isNull(i), "unexpected cleared bit at index: " + i);
385384
} else {
386-
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
385+
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
387386
}
388387
} else {
389-
assertTrue("unexpected set bit at index: " + i, toVector.isNull(i));
388+
assertTrue(toVector.isNull(i), "unexpected set bit at index: " + i);
390389
}
391390
}
392391

@@ -500,13 +499,13 @@ private void validateRange(int length, int start, int count) {
500499
bitVector.allocateNew(length);
501500
bitVector.setRangeToOne(start, count);
502501
for (int i = 0; i < start; i++) {
503-
Assert.assertTrue(desc + i, bitVector.isNull(i));
502+
assertTrue(bitVector.isNull(i), desc + i);
504503
}
505504
for (int i = start; i < start + count; i++) {
506-
Assert.assertEquals(desc + i, 1, bitVector.get(i));
505+
assertEquals(1, bitVector.get(i), desc + i);
507506
}
508507
for (int i = start + count; i < length; i++) {
509-
Assert.assertTrue(desc + i, bitVector.isNull(i));
508+
assertTrue(bitVector.isNull(i), desc + i);
510509
}
511510
}
512511
}

java/vector/src/test/java/org/apache/arrow/vector/TestBitVectorHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717

1818
package org.apache.arrow.vector;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
2221
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

2424
import org.apache.arrow.memory.ArrowBuf;
2525
import org.apache.arrow.memory.BufferAllocator;
2626
import org.apache.arrow.memory.RootAllocator;
2727
import org.apache.arrow.memory.util.MemoryUtil;
2828
import org.apache.arrow.vector.ipc.message.ArrowFieldNode;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Test;
3030

3131
public class TestBitVectorHelper {
3232
@Test

java/vector/src/test/java/org/apache/arrow/vector/TestBufferOwnershipTransfer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
package org.apache.arrow.vector;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertFalse;
22-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2323

2424
import java.nio.charset.StandardCharsets;
2525

@@ -30,7 +30,7 @@
3030
import org.apache.arrow.vector.types.pojo.ArrowType;
3131
import org.apache.arrow.vector.types.pojo.FieldType;
3232
import org.apache.arrow.vector.util.CallBack;
33-
import org.junit.Test;
33+
import org.junit.jupiter.api.Test;
3434

3535
public class TestBufferOwnershipTransfer {
3636

0 commit comments

Comments
 (0)