Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fixed for jsoncreator primive type default values. issue #802
- Loading branch information
Showing
9 changed files
with
252 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_boolean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.alibaba.json.bvt.parser.creator; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONCreator; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONCreatorTest_default_boolean extends TestCase { | ||
|
||
public void test_create() throws Exception { | ||
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class); | ||
Assert.assertFalse(model.id); | ||
Assert.assertEquals("wenshao", model.name); | ||
} | ||
|
||
|
||
public static class Model { | ||
|
||
private final boolean id; | ||
private final String name; | ||
|
||
@JSONCreator | ||
public Model(@JSONField(name="id") boolean id, @JSONField(name="name") String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} | ||
|
||
public static class Value { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_byte.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.alibaba.json.bvt.parser.creator; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONCreator; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONCreatorTest_default_byte extends TestCase { | ||
|
||
public void test_create() throws Exception { | ||
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class); | ||
Assert.assertEquals(0, model.id); | ||
Assert.assertEquals("wenshao", model.name); | ||
} | ||
|
||
|
||
public static class Model { | ||
|
||
private final byte id; | ||
private final String name; | ||
|
||
@JSONCreator | ||
public Model(@JSONField(name="id") byte id, @JSONField(name="name") String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} | ||
|
||
public static class Value { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_double.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.alibaba.json.bvt.parser.creator; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONCreator; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONCreatorTest_default_double extends TestCase { | ||
|
||
public void test_create() throws Exception { | ||
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class); | ||
Assert.assertTrue(model.id == 0); | ||
Assert.assertEquals("wenshao", model.name); | ||
} | ||
|
||
|
||
public static class Model { | ||
|
||
private final double id; | ||
private final String name; | ||
|
||
@JSONCreator | ||
public Model(@JSONField(name="id") double id, @JSONField(name="name") String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} | ||
|
||
public static class Value { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_float.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.alibaba.json.bvt.parser.creator; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONCreator; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONCreatorTest_default_float extends TestCase { | ||
|
||
public void test_create() throws Exception { | ||
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class); | ||
Assert.assertTrue(model.id == 0); | ||
Assert.assertEquals("wenshao", model.name); | ||
} | ||
|
||
|
||
public static class Model { | ||
|
||
private final float id; | ||
private final String name; | ||
|
||
@JSONCreator | ||
public Model(@JSONField(name="id") float id, @JSONField(name="name") String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} | ||
|
||
public static class Value { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_int.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.alibaba.json.bvt.parser.creator; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONCreator; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONCreatorTest_default_int extends TestCase { | ||
|
||
public void test_create() throws Exception { | ||
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class); | ||
Assert.assertEquals(0, model.id); | ||
Assert.assertEquals("wenshao", model.name); | ||
} | ||
|
||
|
||
public static class Model { | ||
|
||
private final int id; | ||
private final String name; | ||
|
||
@JSONCreator | ||
public Model(@JSONField(name="id") int id, @JSONField(name="name") String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} | ||
|
||
public static class Value { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_long.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.alibaba.json.bvt.parser.creator; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONCreator; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONCreatorTest_default_long extends TestCase { | ||
|
||
public void test_create() throws Exception { | ||
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class); | ||
Assert.assertEquals(0, model.id); | ||
Assert.assertEquals("wenshao", model.name); | ||
} | ||
|
||
|
||
public static class Model { | ||
|
||
private final long id; | ||
private final String name; | ||
|
||
@JSONCreator | ||
public Model(@JSONField(name="id") long id, @JSONField(name="name") String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} | ||
|
||
public static class Value { | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_short.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.alibaba.json.bvt.parser.creator; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONCreator; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
public class JSONCreatorTest_default_short extends TestCase { | ||
|
||
public void test_create() throws Exception { | ||
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class); | ||
Assert.assertEquals(0, model.id); | ||
Assert.assertEquals("wenshao", model.name); | ||
} | ||
|
||
|
||
public static class Model { | ||
|
||
private final short id; | ||
private final String name; | ||
|
||
@JSONCreator | ||
public Model(@JSONField(name="id") short id, @JSONField(name="name") String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} | ||
|
||
public static class Value { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters