@@ -28,30 +28,16 @@ public void testUseThreadLocal() {
28
28
assertEquals ("tx" , Intercom .getToken ());
29
29
}
30
30
31
- @ Test
32
- public void testApiKey () {
33
- Intercom .setApiKey ("k1" );
34
- assertEquals ("k1" , Intercom .getApiKey ());
35
- assertEquals (Intercom .AuthKeyType .API_KEY , Intercom .getAuthKeyType ());
36
- assertNull (Intercom .getToken ());
37
- }
38
-
39
31
@ Test
40
32
public void testToken () {
41
33
Intercom .setToken ("t1" );
42
34
assertEquals ("t1" , Intercom .getToken ());
43
- assertEquals (Intercom .AuthKeyType .TOKEN , Intercom .getAuthKeyType ());
44
- assertNull (Intercom .getApiKey ());
45
35
}
46
36
47
37
@ Test
48
38
public void testStaticContext () throws Exception {
49
- Intercom .setApiKey ("k1" );
50
- assertEquals ("k1" , Intercom .getApiKey ());
51
- assertNull (Intercom .getToken ());
52
- assertEquals (Intercom .AuthKeyType .API_KEY , Intercom .getAuthKeyType ());
53
- Intercom .setAppID ("app1" );
54
- assertEquals ("app1" , Intercom .getAppID ());
39
+ Intercom .setToken ("t1" );
40
+ assertEquals ("t1" , Intercom .getToken ());
55
41
Intercom .setConnectionTimeout (98765 );
56
42
assertEquals (98765 , Intercom .getConnectionTimeout ());
57
43
Intercom .setRequestTimeout (12345 );
@@ -66,15 +52,11 @@ public void testStaticContext() throws Exception {
66
52
tt1 .waitUntilComplete ();
67
53
tt2 .waitUntilComplete ();
68
54
69
- assertEquals (Intercom .getApiKey (), tt1 .apiKey );
70
- assertEquals (Intercom .getAuthKeyType (), tt1 .authKeyType );
71
55
assertEquals (Intercom .getToken (), tt1 .token );
72
56
assertEquals (Intercom .getConnectionTimeout (), tt1 .connectionTimeout );
73
57
assertEquals (Intercom .getRequestTimeout (), tt1 .requestTimeout );
74
58
assertEquals (Intercom .isRequestUsingCaches (), tt1 .requestUsingCaches );
75
59
76
- assertEquals (Intercom .getApiKey (), tt2 .apiKey );
77
- assertEquals (Intercom .getAuthKeyType (), tt2 .authKeyType );
78
60
assertEquals (Intercom .getToken (), tt2 .token );
79
61
assertEquals (Intercom .getConnectionTimeout (), tt2 .connectionTimeout );
80
62
assertEquals (Intercom .getRequestTimeout (), tt2 .requestTimeout );
@@ -93,15 +75,11 @@ public void testThreadLocalContext() throws Exception {
93
75
tt2 .waitUntilComplete ();
94
76
95
77
assertEquals (tt1 .localToken , tt1 .token );
96
- assertNull (tt1 .apiKey );
97
- assertEquals (Intercom .AuthKeyType .TOKEN , tt1 .authKeyType );
98
78
assertEquals (tt1 .localConnectionTimeout , tt1 .connectionTimeout );
99
79
assertEquals (tt1 .localRequestTimeout , tt1 .requestTimeout );
100
80
assertEquals (tt1 .localRequestUsingCaches , tt1 .requestUsingCaches );
101
81
102
- assertEquals (tt2 .localApiKey , tt2 .apiKey );
103
- assertNull (tt2 .token );
104
- assertEquals (Intercom .AuthKeyType .API_KEY , tt2 .authKeyType );
82
+ assertEquals (tt2 .localToken , tt2 .token );
105
83
assertEquals (tt2 .localConnectionTimeout , tt2 .connectionTimeout );
106
84
assertEquals (tt2 .localRequestTimeout , tt2 .requestTimeout );
107
85
assertEquals (tt2 .localRequestUsingCaches , tt2 .requestUsingCaches );
@@ -111,44 +89,40 @@ public void testThreadLocalContext() throws Exception {
111
89
public void testClearThreadLocalContexts () throws Exception {
112
90
Intercom .setUseThreadLocal (true );
113
91
114
- Intercom .setApiKey ( "testKey " );
115
- assertEquals ("testKey " , Intercom .getApiKey ());
92
+ Intercom .setToken ( "testToken " );
93
+ assertEquals ("testToken " , Intercom .getToken ());
116
94
117
95
Intercom .clearThreadLocalContexts ();
118
- assertNull (Intercom .getApiKey ());
96
+ assertNull (Intercom .getToken ());
119
97
120
- Intercom .setApiKey ( "testKey2 " );
121
- assertEquals ("testKey2 " , Intercom .getApiKey ());
98
+ Intercom .setToken ( "testToken2 " );
99
+ assertEquals ("testToken2 " , Intercom .getToken ());
122
100
}
123
101
124
102
@ Test
125
103
public void testClearThreadLocalContext () throws Exception {
126
104
Intercom .setUseThreadLocal (true );
127
105
128
- Intercom .setApiKey ( "testKey " );
129
- assertEquals ("testKey " , Intercom .getApiKey ());
106
+ Intercom .setToken ( "testToken " );
107
+ assertEquals ("testToken " , Intercom .getToken ());
130
108
131
109
Intercom .clearThreadLocalContext ();
132
- assertNull (Intercom .getApiKey ());
110
+ assertNull (Intercom .getToken ());
133
111
134
- Intercom .setApiKey ( "testKey2 " );
135
- assertEquals ("testKey2 " , Intercom .getApiKey ());
112
+ Intercom .setToken ( "testToken2 " );
113
+ assertEquals ("testToken2 " , Intercom .getToken ());
136
114
}
137
115
138
116
class ThreadTester implements Runnable {
139
- String apiKey , appId , token ;
140
- Intercom .AuthKeyType authKeyType ;
117
+ String token ;
141
118
int connectionTimeout = -1 ;
142
119
int requestTimeout = -1 ;
143
120
Boolean requestUsingCaches ;
144
121
boolean completed = false ;
145
122
146
123
@ Override
147
124
public void run () {
148
- apiKey = Intercom .getApiKey ();
149
- authKeyType = Intercom .getAuthKeyType ();
150
125
token = Intercom .getToken ();
151
- appId = Intercom .getAppID ();
152
126
connectionTimeout = Intercom .getConnectionTimeout ();
153
127
requestTimeout = Intercom .getRequestTimeout ();
154
128
requestUsingCaches = Intercom .isRequestUsingCaches ();
@@ -170,7 +144,6 @@ void waitUntilComplete() throws InterruptedException {
170
144
class ThreadLocalTester1 extends ThreadTester {
171
145
final Random rnd = new Random ();
172
146
final String localToken = "tx" ;
173
- final String localAppId = "appx" ;
174
147
final int localConnectionTimeout = rnd .nextInt ();
175
148
final int localRequestTimeout = rnd .nextInt ();
176
149
final boolean localRequestUsingCaches = rnd .nextBoolean ();
@@ -179,7 +152,6 @@ class ThreadLocalTester1 extends ThreadTester {
179
152
public void run () {
180
153
Intercom .clearThreadLocalContext ();
181
154
Intercom .setToken (localToken );
182
- Intercom .setAppID (localAppId );
183
155
Intercom .setConnectionTimeout (localConnectionTimeout );
184
156
Intercom .setRequestTimeout (localRequestTimeout );
185
157
Intercom .setRequestUsingCaches (localRequestUsingCaches );
@@ -189,17 +161,15 @@ public void run() {
189
161
190
162
class ThreadLocalTester2 extends ThreadTester {
191
163
final Random rnd = new Random ();
192
- final String localApiKey = "api" ;
193
- final String localAppId = "appId" ;
164
+ final String localToken = "t2" ;
194
165
final int localConnectionTimeout = rnd .nextInt ();
195
166
final int localRequestTimeout = rnd .nextInt ();
196
167
final boolean localRequestUsingCaches = rnd .nextBoolean ();
197
168
198
169
@ Override
199
170
public void run () {
200
171
Intercom .clearThreadLocalContext ();
201
- Intercom .setApiKey (localApiKey );
202
- Intercom .setAppID (localAppId );
172
+ Intercom .setToken (localToken );
203
173
Intercom .setConnectionTimeout (localConnectionTimeout );
204
174
Intercom .setRequestTimeout (localRequestTimeout );
205
175
Intercom .setRequestUsingCaches (localRequestUsingCaches );
0 commit comments