The following issues were found
src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain_EishayDecode_WriteAsArray.java
18 issues
Line: 32
// ParserConfig.getGlobalInstance().putDeserializer(MediaContent.class, new MediaContentDeserializer());
System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
System.out.println(arguments);
String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
System.out.println(text);
Reported by PMD.
Line: 34
System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
System.out.println(arguments);
String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
System.out.println(text);
for (int i = 0; i < 10; ++i) {
Reported by PMD.
Line: 37
System.out.println(arguments);
String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
System.out.println(text);
for (int i = 0; i < 10; ++i) {
perf(text);
}
}
Reported by PMD.
Line: 59
long ygct = TestUtils.getYoungGCTime() - startYGCTime;
long fgc = TestUtils.getFullGC() - startFGC;
System.out.println("decode\t" + millis + ", ygc " + ygc + ", ygct " + ygct + ", fgc " + fgc);
return millis;
}
static void decode(String text) {
MediaContent content = JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
Reported by PMD.
Line: 22
import data.media.writeAsArray.MediaContentSerializer;
import data.media.writeAsArray.MediaSerializer;
public class BenchmarkMain_EishayDecode_WriteAsArray {
public static void main(String[] args) throws Exception {
// SerializeConfig config = SerializeConfig.getGlobalInstance();
// config.put(MediaContent.class, new MediaContentSerializer());
// config.put(Media.class, new MediaSerializer());
Reported by PMD.
Line: 24
public class BenchmarkMain_EishayDecode_WriteAsArray {
public static void main(String[] args) throws Exception {
// SerializeConfig config = SerializeConfig.getGlobalInstance();
// config.put(MediaContent.class, new MediaContentSerializer());
// config.put(Media.class, new MediaSerializer());
// config.put(Image.class, new ImageSerializer());
Reported by PMD.
Line: 33
// ParserConfig.getGlobalInstance().putDeserializer(MediaContent.class, new MediaContentDeserializer());
System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
System.out.println(arguments);
String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
System.out.println(text);
Reported by PMD.
Line: 36
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
System.out.println(arguments);
String text = JSON.toJSONString(EishayDecodeBytes.instance.getContent(), SerializerFeature.BeanToArray);
System.out.println(text);
for (int i = 0; i < 10; ++i) {
perf(text);
}
Reported by PMD.
Line: 64
}
static void decode(String text) {
MediaContent content = JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
// JSON.parseObject(text);
}
}
Reported by PMD.
Line: 8
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.json.test.TestUtils;
import com.alibaba.json.test.benchmark.decode.EishayDecodeBytes;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_8.java
18 issues
Line: 13
public class JSONPath_8 extends TestCase {
public void test_path() throws Exception {
Model m = new Model();
m.f0 = 101;
m.f1 = 102;
JSONPath.remove(m, "$.f0");
Reported by PMD.
Line: 13
public class JSONPath_8 extends TestCase {
public void test_path() throws Exception {
Model m = new Model();
m.f0 = 101;
m.f1 = 102;
JSONPath.remove(m, "$.f0");
Reported by PMD.
Line: 19
m.f1 = 102;
JSONPath.remove(m, "$.f0");
assertNull(m.f0);
JSONPath.remove(m, "$.f1");
assertNull(m.f1);
Reported by PMD.
Line: 22
assertNull(m.f0);
JSONPath.remove(m, "$.f1");
assertNull(m.f1);
JSONPath.remove(m, "$.f2");
JSONPath.eval(m, "$.f2");
Reported by PMD.
Line: 30
JSONPath.eval(m, "$.f2");
}
public void test_error() throws Exception {
Exception error = null;
Model m = new Model();
m.f0 = 101;
m.f1 = 102;
Reported by PMD.
Line: 42
} catch (JSONPathException ex) {
error = ex;
}
assertNotNull(error);
}
public void test_error_1() throws Exception {
Exception error = null;
Reported by PMD.
Line: 45
assertNotNull(error);
}
public void test_error_1() throws Exception {
Exception error = null;
Model m = new Model();
m.f0 = 101;
m.f1 = 102;
Reported by PMD.
Line: 57
} catch (JSONPathException ex) {
error = ex;
}
assertNotNull(error);
}
public void test_paths() throws Exception {
Model m = new Model();
m.f0 = 101;
Reported by PMD.
Line: 60
assertNotNull(error);
}
public void test_paths() throws Exception {
Model m = new Model();
m.f0 = 101;
m.f1 = 102;
Exception error = null;
Reported by PMD.
Line: 67
Exception error = null;
try {
Map<String, Object> paths = JSONPath.paths(m);
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest.java
18 issues
Line: 18
public class NameFilterTest extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 22
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 22
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 33
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 42
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 46
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 46
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 57
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 67
Assert.assertEquals("{\"ID\":0}", text);
}
public static void test_toJSONString() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 71
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/StringBuilderFieldTest.java
18 issues
Line: 14
public class StringBuilderFieldTest extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 28
V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
Reported by PMD.
Line: 31
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 42
Assert.assertEquals("{\"value\":\"\"}", text);
}
public void test_deserialize_1() throws Exception {
String json = "{\"value\":\"\"}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
Reported by PMD.
Line: 46
String json = "{\"value\":\"\"}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
Reported by PMD.
Line: 47
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
Reported by PMD.
Line: 47
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
Reported by PMD.
Line: 50
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNull(vo.getValue());
}
Reported by PMD.
Line: 54
String json = "{\"value\":null}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNull(vo.getValue());
}
public void test_deserialize_3() throws Exception {
String json = "{\"value\":\"true\"}";
Reported by PMD.
Line: 57
Assert.assertNull(vo.getValue());
}
public void test_deserialize_3() throws Exception {
String json = "{\"value\":\"true\"}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("true", vo.getValue().toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTimeTest.java
18 issues
Line: 44
VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);
String text2 = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
System.out.println(text2);//{"date":"2017-11-22 15:09:51"}
VO vo2 = JSON.parseObject(text2, VO.class);
String text3 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
System.out.println(text3);//{"date":"2017-11-22T15:09:51"}
VO vo3 = JSON.parseObject(text3, VO.class);
Reported by PMD.
Line: 48
VO vo2 = JSON.parseObject(text2, VO.class);
String text3 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
System.out.println(text3);//{"date":"2017-11-22T15:09:51"}
VO vo3 = JSON.parseObject(text3, VO.class);
String text4 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat, SerializerFeature.WriteDateUseDateFormat);
System.out.println(text4);//{"date":"2017-11-22T15:09:51"}
VO vo4 = JSON.parseObject(text4, VO.class);
Reported by PMD.
Line: 52
VO vo3 = JSON.parseObject(text3, VO.class);
String text4 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat, SerializerFeature.WriteDateUseDateFormat);
System.out.println(text4);//{"date":"2017-11-22T15:09:51"}
VO vo4 = JSON.parseObject(text4, VO.class);
}
public void test_for_issue_1() throws Exception {
String text = "{\"date\":\"2018-08-03 22:38:33.145\"}";
Reported by PMD.
Line: 14
public class LocalDateTimeTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setDate(LocalDateTime.now().minusNanos(10L));
String text = JSON.toJSONString(vo);
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setDate(LocalDateTime.now().minusNanos(10L));
String text = JSON.toJSONString(vo);
VO vo1 = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 22
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(JSON.toJSONString(vo.getDate()), JSON.toJSONString(vo1.getDate()));
}
/**
* 方法描述: 测试LocalDateTime 转化时间戳等 操作
* 问题点1、 LocalDateTime 进来的值无法确定其时区,所以此处统一按着系统时区走。
Reported by PMD.
Line: 37
* 4)如设置WriteDateUseDateFormat、UseISO8601DateFormat 同时设置,则按ISO8601的标准 "yyyy-MM-dd'T'HH:mm:ss"进行格式化
* @author wuqiong 2017/11/22 15:08
*/
public void test_toJsonString_ofLong()throws Exception {
VO vo = new VO();
vo.setDate(LocalDateTime.now());
VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);
Reported by PMD.
Line: 37
* 4)如设置WriteDateUseDateFormat、UseISO8601DateFormat 同时设置,则按ISO8601的标准 "yyyy-MM-dd'T'HH:mm:ss"进行格式化
* @author wuqiong 2017/11/22 15:08
*/
public void test_toJsonString_ofLong()throws Exception {
VO vo = new VO();
vo.setDate(LocalDateTime.now());
VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);
Reported by PMD.
Line: 41
VO vo = new VO();
vo.setDate(LocalDateTime.now());
VO vo1 = JSON.parseObject("{\"date\":1511334591189}", VO.class);
String text2 = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
System.out.println(text2);//{"date":"2017-11-22 15:09:51"}
VO vo2 = JSON.parseObject(text2, VO.class);
Reported by PMD.
Line: 45
String text2 = JSON.toJSONString(vo, SerializerFeature.WriteDateUseDateFormat);
System.out.println(text2);//{"date":"2017-11-22 15:09:51"}
VO vo2 = JSON.parseObject(text2, VO.class);
String text3 = JSON.toJSONString(vo, SerializerFeature.UseISO8601DateFormat);
System.out.println(text3);//{"date":"2017-11-22T15:09:51"}
VO vo3 = JSON.parseObject(text3, VO.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/StringBufferFieldTest.java
18 issues
Line: 14
public class StringBufferFieldTest extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 28
V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
Reported by PMD.
Line: 31
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 42
Assert.assertEquals("{\"value\":\"\"}", text);
}
public void test_deserialize_1() throws Exception {
String json = "{\"value\":\"\"}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
Reported by PMD.
Line: 46
String json = "{\"value\":\"\"}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
Reported by PMD.
Line: 47
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
Reported by PMD.
Line: 47
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
Reported by PMD.
Line: 50
Assert.assertEquals("", vo.getValue().toString());
}
public void test_deserialize_2() throws Exception {
String json = "{\"value\":null}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNull(vo.getValue());
}
Reported by PMD.
Line: 54
String json = "{\"value\":null}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNull(vo.getValue());
}
public void test_deserialize_3() throws Exception {
String json = "{\"value\":\"true\"}";
Reported by PMD.
Line: 57
Assert.assertNull(vo.getValue());
}
public void test_deserialize_3() throws Exception {
String json = "{\"value\":\"true\"}";
V0 vo = JSON.parseObject(json, V0.class);
Assert.assertNotNull(vo.getValue());
Assert.assertEquals("true", vo.getValue().toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jsonpatch/JSONPatchTest_0.java
18 issues
Line: 8
import junit.framework.TestCase;
public class JSONPatchTest_0 extends TestCase {
public void test_for_multi_0() throws Exception {
String original = "{\n" +
" \"baz\": \"qux\",\n" +
" \"foo\": \"bar\"\n" +
"}";
Reported by PMD.
Line: 21
"]";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"baz\":\"boo\",\"hello\":[\"world\"]}", result);
}
public void test_for_add_1() throws Exception {
String original = "{}";
Reported by PMD.
Line: 24
assertEquals("{\"baz\":\"boo\",\"hello\":[\"world\"]}", result);
}
public void test_for_add_1() throws Exception {
String original = "{}";
String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
Line: 30
String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
}
public void test_for_remove_0() throws Exception {
String original = "{}";
Reported by PMD.
Line: 30
String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
}
public void test_for_remove_0() throws Exception {
String original = "{}";
Reported by PMD.
Line: 33
assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
}
public void test_for_remove_0() throws Exception {
String original = "{}";
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
Line: 39
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
assertEquals("{}", result);
}
public void test_for_remove_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
Reported by PMD.
Line: 42
assertEquals("{}", result);
}
public void test_for_remove_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
Line: 48
String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";
String result = JSONPatch.apply(original, patch);
assertEquals("{\"a\":{\"b\":{}}}", result);
}
public void test_for_replace_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
Reported by PMD.
Line: 51
assertEquals("{\"a\":{\"b\":{}}}", result);
}
public void test_for_replace_1() throws Exception {
String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";
String patch = "{ \"op\": \"replace\", \"path\": \"/a/b/c\", \"value\": 42 }";
String result = JSONPatch.apply(original, patch);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReaderTest_5.java
17 issues
Line: 16
import java.util.Map;
public class JSONReaderTest_5 extends TestCase {
public void test_read() throws Exception {
final int COUNT = 1000 * 10;
StringBuilder buf = new StringBuilder();
buf.append('[');
for (int i = 0; i < COUNT; ++i) {
if (i != 0) {
Reported by PMD.
Line: 32
JSONReader reader = new JSONReader(new StringReader(buf.toString()));
reader.startArray();
Map map = new HashMap();
int count = 0;
for (;;) {
if (reader.hasNext()) {
reader.startObject();
String key = reader.readString();
Reported by PMD.
Line: 37
for (;;) {
if (reader.hasNext()) {
reader.startObject();
String key = reader.readString();
Long value = reader.readLong();
reader.endObject();
count++;
} else {
break;
Reported by PMD.
Line: 38
if (reader.hasNext()) {
reader.startObject();
String key = reader.readString();
Long value = reader.readLong();
reader.endObject();
count++;
} else {
break;
}
Reported by PMD.
Line: 45
break;
}
}
assertEquals(COUNT, count);
reader.endArray();
reader.close();
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.parser.stream;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONReader;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.InputStream;
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.parser.stream;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONReader;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.InputStream;
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONReader;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.HashMap;
Reported by PMD.
Line: 9
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
Reported by PMD.
Line: 10
import org.junit.Assert;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
public class JSONReaderTest_5 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_BrowserSecure_4_script.java
17 issues
Line: 14
public class SerializeWriterTest_BrowserSecure_4_script extends TestCase {
public void test_0() throws Exception {
JSONObject object = new JSONObject();
object.put("value", "<script>alert(1);</script>");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
Reported by PMD.
Line: 14
public class SerializeWriterTest_BrowserSecure_4_script extends TestCase {
public void test_0() throws Exception {
JSONObject object = new JSONObject();
object.put("value", "<script>alert(1);</script>");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
Reported by PMD.
Line: 19
object.put("value", "<script>alert(1);</script>");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
Reported by PMD.
Line: 21
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
Reported by PMD.
Line: 21
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
Reported by PMD.
Line: 24
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
}
public void test_2() throws Exception {
Reported by PMD.
Line: 26
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
}
public void test_2() throws Exception {
String text = JSON.toJSONString("<script>", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003Cscript\\u003E\"", text);
Reported by PMD.
Line: 29
assertEquals("\"\\u003C\"", text);
}
public void test_2() throws Exception {
String text = JSON.toJSONString("<script>", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003Cscript\\u003E\"", text);
}
public void test_3() throws Exception {
Reported by PMD.
Line: 31
public void test_2() throws Exception {
String text = JSON.toJSONString("<script>", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003Cscript\\u003E\"", text);
}
public void test_3() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 500; i++) {
Reported by PMD.
Line: 34
assertEquals("\"\\u003Cscript\\u003E\"", text);
}
public void test_3() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 500; i++) {
buf.append("<script>");
}
Reported by PMD.
src/test/java/com/alibaba/json/test/Issue1407.java
17 issues
Line: 28
// synchronized(map) {
map.put(kk, kk);
System.out.println("\tput_a " + kk);
// }
Object val = map.get(kk);
if(val == null) {
System.err.println("err_a : " + kk);
}
Reported by PMD.
Line: 32
// }
Object val = map.get(kk);
if(val == null) {
System.err.println("err_a : " + kk);
}
}
}
}.start();
Reported by PMD.
Line: 49
}
map.put(kk, kk);
System.out.println("\tput_b " + kk);
// }
Object val = map.get(kk);
if(val == null) {
System.err.println("err_b : " + kk);
}
Reported by PMD.
Line: 53
// }
Object val = map.get(kk);
if(val == null) {
System.err.println("err_b : " + kk);
}
}
}
}.start();
Reported by PMD.
Line: 11
/**
* Created by wenshao on 14/08/2017.
*/
public class Issue1407 extends TestCase {
public void test_for_issue() throws Exception {
final String key = "k";
final IdentityHashMap map = new IdentityHashMap(2);
final Random ran = new Random();
Reported by PMD.
Line: 11
/**
* Created by wenshao on 14/08/2017.
*/
public class Issue1407 extends TestCase {
public void test_for_issue() throws Exception {
final String key = "k";
final IdentityHashMap map = new IdentityHashMap(2);
final Random ran = new Random();
Reported by PMD.
Line: 12
* Created by wenshao on 14/08/2017.
*/
public class Issue1407 extends TestCase {
public void test_for_issue() throws Exception {
final String key = "k";
final IdentityHashMap map = new IdentityHashMap(2);
final Random ran = new Random();
new Thread() {
Reported by PMD.
Line: 12
* Created by wenshao on 14/08/2017.
*/
public class Issue1407 extends TestCase {
public void test_for_issue() throws Exception {
final String key = "k";
final IdentityHashMap map = new IdentityHashMap(2);
final Random ran = new Random();
new Thread() {
Reported by PMD.
Line: 13
*/
public class Issue1407 extends TestCase {
public void test_for_issue() throws Exception {
final String key = "k";
final IdentityHashMap map = new IdentityHashMap(2);
final Random ran = new Random();
new Thread() {
public void run() {
Reported by PMD.
Line: 13
*/
public class Issue1407 extends TestCase {
public void test_for_issue() throws Exception {
final String key = "k";
final IdentityHashMap map = new IdentityHashMap(2);
final Random ran = new Random();
new Thread() {
public void run() {
Reported by PMD.