Skip to content

Commit 97b00eb

Browse files
committed
refactor android tests to categorize under each service it's testing
1 parent 3e88096 commit 97b00eb

File tree

16 files changed

+2512
-1482
lines changed

16 files changed

+2512
-1482
lines changed

src/AndroidClient/android/build.gradle

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ android {
2020
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2121
}
2222
}
23-
packagingOptions {
24-
exclude 'META-INF/DEPENDENCIES'
25-
exclude 'META-INF/NOTICE'
26-
exclude 'META-INF/NOTICE.txt'
27-
exclude 'META-INF/LICENSE'
28-
exclude 'META-INF/LICENSE.txt'
29-
}
3023
}
3124

3225
Properties properties = System.properties;
@@ -97,13 +90,10 @@ install {
9790
}
9891
}
9992

100-
10193
dependencies {
94+
compile 'com.google.code.gson:gson:2.4'
10295
compile 'com.android.support:appcompat-v7:21.0.3'
103-
compile project(':client')
10496
compile fileTree(include: '*.jar', dir: 'libs')
10597
testCompile 'junit:junit:4.11'
10698
testCompile 'org.mockito:mockito-core:1.9.5'
10799
}
108-
109-
configurations.compile.exclude group: 'org.apache.httpcomponents'

src/AndroidClient/android/src/androidTest/java/net/servicestack/android/ExtendedRockstar.java renamed to src/AndroidClient/android/src/androidTest/java/net/servicestack/android/checkweb/ExtendedRockstar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package net.servicestack.android;
1+
package net.servicestack.android.checkweb;
22

33
/**
44
* Created by mythz on 6/30/2015.
55
*/
6-
public class ExtendedRockstar extends dto.Rockstar {
6+
public class ExtendedRockstar extends dtos.Rockstar {
77
public Integer ExtendedId = null;
88

99
public ExtendedRockstar(Integer extendedId) {
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Copyright (c) 2015 ServiceStack LLC. All rights reserved.
2+
3+
package net.servicestack.android.checkweb;
4+
5+
import com.google.gson.Gson;
6+
7+
import junit.framework.TestCase;
8+
9+
import net.servicestack.android.checkweb.dtos.*;
10+
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
public class GsonTests extends TestCase {
15+
16+
public GsonTests() {
17+
18+
}
19+
20+
public void test_Gson() {
21+
System.out.println("=========== HELLO JSON ============");
22+
23+
String json = "{\n" +
24+
" \"posts\": [\n" +
25+
" {\n" +
26+
" \"post\": {\n" +
27+
" \"username\": \"John\",\n" +
28+
" \"message\": \"I'm back\",\n" +
29+
" \"time\": \"2010-5-6 7:00:34\"\n" +
30+
" }\n" +
31+
" },\n" +
32+
" {\n" +
33+
" \"post\": {\n" +
34+
" \"username\": \"Smith\",\n" +
35+
" \"message\": \"I've been waiting\",\n" +
36+
" \"time\": \"2010-4-6 10:30:26\"\n" +
37+
" }\n" +
38+
" }\n" +
39+
" ]\n" +
40+
"}";
41+
42+
Gson gson = new Gson();
43+
PostList list = gson.fromJson(json, PostList.class);
44+
45+
System.out.println("JSON: " + gson.toJson(list));
46+
}
47+
48+
public class PostList {
49+
private List<PostContainer> posts = new ArrayList<>();
50+
51+
public List<PostContainer> getPostContainterList() {
52+
return posts;
53+
}
54+
}
55+
56+
class PostContainer {
57+
Posts post;
58+
public Posts getPost() {
59+
return post;
60+
}
61+
}
62+
63+
public class Posts {
64+
String message;
65+
String time;
66+
String username;
67+
}
68+
69+
public static class dto
70+
{
71+
public static class Foo {
72+
Integer fooId;
73+
String fooName;
74+
}
75+
public static class Bar {
76+
Integer barId;
77+
String barName;
78+
Foo foo;
79+
}
80+
}
81+
82+
class NestedPojo {
83+
dto.Foo foo;
84+
dto.Bar bar;
85+
public Integer version = 1;
86+
}
87+
88+
class NestedList extends ArrayList<NestedPojo> {
89+
90+
}
91+
public static interface MetadataTestChild
92+
{
93+
public String name = null;
94+
// ArrayList<MetadataTestNestedChild> results;
95+
}
96+
97+
public void test_Can_serialize_nested_classes() {
98+
NestedPojo o = new NestedPojo();
99+
o.foo = new dto.Foo();
100+
o.foo.fooId = 1;
101+
o.foo.fooName = "foo";
102+
103+
o.bar = new dto.Bar();
104+
o.bar.barId = 2;
105+
o.bar.barName = "bar";
106+
107+
List<NestedPojo> list = new ArrayList<>();
108+
list.add(o);
109+
list.add(o);
110+
list.add(o);
111+
112+
Gson gson = new Gson();
113+
System.out.println("JSON LIST: " + gson.toJson(list));
114+
115+
Class a = NestedPojo.class;
116+
}
117+
118+
public void test_Can_deserialize_Hello() {
119+
String json = "{\"Result\":\"World\"}\n";
120+
121+
Gson gson = new Gson();
122+
123+
HelloResponse response = gson.fromJson(json, HelloResponse.class);
124+
125+
assertEquals("World", response.getResult());
126+
}
127+
}

src/AndroidClient/android/src/androidTest/java/net/servicestack/android/dto.java renamed to src/AndroidClient/android/src/androidTest/java/net/servicestack/android/checkweb/dtos.java

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Version: 1
44
BaseUrl: http://localhost:2020
55
6-
Package: servicestack.net.client.tests
6+
Package: net.servicestack.android.checkweb
77
//GlobalNamespace: dto
88
//AddPropertyAccessors: True
99
//SettersReturnThis: True
@@ -15,15 +15,29 @@
1515
//DefaultImports: java.math.*,java.util.*,net.servicestack.client.*
1616
*/
1717

18-
package net.servicestack.android;
19-
20-
import com.google.gson.annotations.SerializedName;
21-
22-
import java.math.*;
23-
import java.util.*;
24-
import net.servicestack.client.*;
25-
26-
public class dto
18+
package net.servicestack.android.checkweb;
19+
20+
import net.servicestack.client.Api;
21+
import net.servicestack.client.ApiMember;
22+
import net.servicestack.client.DataContract;
23+
import net.servicestack.client.DataMember;
24+
import net.servicestack.client.Flags;
25+
import net.servicestack.client.IReturn;
26+
import net.servicestack.client.IReturnVoid;
27+
import net.servicestack.client.Required;
28+
import net.servicestack.client.ResponseStatus;
29+
import net.servicestack.client.Route;
30+
import net.servicestack.client.StringLength;
31+
import net.servicestack.client.TimeSpan;
32+
33+
import java.math.BigDecimal;
34+
import java.math.BigInteger;
35+
import java.util.ArrayList;
36+
import java.util.Date;
37+
import java.util.HashMap;
38+
import java.util.UUID;
39+
40+
public class dtos
2741
{
2842

2943
public static class QueryBase_1<T> extends QueryBase

0 commit comments

Comments
 (0)