extend unit tests for UraClientConfiguration
Timeout values are tested in different cases, but for completeness the unit test for UraClientConfiguration checks the values now, too.
This commit is contained in:
@ -2,7 +2,10 @@ package de.stklcode.pubtrans.ura;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for {@link UraClientConfiguration}.
|
* Unit test for {@link UraClientConfiguration}.
|
||||||
@ -15,12 +18,16 @@ public class UraClientConfigurationTest {
|
|||||||
final String baseURL = "https://ura.example.com";
|
final String baseURL = "https://ura.example.com";
|
||||||
final String instantPath = "/path/to/instant";
|
final String instantPath = "/path/to/instant";
|
||||||
final String streamPath = "/path/to/stream";
|
final String streamPath = "/path/to/stream";
|
||||||
|
final Duration timeout = Duration.ofSeconds(2);
|
||||||
|
final Duration conTimeout = Duration.ofSeconds(41);
|
||||||
|
|
||||||
// With Base-URL only.
|
// With Base-URL only.
|
||||||
UraClientConfiguration config = UraClientConfiguration.forBaseURL(baseURL).build();
|
UraClientConfiguration config = UraClientConfiguration.forBaseURL(baseURL).build();
|
||||||
assertEquals(baseURL, config.getBaseURL(), "Unexpected base URL");
|
assertEquals(baseURL, config.getBaseURL(), "Unexpected base URL");
|
||||||
assertEquals("/interfaces/ura/instant_V1", config.getInstantPath(), "Unexpected default instant path");
|
assertEquals("/interfaces/ura/instant_V1", config.getInstantPath(), "Unexpected default instant path");
|
||||||
assertEquals("/interfaces/ura/stream_V1", config.getStreeamPath(), "Unexpected default stream path");
|
assertEquals("/interfaces/ura/stream_V1", config.getStreeamPath(), "Unexpected default stream path");
|
||||||
|
assertNull(config.getConnectTimeout(), "No default connection timeout expected");
|
||||||
|
assertNull(config.getTimeout(), "No default timeout expected");
|
||||||
|
|
||||||
// With custom paths.
|
// With custom paths.
|
||||||
config = UraClientConfiguration.forBaseURL(baseURL)
|
config = UraClientConfiguration.forBaseURL(baseURL)
|
||||||
@ -30,5 +37,13 @@ public class UraClientConfigurationTest {
|
|||||||
assertEquals(baseURL, config.getBaseURL(), "Unexpected base URL");
|
assertEquals(baseURL, config.getBaseURL(), "Unexpected base URL");
|
||||||
assertEquals(instantPath, config.getInstantPath(), "Unexpected custom instant path");
|
assertEquals(instantPath, config.getInstantPath(), "Unexpected custom instant path");
|
||||||
assertEquals(streamPath, config.getStreeamPath(), "Unexpected custom stream path");
|
assertEquals(streamPath, config.getStreeamPath(), "Unexpected custom stream path");
|
||||||
|
|
||||||
|
// With timeouts. (#14)
|
||||||
|
config = UraClientConfiguration.forBaseURL(baseURL)
|
||||||
|
.withConnectTimeout(conTimeout)
|
||||||
|
.withTimeout(timeout)
|
||||||
|
.build();
|
||||||
|
assertEquals(conTimeout, config.getConnectTimeout(), "Unexpected connection timeout value");
|
||||||
|
assertEquals(timeout, config.getTimeout(), "Unexpected timeout value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user