Skip to content

Commit 8fdb64e

Browse files
committed
fix tests
1 parent e320c20 commit 8fdb64e

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

pom.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,31 @@
77
<version>0.9.1</version>
88
<artifactId>jsoniter</artifactId>
99
<name>json iterator</name>
10+
<description>json iterator is fast and easy to use json parser</description>
1011
<url>http://jsoniter.com</url>
12+
<packaging>jar</packaging>
13+
14+
<licenses>
15+
<license>
16+
<name>MIT License</name>
17+
<url>http://www.opensource.org/licenses/mit-license.php</url>
18+
</license>
19+
</licenses>
20+
21+
<developers>
22+
<developer>
23+
<name>Tao Wen</name>
24+
<email>taowen@gmail.com</email>
25+
<organization>jsoniter</organization>
26+
<organizationUrl>http://jsoniter.com</organizationUrl>
27+
</developer>
28+
</developers>
29+
30+
<scm>
31+
<connection>scm:git:git://github.com/json-iterator/java.git</connection>
32+
<developerConnection>scm:git:ssh://github.com:json-iterator/java.git</developerConnection>
33+
<url>http://github.com/json-iterator/java/tree/master</url>
34+
</scm>
1135

1236
<properties>
1337
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.jsoniter;
2+
3+
public class CustomizedObject {
4+
public String field2;
5+
public String field1;
6+
7+
@Override
8+
public boolean equals(Object o) {
9+
if (this == o) return true;
10+
11+
CustomizedObject that = (CustomizedObject) o;
12+
13+
if (field2 != null ? !field2.equals(that.field2) : that.field2 != null) return false;
14+
return field1 != null ? field1.equals(that.field1) : that.field1 == null;
15+
16+
}
17+
18+
@Override
19+
public int hashCode() {
20+
int result = field2 != null ? field2.hashCode() : 0;
21+
result = 31 * result + (field1 != null ? field1.hashCode() : 0);
22+
return result;
23+
}
24+
}

test/main/java/com/jsoniter/TestCustomize.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,18 @@ public Object decode(Type type, Jsoniter iter) throws IOException {
1717
Jsoniter iter = Jsoniter.parse("1481365190000");
1818
Date date = iter.read(Date.class);
1919
assertEquals(1481365190000L, date.getTime());
20-
Jsoniter.clearDecoders();
2120
}
2221

2322
public void test_customize_field() throws IOException {
24-
Jsoniter.registerFieldDecoder(SimpleObject.class, "field1", new Decoder(){
23+
Jsoniter.registerFieldDecoder(CustomizedObject.class, "field1", new Decoder(){
2524

2625
@Override
2726
public Object decode(Type type, Jsoniter iter) throws IOException {
2827
return Integer.toString(iter.readInt());
2928
}
3029
});
3130
Jsoniter iter = Jsoniter.parse("{'field1': 100}".replace('\'', '"'));
32-
SimpleObject myObject = iter.read(SimpleObject.class);
31+
CustomizedObject myObject = iter.read(CustomizedObject.class);
3332
assertEquals("100", myObject.field1);
34-
Jsoniter.clearDecoders();
3533
}
3634
}

0 commit comments

Comments
 (0)