This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1506 from kimmking/master
fix #1500
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 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
63 changes: 63 additions & 0 deletions
63
src/test/java/com/alibaba/json/bvt/issue_1500/Issue1500.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,63 @@ | ||
package com.alibaba.json.bvt.issue_1500; | ||
|
||
import clojure.lang.Obj; | ||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.parser.ParserConfig; | ||
import com.alibaba.fastjson.serializer.SerializerFeature; | ||
import junit.framework.TestCase; | ||
import org.junit.Assert; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Issue1500 extends TestCase { | ||
|
||
|
||
public void test_for_issue() throws Exception { | ||
|
||
// test aa | ||
Aa aa = new Aa(); | ||
aa.setName("aa"); | ||
String jsonAa = JSON.toJSONString(aa); | ||
Aa aa1 = JSON.parseObject(jsonAa, Aa.class); | ||
Assert.assertEquals("aa",aa1.getName()); | ||
|
||
// test C | ||
C c = new C(); | ||
c.setE(aa); | ||
String jsonC = JSON.toJSONString(c, SerializerFeature.WriteClassName); | ||
C c2 = JSON.parseObject(jsonC, C.class); | ||
Assert.assertEquals("Aa",c2.getE().getClass().getSimpleName()); | ||
Assert.assertEquals("aa",((Aa)c2.getE()).getName()); | ||
} | ||
|
||
public static class Aa extends Exception { | ||
|
||
public Aa(){ | ||
} | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} | ||
public static class C { | ||
|
||
private Exception e; | ||
|
||
public Exception getE() { | ||
return e; | ||
} | ||
|
||
public void setE(Exception e) { | ||
this.e = e; | ||
} | ||
|
||
} | ||
|
||
} |