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.
bug fixed for Comparable deserialize, for issue #1834
- Loading branch information
Showing
2 changed files
with
72 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
65 changes: 65 additions & 0 deletions
65
src/test/java/com/alibaba/json/bvt/issue_1800/Issue1834.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,65 @@ | ||
package com.alibaba.json.bvt.issue_1800; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.TypeReference; | ||
import junit.framework.TestCase; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Issue1834 extends TestCase { | ||
public void test_for_issue() throws Exception { | ||
IndexQuery_Number query_number = new IndexQuery_Number(); | ||
IndexQuery_Comparable query_comparable = new IndexQuery_Comparable(); | ||
List<Integer> keys = Arrays.asList(1234); | ||
query_number.setKeys(keys); | ||
query_comparable.setKeys(keys); | ||
|
||
String json1 = JSON.toJSONString(query_number); | ||
System.out.println(json1); | ||
IndexQuery_Number queryNumber = JSON.parseObject(json1, new TypeReference<IndexQuery_Number>(){}); | ||
|
||
String json2 = JSON.toJSONString(query_comparable); | ||
System.out.println(json2); | ||
IndexQuery_Comparable queryComparable = JSON.parseObject(json2, new TypeReference<IndexQuery_Comparable>(){}); | ||
} | ||
|
||
static class IndexQuery_Comparable{ | ||
List<? extends Comparable> keys; | ||
|
||
public List<? extends Comparable> getKeys() { | ||
return keys; | ||
} | ||
|
||
public void setKeys(List<? extends Comparable> keys) { | ||
this.keys = keys; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "IndexQuery{" + | ||
"keys=" + keys + | ||
'}'; | ||
} | ||
} | ||
|
||
static class IndexQuery_Number{ | ||
List<? extends Number> keys; | ||
|
||
public List<? extends Number> getKeys() { | ||
return keys; | ||
} | ||
|
||
public void setKeys(List<? extends Number> keys) { | ||
this.keys = keys; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "IndexQuery{" + | ||
"keys=" + keys + | ||
'}'; | ||
} | ||
} | ||
|
||
} |