The following issues were found
src/test/java/com/wheelchair/parser/JSONScannerTest.java
84 issues
Line: 13
import com.diffblue.deeptestutils.Reflector;
public class JSONScannerTest {
@Test
public void checkDate1() throws Throwable {
// Arrange
char y0 = '2';
Reported by PMD.
Line: 28
int d1 = 52;
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Reported by PMD.
Line: 29
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(true, retval);
Reported by PMD.
Line: 29
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(true, retval);
Reported by PMD.
Line: 29
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(true, retval);
Reported by PMD.
Line: 29
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(true, retval);
Reported by PMD.
Line: 30
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(true, retval);
}
Reported by PMD.
Line: 31
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(true, retval);
}
@Test
Reported by PMD.
Line: 50
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(false, retval);
Reported by PMD.
Line: 51
// Act
Class<?> c = Reflector.forName("com.alibaba.fastjson.parser.JSONScanner");
Method m = c.getDeclaredMethod("checkDate", Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("char"), Reflector.forName("int"), Reflector.forName("int"));
m.setAccessible(true);
boolean retval = (Boolean)m.invoke(null, y0, y1, y2, y3, M0, M1, d0, d1);
// Assert result
Assert.assertEquals(false, retval);
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/JSONValidator.java
79 issues
Line: 411
public UTF8Validator(byte[] bytes) {
this.bytes = bytes;
next();
skipWhiteSpace();
}
void next() {
++pos;
Reported by PMD.
Line: 444
buf = new byte[1024 * 8];
}
next();
skipWhiteSpace();
}
void next() {
if (pos < end) {
Reported by PMD.
Line: 495
public UTF16Validator(String str) {
this.str = str;
next();
skipWhiteSpace();
}
void next() {
++pos;
Reported by PMD.
Line: 572
buf = new char[1024 * 8];
}
next();
skipWhiteSpace();
}
void next() {
if (pos < end) {
Reported by PMD.
Line: 8
import java.io.InputStream;
import java.io.Reader;
public abstract class JSONValidator implements Cloneable, Closeable {
public enum Type {
Object, Array, Value
}
protected boolean eof;
Reported by PMD.
Line: 8
import java.io.InputStream;
import java.io.Reader;
public abstract class JSONValidator implements Cloneable, Closeable {
public enum Type {
Object, Array, Value
}
protected boolean eof;
Reported by PMD.
Line: 8
import java.io.InputStream;
import java.io.Reader;
public abstract class JSONValidator implements Cloneable, Closeable {
public enum Type {
Object, Array, Value
}
protected boolean eof;
Reported by PMD.
Line: 8
import java.io.InputStream;
import java.io.Reader;
public abstract class JSONValidator implements Cloneable, Closeable {
public enum Type {
Object, Array, Value
}
protected boolean eof;
Reported by PMD.
Line: 8
import java.io.InputStream;
import java.io.Reader;
public abstract class JSONValidator implements Cloneable, Closeable {
public enum Type {
Object, Array, Value
}
protected boolean eof;
Reported by PMD.
Line: 13
Object, Array, Value
}
protected boolean eof;
protected int pos = -1;
protected char ch;
protected Type type;
private Boolean validateResult;
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/DateCodec.java
78 issues
Line: 41
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class DateCodec extends AbstractDateDeserializer implements ObjectSerializer, ObjectDeserializer {
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
Reported by PMD.
Line: 41
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class DateCodec extends AbstractDateDeserializer implements ObjectSerializer, ObjectDeserializer {
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
Reported by PMD.
Line: 41
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class DateCodec extends AbstractDateDeserializer implements ObjectSerializer, ObjectDeserializer {
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
Reported by PMD.
Line: 45
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull();
return;
Reported by PMD.
Line: 45
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull();
return;
Reported by PMD.
Line: 45
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull();
return;
Reported by PMD.
Line: 45
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull();
return;
Reported by PMD.
Line: 45
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull();
return;
Reported by PMD.
Line: 45
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull();
return;
Reported by PMD.
Line: 45
public final static DateCodec instance = new DateCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull();
return;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/LongTest2_obj.java
77 issues
Line: 14
* Created by wenshao on 11/08/2017.
*/
public class LongTest2_obj extends TestCase {
public void test_0() throws Exception {
String json = "{\"v1\":-1883391953414482124,\"v2\":-3019416596934963650,\"v3\":6497525620823745793,\"v4\":2136224289077142499,\"v5\":-2090575024006307745}";
String json2 = "{\"v1\":\"-1883391953414482124\",\"v2\":\"-3019416596934963650\",\"v3\":\"6497525620823745793\",\"v4\":\"2136224289077142499\",\"v5\":\"-2090575024006307745\"}";
Model m1 = JSON.parseObject(json, Model.class);
Model m2 = JSON.parseObject(json2, Model.class);
Reported by PMD.
Line: 14
* Created by wenshao on 11/08/2017.
*/
public class LongTest2_obj extends TestCase {
public void test_0() throws Exception {
String json = "{\"v1\":-1883391953414482124,\"v2\":-3019416596934963650,\"v3\":6497525620823745793,\"v4\":2136224289077142499,\"v5\":-2090575024006307745}";
String json2 = "{\"v1\":\"-1883391953414482124\",\"v2\":\"-3019416596934963650\",\"v3\":\"6497525620823745793\",\"v4\":\"2136224289077142499\",\"v5\":\"-2090575024006307745\"}";
Model m1 = JSON.parseObject(json, Model.class);
Model m2 = JSON.parseObject(json2, Model.class);
Reported by PMD.
Line: 21
Model m1 = JSON.parseObject(json, Model.class);
Model m2 = JSON.parseObject(json2, Model.class);
assertNotNull(m1);
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
Reported by PMD.
Line: 22
Model m2 = JSON.parseObject(json2, Model.class);
assertNotNull(m1);
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
assertEquals(2136224289077142499L, m1.v4.longValue());
Reported by PMD.
Line: 24
assertNotNull(m1);
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
assertEquals(2136224289077142499L, m1.v4.longValue());
assertEquals(-2090575024006307745L, m1.v5.longValue());
Reported by PMD.
Line: 24
assertNotNull(m1);
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
assertEquals(2136224289077142499L, m1.v4.longValue());
assertEquals(-2090575024006307745L, m1.v5.longValue());
Reported by PMD.
Line: 25
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
assertEquals(2136224289077142499L, m1.v4.longValue());
assertEquals(-2090575024006307745L, m1.v5.longValue());
assertEquals(-1883391953414482124L, m2.v1.longValue());
Reported by PMD.
Line: 25
assertNotNull(m2);
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
assertEquals(2136224289077142499L, m1.v4.longValue());
assertEquals(-2090575024006307745L, m1.v5.longValue());
assertEquals(-1883391953414482124L, m2.v1.longValue());
Reported by PMD.
Line: 26
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
assertEquals(2136224289077142499L, m1.v4.longValue());
assertEquals(-2090575024006307745L, m1.v5.longValue());
assertEquals(-1883391953414482124L, m2.v1.longValue());
assertEquals(-3019416596934963650L, m2.v2.longValue());
Reported by PMD.
Line: 26
assertEquals(-1883391953414482124L, m1.v1.longValue());
assertEquals(-3019416596934963650L, m1.v2.longValue());
assertEquals(6497525620823745793L, m1.v3.longValue());
assertEquals(2136224289077142499L, m1.v4.longValue());
assertEquals(-2090575024006307745L, m1.v5.longValue());
assertEquals(-1883391953414482124L, m2.v1.longValue());
assertEquals(-3019416596934963650L, m2.v2.longValue());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest.java
76 issues
Line: 52
public void test_cast_Integer() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1L);
Assert.assertEquals(new Integer(1), json.getObject("id", int.class));
}
public void test_cast_Integer_2() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1L);
Reported by PMD.
Line: 58
public void test_cast_Integer_2() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1L);
Assert.assertEquals(new Integer(1), json.getObject("id", Integer.class));
}
public void test_cast_to_long() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Reported by PMD.
Line: 64
public void test_cast_to_long() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Assert.assertEquals(new Long(1), json.getObject("id", long.class));
}
public void test_cast_to_Long() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Reported by PMD.
Line: 70
public void test_cast_to_Long() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Assert.assertEquals(new Long(1), json.getObject("id", Long.class));
}
public void test_cast_to_short() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Reported by PMD.
Line: 76
public void test_cast_to_short() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Assert.assertEquals(new Short((short) 1), json.getObject("id", short.class));
}
public void test_cast_to_Short() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Reported by PMD.
Line: 82
public void test_cast_to_Short() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Assert.assertEquals(new Short((short) 1), json.getObject("id", Short.class));
}
public void test_cast_to_byte() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Reported by PMD.
Line: 88
public void test_cast_to_byte() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Assert.assertEquals(new Byte((byte) 1), json.getObject("id", byte.class));
}
public void test_cast_to_Byte() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Reported by PMD.
Line: 94
public void test_cast_to_Byte() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Assert.assertEquals(new Byte((byte) 1), json.getObject("id", Byte.class));
}
public void test_cast_to_BigInteger() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Reported by PMD.
Line: 1
package com.alibaba.json.bvt.parser;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
Reported by PMD.
Line: 26
import com.alibaba.fastjson.util.TypeUtils;
@SuppressWarnings("rawtypes")
public class TypeUtilsTest extends TestCase {
public void test_0() throws Exception {
HashMap map = new HashMap();
Assert.assertTrue(map == TypeUtils.castToJavaBean(map, Map.class));
Reported by PMD.
src/main/java/com/alibaba/fastjson/asm/ClassReader.java
75 issues
Line: 184
return u + 2;
}
private int readMethod(TypeCollector classVisitor, char[] c, int u) {
int v;
int w;
int j;
String attrName;
int k;
Reported by PMD.
Line: 184
return u + 2;
}
private int readMethod(TypeCollector classVisitor, char[] c, int u) {
int v;
int w;
int j;
String attrName;
int k;
Reported by PMD.
Line: 184
return u + 2;
}
private int readMethod(TypeCollector classVisitor, char[] c, int u) {
int v;
int w;
int j;
String attrName;
int k;
Reported by PMD.
Line: 288
| ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF);
}
private String readUTF8(int index, final char[] buf) {
int item = readUnsignedShort(index);
String s = strings[item];
if (s != null) {
return s;
}
Reported by PMD.
Line: 298
return strings[item] = readUTF(index + 2, readUnsignedShort(index), buf);
}
private String readUTF(int index, final int utfLen, final char[] buf) {
int endIndex = index + utfLen;
byte[] b = this.b;
int strLen = 0;
int c;
int st = 0;
Reported by PMD.
Line: 10
/**
* Created by wenshao on 05/08/2017.
*/
public class ClassReader {
public final byte[] b;
private final int[] items;
private final String[] strings;
private final int maxStringLength;
public final int header;
Reported by PMD.
Line: 10
/**
* Created by wenshao on 05/08/2017.
*/
public class ClassReader {
public final byte[] b;
private final int[] items;
private final String[] strings;
private final int maxStringLength;
public final int header;
Reported by PMD.
Line: 11
* Created by wenshao on 05/08/2017.
*/
public class ClassReader {
public final byte[] b;
private final int[] items;
private final String[] strings;
private final int maxStringLength;
public final int header;
private boolean readAnnotations;
Reported by PMD.
Line: 12
*/
public class ClassReader {
public final byte[] b;
private final int[] items;
private final String[] strings;
private final int maxStringLength;
public final int header;
private boolean readAnnotations;
Reported by PMD.
Line: 13
public class ClassReader {
public final byte[] b;
private final int[] items;
private final String[] strings;
private final int maxStringLength;
public final int header;
private boolean readAnnotations;
public ClassReader(InputStream is, boolean readAnnotations) throws IOException {
Reported by PMD.
src/main/java/com/alibaba/fastjson/JSONObject.java
74 issues
Line: 233
return castToShort(value);
}
public short getShortValue(String key) {
Object value = get(key);
Short shortVal = castToShort(value);
if (shortVal == null) {
return 0;
Reported by PMD.
Line: 401
}
@Override
public JSONObject clone() {
return new JSONObject(map instanceof LinkedHashMap //
? new LinkedHashMap<String, Object>(map) //
: new HashMap<String, Object>(map)
);
}
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.fastjson;
import static com.alibaba.fastjson.util.TypeUtils.castToBigDecimal;
import static com.alibaba.fastjson.util.TypeUtils.castToBigInteger;
import static com.alibaba.fastjson.util.TypeUtils.castToBoolean;
import static com.alibaba.fastjson.util.TypeUtils.castToByte;
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.fastjson;
import static com.alibaba.fastjson.util.TypeUtils.castToBigDecimal;
import static com.alibaba.fastjson.util.TypeUtils.castToBigInteger;
import static com.alibaba.fastjson.util.TypeUtils.castToBoolean;
import static com.alibaba.fastjson.util.TypeUtils.castToByte;
Reported by PMD.
Line: 49
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONObject extends JSON implements Map<String, Object>, Cloneable, Serializable, InvocationHandler {
private static final long serialVersionUID = 1L;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final Map<String, Object> map;
Reported by PMD.
Line: 49
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONObject extends JSON implements Map<String, Object>, Cloneable, Serializable, InvocationHandler {
private static final long serialVersionUID = 1L;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final Map<String, Object> map;
Reported by PMD.
Line: 49
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONObject extends JSON implements Map<String, Object>, Cloneable, Serializable, InvocationHandler {
private static final long serialVersionUID = 1L;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final Map<String, Object> map;
Reported by PMD.
Line: 49
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONObject extends JSON implements Map<String, Object>, Cloneable, Serializable, InvocationHandler {
private static final long serialVersionUID = 1L;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final Map<String, Object> map;
Reported by PMD.
Line: 49
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONObject extends JSON implements Map<String, Object>, Cloneable, Serializable, InvocationHandler {
private static final long serialVersionUID = 1L;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final Map<String, Object> map;
Reported by PMD.
Line: 54
private static final long serialVersionUID = 1L;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
private final Map<String, Object> map;
public JSONObject(){
this(DEFAULT_INITIAL_CAPACITY, false);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/spring/security/DefaultSavedRequestTest.java
74 issues
Line: 85
public void test_PreAuthenticatedAuthenticationToken() throws Exception {
PreAuthenticatedAuthenticationToken token = new PreAuthenticatedAuthenticationToken("ppp", "cccc");
String json = JSON.toJSONString(token);
System.out.println(json);
PreAuthenticatedAuthenticationToken token1 = JSON.parseObject(json, PreAuthenticatedAuthenticationToken.class);
assertEquals("ppp", token1.getPrincipal());
assertEquals("cccc", token1.getCredentials());
}
Reported by PMD.
Line: 28
/**
* Created by wenshao on 11/08/2017.
*/
public class DefaultSavedRequestTest extends TestCase {
ParserConfig config;
protected void setUp() throws Exception {
Field field = GenericFastJsonRedisSerializer.class.getDeclaredField("defaultRedisConfig");
field.setAccessible(true);
Reported by PMD.
Line: 29
* Created by wenshao on 11/08/2017.
*/
public class DefaultSavedRequestTest extends TestCase {
ParserConfig config;
protected void setUp() throws Exception {
Field field = GenericFastJsonRedisSerializer.class.getDeclaredField("defaultRedisConfig");
field.setAccessible(true);
config = (ParserConfig) field.get(null);
Reported by PMD.
Line: 31
public class DefaultSavedRequestTest extends TestCase {
ParserConfig config;
protected void setUp() throws Exception {
Field field = GenericFastJsonRedisSerializer.class.getDeclaredField("defaultRedisConfig");
field.setAccessible(true);
config = (ParserConfig) field.get(null);
config.addAccept("org.springframework.security.web.savedrequest.DefaultSavedRequest");
}
Reported by PMD.
Line: 33
protected void setUp() throws Exception {
Field field = GenericFastJsonRedisSerializer.class.getDeclaredField("defaultRedisConfig");
field.setAccessible(true);
config = (ParserConfig) field.get(null);
config.addAccept("org.springframework.security.web.savedrequest.DefaultSavedRequest");
}
public void test_for_issue() throws Exception {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
Reported by PMD.
Line: 34
protected void setUp() throws Exception {
Field field = GenericFastJsonRedisSerializer.class.getDeclaredField("defaultRedisConfig");
field.setAccessible(true);
config = (ParserConfig) field.get(null);
config.addAccept("org.springframework.security.web.savedrequest.DefaultSavedRequest");
}
public void test_for_issue() throws Exception {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
DefaultSavedRequest request = new DefaultSavedRequest(mockReq, new PortResolver() {
Reported by PMD.
Line: 37
config = (ParserConfig) field.get(null);
config.addAccept("org.springframework.security.web.savedrequest.DefaultSavedRequest");
}
public void test_for_issue() throws Exception {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
DefaultSavedRequest request = new DefaultSavedRequest(mockReq, new PortResolver() {
public int getServerPort(ServletRequest servletRequest) {
return 0;
Reported by PMD.
Line: 37
config = (ParserConfig) field.get(null);
config.addAccept("org.springframework.security.web.savedrequest.DefaultSavedRequest");
}
public void test_for_issue() throws Exception {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
DefaultSavedRequest request = new DefaultSavedRequest(mockReq, new PortResolver() {
public int getServerPort(ServletRequest servletRequest) {
return 0;
Reported by PMD.
Line: 56
}
public void test_cookie() throws Exception {
String json = "{\"name\":\"xx\",\"value\":\"xx\",\"comment\":\"xx\",\"domain\":\"xx\"}";
SavedCookie cookie = JSON.parseObject(json, SavedCookie.class);
assertEquals("xx", cookie.getName());
assertEquals("{\"comment\":\"xx\",\"cookie\":{\"comment\":\"xx\",\"domain\":\"xx\",\"httpOnly\":false,\"maxAge\":0,\"name\":\"xx\",\"secure\":false,\"value\":\"xx\",\"version\":0},\"domain\":\"xx\",\"maxAge\":0,\"name\":\"xx\",\"secure\":false,\"value\":\"xx\",\"version\":0}", JSON.toJSONString(cookie));
}
Reported by PMD.
Line: 56
}
public void test_cookie() throws Exception {
String json = "{\"name\":\"xx\",\"value\":\"xx\",\"comment\":\"xx\",\"domain\":\"xx\"}";
SavedCookie cookie = JSON.parseObject(json, SavedCookie.class);
assertEquals("xx", cookie.getName());
assertEquals("{\"comment\":\"xx\",\"cookie\":{\"comment\":\"xx\",\"domain\":\"xx\",\"httpOnly\":false,\"maxAge\":0,\"name\":\"xx\",\"secure\":false,\"value\":\"xx\",\"version\":0},\"domain\":\"xx\",\"maxAge\":0,\"name\":\"xx\",\"secure\":false,\"value\":\"xx\",\"version\":0}", JSON.toJSONString(cookie));
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/JSON.java
74 issues
Line: 334
}
@SuppressWarnings("unchecked")
public static <T> T parseObject(String input, Type clazz, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature feature : features) {
Reported by PMD.
Line: 367
@SuppressWarnings("unchecked")
public static <T> T parseObject(String input, Type clazz, ParserConfig config, ParseProcess processor,
int featureValues, Feature... features) {
if (input == null || input.length() == 0) {
return null;
}
if (features != null) {
Reported by PMD.
Line: 435
*/
@SuppressWarnings("unchecked")
public static <T> T parseObject(byte[] bytes, int offset, int len,
Charset charset,
Type clazz,
ParserConfig config,
ParseProcess processor,
int featureValues,
Feature... features) {
Reported by PMD.
Line: 559
*/
@SuppressWarnings("unchecked")
public static <T> T parseObject(InputStream is, //
Charset charset, //
Type type, //
ParserConfig config, //
ParseProcess processor, //
int featureValues, //
Feature... features) throws IOException {
Reported by PMD.
Line: 16
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.fastjson;
import java.io.*;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
Reported by PMD.
Line: 65
*
* @author wenshao[szujobs@hotmail.com]
*/
public abstract class JSON implements JSONStreamAware, JSONAware {
public static TimeZone defaultTimeZone = TimeZone.getDefault();
public static Locale defaultLocale = Locale.getDefault();
public static String DEFAULT_TYPE_KEY = "@type";
static final SerializeFilter[] emptyFilters = new SerializeFilter[0];
public static String DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
Reported by PMD.
Line: 65
*
* @author wenshao[szujobs@hotmail.com]
*/
public abstract class JSON implements JSONStreamAware, JSONAware {
public static TimeZone defaultTimeZone = TimeZone.getDefault();
public static Locale defaultLocale = Locale.getDefault();
public static String DEFAULT_TYPE_KEY = "@type";
static final SerializeFilter[] emptyFilters = new SerializeFilter[0];
public static String DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
Reported by PMD.
Line: 65
*
* @author wenshao[szujobs@hotmail.com]
*/
public abstract class JSON implements JSONStreamAware, JSONAware {
public static TimeZone defaultTimeZone = TimeZone.getDefault();
public static Locale defaultLocale = Locale.getDefault();
public static String DEFAULT_TYPE_KEY = "@type";
static final SerializeFilter[] emptyFilters = new SerializeFilter[0];
public static String DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
Reported by PMD.
Line: 65
*
* @author wenshao[szujobs@hotmail.com]
*/
public abstract class JSON implements JSONStreamAware, JSONAware {
public static TimeZone defaultTimeZone = TimeZone.getDefault();
public static Locale defaultLocale = Locale.getDefault();
public static String DEFAULT_TYPE_KEY = "@type";
static final SerializeFilter[] emptyFilters = new SerializeFilter[0];
public static String DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
Reported by PMD.
Line: 65
*
* @author wenshao[szujobs@hotmail.com]
*/
public abstract class JSON implements JSONStreamAware, JSONAware {
public static TimeZone defaultTimeZone = TimeZone.getDefault();
public static Locale defaultLocale = Locale.getDefault();
public static String DEFAULT_TYPE_KEY = "@type";
static final SerializeFilter[] emptyFilters = new SerializeFilter[0];
public static String DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/date/DateFieldTest11_reader.java
73 issues
Line: 71
assertEquals(0, calendar.get(Calendar.SECOND));
assertEquals(0, calendar.get(Calendar.MILLISECOND));
System.out.println(vo.date0.getTime());
System.out.println(vo.date1.getTime());
}
public static class Model {
public Date date0;
Reported by PMD.
Line: 72
assertEquals(0, calendar.get(Calendar.MILLISECOND));
System.out.println(vo.date0.getTime());
System.out.println(vo.date1.getTime());
}
public static class Model {
public Date date0;
public Date date1;
Reported by PMD.
Line: 19
* Created by wenshao on 07/04/2017.
*/
public class DateFieldTest11_reader extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_cn() throws Exception {
Reported by PMD.
Line: 24
JSON.defaultLocale = Locale.CHINA;
}
public void test_cn() throws Exception {
Model vo = new JSONReader(new StringReader("{\"date0\":\"2016-05-06\",\"date1\":\"2017-03-01\"}")).readObject(Model.class);
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date0);
Reported by PMD.
Line: 24
JSON.defaultLocale = Locale.CHINA;
}
public void test_cn() throws Exception {
Model vo = new JSONReader(new StringReader("{\"date0\":\"2016-05-06\",\"date1\":\"2017-03-01\"}")).readObject(Model.class);
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date0);
Reported by PMD.
Line: 29
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date0);
assertEquals(2016, calendar.get(Calendar.YEAR));
assertEquals(4, calendar.get(Calendar.MONTH));
assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
assertEquals(0, calendar.get(Calendar.MINUTE));
Reported by PMD.
Line: 30
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date0);
assertEquals(2016, calendar.get(Calendar.YEAR));
assertEquals(4, calendar.get(Calendar.MONTH));
assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
assertEquals(0, calendar.get(Calendar.MINUTE));
assertEquals(0, calendar.get(Calendar.SECOND));
Reported by PMD.
Line: 30
Calendar calendar = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
calendar.setTime(vo.date0);
assertEquals(2016, calendar.get(Calendar.YEAR));
assertEquals(4, calendar.get(Calendar.MONTH));
assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
assertEquals(0, calendar.get(Calendar.MINUTE));
assertEquals(0, calendar.get(Calendar.SECOND));
Reported by PMD.
Line: 31
calendar.setTime(vo.date0);
assertEquals(2016, calendar.get(Calendar.YEAR));
assertEquals(4, calendar.get(Calendar.MONTH));
assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
assertEquals(0, calendar.get(Calendar.MINUTE));
assertEquals(0, calendar.get(Calendar.SECOND));
assertEquals(0, calendar.get(Calendar.MILLISECOND));
Reported by PMD.
Line: 31
calendar.setTime(vo.date0);
assertEquals(2016, calendar.get(Calendar.YEAR));
assertEquals(4, calendar.get(Calendar.MONTH));
assertEquals(6, calendar.get(Calendar.DAY_OF_MONTH));
assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY));
assertEquals(0, calendar.get(Calendar.MINUTE));
assertEquals(0, calendar.get(Calendar.SECOND));
assertEquals(0, calendar.get(Calendar.MILLISECOND));
Reported by PMD.