This commit is contained in:
jianghang.loujh
2024-05-22 09:46:13 +08:00
parent 5ff6449620
commit aa05d8e2a0
8 changed files with 180 additions and 169 deletions

View File

@@ -1,5 +1,7 @@
package com.taobao.tddl.dbsync.binlog;
import java.nio.charset.Charset;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -9,8 +11,6 @@ import org.junit.rules.Timeout;
import com.taobao.tddl.dbsync.binlog.JsonConversion.Json_Value;
import com.taobao.tddl.dbsync.binlog.JsonConversion.Json_enum_type;
import java.nio.charset.Charset;
public class JsonConversion_Json_ValueTest {
@Rule
@@ -50,7 +50,6 @@ public class JsonConversion_Json_ValueTest {
// Act
thrown.expect(IllegalArgumentException.class);
JsonConversion.parse_value(type, buffer, len, charsetName);
// Method is not expected to return due to exception thrown
}
@@ -60,7 +59,10 @@ public class JsonConversion_Json_ValueTest {
// {"internal_uri_rewrite": {"(.*)(/[^/]+\\.(mp|MP)4)$": "$1/mp4$2"}}
String jsonData = "{\"internal_uri_rewrite\": {\"(.*)(/[^/]+\\\\.(mp|MP)4)$\": \"$1/mp4$2\"}}";
byte[] data = new byte[]{1, 0, 74, 0, 11, 0, 20, 0, 0, 31, 0, 105, 110, 116, 101, 114, 110, 97, 108, 95, 117, 114, 105, 95, 114, 101, 119, 114, 105, 116, 101, 1, 0, 43, 0, 11, 0, 23, 0, 12, 34, 0, 40, 46, 42, 41, 40, 47, 91, 94, 47, 93, 43, 92, 46, 40, 109, 112, 124, 77, 80, 41, 52, 41, 36, 8, 36, 49, 47, 109, 112, 52, 36, 50};
byte[] data = new byte[] { 1, 0, 74, 0, 11, 0, 20, 0, 0, 31, 0, 105, 110, 116, 101, 114, 110, 97, 108, 95, 117,
114, 105, 95, 114, 101, 119, 114, 105, 116, 101, 1, 0, 43, 0, 11, 0, 23, 0, 12, 34,
0, 40, 46, 42, 41, 40, 47, 91, 94, 47, 93, 43, 92, 46, 40, 109, 112, 124, 77, 80, 41,
52, 41, 36, 8, 36, 49, 47, 109, 112, 52, 36, 50 };
final LogBuffer buffer = new LogBuffer(data, 0, 74);
Charset charset = Charset.forName("UTF-8");
@@ -68,7 +70,6 @@ public class JsonConversion_Json_ValueTest {
StringBuilder builder = new StringBuilder();
jsonValue.toJsonString(builder, charset);
Assert.assertEquals(builder.toString(), jsonData);
Assert.assertEquals(jsonValue.key(0, charset), "internal_uri_rewrite");