-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
201 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
project.version=${project.version} | ||
project.name=${project.name} | ||
project.auxiliary_flag= | ||
project.java.version=${maven.compiler.source} |
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
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
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,57 @@ | ||
package com.sinch.sdk; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.adelean.inject.resources.junit.jupiter.TestWithResources; | ||
import com.sinch.sdk.core.exceptions.ApiException; | ||
import com.sinch.sdk.models.Configuration; | ||
import java.io.IOException; | ||
import okhttp3.mockwebserver.MockResponse; | ||
import okhttp3.mockwebserver.MockWebServer; | ||
import okhttp3.mockwebserver.RecordedRequest; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@TestWithResources | ||
class SinchClientTestIT extends BaseTest { | ||
static MockWebServer mockBackEnd; | ||
String serverUrl = String.format("http://localhost:%s", mockBackEnd.getPort()); | ||
|
||
Configuration configuration = | ||
Configuration.builder() | ||
.setKeyId("foo") | ||
.setKeySecret("foo") | ||
.setProjectId("foo") | ||
.setNumbersUrl(serverUrl) | ||
.build(); | ||
|
||
SinchClient sinchClient = new SinchClient(configuration); | ||
|
||
@BeforeAll | ||
static void classSetUp() throws IOException { | ||
mockBackEnd = new MockWebServer(); | ||
mockBackEnd.start(); | ||
} | ||
|
||
@AfterAll | ||
static void tearDown() throws IOException { | ||
mockBackEnd.shutdown(); | ||
} | ||
|
||
@Test | ||
void sdkUserAgent() throws InterruptedException { | ||
|
||
mockBackEnd.enqueue( | ||
new MockResponse().setBody("foo").addHeader("Content-Type", "application/json")); | ||
|
||
try { | ||
sinchClient.numbers().available().checkAvailability("foo"); | ||
} catch (ApiException ae) { | ||
// noop | ||
} | ||
RecordedRequest recordedRequest = mockBackEnd.takeRequest(); | ||
String header = recordedRequest.getHeader("User-Agent"); | ||
assertThat(header).matches("^sinch-sdk/.* \\(Java/.*; Apache; .*\\)$"); | ||
} | ||
} |
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
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
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