forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
98 additions
and
1 deletion.
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
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
81 changes: 81 additions & 0 deletions
81
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1276.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,81 @@ | ||
package com.alibaba.json.bvt.issue_1200; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONType; | ||
import com.alibaba.fastjson.serializer.JSONSerializer; | ||
import com.alibaba.fastjson.serializer.NameFilter; | ||
import junit.framework.TestCase; | ||
|
||
/** | ||
* Created by kimmking on 15/06/2017. | ||
*/ | ||
public class Issue1276 extends TestCase { | ||
public void test_for_issue() throws Exception { | ||
|
||
MyException myException = new MyException(100,"error msg"); | ||
String str= JSON.toJSONString(myException); | ||
System.out.println(str); | ||
|
||
Object me = JSON.parseObject(str, MyException.class); | ||
MyException myExceptionJson = (MyException)me; | ||
assertEquals(myException.code, myExceptionJson.code); | ||
|
||
} | ||
|
||
public static class MyException extends RuntimeException{ | ||
private static final long serialVersionUID = 7815426752583648734L; | ||
private long code; | ||
|
||
public MyException() { | ||
super(); | ||
} | ||
|
||
public MyException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public MyException(String message) { | ||
super(message); | ||
} | ||
|
||
public MyException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public MyException(long code) { | ||
super(); | ||
this.code = code; | ||
} | ||
|
||
public MyException(long code, String message, Throwable cause) { | ||
super(message, cause); | ||
this.code = code; | ||
} | ||
|
||
public MyException(long code, String message) { | ||
super(message); | ||
this.code = code; | ||
} | ||
|
||
public MyException(long code, Throwable cause) { | ||
super(cause); | ||
this.code = code; | ||
} | ||
|
||
public void setCode(long code) { | ||
this.code = code; | ||
} | ||
|
||
public long getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MyException{" + | ||
"code=" + code + | ||
'}'; | ||
} | ||
} | ||
|
||
} |