The following issues were found
src/test/java/com/alibaba/json/test/jackson/JacksonInnerClassTest.java
5 issues
Line: 11
public class JacksonInnerClassTest extends TestCase {
public void test_0() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.readValue("{a:3}", Map.class);
}
Reported by PMD.
Line: 11
public class JacksonInnerClassTest extends TestCase {
public void test_0() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.readValue("{a:3}", Map.class);
}
Reported by PMD.
Line: 18
mapper.readValue("{a:3}", Map.class);
}
public void test_1() throws Exception {
Model model = new Model();
model.id = 1001;
ObjectMapper mapper = new ObjectMapper();
String text = mapper.writeValueAsString(model);
Reported by PMD.
Line: 18
mapper.readValue("{a:3}", Map.class);
}
public void test_1() throws Exception {
Model model = new Model();
model.id = 1001;
ObjectMapper mapper = new ObjectMapper();
String text = mapper.writeValueAsString(model);
Reported by PMD.
Line: 32
public Model() {
}
public int id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/test/DetectProhibitChar.java
5 issues
Line: 46
}
public DetectProhibitChar(char prohibits[]){
addProhibitChar(prohibits);
}
/**
* 增加一个跳越字符
*
Reported by PMD.
Line: 39
*/
public class DetectProhibitChar {
byte[] masks = new byte[1024 * 8];
public DetectProhibitChar(){
}
Reported by PMD.
Line: 45
}
public DetectProhibitChar(char prohibits[]){
addProhibitChar(prohibits);
}
/**
* 增加一个跳越字符
Reported by PMD.
Line: 73
}
}
public void addProhibitChar(char prohibits[]) {
if (prohibits != null) {
for (char c : prohibits) {
addProhibitChar(c);
}
}
Reported by PMD.
Line: 92
return (i != 0);
}
public boolean hasProhibitChar(char cs[]) {
if (cs != null) {
for (char c : cs) {
if (isProhibitChar(c)) {
return true;
}
Reported by PMD.
src/test/java/com/alibaba/json/test/DateTest.java
5 issues
Line: 27
long time = System.currentTimeMillis();
for (Codec codec : decoders) {
String text = codec.encode(new java.sql.Date(time));
System.out.println(codec.getName() + " : " + text);
// codec.decodeObject(text, java.sql.Date.class);
}
}
}
Reported by PMD.
Line: 16
public class DateTest extends TestCase {
public void test_0() throws Exception {
List<Codec> decoders = new ArrayList<Codec>();
decoders.add(new FastjsonCodec());
decoders.add(new JacksonCodec());
decoders.add(new SimpleJsonCodec());
// decoders.add(new JsonLibDecoderImpl());
Reported by PMD.
Line: 16
public class DateTest extends TestCase {
public void test_0() throws Exception {
List<Codec> decoders = new ArrayList<Codec>();
decoders.add(new FastjsonCodec());
decoders.add(new JacksonCodec());
decoders.add(new SimpleJsonCodec());
// decoders.add(new JsonLibDecoderImpl());
Reported by PMD.
Line: 26
long time = System.currentTimeMillis();
for (Codec codec : decoders) {
String text = codec.encode(new java.sql.Date(time));
System.out.println(codec.getName() + " : " + text);
// codec.decodeObject(text, java.sql.Date.class);
}
}
}
Reported by PMD.
Line: 24
// decoders.add(new JsonLibDecoderImpl());
decoders.add(new GsonCodec());
long time = System.currentTimeMillis();
for (Codec codec : decoders) {
String text = codec.encode(new java.sql.Date(time));
System.out.println(codec.getName() + " : " + text);
// codec.decodeObject(text, java.sql.Date.class);
}
Reported by PMD.
src/test/java/com/alibaba/json/demo/hibernate/data/Product.java
5 issues
Line: 28
private String productScale;
private String productVendor;
private String productDescription;
private short quantityInStock;
private double buyPrice;
private double msrp;
private Set<OrderDetail> orderDetails = new HashSet<OrderDetail>(0);
public Product() {
Reported by PMD.
Line: 118
}
@Column(name="quantityInStock", nullable=false)
public short getQuantityInStock() {
return this.quantityInStock;
}
public void setQuantityInStock(short quantityInStock) {
this.quantityInStock = quantityInStock;
Reported by PMD.
Line: 122
return this.quantityInStock;
}
public void setQuantityInStock(short quantityInStock) {
this.quantityInStock = quantityInStock;
}
@Column(name="buyPrice", nullable=false, precision=22, scale=0)
public double getBuyPrice() {
Reported by PMD.
Line: 19
@Table(name="Product"
,catalog="classicmodels"
)
public class Product implements java.io.Serializable {
private String productCode;
private String productName;
private String productLine;
Reported by PMD.
Line: 48
this.buyPrice = buyPrice;
this.msrp = msrp;
}
public Product(String productCode, String productName, String productLine, String productScale, String productVendor, String productDescription, short quantityInStock, double buyPrice, double msrp, Set<OrderDetail> orderDetails) {
this.productCode = productCode;
this.productName = productName;
this.productLine = productLine;
this.productScale = productScale;
this.productVendor = productVendor;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/FieldDeserializerTest3.java
5 issues
Line: 54
}
public void setValue(String value) {
throw new RuntimeException();
}
}
}
Reported by PMD.
Line: 13
public class FieldDeserializerTest3 extends TestCase {
public void test_error_1() throws Exception {
Exception error = null;
try {
String input = "{\"value\":null}";
int featureValues = 0;
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
Reported by PMD.
Line: 29
Assert.assertNotNull(error);
}
public void test_error_2() throws Exception {
Exception error = null;
try {
String input = "{,,\"value\":null}";
int featureValues = 0;
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
Reported by PMD.
Line: 14
public class FieldDeserializerTest3 extends TestCase {
public void test_error_1() throws Exception {
Exception error = null;
try {
String input = "{\"value\":null}";
int featureValues = 0;
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
featureValues);
Reported by PMD.
Line: 30
}
public void test_error_2() throws Exception {
Exception error = null;
try {
String input = "{,,\"value\":null}";
int featureValues = 0;
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
featureValues);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/str/StringTest_02.java
5 issues
Line: 14
public class StringTest_02 extends TestCase {
public void test_string() throws Exception {
char[] chars = new char[1024];
Arrays.fill(chars, '0');
StringBuilder buf = new StringBuilder();
buf.append("[\"");
for (int i = 0; i < 16; ++i) {
Reported by PMD.
Line: 21
buf.append("[\"");
for (int i = 0; i < 16; ++i) {
buf.append("\\\"");
buf.append(new String(chars));
}
buf.append("\"]");
String text = buf.toString();
JSONArray array = (JSONArray) JSON.parse(text);
Reported by PMD.
Line: 27
String text = buf.toString();
JSONArray array = (JSONArray) JSON.parse(text);
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 16, item.length());
for (int i = 0; i < 16; ++i) {
Reported by PMD.
Line: 29
JSONArray array = (JSONArray) JSON.parse(text);
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 16, item.length());
for (int i = 0; i < 16; ++i) {
Assert.assertTrue(item.charAt(i * 1025) == '\"');
for (int j = 0; j < 1024; ++j) {
Reported by PMD.
Line: 30
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 16, item.length());
for (int i = 0; i < 16; ++i) {
Assert.assertTrue(item.charAt(i * 1025) == '\"');
for (int j = 0; j < 1024; ++j) {
Assert.assertTrue(item.charAt(i * 1025 + j + 1) == '0');
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/stream/StreamWriterTest_writeArray2.java
5 issues
Line: 12
public class StreamWriterTest_writeArray2 extends TestCase {
public void test_0() throws Exception {
StringWriter out = new StringWriter();
SerializeWriter writer = new SerializeWriter(out, 10);
Assert.assertEquals(10, writer.getBufferLength());
Reported by PMD.
Line: 20
int blockSize = 21;
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(chars, 0, chars.length);
}
Reported by PMD.
Line: 29
writer.close();
String text = out.toString();
Assert.assertEquals(26 * blockSize, text.length());
for (int i = 0; i < 26; ++i) {
for (int j = 0; j < blockSize; ++j) {
Assert.assertEquals(text.charAt(i * blockSize + j), (char) ('a' + i));
}
Reported by PMD.
Line: 20
int blockSize = 21;
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(chars, 0, chars.length);
}
Reported by PMD.
Line: 22
for (char ch = 'a'; ch <= 'z'; ++ch) {
char[] chars = new char[blockSize];
for (int i = 0; i < blockSize; ++i) {
chars[i] = ch;
}
writer.write(chars, 0, chars.length);
}
writer.close();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_13.java
5 issues
Line: 18
public class SerializeWriterTest_13 extends TestCase {
public void test_default() throws Exception {
Assert.assertEquals("{\"\":\"\"}", //
JSON.toJSONStringZ(Collections.singletonMap("", ""), //
SerializeConfig.getGlobalInstance()));
}
Reported by PMD.
Line: 24
SerializeConfig.getGlobalInstance()));
}
public void test_single() throws Exception {
Assert.assertEquals("{'':''}", //
JSON.toJSONStringZ(Collections.singletonMap("", ""), //
SerializeConfig.getGlobalInstance(), SerializerFeature.UseSingleQuotes));
}
Reported by PMD.
Line: 30
SerializeConfig.getGlobalInstance(), SerializerFeature.UseSingleQuotes));
}
public void test_writer() throws Exception {
SerializeWriter out = new SerializeWriter(3);
try {
JSONSerializer serializer = new JSONSerializer(out);
Reported by PMD.
Line: 43
}
}
public void test_writer_single() throws Exception {
SerializeWriter out = new SerializeWriter(3);
out.config(SerializerFeature.UseSingleQuotes, true);
try {
JSONSerializer serializer = new JSONSerializer(out);
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.serializer;
import java.io.StringWriter;
import java.util.Collections;
import junit.framework.TestCase;
import org.junit.Assert;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/str/EmptyStringTest.java
5 issues
Line: 10
* Created by wenshao on 13/03/2017.
*/
public class EmptyStringTest extends TestCase {
public void test_for_emptyString() throws Exception {
SolutionIdentifier solutionIdentifier = JSON.parseObject("{\"id\":\"\"}", SolutionIdentifier.class);
assertNull(solutionIdentifier.id);
}
public static class SolutionIdentifier {
Reported by PMD.
Line: 12
public class EmptyStringTest extends TestCase {
public void test_for_emptyString() throws Exception {
SolutionIdentifier solutionIdentifier = JSON.parseObject("{\"id\":\"\"}", SolutionIdentifier.class);
assertNull(solutionIdentifier.id);
}
public static class SolutionIdentifier {
public Id id;
}
Reported by PMD.
Line: 16
}
public static class SolutionIdentifier {
public Id id;
}
public static class Id {
public String id;
}
Reported by PMD.
Line: 20
}
public static class Id {
public String id;
}
}
Reported by PMD.
Line: 20
}
public static class Id {
public String id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/taobao/MTopTest.java
5 issues
Line: 19
public class MTopTest extends TestCase {
public void test_for_mtop() throws Exception {
P0 p = new P0();
p.model = new Model();
ContextValueFilter valueFilter = new ContextValueFilter() {
Reported by PMD.
Line: 39
Assert.assertEquals(SerializerFeature.WriteMapNullValue.mask, context.getFeatures());
Field field = context.getField();
Assert.assertNotNull(field.getAnnotation(UrlIdentify.class));
Assert.assertNotNull(context.getAnnation(UrlIdentify.class));
return value;
}
Reported by PMD.
Line: 68
}
public static class Model {
private int id;
private String url;
public String getUrl() {
Reported by PMD.
Line: 23
P0 p = new P0();
p.model = new Model();
ContextValueFilter valueFilter = new ContextValueFilter() {
@Override
public Object process(BeanContext context, Object object, String name, Object value) {
Reported by PMD.
Line: 23
P0 p = new P0();
p.model = new Model();
ContextValueFilter valueFilter = new ContextValueFilter() {
@Override
public Object process(BeanContext context, Object object, String name, Object value) {
Reported by PMD.