The following issues were found
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1233.java
12 issues
Line: 17
* Created by wenshao on 30/05/2017.
*/
public class Issue1233 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 17
* Created by wenshao on 30/05/2017.
*/
public class Issue1233 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 23
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
if (jsonObject.get("type") instanceof String) {
areaType = (String) jsonObject.get("type");
} else {
return null;
}
if (Area.TYPE_SECTION.equals(areaType)) {
Reported by PMD.
Line: 28
} else {
return null;
}
if (Area.TYPE_SECTION.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
Reported by PMD.
Line: 30
}
if (Area.TYPE_SECTION.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
}
return null;
Reported by PMD.
Line: 32
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
}
return null;
}
Reported by PMD.
Line: 45
JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
Reported by PMD.
Line: 46
JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 47
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
Reported by PMD.
Line: 63
public String type;
public String templateId;
public String getName() {
return templateId;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1235.java
12 issues
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 16
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 17
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
Reported by PMD.
Line: 18
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 19
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 22
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 27
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
Reported by PMD.
Line: 28
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
public static class FloorV2 implements Area {
Reported by PMD.
Line: 29
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
public static class FloorV2 implements Area {
public String type;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/deny/InitJavaBeanDeserializerTest.java
12 issues
Line: 36
Exception error = null;
try {
Object obj = JSON.parseObject(text, Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
Reported by PMD.
Line: 14
* Created by wenshao on 28/01/2017.
*/
public class InitJavaBeanDeserializerTest extends TestCase {
ParserConfig config = new ParserConfig();
protected void setUp() throws Exception {
assertFalse(config.isAutoTypeSupport());
Properties properties = new Properties();
Reported by PMD.
Line: 16
public class InitJavaBeanDeserializerTest extends TestCase {
ParserConfig config = new ParserConfig();
protected void setUp() throws Exception {
assertFalse(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
// config.addAccept("com.alibaba.json.bvt.parser.deser.deny.DenyTest11.Model");
Reported by PMD.
Line: 17
ParserConfig config = new ParserConfig();
protected void setUp() throws Exception {
assertFalse(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
// config.addAccept("com.alibaba.json.bvt.parser.deser.deny.DenyTest11.Model");
// -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
Reported by PMD.
Line: 25
// -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
config.configFromPropety(properties);
assertFalse(config.isAutoTypeSupport());
}
public void test_desktop() throws Exception {
DenyTest11.Model model = new DenyTest11.Model();
model.a = new DenyTest11.B();
Reported by PMD.
Line: 28
assertFalse(config.isAutoTypeSupport());
}
public void test_desktop() throws Exception {
DenyTest11.Model model = new DenyTest11.Model();
model.a = new DenyTest11.B();
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.InitJavaBeanDeserializerTest$Model\"}";
Exception error = null;
Reported by PMD.
Line: 28
assertFalse(config.isAutoTypeSupport());
}
public void test_desktop() throws Exception {
DenyTest11.Model model = new DenyTest11.Model();
model.a = new DenyTest11.B();
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.InitJavaBeanDeserializerTest$Model\"}";
Exception error = null;
Reported by PMD.
Line: 36
Exception error = null;
try {
Object obj = JSON.parseObject(text, Object.class, config);
System.out.println(obj.getClass());
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
Reported by PMD.
Line: 40
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
config.initJavaBeanDeserializers(Model.class);
Object obj = JSON.parseObject(text, Object.class, config);
assertEquals(Model.class, obj.getClass());
Reported by PMD.
Line: 45
config.initJavaBeanDeserializers(Model.class);
Object obj = JSON.parseObject(text, Object.class, config);
assertEquals(Model.class, obj.getClass());
}
public static class Model {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3693.java
12 issues
Line: 16
public class Issue3693 extends TestCase {
public void test_for_issue() throws Exception {
Model<ModelProperties> model = new Model<ModelProperties>("hello 世界", new ModelProperties("红色", 66));
String json = JSON.toJSONString(model);
assertEquals("{\"name\":\"hello 世界\",\"properties\":\"{\\\"color\\\":\\\"红色\\\",\\\"size\\\":66}\"}", json);
Model<ModelProperties> deserializedModel = JSON.parseObject(json, new TypeReference<Model<ModelProperties>>() {
Reported by PMD.
Line: 16
public class Issue3693 extends TestCase {
public void test_for_issue() throws Exception {
Model<ModelProperties> model = new Model<ModelProperties>("hello 世界", new ModelProperties("红色", 66));
String json = JSON.toJSONString(model);
assertEquals("{\"name\":\"hello 世界\",\"properties\":\"{\\\"color\\\":\\\"红色\\\",\\\"size\\\":66}\"}", json);
Model<ModelProperties> deserializedModel = JSON.parseObject(json, new TypeReference<Model<ModelProperties>>() {
Reported by PMD.
Line: 19
public void test_for_issue() throws Exception {
Model<ModelProperties> model = new Model<ModelProperties>("hello 世界", new ModelProperties("红色", 66));
String json = JSON.toJSONString(model);
assertEquals("{\"name\":\"hello 世界\",\"properties\":\"{\\\"color\\\":\\\"红色\\\",\\\"size\\\":66}\"}", json);
Model<ModelProperties> deserializedModel = JSON.parseObject(json, new TypeReference<Model<ModelProperties>>() {
});
assertNotNull(deserializedModel);
assertEquals("hello 世界", deserializedModel.getName());
Reported by PMD.
Line: 23
Model<ModelProperties> deserializedModel = JSON.parseObject(json, new TypeReference<Model<ModelProperties>>() {
});
assertNotNull(deserializedModel);
assertEquals("hello 世界", deserializedModel.getName());
assertNotNull(deserializedModel.getProperties());
assertEquals("红色", deserializedModel.getProperties().getColor());
assertEquals(66, deserializedModel.getProperties().getSize());
}
Reported by PMD.
Line: 24
Model<ModelProperties> deserializedModel = JSON.parseObject(json, new TypeReference<Model<ModelProperties>>() {
});
assertNotNull(deserializedModel);
assertEquals("hello 世界", deserializedModel.getName());
assertNotNull(deserializedModel.getProperties());
assertEquals("红色", deserializedModel.getProperties().getColor());
assertEquals(66, deserializedModel.getProperties().getSize());
}
Reported by PMD.
Line: 25
});
assertNotNull(deserializedModel);
assertEquals("hello 世界", deserializedModel.getName());
assertNotNull(deserializedModel.getProperties());
assertEquals("红色", deserializedModel.getProperties().getColor());
assertEquals(66, deserializedModel.getProperties().getSize());
}
Reported by PMD.
Line: 26
assertNotNull(deserializedModel);
assertEquals("hello 世界", deserializedModel.getName());
assertNotNull(deserializedModel.getProperties());
assertEquals("红色", deserializedModel.getProperties().getColor());
assertEquals(66, deserializedModel.getProperties().getSize());
}
static class Model<T> {
Reported by PMD.
Line: 26
assertNotNull(deserializedModel);
assertEquals("hello 世界", deserializedModel.getName());
assertNotNull(deserializedModel.getProperties());
assertEquals("红色", deserializedModel.getProperties().getColor());
assertEquals(66, deserializedModel.getProperties().getSize());
}
static class Model<T> {
Reported by PMD.
Line: 27
assertEquals("hello 世界", deserializedModel.getName());
assertNotNull(deserializedModel.getProperties());
assertEquals("红色", deserializedModel.getProperties().getColor());
assertEquals(66, deserializedModel.getProperties().getSize());
}
static class Model<T> {
private String name;
Reported by PMD.
Line: 27
assertEquals("hello 世界", deserializedModel.getName());
assertNotNull(deserializedModel.getProperties());
assertEquals("红色", deserializedModel.getProperties().getColor());
assertEquals(66, deserializedModel.getProperties().getSize());
}
static class Model<T> {
private String name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_wangran1.java
12 issues
Line: 26
String text = JSON.toJSONString(entity);
System.out.println(text);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Reported by PMD.
Line: 13
public class Bug_for_wangran1 extends TestCase {
public void test_0() throws Exception {
Entity entity = new Entity();
entity.setId(11);
entity.setName("xx");
Reported by PMD.
Line: 22
Queue q = new Queue();
q.setId(55);
entity.getQueue().put(q.getId(), q);
String text = JSON.toJSONString(entity);
System.out.println(text);
Reported by PMD.
Line: 30
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
}
public static class Entity {
Reported by PMD.
Line: 31
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
}
public static class Entity {
Reported by PMD.
Line: 31
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
}
public static class Entity {
Reported by PMD.
Line: 32
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
}
public static class Entity {
private int id;
Reported by PMD.
Line: 32
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
}
public static class Entity {
private int id;
Reported by PMD.
Line: 32
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
}
public static class Entity {
private int id;
Reported by PMD.
Line: 32
Assert.assertNotNull(entity2.getQueue());
Assert.assertEquals(1, entity2.getQueue().size());
Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
}
public static class Entity {
private int id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1235_noasm.java
12 issues
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235_noasm extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235_noasm extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 16
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 17
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
Reported by PMD.
Line: 18
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 19
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 22
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 27
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
Reported by PMD.
Line: 28
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
private static class FloorV2 implements Area {
Reported by PMD.
Line: 29
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
private static class FloorV2 implements Area {
public String type;
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/BigDecimalCodec.java
12 issues
Line: 38
public final static BigDecimalCodec instance = new BigDecimalCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullNumberAsZero);
} else {
Reported by PMD.
Line: 45
out.writeNull(SerializerFeature.WriteNullNumberAsZero);
} else {
BigDecimal val = (BigDecimal) object;
int scale = val.scale();
String outText;
if (SerializerFeature.isEnabled(features, out.features, SerializerFeature.WriteBigDecimalAsPlain)
&& scale >= -100 && scale < 100) {
outText = val.toPlainString();
Reported by PMD.
Line: 50
String outText;
if (SerializerFeature.isEnabled(features, out.features, SerializerFeature.WriteBigDecimalAsPlain)
&& scale >= -100 && scale < 100) {
outText = val.toPlainString();
} else {
outText = val.toString();
}
if (scale == 0) {
Reported by PMD.
Line: 52
&& scale >= -100 && scale < 100) {
outText = val.toPlainString();
} else {
outText = val.toString();
}
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
Reported by PMD.
Line: 56
}
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
Reported by PMD.
Line: 56
}
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
Reported by PMD.
Line: 58
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
return;
}
Reported by PMD.
Line: 59
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
return;
}
}
Reported by PMD.
Line: 68
out.write(outText);
if (out.isEnabled(SerializerFeature.WriteClassName) && fieldType != BigDecimal.class && val.scale() == 0) {
out.write('.');
}
}
}
Reported by PMD.
Line: 78
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
try {
return (T) deserialze(parser);
} catch (Exception ex) {
throw new JSONException("parseDecimal error, field : " + fieldName, ex);
}
}
@SuppressWarnings("unchecked")
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TestExternal4.java
12 issues
Line: 37
{
String text = JSON.toJSONString(obj);
System.out.println(text);
}
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
Reported by PMD.
Line: 41
}
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
String clazzName = JSON.parse(text, confg).getClass().getName();
Assert.assertEquals(clazz.getName(), clazzName);
}
Reported by PMD.
Line: 20
import com.alibaba.fastjson.serializer.SerializerFeature;
public class TestExternal4 extends TestCase {
ParserConfig confg = ParserConfig.global;
protected void setUp() throws Exception {
confg.addAccept("external.VO2");
}
public void test_0() throws Exception {
Reported by PMD.
Line: 21
public class TestExternal4 extends TestCase {
ParserConfig confg = ParserConfig.global;
protected void setUp() throws Exception {
confg.addAccept("external.VO2");
}
public void test_0() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Reported by PMD.
Line: 25
confg.addAccept("external.VO2");
}
public void test_0() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class<?> clazz = classLoader.loadClass("external.VO2");
Method method = clazz.getMethod("setName", new Class[] { String.class });
Method methodSetValue = clazz.getMethod("setValue", new Class[] { Serializable.class });
Reported by PMD.
Line: 31
Method method = clazz.getMethod("setName", new Class[] { String.class });
Method methodSetValue = clazz.getMethod("setValue", new Class[] { Serializable.class });
Object obj = clazz.newInstance();
method.invoke(obj, "jobs");
methodSetValue.invoke(obj, obj);
{
String text = JSON.toJSONString(obj);
Reported by PMD.
Line: 43
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
String clazzName = JSON.parse(text, confg).getClass().getName();
Assert.assertEquals(clazz.getName(), clazzName);
}
public static class ExtClassLoader extends ClassLoader {
Reported by PMD.
Line: 43
String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
System.out.println(text);
JSON.parseObject(text, clazz, confg);
String clazzName = JSON.parse(text, confg).getClass().getName();
Assert.assertEquals(clazz.getName(), clazzName);
}
public static class ExtClassLoader extends ClassLoader {
Reported by PMD.
Line: 44
System.out.println(text);
JSON.parseObject(text, clazz, confg);
String clazzName = JSON.parse(text, confg).getClass().getName();
Assert.assertEquals(clazz.getName(), clazzName);
}
public static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException{
Reported by PMD.
Line: 54
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("external/VO2.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("external.VO2", bytes, 0, bytes.length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1764_bean_biginteger.java
11 issues
Line: 13
import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;
public class Issue1764_bean_biginteger extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(
new Model(9007199254741992L), BrowserCompatible));
assertEquals("{\"value\":\"-9007199254741992\"}"
Reported by PMD.
Line: 13
import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;
public class Issue1764_bean_biginteger extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(
new Model(9007199254741992L), BrowserCompatible));
assertEquals("{\"value\":\"-9007199254741992\"}"
Reported by PMD.
Line: 14
public class Issue1764_bean_biginteger extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(
new Model(9007199254741992L), BrowserCompatible));
assertEquals("{\"value\":\"-9007199254741992\"}"
, JSON.toJSONString(
Reported by PMD.
Line: 18
, JSON.toJSONString(
new Model(9007199254741992L), BrowserCompatible));
assertEquals("{\"value\":\"-9007199254741992\"}"
, JSON.toJSONString(
new Model(-9007199254741992L), BrowserCompatible));
assertEquals("{\"value\":9007199254740990}"
, JSON.toJSONString(
Reported by PMD.
Line: 22
, JSON.toJSONString(
new Model(-9007199254741992L), BrowserCompatible));
assertEquals("{\"value\":9007199254740990}"
, JSON.toJSONString(
new Model(9007199254740990L), BrowserCompatible));
assertEquals("{\"value\":-9007199254740990}"
, JSON.toJSONString(
Reported by PMD.
Line: 26
, JSON.toJSONString(
new Model(9007199254740990L), BrowserCompatible));
assertEquals("{\"value\":-9007199254740990}"
, JSON.toJSONString(
new Model(-9007199254740990L), BrowserCompatible));
assertEquals("{\"value\":100}"
, JSON.toJSONString(
Reported by PMD.
Line: 30
, JSON.toJSONString(
new Model(-9007199254740990L), BrowserCompatible));
assertEquals("{\"value\":100}"
, JSON.toJSONString(
new Model(100), BrowserCompatible));
assertEquals("{\"value\":-100}"
, JSON.toJSONString(
Reported by PMD.
Line: 34
, JSON.toJSONString(
new Model(100), BrowserCompatible));
assertEquals("{\"value\":-100}"
, JSON.toJSONString(
new Model(-100), BrowserCompatible));
}
Reported by PMD.
Line: 43
public static class Model {
public BigInteger value;
public Model() {
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_1700;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.math.BigInteger;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_colon.java
11 issues
Line: 17
*/
public class JSONScannerTest_colon extends TestCase {
public void test_0() throws Exception {
JSONScanner lexer = new JSONScanner(":true");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 23
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_1() throws Exception {
JSONScanner lexer = new JSONScanner(" : true");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 29
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_2() throws Exception {
JSONScanner lexer = new JSONScanner("\n:\ntrue");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 35
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_3() throws Exception {
JSONScanner lexer = new JSONScanner("\r:\rtrue");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 41
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_4() throws Exception {
JSONScanner lexer = new JSONScanner("\t:\ttrue");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 47
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_5() throws Exception {
JSONScanner lexer = new JSONScanner("\t:\ftrue");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 53
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_6() throws Exception {
JSONScanner lexer = new JSONScanner("\b:\btrue");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 59
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_f() throws Exception {
JSONScanner lexer = new JSONScanner("\f:\btrue");
lexer.nextTokenWithColon();
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
Reported by PMD.
Line: 65
Assert.assertEquals(JSONToken.TRUE, lexer.token());
}
public void test_7() throws Exception {
JSONException error = null;
try {
JSONScanner lexer = new JSONScanner("true");
lexer.nextTokenWithColon();
} catch (JSONException e) {
Reported by PMD.
Line: 76
Assert.assertNotNull(error);
}
public void test_8() throws Exception {
JSONScanner lexer = new JSONScanner("\b:\btrue");
lexer.nextToken();
Assert.assertEquals(JSONToken.COLON, lexer.token());
}
}
Reported by PMD.