The following issues were found
src/test/java/com/alibaba/json/bvt/path/JSONPath_field_access_filter_like_simple.java
55 issues
Line: 12
import com.alibaba.fastjson.JSONPath;
public class JSONPath_field_access_filter_like_simple extends TestCase {
public void test_list_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name like 'ljw2083']");
List<Entity> entities = new ArrayList<Entity>();
Reported by PMD.
Line: 14
public class JSONPath_field_access_filter_like_simple extends TestCase {
public void test_list_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name like 'ljw2083']");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 18
JSONPath path = new JSONPath("$[name like 'ljw2083']");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Reported by PMD.
Line: 19
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, null));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Reported by PMD.
Line: 24
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name not like 'ljw2083']");
Reported by PMD.
Line: 25
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name not like 'ljw2083']");
Reported by PMD.
Line: 28
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_like_extract() throws Exception {
JSONPath path = new JSONPath("$[name not like 'ljw2083']");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 34
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Reported by PMD.
Line: 38
entities.add(new Entity(null, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
Reported by PMD.
Line: 39
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
public void test_list_like_left_match() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/spring/mock/testcase/FastJsonViewTest.java
54 issues
Line: 34
public class FastJsonViewTest {
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setup() {
Reported by PMD.
Line: 36
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac) //
.addFilter(new CharacterEncodingFilter("UTF-8", true)) // 设置服务器端返回的字符集为:UTF-8
Reported by PMD.
Line: 41
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac) //
.addFilter(new CharacterEncodingFilter("UTF-8", true)) // 设置服务器端返回的字符集为:UTF-8
.build();
}
@Test
public void isInjectComponent() {
Reported by PMD.
Line: 46
}
@Test
public void isInjectComponent() {
wac.getBean(FastJsonViewResponseBodyAdvice.class);
}
/**
* 只包括简单属性的对象,单独使用include属性
Reported by PMD.
Line: 54
* 只包括简单属性的对象,单独使用include属性
*/
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status
().isOk()).andDo(print()
).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
Reported by PMD.
Line: 55
*/
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status
().isOk()).andDo(print()
).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
}
Reported by PMD.
Line: 55
*/
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status
().isOk()).andDo(print()
).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
}
Reported by PMD.
Line: 55
*/
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status
().isOk()).andDo(print()
).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
}
Reported by PMD.
Line: 56
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status
().isOk()).andDo(print()
).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
}
Reported by PMD.
Line: 56
@Test
public void test1() throws Exception {
mockMvc.perform(
(post("/fastjsonview/test1").characterEncoding("UTF-8")
.contentType(MediaType.APPLICATION_JSON))).andExpect(status
().isOk()).andDo(print()
).andExpect(content().string("{\"id\":100,\"name\":\"测试\"}"));
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/MapSerializer.java
54 issues
Line: 29
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class MapSerializer extends SerializeFilterable implements ObjectSerializer {
public static MapSerializer instance = new MapSerializer();
private static final int NON_STRINGKEY_AS_STRING = SerializerFeature.of(
new SerializerFeature[] {
Reported by PMD.
Line: 29
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class MapSerializer extends SerializeFilterable implements ObjectSerializer {
public static MapSerializer instance = new MapSerializer();
private static final int NON_STRINGKEY_AS_STRING = SerializerFeature.of(
new SerializerFeature[] {
Reported by PMD.
Line: 29
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class MapSerializer extends SerializeFilterable implements ObjectSerializer {
public static MapSerializer instance = new MapSerializer();
private static final int NON_STRINGKEY_AS_STRING = SerializerFeature.of(
new SerializerFeature[] {
Reported by PMD.
Line: 48
}
@SuppressWarnings({ "rawtypes"})
public void write(JSONSerializer serializer
, Object object
, Object fieldName
, Type fieldType
, int features //
, boolean unwrapped) throws IOException {
Reported by PMD.
Line: 48
}
@SuppressWarnings({ "rawtypes"})
public void write(JSONSerializer serializer
, Object object
, Object fieldName
, Type fieldType
, int features //
, boolean unwrapped) throws IOException {
Reported by PMD.
Line: 48
}
@SuppressWarnings({ "rawtypes"})
public void write(JSONSerializer serializer
, Object object
, Object fieldName
, Type fieldType
, int features //
, boolean unwrapped) throws IOException {
Reported by PMD.
Line: 48
}
@SuppressWarnings({ "rawtypes"})
public void write(JSONSerializer serializer
, Object object
, Object fieldName
, Type fieldType
, int features //
, boolean unwrapped) throws IOException {
Reported by PMD.
Line: 48
}
@SuppressWarnings({ "rawtypes"})
public void write(JSONSerializer serializer
, Object object
, Object fieldName
, Type fieldType
, int features //
, boolean unwrapped) throws IOException {
Reported by PMD.
Line: 48
}
@SuppressWarnings({ "rawtypes"})
public void write(JSONSerializer serializer
, Object object
, Object fieldName
, Type fieldType
, int features //
, boolean unwrapped) throws IOException {
Reported by PMD.
Line: 48
}
@SuppressWarnings({ "rawtypes"})
public void write(JSONSerializer serializer
, Object object
, Object fieldName
, Type fieldType
, int features //
, boolean unwrapped) throws IOException {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/SqlTimestampTest.java
54 issues
Line: 29
12345678
);
System.out.println('"' + ts.toString() + '"');
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
Reported by PMD.
Line: 32
System.out.println('"' + ts.toString() + '"');
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
System.out.println(json2);
assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
}
Reported by PMD.
Line: 35
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
System.out.println(json2);
assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
}
public void test_date_1() throws Exception {
// 2020-04-11 03:10:19.516
Reported by PMD.
Line: 51
516000000
);
System.out.println('"' + ts.toString() + '"');
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
Reported by PMD.
Line: 54
System.out.println('"' + ts.toString() + '"');
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
System.out.println(json2);
assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
}
Reported by PMD.
Line: 57
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
System.out.println(json2);
assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
}
// 1997-03-17 15:53:01.01
public void test_date_2() throws Exception {
Reported by PMD.
Line: 74
10000000
);
System.out.println('"' + ts.toString() + '"');
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
Reported by PMD.
Line: 77
System.out.println('"' + ts.toString() + '"');
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
System.out.println(json2);
assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
}
Reported by PMD.
Line: 80
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
System.out.println(json2);
assertEquals('"' + ts.toString() + '"', '"' + ts2.toString() + '"');
}
public void test_date_999999999() throws Exception {
// 2020-04-11 03:10:19.516
Reported by PMD.
Line: 96
999999999
);
System.out.println('"' + ts.toString() + '"');
String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
System.out.println(json);
Timestamp ts2 = JSON.parseObject(json, Timestamp.class);
String json2 = JSON.toJSONString(ts2, SerializerFeature.UseISO8601DateFormat);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/BigStringFieldTest_private.java
54 issues
Line: 16
import junit.framework.TestCase;
public class BigStringFieldTest_private extends TestCase {
public void test_bigFieldString() throws Exception {
Model model = new Model();
model.f0 = random(1024);
model.f1 = random(1024);
model.f2 = random(1024);
model.f3 = random(1024);
Reported by PMD.
Line: 16
import junit.framework.TestCase;
public class BigStringFieldTest_private extends TestCase {
public void test_bigFieldString() throws Exception {
Model model = new Model();
model.f0 = random(1024);
model.f1 = random(1024);
model.f2 = random(1024);
model.f3 = random(1024);
Reported by PMD.
Line: 26
String text = JSON.toJSONString(model);
Model model2 = JSON.parseObject(text, Model.class);
assertEquals(model2.f0, model.f0);
assertEquals(model2.f1, model.f1);
assertEquals(model2.f2, model.f2);
assertEquals(model2.f3, model.f3);
assertEquals(model2.f4, model.f4);
}
Reported by PMD.
Line: 27
String text = JSON.toJSONString(model);
Model model2 = JSON.parseObject(text, Model.class);
assertEquals(model2.f0, model.f0);
assertEquals(model2.f1, model.f1);
assertEquals(model2.f2, model.f2);
assertEquals(model2.f3, model.f3);
assertEquals(model2.f4, model.f4);
}
Reported by PMD.
Line: 28
Model model2 = JSON.parseObject(text, Model.class);
assertEquals(model2.f0, model.f0);
assertEquals(model2.f1, model.f1);
assertEquals(model2.f2, model.f2);
assertEquals(model2.f3, model.f3);
assertEquals(model2.f4, model.f4);
}
public void test_list() throws Exception {
Reported by PMD.
Line: 29
assertEquals(model2.f0, model.f0);
assertEquals(model2.f1, model.f1);
assertEquals(model2.f2, model.f2);
assertEquals(model2.f3, model.f3);
assertEquals(model2.f4, model.f4);
}
public void test_list() throws Exception {
List<Model> list = new ArrayList<Model>();
Reported by PMD.
Line: 30
assertEquals(model2.f1, model.f1);
assertEquals(model2.f2, model.f2);
assertEquals(model2.f3, model.f3);
assertEquals(model2.f4, model.f4);
}
public void test_list() throws Exception {
List<Model> list = new ArrayList<Model>();
for (int i = 0; i < 1000; ++i) {
Reported by PMD.
Line: 33
assertEquals(model2.f4, model.f4);
}
public void test_list() throws Exception {
List<Model> list = new ArrayList<Model>();
for (int i = 0; i < 1000; ++i) {
Model model = new Model();
model.f0 = random(64);
model.f1 = random(64);
Reported by PMD.
Line: 33
assertEquals(model2.f4, model.f4);
}
public void test_list() throws Exception {
List<Model> list = new ArrayList<Model>();
for (int i = 0; i < 1000; ++i) {
Model model = new Model();
model.f0 = random(64);
model.f1 = random(64);
Reported by PMD.
Line: 36
public void test_list() throws Exception {
List<Model> list = new ArrayList<Model>();
for (int i = 0; i < 1000; ++i) {
Model model = new Model();
model.f0 = random(64);
model.f1 = random(64);
model.f2 = random(64);
model.f3 = random(64);
model.f4 = random(64);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/LexerTest.java
52 issues
Line: 29
import com.alibaba.fastjson.parser.JSONScanner;
import com.alibaba.fastjson.parser.JSONToken;
public class LexerTest extends TestCase {
public void test_float() throws Exception {
String text = "123456789.0123";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken();
Reported by PMD.
Line: 31
public class LexerTest extends TestCase {
public void test_float() throws Exception {
String text = "123456789.0123";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken();
BigDecimal decimalValue = lexer.decimalValue();
Assert.assertEquals(new BigDecimal("123456789.0123"), decimalValue);
Reported by PMD.
Line: 40
}
public void test_string() throws Exception {
{
JSONScanner lexer = new JSONScanner("\"中国\"");
lexer.nextToken();
Assert.assertEquals("中国", lexer.stringVal());
}
Reported by PMD.
Line: 57
Assert.assertEquals("中国\tV5", lexer.stringVal());
}
StringBuilder buf = new StringBuilder();
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
Reported by PMD.
Line: 59
StringBuilder buf = new StringBuilder();
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 59
StringBuilder buf = new StringBuilder();
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 60
StringBuilder buf = new StringBuilder();
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 60
StringBuilder buf = new StringBuilder();
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
String text = buf.toString();
Reported by PMD.
Line: 61
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
Reported by PMD.
Line: 61
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
Reported by PMD.
src/test/java/com/alibaba/json/test/FNV32_CollisionTest_2.java
52 issues
Line: 29
long id_hash_64 = fnv_hash("name".toCharArray());
int id_hash_32 = (int) id_hash_64;
System.out.println("name : " + id_hash_32 + ", " + id_hash_64);
long v = 0;
long time = System.currentTimeMillis();
NumberFormat format = NumberFormat.getInstance();
Reported by PMD.
Line: 97
v++;
if (h6 == id_hash_64) {
int hash_32 = (int) h6;
System.out.println("collision : " + build(v, len) + ", hash64 : " + h6 + ", hash 32 " + hash_32);
break;
}
if (v != 0 && v % (1000 * 1000 * 1000) == 0) {
long now = System.currentTimeMillis();
Reported by PMD.
Line: 105
long now = System.currentTimeMillis();
long millis = now - time;
time = now;
System.out.println("millis : " + millis + ", " + format.format(v));
}
}
}
}
}
Reported by PMD.
Line: 116
}
System.out.println("end : " + len);
}
String build(long v, int len) {
char[] chars = new char[len];
Reported by PMD.
Line: 11
/**
* Created by wenshao on 08/01/2017.
*/
public class FNV32_CollisionTest_2 extends TestCase {
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
//char[] digLetters = "0123456789".toCharArray();
Random r = new Random();
int[] powers = new int[10];
Reported by PMD.
Line: 11
/**
* Created by wenshao on 08/01/2017.
*/
public class FNV32_CollisionTest_2 extends TestCase {
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
//char[] digLetters = "0123456789".toCharArray();
Random r = new Random();
int[] powers = new int[10];
Reported by PMD.
Line: 12
* Created by wenshao on 08/01/2017.
*/
public class FNV32_CollisionTest_2 extends TestCase {
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
//char[] digLetters = "0123456789".toCharArray();
Random r = new Random();
int[] powers = new int[10];
{
Reported by PMD.
Line: 15
char[] digLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".toCharArray();
//char[] digLetters = "0123456789".toCharArray();
Random r = new Random();
int[] powers = new int[10];
{
for (int i = 0; i < powers.length; ++i) {
powers[i] = (int) Math.pow(digLetters.length, i);
}
Reported by PMD.
Line: 17
Random r = new Random();
int[] powers = new int[10];
{
for (int i = 0; i < powers.length; ++i) {
powers[i] = (int) Math.pow(digLetters.length, i);
}
}
Reported by PMD.
Line: 24
}
public void test_fnv_hash_7() throws Exception {
int COUNT = 1000 * 1000 * 1000;
long id_hash_64 = fnv_hash("name".toCharArray());
int id_hash_32 = (int) id_hash_64;
System.out.println("name : " + id_hash_32 + ", " + id_hash_64);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2200/Issue2249.java
51 issues
Line: 9
import junit.framework.TestCase;
public class Issue2249 extends TestCase {
public void test_for_issue() throws Exception {
assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class Issue2249 extends TestCase {
public void test_for_issue() throws Exception {
assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
Reported by PMD.
Line: 10
public class Issue2249 extends TestCase {
public void test_for_issue() throws Exception {
assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
Reported by PMD.
Line: 11
public class Issue2249 extends TestCase {
public void test_for_issue() throws Exception {
assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
Reported by PMD.
Line: 12
public void test_for_issue() throws Exception {
assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
Reported by PMD.
Line: 13
assertSame(Type.Big, JSON.parseObject("\"big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
Reported by PMD.
Line: 14
assertSame(Type.Big, JSON.parseObject("\"Big\"", Type.class));
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));
Reported by PMD.
Line: 15
assertSame(Type.Big, JSON.parseObject("\"BIG\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));
assertNull(JSON.parseObject("\"\"", Type.class));
Reported by PMD.
Line: 16
assertSame(Type.Small, JSON.parseObject("\"Small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));
assertNull(JSON.parseObject("\"\"", Type.class));
}
Reported by PMD.
Line: 17
assertSame(Type.Small, JSON.parseObject("\"small\"", Type.class));
assertSame(Type.Small, JSON.parseObject("\"SMALL\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MEDIUM\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"Medium\"", Type.class));
assertSame(Type.Medium, JSON.parseObject("\"MediuM\"", Type.class));
assertNull(JSON.parseObject("\"\"", Type.class));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONTest.java
51 issues
Line: 31
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializeWriter;
public class JSONTest extends TestCase {
public void test_number() throws Exception {
Assert.assertEquals("3", JSON.parse("3").toString());
Assert.assertEquals("34", JSON.parse("34").toString());
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Reported by PMD.
Line: 33
public class JSONTest extends TestCase {
public void test_number() throws Exception {
Assert.assertEquals("3", JSON.parse("3").toString());
Assert.assertEquals("34", JSON.parse("34").toString());
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Reported by PMD.
Line: 34
public class JSONTest extends TestCase {
public void test_number() throws Exception {
Assert.assertEquals("3", JSON.parse("3").toString());
Assert.assertEquals("34", JSON.parse("34").toString());
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
Reported by PMD.
Line: 35
public void test_number() throws Exception {
Assert.assertEquals("3", JSON.parse("3").toString());
Assert.assertEquals("34", JSON.parse("34").toString());
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
Reported by PMD.
Line: 36
public void test_number() throws Exception {
Assert.assertEquals("3", JSON.parse("3").toString());
Assert.assertEquals("34", JSON.parse("34").toString());
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
}
Reported by PMD.
Line: 37
Assert.assertEquals("3", JSON.parse("3").toString());
Assert.assertEquals("34", JSON.parse("34").toString());
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
}
Reported by PMD.
Line: 38
Assert.assertEquals("34", JSON.parse("34").toString());
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
}
public void test_string() throws Exception {
Reported by PMD.
Line: 39
Assert.assertEquals("922337203685477580755", JSON.parse("922337203685477580755").toString());
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
}
public void test_string() throws Exception {
Assert.assertEquals("", JSON.parse("\"\"").toString());
Reported by PMD.
Line: 40
Assert.assertEquals("-34", JSON.parse("-34").toString());
Assert.assertEquals(new BigDecimal("9.223372036854776E18"), new BigDecimal(JSON.parse("9.223372036854776E18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E+18"), new BigDecimal(JSON.parse("9.223372036854776E+18").toString()));
Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
}
public void test_string() throws Exception {
Assert.assertEquals("", JSON.parse("\"\"").toString());
Assert.assertEquals("3", JSON.parse("\"3\"").toString());
Reported by PMD.
Line: 43
Assert.assertEquals(new BigDecimal("9.223372036854776E-18"), new BigDecimal(JSON.parse("9.223372036854776E-18").toString()));
}
public void test_string() throws Exception {
Assert.assertEquals("", JSON.parse("\"\"").toString());
Assert.assertEquals("3", JSON.parse("\"3\"").toString());
Assert.assertEquals("34", JSON.parse("\"34\"").toString());
Assert.assertEquals("3\\4", JSON.parse("\"3\\\\4\"").toString());
Assert.assertEquals("3\"4", JSON.parse("\"3\\\"4\"").toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_castToJavaBean.java
49 issues
Line: 97
TypeUtils.clearClassMapping();
}
public static void addClassMapping(String className, Class<?> clazz) throws Exception {
Field field = TypeUtils.class.getDeclaredField("mappings");
field.setAccessible(true);
field.get(null);
ConcurrentMap<String, Class<?>> mappings = (ConcurrentMap<String, Class<?>>) field.get(null);
Reported by PMD.
Line: 22
import junit.framework.TestCase;
public class TypeUtilsTest_castToJavaBean extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
}
public void test_castToJavaBean_StackTraceElement() throws Exception {
Reported by PMD.
Line: 23
import junit.framework.TestCase;
public class TypeUtilsTest_castToJavaBean extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
}
public void test_castToJavaBean_StackTraceElement() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Reported by PMD.
Line: 24
public class TypeUtilsTest_castToJavaBean extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
}
public void test_castToJavaBean_StackTraceElement() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("className", "java.lang.Object");
Reported by PMD.
Line: 27
ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.TypeUtilsTest_castToJavaBean.");
}
public void test_castToJavaBean_StackTraceElement() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("className", "java.lang.Object");
map.put("methodName", "hashCode");
StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
Assert.assertEquals("java.lang.Object", element.getClassName());
Reported by PMD.
Line: 29
public void test_castToJavaBean_StackTraceElement() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("className", "java.lang.Object");
map.put("methodName", "hashCode");
StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
Assert.assertEquals("java.lang.Object", element.getClassName());
Assert.assertEquals("hashCode", element.getMethodName());
Assert.assertEquals(null, element.getFileName());
Reported by PMD.
Line: 30
public void test_castToJavaBean_StackTraceElement() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("className", "java.lang.Object");
map.put("methodName", "hashCode");
StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
Assert.assertEquals("java.lang.Object", element.getClassName());
Assert.assertEquals("hashCode", element.getMethodName());
Assert.assertEquals(null, element.getFileName());
}
Reported by PMD.
Line: 32
map.put("className", "java.lang.Object");
map.put("methodName", "hashCode");
StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
Assert.assertEquals("java.lang.Object", element.getClassName());
Assert.assertEquals("hashCode", element.getMethodName());
Assert.assertEquals(null, element.getFileName());
}
public void test_castToJavaBean_StackTraceElement_1() throws Exception {
Reported by PMD.
Line: 33
map.put("methodName", "hashCode");
StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
Assert.assertEquals("java.lang.Object", element.getClassName());
Assert.assertEquals("hashCode", element.getMethodName());
Assert.assertEquals(null, element.getFileName());
}
public void test_castToJavaBean_StackTraceElement_1() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Reported by PMD.
Line: 34
StackTraceElement element = TypeUtils.castToJavaBean(map, StackTraceElement.class, null);
Assert.assertEquals("java.lang.Object", element.getClassName());
Assert.assertEquals("hashCode", element.getMethodName());
Assert.assertEquals(null, element.getFileName());
}
public void test_castToJavaBean_StackTraceElement_1() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("className", "java.lang.Object");
Reported by PMD.