forked from ringcentral/ringcentral-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OkHttpClientTest.java
34 lines (30 loc) · 1.32 KB
/
OkHttpClientTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.ringcentral;
import okhttp3.*;
import java.util.concurrent.TimeUnit;
import com.ringcentral.definitions.CreateSMSMessage;
import com.ringcentral.definitions.MessageStoreCallerInfoRequest;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.*;
public class OkHttpClientTest extends BaseTest {
@Test
public void testTimeout() throws IOException, RestException {
restClient.SetOkHttpClient(new OkHttpClient.Builder()
.connectTimeout(1, TimeUnit.MILLISECONDS)
.writeTimeout(1, TimeUnit.MILLISECONDS)
.readTimeout(1, TimeUnit.MILLISECONDS)
.build()
);
CreateSMSMessage postParameters = new CreateSMSMessage();
postParameters.from = new MessageStoreCallerInfoRequest().phoneNumber(config.get("username"));
postParameters.to = new MessageStoreCallerInfoRequest[]{new MessageStoreCallerInfoRequest().phoneNumber(config.get("receiver"))};
postParameters.text = "hello world";
try{
restClient.post("/restapi/v1.0/account/~/extension/~/sms", postParameters).string();
fail("Expected java.net.SocketTimeoutException was not thrown");
} catch(java.net.SocketTimeoutException e) {
} finally {
restClient.SetOkHttpClient(new OkHttpClient());
}
}
}