1
0

[HUDI-4336] Fix records overwritten bug with binary primary key (#5996)

This commit is contained in:
luoyajun
2022-06-30 09:12:00 +08:00
committed by GitHub
parent 03a94d9ff5
commit 3948b8935a
2 changed files with 20 additions and 1 deletions

View File

@@ -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(""));