The following issues were found
src/test/java/com/alibaba/json/bvt/parser/JSONReaderScannerTest_error4.java
4 issues
Line: 14
public class JSONReaderScannerTest_error4 extends TestCase {
public void test_e() throws Exception {
Exception error = null;
try {
StringBuilder buf = new StringBuilder();
buf.append("[{\"type\":\"");
for (int i = 0; i < 8180; ++i) {
Reported by PMD.
Line: 17
public void test_e() throws Exception {
Exception error = null;
try {
StringBuilder buf = new StringBuilder();
buf.append("[{\"type\":\"");
for (int i = 0; i < 8180; ++i) {
buf.append('A');
}
buf.append("\\t");
Reported by PMD.
Line: 26
JSONReader reader = new JSONReader(new MyReader(buf.toString()));
reader.readObject();
reader.close();
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 15
public class JSONReaderScannerTest_error4 extends TestCase {
public void test_e() throws Exception {
Exception error = null;
try {
StringBuilder buf = new StringBuilder();
buf.append("[{\"type\":\"");
for (int i = 0; i < 8180; ++i) {
buf.append('A');
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONReaderScannerTest_error5.java
4 issues
Line: 14
public class JSONReaderScannerTest_error5 extends TestCase {
public void test_e() throws Exception {
Exception error = null;
try {
StringBuilder buf = new StringBuilder();
buf.append("[{\"type\":\"");
for (int i = 0; i < 8180; ++i) {
Reported by PMD.
Line: 17
public void test_e() throws Exception {
Exception error = null;
try {
StringBuilder buf = new StringBuilder();
buf.append("[{\"type\":\"");
for (int i = 0; i < 8180; ++i) {
buf.append('A');
}
buf.append("\\t");
Reported by PMD.
Line: 26
JSONReader reader = new JSONReader(new MyReader(buf.toString()));
reader.readObject();
reader.close();
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 15
public class JSONReaderScannerTest_error5 extends TestCase {
public void test_e() throws Exception {
Exception error = null;
try {
StringBuilder buf = new StringBuilder();
buf.append("[{\"type\":\"");
for (int i = 0; i < 8180; ++i) {
buf.append('A');
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1121.java
4 issues
Line: 23
result.put("admin",userObject);
String json = JSON.toJSONString(result, true);
System.out.println(json);
JSONObject jsonObject2 = JSON.parseObject(json);
assertEquals(result, jsonObject2);
}
}
Reported by PMD.
Line: 11
* Created by wenshao on 01/04/2017.
*/
public class Issue1121 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject userObject = new JSONObject();
userObject.put("name","jack");
userObject.put("age",20);
JSONObject result = new JSONObject();
Reported by PMD.
Line: 17
userObject.put("age",20);
JSONObject result = new JSONObject();
result.put("host","127.0.0.1");
result.put("port",3306);
result.put("user",userObject);
result.put("admin",userObject);
String json = JSON.toJSONString(result, true);
Reported by PMD.
Line: 26
System.out.println(json);
JSONObject jsonObject2 = JSON.parseObject(json);
assertEquals(result, jsonObject2);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONReader_top.java
4 issues
Line: 16
public void test_int() throws Exception {
JSONReader reader = new JSONReader(new StringReader("123"));
Assert.assertEquals(new Integer(123), reader.readInteger());
reader.close();
}
public void test_long() throws Exception {
Reported by PMD.
Line: 24
public void test_long() throws Exception {
JSONReader reader = new JSONReader(new StringReader("123"));
Assert.assertEquals(new Long(123), reader.readLong());
reader.close();
}
}
Reported by PMD.
Line: 13
public class JSONReader_top extends TestCase {
public void test_int() throws Exception {
JSONReader reader = new JSONReader(new StringReader("123"));
Assert.assertEquals(new Integer(123), reader.readInteger());
reader.close();
Reported by PMD.
Line: 21
reader.close();
}
public void test_long() throws Exception {
JSONReader reader = new JSONReader(new StringReader("123"));
Assert.assertEquals(new Long(123), reader.readLong());
reader.close();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_ISO8601.java
4 issues
Line: 12
public class JSONScannerTest_ISO8601 extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals(false, new JSONScanner("1").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("3").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("3000-10-02").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("4000-10-02").scanISO8601DateIfMatch());
Reported by PMD.
Line: 12
public class JSONScannerTest_ISO8601 extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals(false, new JSONScanner("1").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("2").scanISO8601DateIfMatch());
Assert.assertEquals(false, new JSONScanner("3").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("3000-10-02").scanISO8601DateIfMatch());
Assert.assertEquals(true, new JSONScanner("4000-10-02").scanISO8601DateIfMatch());
Reported by PMD.
Line: 109
Assert.assertEquals(false, new JSONScanner("2000-02-10T00:00:00.00a").scanISO8601DateIfMatch());
}
public void test_2() throws Exception {
JSONScanner lexer = new JSONScanner("2000-02-10T00:00:00.000");
lexer.config(Feature.AllowISO8601DateFormat, true);
Assert.assertEquals(true, lexer.scanISO8601DateIfMatch());
Assert.assertEquals(JSONToken.LITERAL_ISO8601_DATE, lexer.token());
lexer.nextToken();
Reported by PMD.
Line: 118
Assert.assertEquals(JSONToken.EOF, lexer.token());
}
public void test_3() throws Exception {
JSONScanner lexer = new JSONScanner("2000-2");
lexer.config(Feature.AllowISO8601DateFormat, true);
lexer.nextToken();
Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
lexer.nextToken();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest__x.java
4 issues
Line: 10
public class JSONScannerTest__x extends TestCase {
public void test_x() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append("\"");
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
buf.append("\\x");
Reported by PMD.
Line: 12
public void test_x() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append("\"");
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
buf.append("\\x");
buf.append(Integer.toHexString(i));
buf.append(Integer.toHexString(j));
Reported by PMD.
Line: 20
buf.append(Integer.toHexString(j));
}
}
buf.append("\"");
String jsonString = (String) JSON.parse(buf.toString());
Assert.assertEquals(16 * 16, jsonString.length());
for (int i = 0; i < 16 * 16; ++i) {
char c = jsonString.charAt(i);
if ((int) c != i) {
Reported by PMD.
Line: 22
}
buf.append("\"");
String jsonString = (String) JSON.parse(buf.toString());
Assert.assertEquals(16 * 16, jsonString.length());
for (int i = 0; i < 16 * 16; ++i) {
char c = jsonString.charAt(i);
if ((int) c != i) {
Assert.fail();
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1000/Issue1095.java
4 issues
Line: 14
* Created by wenshao on 22/03/2017.
*/
public class Issue1095 extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"Grade\": 1, \"UpdateTime\": \"2017-03-22T11:41:17\"}";
JSONObject jsonObject = JSON.parseObject(text, Feature.AllowISO8601DateFormat);
assertEquals(Date.class, jsonObject.get("UpdateTime").getClass());
}
}
Reported by PMD.
Line: 17
public void test_for_issue() throws Exception {
String text = "{\"Grade\": 1, \"UpdateTime\": \"2017-03-22T11:41:17\"}";
JSONObject jsonObject = JSON.parseObject(text, Feature.AllowISO8601DateFormat);
assertEquals(Date.class, jsonObject.get("UpdateTime").getClass());
}
}
Reported by PMD.
Line: 17
public void test_for_issue() throws Exception {
String text = "{\"Grade\": 1, \"UpdateTime\": \"2017-03-22T11:41:17\"}";
JSONObject jsonObject = JSON.parseObject(text, Feature.AllowISO8601DateFormat);
assertEquals(Date.class, jsonObject.get("UpdateTime").getClass());
}
}
Reported by PMD.
Line: 17
public void test_for_issue() throws Exception {
String text = "{\"Grade\": 1, \"UpdateTime\": \"2017-03-22T11:41:17\"}";
JSONObject jsonObject = JSON.parseObject(text, Feature.AllowISO8601DateFormat);
assertEquals(Date.class, jsonObject.get("UpdateTime").getClass());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1000/Issue1083.java
4 issues
Line: 16
* Created by wenshao on 11/06/2017.
*/
public class Issue1083 extends TestCase {
public void test_for_issue() throws Exception {
Map map = new HashMap();
map.put("userId", 456);
String json = JSON.toJSONString(map, SerializerFeature.WriteNonStringValueAsString);
assertEquals("{\"userId\":\"456\"}", json);
}
Reported by PMD.
Line: 20
Map map = new HashMap();
map.put("userId", 456);
String json = JSON.toJSONString(map, SerializerFeature.WriteNonStringValueAsString);
assertEquals("{\"userId\":\"456\"}", json);
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_1000;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.util.HashMap;
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.Map;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/MaximumLevelTest.java
4 issues
Line: 8
import junit.framework.TestCase;
public class MaximumLevelTest extends TestCase {
public void test_for_maximum() throws Exception {
int[] chars = new int[] {0x5b, 0x7b};
for (int ch : chars) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1000; ++i) {
Reported by PMD.
Line: 12
int[] chars = new int[] {0x5b, 0x7b};
for (int ch : chars) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1000; ++i) {
sb.append((char) ch);
}
Exception error = null;
Reported by PMD.
Line: 24
error = ex;
}
assertNotNull(error);
}
}
}
Reported by PMD.
Line: 17
sb.append((char) ch);
}
Exception error = null;
try {
JSON.parseObject(sb.toString());
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/fullSer/ToJavaObjectTest.java
4 issues
Line: 11
* Created by wenshao on 04/02/2017.
*/
public class ToJavaObjectTest extends TestCase {
public void test_for_toJavaObject() throws Exception {
JSONObject obj = JSON.parseObject("{\"id\":123}");
Model model = obj.toJavaObject(Model.class);
assertEquals(123, model.id);
}
Reported by PMD.
Line: 13
public class ToJavaObjectTest extends TestCase {
public void test_for_toJavaObject() throws Exception {
JSONObject obj = JSON.parseObject("{\"id\":123}");
Model model = obj.toJavaObject(Model.class);
assertEquals(123, model.id);
}
public static class Model {
public int id;
Reported by PMD.
Line: 14
public void test_for_toJavaObject() throws Exception {
JSONObject obj = JSON.parseObject("{\"id\":123}");
Model model = obj.toJavaObject(Model.class);
assertEquals(123, model.id);
}
public static class Model {
public int id;
}
Reported by PMD.
Line: 18
}
public static class Model {
public int id;
}
}
Reported by PMD.