The following issues were found
src/main/java/com/alibaba/fastjson/asm/ClassWriter.java
40 issues
Line: 36
*
* @author Eric Bruneton
*/
public class ClassWriter {
/**
* Minor and major version numbers of the class to be generated.
*/
int version;
Reported by PMD.
Line: 40
/**
* Minor and major version numbers of the class to be generated.
*/
int version;
/**
* Index of the next item to be added in the constant pool.
*/
int index;
Reported by PMD.
Line: 45
/**
* Index of the next item to be added in the constant pool.
*/
int index;
/**
* The constant pool of this class.
*/
final ByteVector pool;
Reported by PMD.
Line: 50
/**
* The constant pool of this class.
*/
final ByteVector pool;
/**
* The constant pool's hash table data.
*/
Item[] items;
Reported by PMD.
Line: 55
/**
* The constant pool's hash table data.
*/
Item[] items;
/**
* The threshold of the constant pool's hash table.
*/
int threshold;
Reported by PMD.
Line: 60
/**
* The threshold of the constant pool's hash table.
*/
int threshold;
/**
* A reusable key used to look for items in the {@link #items} hash table.
*/
final Item key;
Reported by PMD.
Line: 65
/**
* A reusable key used to look for items in the {@link #items} hash table.
*/
final Item key;
/**
* A reusable key used to look for items in the {@link #items} hash table.
*/
final Item key2;
Reported by PMD.
Line: 70
/**
* A reusable key used to look for items in the {@link #items} hash table.
*/
final Item key2;
/**
* A reusable key used to look for items in the {@link #items} hash table.
*/
final Item key3;
Reported by PMD.
Line: 75
/**
* A reusable key used to look for items in the {@link #items} hash table.
*/
final Item key3;
/**
* A type table used to temporarily store internal names that will not necessarily be stored in the constant pool.
* This type table is used by the control flow and data flow analysis algorithm used to compute stack map frames
* from scratch. This array associates to each index <tt>i</tt> the Item whose index is <tt>i</tt>. All Item objects
Reported by PMD.
Line: 90
/**
* The access flags of this class.
*/
private int access;
/**
* The constant pool item that contains the internal name of this class.
*/
private int name;
Reported by PMD.
src/main/java/com/alibaba/fastjson/util/ASMUtils.java
40 issues
Line: 15
import java.lang.reflect.Method;
import java.lang.reflect.Type;
public class ASMUtils {
public static final String JAVA_VM_NAME = System.getProperty("java.vm.name");
public static final boolean IS_ANDROID = isAndroid(JAVA_VM_NAME);
Reported by PMD.
Line: 15
import java.lang.reflect.Method;
import java.lang.reflect.Type;
public class ASMUtils {
public static final String JAVA_VM_NAME = System.getProperty("java.vm.name");
public static final boolean IS_ANDROID = isAndroid(JAVA_VM_NAME);
Reported by PMD.
Line: 15
import java.lang.reflect.Method;
import java.lang.reflect.Type;
public class ASMUtils {
public static final String JAVA_VM_NAME = System.getProperty("java.vm.name");
public static final boolean IS_ANDROID = isAndroid(JAVA_VM_NAME);
Reported by PMD.
Line: 26
return false;
}
String lowerVMName = vmName.toLowerCase();
return lowerVMName.contains("dalvik") //
|| lowerVMName.contains("lemur") // aliyun-vm name
;
}
Reported by PMD.
Line: 28
String lowerVMName = vmName.toLowerCase();
return lowerVMName.contains("dalvik") //
|| lowerVMName.contains("lemur") // aliyun-vm name
;
}
public static String desc(Method method) {
Reported by PMD.
Line: 29
String lowerVMName = vmName.toLowerCase();
return lowerVMName.contains("dalvik") //
|| lowerVMName.contains("lemur") // aliyun-vm name
;
}
public static String desc(Method method) {
Class<?>[] types = method.getParameterTypes();
Reported by PMD.
Line: 37
Class<?>[] types = method.getParameterTypes();
StringBuilder buf = new StringBuilder((types.length + 1) << 4);
buf.append('(');
for (int i = 0; i < types.length; ++i) {
buf.append(desc(types[i]));
}
buf.append(')');
buf.append(desc(method.getReturnType()));
return buf.toString();
Reported by PMD.
Line: 40
for (int i = 0; i < types.length; ++i) {
buf.append(desc(types[i]));
}
buf.append(')');
buf.append(desc(method.getReturnType()));
return buf.toString();
}
public static String desc(Class<?> returnType) {
Reported by PMD.
Line: 61
} else {
if (!parameterType.isPrimitive()) {
String clsName = parameterType.getName();
return clsName.replace('.', '/'); // 直接基于字符串替换,不使用正则替换
} else {
return getPrimitiveLetter(parameterType);
}
}
}
Reported by PMD.
Line: 69
}
public static String getPrimitiveLetter(Class<?> type) {
if (Integer.TYPE == type) {
return "I";
} else if (Void.TYPE == type) {
return "V";
} else if (Boolean.TYPE == type) {
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/SerializeFilterable.java
40 issues
Line: 179
protected String processKey(JSONSerializer jsonBeanDeser, //
Object object, //
String key, //
Object propertyValue) {
if (jsonBeanDeser.nameFilters != null) {
for (NameFilter nameFilter : jsonBeanDeser.nameFilters) {
key = nameFilter.process(object, key, propertyValue);
Reported by PMD.
Line: 179
protected String processKey(JSONSerializer jsonBeanDeser, //
Object object, //
String key, //
Object propertyValue) {
if (jsonBeanDeser.nameFilters != null) {
for (NameFilter nameFilter : jsonBeanDeser.nameFilters) {
key = nameFilter.process(object, key, propertyValue);
Reported by PMD.
Line: 209
BeanContext beanContext,
Object object, //
String key, //
Object propertyValue, //
int features) {
if (propertyValue != null) {
if ((SerializerFeature.isEnabled(jsonBeanDeser.out.features, features, SerializerFeature.WriteNonStringValueAsString) //
|| (beanContext != null && (beanContext.getFeatures() & SerializerFeature.WriteNonStringValueAsString.mask) != 0))
Reported by PMD.
Line: 209
BeanContext beanContext,
Object object, //
String key, //
Object propertyValue, //
int features) {
if (propertyValue != null) {
if ((SerializerFeature.isEnabled(jsonBeanDeser.out.features, features, SerializerFeature.WriteNonStringValueAsString) //
|| (beanContext != null && (beanContext.getFeatures() & SerializerFeature.WriteNonStringValueAsString.mask) != 0))
Reported by PMD.
Line: 209
BeanContext beanContext,
Object object, //
String key, //
Object propertyValue, //
int features) {
if (propertyValue != null) {
if ((SerializerFeature.isEnabled(jsonBeanDeser.out.features, features, SerializerFeature.WriteNonStringValueAsString) //
|| (beanContext != null && (beanContext.getFeatures() & SerializerFeature.WriteNonStringValueAsString.mask) != 0))
Reported by PMD.
Line: 209
BeanContext beanContext,
Object object, //
String key, //
Object propertyValue, //
int features) {
if (propertyValue != null) {
if ((SerializerFeature.isEnabled(jsonBeanDeser.out.features, features, SerializerFeature.WriteNonStringValueAsString) //
|| (beanContext != null && (beanContext.getFeatures() & SerializerFeature.WriteNonStringValueAsString.mask) != 0))
Reported by PMD.
Line: 209
BeanContext beanContext,
Object object, //
String key, //
Object propertyValue, //
int features) {
if (propertyValue != null) {
if ((SerializerFeature.isEnabled(jsonBeanDeser.out.features, features, SerializerFeature.WriteNonStringValueAsString) //
|| (beanContext != null && (beanContext.getFeatures() & SerializerFeature.WriteNonStringValueAsString.mask) != 0))
Reported by PMD.
Line: 209
BeanContext beanContext,
Object object, //
String key, //
Object propertyValue, //
int features) {
if (propertyValue != null) {
if ((SerializerFeature.isEnabled(jsonBeanDeser.out.features, features, SerializerFeature.WriteNonStringValueAsString) //
|| (beanContext != null && (beanContext.getFeatures() & SerializerFeature.WriteNonStringValueAsString.mask) != 0))
Reported by PMD.
Line: 209
BeanContext beanContext,
Object object, //
String key, //
Object propertyValue, //
int features) {
if (propertyValue != null) {
if ((SerializerFeature.isEnabled(jsonBeanDeser.out.features, features, SerializerFeature.WriteNonStringValueAsString) //
|| (beanContext != null && (beanContext.getFeatures() & SerializerFeature.WriteNonStringValueAsString.mask) != 0))
Reported by PMD.
Line: 9
import com.alibaba.fastjson.JSON;
public abstract class SerializeFilterable {
protected List<BeforeFilter> beforeFilters = null;
protected List<AfterFilter> afterFilters = null;
protected List<PropertyFilter> propertyFilters = null;
protected List<ValueFilter> valueFilters = null;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_scanFieldStringArray.java
40 issues
Line: 11
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
public class JSONScannerTest_scanFieldStringArray extends TestCase {
public void test_string() throws Exception {
String text = "{\"value\":[1]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
Reported by PMD.
Line: 13
public class JSONScannerTest_scanFieldStringArray extends TestCase {
public void test_string() throws Exception {
String text = "{\"value\":[1]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
Reported by PMD.
Line: 16
public void test_string() throws Exception {
String text = "{\"value\":[1]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_1() throws Exception {
String text = "{\"value\":[\"1\"]}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 16
public void test_string() throws Exception {
String text = "{\"value\":[1]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_1() throws Exception {
String text = "{\"value\":[\"1\"]}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 16
public void test_string() throws Exception {
String text = "{\"value\":[1]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_1() throws Exception {
String text = "{\"value\":[\"1\"]}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 19
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_1() throws Exception {
String text = "{\"value\":[\"1\"]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
Reported by PMD.
Line: 22
public void test_string_1() throws Exception {
String text = "{\"value\":[\"1\"]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_2() throws Exception {
String text = "{\"value\":['1']}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 22
public void test_string_1() throws Exception {
String text = "{\"value\":[\"1\"]}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_2() throws Exception {
String text = "{\"value\":['1']}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 25
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_2() throws Exception {
String text = "{\"value\":['1']}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
Reported by PMD.
Line: 28
public void test_string_2() throws Exception {
String text = "{\"value\":['1']}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals("[1]", obj.getValue().toString());
}
public void test_string_3() throws Exception {
String text = "{\"value\":[\"1\\t2\"]}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/ObjectArrayCodec.java
40 issues
Line: 35
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class ObjectArrayCodec implements ObjectSerializer, ObjectDeserializer {
public static final ObjectArrayCodec instance = new ObjectArrayCodec();
public ObjectArrayCodec(){
}
Reported by PMD.
Line: 35
/**
* @author wenshao[szujobs@hotmail.com]
*/
public class ObjectArrayCodec implements ObjectSerializer, ObjectDeserializer {
public static final ObjectArrayCodec instance = new ObjectArrayCodec();
public ObjectArrayCodec(){
}
Reported by PMD.
Line: 42
public ObjectArrayCodec(){
}
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)
throws IOException {
SerializeWriter out = serializer.out;
Object[] array = (Object[]) object;
Reported by PMD.
Line: 42
public ObjectArrayCodec(){
}
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)
throws IOException {
SerializeWriter out = serializer.out;
Object[] array = (Object[]) object;
Reported by PMD.
Line: 42
public ObjectArrayCodec(){
}
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)
throws IOException {
SerializeWriter out = serializer.out;
Object[] array = (Object[]) object;
Reported by PMD.
Line: 42
public ObjectArrayCodec(){
}
public final void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)
throws IOException {
SerializeWriter out = serializer.out;
Object[] array = (Object[]) object;
Reported by PMD.
Line: 95
if (serializer.containsReference(item)) {
serializer.writeReference(item);
} else {
Class<?> clazz = item.getClass();
if (clazz == preClazz) {
preWriter.write(serializer, item, i, null, 0);
} else {
preClazz = clazz;
Reported by PMD.
Line: 98
Class<?> clazz = item.getClass();
if (clazz == preClazz) {
preWriter.write(serializer, item, i, null, 0);
} else {
preClazz = clazz;
preWriter = serializer.getObjectWriter(clazz);
preWriter.write(serializer, item, i, null, 0);
Reported by PMD.
Line: 103
preClazz = clazz;
preWriter = serializer.getObjectWriter(clazz);
preWriter.write(serializer, item, i, null, 0);
}
}
out.append(',');
}
}
Reported by PMD.
Line: 128
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
final JSONLexer lexer = parser.lexer;
int token = lexer.token();
if (token == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/date/DateFieldTest10.java
40 issues
Line: 16
* Created by wenshao on 07/04/2017.
*/
public class DateFieldTest10 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_zero() throws Exception {
Reported by PMD.
Line: 21
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_zero() throws Exception {
String text = "{\"date\":\"0000-00-00\"}";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Object object = format.parse("0000-00-00");
JSON.parseObject(text, Model.class);
Reported by PMD.
Line: 21
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_zero() throws Exception {
String text = "{\"date\":\"0000-00-00\"}";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Object object = format.parse("0000-00-00");
JSON.parseObject(text, Model.class);
Reported by PMD.
Line: 24
public void test_for_zero() throws Exception {
String text = "{\"date\":\"0000-00-00\"}";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Object object = format.parse("0000-00-00");
JSON.parseObject(text, Model.class);
}
public void test_1() throws Exception {
Reported by PMD.
Line: 25
String text = "{\"date\":\"0000-00-00\"}";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Object object = format.parse("0000-00-00");
JSON.parseObject(text, Model.class);
}
public void test_1() throws Exception {
String text = "{\"date\":\"2017-08-14 19:05:30.000|America/Los_Angeles\"}";
Reported by PMD.
Line: 29
JSON.parseObject(text, Model.class);
}
public void test_1() throws Exception {
String text = "{\"date\":\"2017-08-14 19:05:30.000|America/Los_Angeles\"}";
JSON.parseObject(text, Model.class);
}
public void test_2() throws Exception {
Reported by PMD.
Line: 29
JSON.parseObject(text, Model.class);
}
public void test_1() throws Exception {
String text = "{\"date\":\"2017-08-14 19:05:30.000|America/Los_Angeles\"}";
JSON.parseObject(text, Model.class);
}
public void test_2() throws Exception {
Reported by PMD.
Line: 34
JSON.parseObject(text, Model.class);
}
public void test_2() throws Exception {
String text = "{\"date\":\"2017-08-16T04:29Z\"}";
Model model = JSON.parseObject(text, Model.class);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Object object = format.parse("2017-08-16 04:29");
Reported by PMD.
Line: 34
JSON.parseObject(text, Model.class);
}
public void test_2() throws Exception {
String text = "{\"date\":\"2017-08-16T04:29Z\"}";
Model model = JSON.parseObject(text, Model.class);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Object object = format.parse("2017-08-16 04:29");
Reported by PMD.
Line: 36
public void test_2() throws Exception {
String text = "{\"date\":\"2017-08-16T04:29Z\"}";
Model model = JSON.parseObject(text, Model.class);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Object object = format.parse("2017-08-16 04:29");
// assertEquals(object, model.date);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_symbol.java
40 issues
Line: 15
*
* @author wenshao[szujobs@hotmail.com]
*/
public class JSONScannerTest_symbol extends TestCase {
public void test_0() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"name\"");
Reported by PMD.
Line: 17
*/
public class JSONScannerTest_symbol extends TestCase {
public void test_0() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("name".equals(symbol));
Reported by PMD.
Line: 26
lexer.close();
}
public void test_1() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick name".equals(symbol));
Reported by PMD.
Line: 35
lexer.close();
}
public void test_2() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\\"name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick \"name" == symbol);
Reported by PMD.
Line: 40
JSONScanner lexer = new JSONScanner("\"nick \\\"name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick \"name" == symbol);
lexer.close();
}
public void test_3() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
Reported by PMD.
Line: 40
JSONScanner lexer = new JSONScanner("\"nick \\\"name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick \"name" == symbol);
lexer.close();
}
public void test_3() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
Reported by PMD.
Line: 44
lexer.close();
}
public void test_3() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\\\name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick \\name" == symbol);
Reported by PMD.
Line: 49
JSONScanner lexer = new JSONScanner("\"nick \\\\name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick \\name" == symbol);
lexer.close();
}
public void test_4() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
Reported by PMD.
Line: 49
JSONScanner lexer = new JSONScanner("\"nick \\\\name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick \\name" == symbol);
lexer.close();
}
public void test_4() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
Reported by PMD.
Line: 53
lexer.close();
}
public void test_4() throws Exception {
SymbolTable symbolTable = new SymbolTable(512);
JSONScanner lexer = new JSONScanner("\"nick \\/name\"");
String symbol = lexer.scanSymbol(symbolTable, '"');
Assert.assertTrue("nick /name" == symbol);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONObjectTest.java
40 issues
Line: 154
Assert.assertEquals(3, array.getByteValue("2"));
Assert.assertEquals(3, array.getShort("2").shortValue());
Assert.assertEquals(3, array.getShortValue("2"));
Assert.assertEquals(new Integer(222), array.getInteger("1"));
Assert.assertEquals(new Long(222), array.getLong("1"));
Assert.assertEquals(new BigDecimal("222"), array.getBigDecimal("1"));
Assert.assertEquals(true, array.getBooleanValue("4"));
Assert.assertTrue(2.0F == array.getFloat("5").floatValue());
Reported by PMD.
Line: 155
Assert.assertEquals(3, array.getShort("2").shortValue());
Assert.assertEquals(3, array.getShortValue("2"));
Assert.assertEquals(new Integer(222), array.getInteger("1"));
Assert.assertEquals(new Long(222), array.getLong("1"));
Assert.assertEquals(new BigDecimal("222"), array.getBigDecimal("1"));
Assert.assertEquals(true, array.getBooleanValue("4"));
Assert.assertTrue(2.0F == array.getFloat("5").floatValue());
Assert.assertTrue(2.0F == array.getFloatValue("5"));
Reported by PMD.
Line: 29
import com.alibaba.fastjson.JSONObject;
public class JSONObjectTest extends TestCase {
public void test_toJSONObject() throws Exception {
{
Assert.assertNull(JSONObject.parse(null));
}
Reported by PMD.
Line: 31
public class JSONObjectTest extends TestCase {
public void test_toJSONObject() throws Exception {
{
Assert.assertNull(JSONObject.parse(null));
}
}
Reported by PMD.
Line: 37
}
}
public void test_writeJSONString() throws Exception {
{
StringWriter out = new StringWriter();
new JSONObject().writeJSONString(out);
Assert.assertEquals("{}", out.toString());
}
Reported by PMD.
Line: 45
}
}
public void test_getLong() throws Exception {
JSONObject json = new JSONObject(true);
json.put("A", 55L);
json.put("B", 55);
json.put("K", true);
Assert.assertEquals(json.getLong("A").longValue(), 55L);
Reported by PMD.
Line: 50
json.put("A", 55L);
json.put("B", 55);
json.put("K", true);
Assert.assertEquals(json.getLong("A").longValue(), 55L);
Assert.assertEquals(json.getLong("B").longValue(), 55L);
Assert.assertEquals(json.getLong("C"), null);
Assert.assertEquals(json.getBooleanValue("K"), true);
Assert.assertEquals(json.getBoolean("K"), Boolean.TRUE);
}
Reported by PMD.
Line: 51
json.put("B", 55);
json.put("K", true);
Assert.assertEquals(json.getLong("A").longValue(), 55L);
Assert.assertEquals(json.getLong("B").longValue(), 55L);
Assert.assertEquals(json.getLong("C"), null);
Assert.assertEquals(json.getBooleanValue("K"), true);
Assert.assertEquals(json.getBoolean("K"), Boolean.TRUE);
}
Reported by PMD.
Line: 57
Assert.assertEquals(json.getBoolean("K"), Boolean.TRUE);
}
public void test_getLong_1() throws Exception {
JSONObject json = new JSONObject(false);
json.put("A", 55L);
json.put("B", 55);
Assert.assertEquals(json.getLong("A").longValue(), 55L);
Assert.assertEquals(json.getLong("B").longValue(), 55L);
Reported by PMD.
Line: 61
JSONObject json = new JSONObject(false);
json.put("A", 55L);
json.put("B", 55);
Assert.assertEquals(json.getLong("A").longValue(), 55L);
Assert.assertEquals(json.getLong("B").longValue(), 55L);
Assert.assertEquals(json.getLong("C"), null);
}
public void test_getDate() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/extract/JSONPath_extract_1.java
39 issues
Line: 9
import java.net.InetSocketAddress;
public class JSONPath_extract_1 extends TestCase {
public void test_0() throws Exception {
String json = "[{\"id\":1001},{\"id\":1002},{\"id\":1003},[1],123,-4,\"a\\\"bc\"]";
assertEquals("{\"id\":1001}"
, JSONPath.extract(json, "$.0")
.toString());
Reported by PMD.
Line: 9
import java.net.InetSocketAddress;
public class JSONPath_extract_1 extends TestCase {
public void test_0() throws Exception {
String json = "[{\"id\":1001},{\"id\":1002},{\"id\":1003},[1],123,-4,\"a\\\"bc\"]";
assertEquals("{\"id\":1001}"
, JSONPath.extract(json, "$.0")
.toString());
Reported by PMD.
Line: 12
public void test_0() throws Exception {
String json = "[{\"id\":1001},{\"id\":1002},{\"id\":1003},[1],123,-4,\"a\\\"bc\"]";
assertEquals("{\"id\":1001}"
, JSONPath.extract(json, "$.0")
.toString());
assertEquals("{\"id\":1002}"
, JSONPath.extract(json, "$.1")
Reported by PMD.
Line: 13
String json = "[{\"id\":1001},{\"id\":1002},{\"id\":1003},[1],123,-4,\"a\\\"bc\"]";
assertEquals("{\"id\":1001}"
, JSONPath.extract(json, "$.0")
.toString());
assertEquals("{\"id\":1002}"
, JSONPath.extract(json, "$.1")
.toString());
Reported by PMD.
Line: 13
String json = "[{\"id\":1001},{\"id\":1002},{\"id\":1003},[1],123,-4,\"a\\\"bc\"]";
assertEquals("{\"id\":1001}"
, JSONPath.extract(json, "$.0")
.toString());
assertEquals("{\"id\":1002}"
, JSONPath.extract(json, "$.1")
.toString());
Reported by PMD.
Line: 16
, JSONPath.extract(json, "$.0")
.toString());
assertEquals("{\"id\":1002}"
, JSONPath.extract(json, "$.1")
.toString());
assertEquals("{\"id\":1003}"
Reported by PMD.
Line: 17
.toString());
assertEquals("{\"id\":1002}"
, JSONPath.extract(json, "$.1")
.toString());
assertEquals("{\"id\":1003}"
, JSONPath.extract(json, "$.2")
Reported by PMD.
Line: 17
.toString());
assertEquals("{\"id\":1002}"
, JSONPath.extract(json, "$.1")
.toString());
assertEquals("{\"id\":1003}"
, JSONPath.extract(json, "$.2")
Reported by PMD.
Line: 21
.toString());
assertEquals("{\"id\":1003}"
, JSONPath.extract(json, "$.2")
.toString());
assertEquals("[1]"
, JSONPath.extract(json, "$.3")
Reported by PMD.
Line: 22
assertEquals("{\"id\":1003}"
, JSONPath.extract(json, "$.2")
.toString());
assertEquals("[1]"
, JSONPath.extract(json, "$.3")
.toString());
Reported by PMD.
src/test/java/com/alibaba/json/test/JsonIteratorImageTest.java
39 issues
Line: 43
long startMillis = System.currentTimeMillis();
fastjson();
long millis = System.currentTimeMillis() - startMillis;
System.out.println("fastjson : " + millis);
}
// jsoniterator();
// for (int i = 0; i < 5; ++i) {
// long startMillis = System.currentTimeMillis();
Reported by PMD.
Line: 20
* Created by wenshao on 27/12/2016.
*/
public class JsonIteratorImageTest extends TestCase {
private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
private byte[] inputBytes = input.getBytes();
private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
private JsonIterator iter;
private int COUNT = 1000 * 1000 * 1;
Reported by PMD.
Line: 20
* Created by wenshao on 27/12/2016.
*/
public class JsonIteratorImageTest extends TestCase {
private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
private byte[] inputBytes = input.getBytes();
private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
private JsonIterator iter;
private int COUNT = 1000 * 1000 * 1;
Reported by PMD.
Line: 21
*/
public class JsonIteratorImageTest extends TestCase {
private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
private byte[] inputBytes = input.getBytes();
private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
private JsonIterator iter;
private int COUNT = 1000 * 1000 * 1;
Reported by PMD.
Line: 22
public class JsonIteratorImageTest extends TestCase {
private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
private byte[] inputBytes = input.getBytes();
private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
private JsonIterator iter;
private int COUNT = 1000 * 1000 * 1;
protected void setUp() throws Exception {
Reported by PMD.
Line: 23
private String input = "{\"bitrate\":262144,\"duration\":18000000,\"format\":\"video/mpg4\",\"height\":480,\"persons\":[\"Bill Gates\",\"Steve Jobs\"],\"player\":\"JAVA\",\"size\":58982400,\"title\":\"Javaone Keynote\",\"uri\":\"http://javaone.com/keynote.mpg\",\"width\":640}";
private byte[] inputBytes = input.getBytes();
private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
private JsonIterator iter;
private int COUNT = 1000 * 1000 * 1;
protected void setUp() throws Exception {
inputBytes = input.getBytes();
Reported by PMD.
Line: 25
private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
private JsonIterator iter;
private int COUNT = 1000 * 1000 * 1;
protected void setUp() throws Exception {
inputBytes = input.getBytes();
iter = new JsonIterator();
modelTypeLiteral = new TypeLiteral<Model>() {
Reported by PMD.
Line: 25
private TypeLiteral<Model> modelTypeLiteral; // this is thread-safe can reused
private JsonIterator iter;
private int COUNT = 1000 * 1000 * 1;
protected void setUp() throws Exception {
inputBytes = input.getBytes();
iter = new JsonIterator();
modelTypeLiteral = new TypeLiteral<Model>() {
Reported by PMD.
Line: 27
private int COUNT = 1000 * 1000 * 1;
protected void setUp() throws Exception {
inputBytes = input.getBytes();
iter = new JsonIterator();
modelTypeLiteral = new TypeLiteral<Model>() {
};
}
Reported by PMD.
Line: 34
};
}
public void test_for_iterator() throws Exception {
iter.reset(inputBytes);
Model m2 = iter.read(modelTypeLiteral);
fastjson();
for (int i = 0; i < 5; ++i) {
Reported by PMD.