[HUDI-4336] Fix records overwritten bug with binary primary key (#5996)
This commit is contained in:
@@ -20,6 +20,7 @@ package org.apache.hudi.common.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -51,6 +52,20 @@ public class TestStringUtils {
|
||||
assertEquals("", StringUtils.nullToEmpty(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringObjToString() {
|
||||
assertNull(StringUtils.objToString(null));
|
||||
assertEquals("Test String", StringUtils.objToString("Test String"));
|
||||
|
||||
// assert byte buffer
|
||||
ByteBuffer byteBuffer1 = ByteBuffer.wrap("1234".getBytes());
|
||||
ByteBuffer byteBuffer2 = ByteBuffer.wrap("5678".getBytes());
|
||||
// assert equal because ByteBuffer has overwritten the toString to return a summary string
|
||||
assertEquals(byteBuffer1.toString(), byteBuffer2.toString());
|
||||
// assert not equal
|
||||
assertNotEquals(StringUtils.objToString(byteBuffer1), StringUtils.objToString(byteBuffer2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringEmptyToNull() {
|
||||
assertNull(StringUtils.emptyToNull(""));
|
||||
|
||||
Reference in New Issue
Block a user