20
20
21
21
import static org .apache .iceberg .types .Types .NestedField .optional ;
22
22
import static org .apache .iceberg .types .Types .NestedField .required ;
23
+ import static org .assertj .core .api .Assertions .assertThat ;
23
24
25
+ import java .io .File ;
24
26
import java .io .IOException ;
27
+ import java .nio .file .Path ;
25
28
import java .util .List ;
26
29
import java .util .stream .Collectors ;
27
30
import org .apache .iceberg .ChangelogOperation ;
41
44
import org .apache .iceberg .io .CloseableIterable ;
42
45
import org .apache .iceberg .relocated .com .google .common .collect .ImmutableSet ;
43
46
import org .apache .iceberg .relocated .com .google .common .collect .Lists ;
44
- import org .apache .iceberg .spark .SparkTestBase ;
47
+ import org .apache .iceberg .spark .TestBase ;
45
48
import org .apache .iceberg .types .Types ;
46
49
import org .apache .spark .sql .catalyst .InternalRow ;
47
- import org .junit .After ;
48
- import org .junit .Assert ;
49
- import org .junit .Before ;
50
- import org .junit .Rule ;
51
- import org .junit .Test ;
52
- import org .junit .rules .TemporaryFolder ;
53
-
54
- public class TestChangelogReader extends SparkTestBase {
50
+ import org .junit .jupiter .api .AfterEach ;
51
+ import org .junit .jupiter .api .BeforeEach ;
52
+ import org .junit .jupiter .api .Test ;
53
+ import org .junit .jupiter .api .io .TempDir ;
54
+
55
+ public class TestChangelogReader extends TestBase {
55
56
private static final Schema SCHEMA =
56
57
new Schema (
57
58
required (1 , "id" , Types .IntegerType .get ()), optional (2 , "data" , Types .StringType .get ()));
@@ -64,9 +65,9 @@ public class TestChangelogReader extends SparkTestBase {
64
65
private DataFile dataFile1 ;
65
66
private DataFile dataFile2 ;
66
67
67
- @ Rule public TemporaryFolder temp = new TemporaryFolder () ;
68
+ @ TempDir private Path temp ;
68
69
69
- @ Before
70
+ @ BeforeEach
70
71
public void before () throws IOException {
71
72
table = catalog .createTable (TableIdentifier .of ("default" , "test" ), SCHEMA , SPEC );
72
73
// create some data
@@ -85,7 +86,7 @@ public void before() throws IOException {
85
86
dataFile2 = writeDataFile (records2 );
86
87
}
87
88
88
- @ After
89
+ @ AfterEach
89
90
public void after () {
90
91
catalog .dropTable (TableIdentifier .of ("default" , "test" ));
91
92
}
@@ -176,7 +177,7 @@ public void testDataFileRewrite() throws IOException {
176
177
reader .close ();
177
178
}
178
179
179
- Assert . assertEquals ("Should have no rows" , 0 , rows . size () );
180
+ assertThat ( rows ). as ("Should have no rows" ). isEmpty ( );
180
181
}
181
182
182
183
@ Test
@@ -254,6 +255,9 @@ private Object[] toJava(InternalRow row) {
254
255
private DataFile writeDataFile (List <Record > records ) throws IOException {
255
256
// records all use IDs that are in bucket id_bucket=0
256
257
return FileHelpers .writeDataFile (
257
- table , Files .localOutput (temp .newFile ()), TestHelpers .Row .of (0 ), records );
258
+ table ,
259
+ Files .localOutput (File .createTempFile ("junit" , null , temp .toFile ())),
260
+ TestHelpers .Row .of (0 ),
261
+ records );
258
262
}
259
263
}
0 commit comments