Skip to content

Commit

Permalink
removed deprecated api DefaultExtJSONParser
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 6, 2016
1 parent 2930820 commit 12e84b5
Show file tree
Hide file tree
Showing 38 changed files with 189 additions and 231 deletions.

This file was deleted.

Expand Up @@ -5,15 +5,15 @@
import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;

@SuppressWarnings("deprecation")
public class DateParserTest_sql extends TestCase {

public void f_test_date_0() throws Exception {
DefaultExtJSONParser parser = new DefaultExtJSONParser("1294552193254");
DefaultJSONParser parser = new DefaultJSONParser("1294552193254");

java.sql.Date date = parser.parseObject(java.sql.Date.class);

Expand All @@ -25,7 +25,7 @@ public void f_test_date_0() throws Exception {
public void test_date_1() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);

java.sql.Date date = parser.parseObject(java.sql.Date.class);

Expand All @@ -35,7 +35,7 @@ public void test_date_1() throws Exception {

public void test_date_2() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
DefaultExtJSONParser parser = new DefaultExtJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);

java.sql.Date date = parser.parseObject(java.sql.Date.class);

Expand All @@ -46,7 +46,7 @@ public void test_date_2() throws Exception {
public void test_date_3() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);

java.sql.Date date = parser.parseObject(java.sql.Date.class);

Expand All @@ -57,7 +57,7 @@ public void test_date_3() throws Exception {
public void test_date_4() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);

java.sql.Date date = parser.parseObject(java.sql.Date.class);

Expand Down
Expand Up @@ -5,15 +5,15 @@
import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;

@SuppressWarnings("deprecation")
public class DateParserTest_sql_timestamp extends TestCase {

public void f_test_date_0() throws Exception {
DefaultExtJSONParser parser = new DefaultExtJSONParser("1294552193254");
DefaultJSONParser parser = new DefaultJSONParser("1294552193254");

java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);

Expand All @@ -24,7 +24,7 @@ public void f_test_date_0() throws Exception {
public void test_date_1() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);

java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);

Expand All @@ -34,7 +34,7 @@ public void test_date_1() throws Exception {

public void test_date_2() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
DefaultExtJSONParser parser = new DefaultExtJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);

java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);

Expand All @@ -45,7 +45,7 @@ public void test_date_2() throws Exception {
public void test_date_3() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);

java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);

Expand All @@ -56,7 +56,7 @@ public void test_date_3() throws Exception {
public void test_date_4() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);

java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);

Expand Down
Expand Up @@ -40,18 +40,18 @@

import org.junit.Assert;

import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.DefaultExtJSONParser;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.util.TypeUtils;

import junit.framework.TestCase;

public class DefaultExtJSONParserTest extends TestCase {

public void test_parseObject() {
new DefaultExtJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
new DefaultJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 0).close();
User user = new User();
user.setName("校长");
user.setAge(3);
Expand All @@ -63,7 +63,7 @@ public void test_parseObject() {

JSON.parseObject(jsonString);

DefaultExtJSONParser parser = new DefaultExtJSONParser(jsonString);
DefaultJSONParser parser = new DefaultJSONParser(jsonString);
User user1 = new User();
parser.parseObject(user1);

Expand All @@ -80,7 +80,7 @@ public void testCastCalendar() throws Exception {

public void testCast() throws Exception {
new TypeUtils();
DefaultExtJSONParser parser = new DefaultExtJSONParser("");
DefaultJSONParser parser = new DefaultJSONParser("");

Assert.assertNull(castToByte(null));
Assert.assertNull(castToShort(null));
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testCast() throws Exception {
}

public void test_casterror2() {
DefaultExtJSONParser parser = new DefaultExtJSONParser("");
DefaultJSONParser parser = new DefaultJSONParser("");
{
Exception error = null;
try {
Expand Down Expand Up @@ -228,7 +228,7 @@ public void test_casterror2() {
}

public void test_casterror() {
DefaultExtJSONParser parser = new DefaultExtJSONParser("");
DefaultJSONParser parser = new DefaultJSONParser("");

{
Exception error = null;
Expand Down Expand Up @@ -330,19 +330,19 @@ public void test_parseArrayWithType() throws Exception {
Type[] types = method.getGenericParameterTypes();
{
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[0])).get(0) instanceof Map);
}
{
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[1])).get(0) instanceof User);
}
{
Exception error = null;
try {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseArrayWithType(types[2]);
;
} catch (Exception ex) {
Expand All @@ -352,14 +352,14 @@ public void test_parseArrayWithType() throws Exception {
}
{
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[3])).get(0) instanceof User);
}
{
Exception error = null;
try {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseArrayWithType(types[4]);
;
} catch (Exception ex) {
Expand All @@ -369,15 +369,15 @@ public void test_parseArrayWithType() throws Exception {
}
{
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[5])).get(0) instanceof User);
}

{
Exception error = null;
try {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseArrayWithType(types[6]);
;
} catch (Exception ex) {
Expand All @@ -395,7 +395,7 @@ public void test_parseArrayWithType_error_1() throws Exception {
Exception error = null;
try {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseArrayWithType(types[6]);
;
} catch (Exception ex) {
Expand All @@ -412,15 +412,15 @@ public static <T extends Object & Comparable<? super T>, T1 extends User> void f

public void test_not_match() throws Exception {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123, \"kxxx\":33}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
Assert.assertEquals(true, (parser.parseArray(User.class).get(0) instanceof User));
}

public void test_not_match_error() throws Exception {
Exception error = null;
try {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123, \"kxxx\":33}]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.config(Feature.IgnoreNotMatch, false);
Assert.assertEquals(true, (parser.parseArray(User.class).get(0) instanceof User));
} catch (Exception ex) {
Expand All @@ -434,7 +434,7 @@ public void test_error() throws Exception {
Exception error = null;
try {
String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123]";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseArray(User.class);
} catch (Exception ex) {
error = ex;
Expand All @@ -445,7 +445,7 @@ public void test_error() throws Exception {
Exception error = null;
try {
String text = "{\"reader\":3}";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseObject(ErrorObject.class);
} catch (Exception ex) {
error = ex;
Expand All @@ -456,7 +456,7 @@ public void test_error() throws Exception {
Exception error = null;
try {
String text = "{\"name\":3}";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseObject(ErrorObject2.class);
} catch (Exception ex) {
error = ex;
Expand Down Expand Up @@ -497,7 +497,7 @@ public void test_error2() throws Exception {
Exception error = null;
try {
String text = "{}";
DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseArray(User.class);
} catch (Exception ex) {
error = ex;
Expand Down

0 comments on commit 12e84b5

Please sign in to comment.