[HUDI-3348] Add UT to verify HoodieRealtimeFileSplit serde (#4951)
This commit is contained in:
@@ -18,11 +18,12 @@
|
|||||||
|
|
||||||
package org.apache.hudi.hadoop.realtime;
|
package org.apache.hudi.hadoop.realtime;
|
||||||
|
|
||||||
|
import org.apache.hudi.common.model.HoodieLogFile;
|
||||||
|
import org.apache.hudi.common.util.Option;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
import org.apache.hadoop.mapred.FileSplit;
|
import org.apache.hadoop.mapred.FileSplit;
|
||||||
import org.apache.hudi.common.model.HoodieLogFile;
|
|
||||||
import org.apache.hudi.common.util.Option;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
@@ -33,7 +34,11 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
|||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -156,4 +161,18 @@ public class TestHoodieRealtimeFileSplit {
|
|||||||
assertEquals(deltaLogPaths, read.getDeltaLogPaths());
|
assertEquals(deltaLogPaths, read.getDeltaLogPaths());
|
||||||
assertEquals(split.toString(), read.toString());
|
assertEquals(split.toString(), read.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSerDe(@TempDir java.nio.file.Path tempDir) throws IOException {
|
||||||
|
final HoodieRealtimeFileSplit original = split;
|
||||||
|
java.nio.file.Path tempFilePath = tempDir.resolve("tmp.txt");
|
||||||
|
try (DataOutputStream out = new DataOutputStream(new FileOutputStream(tempFilePath.toFile()))) {
|
||||||
|
original.write(out);
|
||||||
|
}
|
||||||
|
HoodieRealtimeFileSplit deserialized = new HoodieRealtimeFileSplit();
|
||||||
|
try (DataInputStream in = new DataInputStream(new FileInputStream(tempFilePath.toFile()))) {
|
||||||
|
deserialized.readFields(in);
|
||||||
|
}
|
||||||
|
assertEquals(original.toString(), deserialized.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user