aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2023-12-28 16:17:47 +0100
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-04-05 17:01:53 +0200
commit598c2469a004c50a1b29882e02e2fab7a8407d8b (patch)
tree3533fe0fa5b25e5e66b7d4294e734d40da316520 /src/test
parent19f034b2554895285f12979b0f36c1629f9af984 (diff)
Make rest-client request timeout in model-loader configurable
- this reduces the test execution time, when test cases run into timouts Issue-ID: AAI-3703 Change-Id: Ie683f55e5ce8d59b10d2788aea6933854dcb7e99 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/modelloader/restclient/TestAaiServiceClient.java8
-rw-r--r--src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java10
2 files changed, 12 insertions, 6 deletions
diff --git a/src/test/java/org/onap/aai/modelloader/restclient/TestAaiServiceClient.java b/src/test/java/org/onap/aai/modelloader/restclient/TestAaiServiceClient.java
index fd65383..18753b1 100644
--- a/src/test/java/org/onap/aai/modelloader/restclient/TestAaiServiceClient.java
+++ b/src/test/java/org/onap/aai/modelloader/restclient/TestAaiServiceClient.java
@@ -53,12 +53,14 @@ public class TestAaiServiceClient {
@BeforeEach
public void startJetty() throws Exception {
- server = new Server(8080);
+ server = new Server(0);
server.setHandler(getMockHandler());
server.start();
Properties props = new Properties();
props.put("ml.aai.KEYSTORE_PASSWORD", "2244");
+ props.put("ml.aai.RESTCLIENT_CONNECT_TIMEOUT", "3000");
+ props.put("ml.aai.RESTCLIENT_READ_TIMEOUT", "3000");
ModelLoaderConfig config = new ModelLoaderConfig(props, ".");
aaiClient = new AaiRestClient(config);
}
@@ -78,11 +80,11 @@ public class TestAaiServiceClient {
@Test
public void testOperations() {
- String url = "http://localhost:8080";
+ String url = server.getURI().toString();
String transId = "";
MediaType mediaType = MediaType.APPLICATION_JSON_TYPE;
aaiClient.getResource(url, "", mediaType);
- aaiClient.deleteResource("http://localhost", transId, "");
+ aaiClient.deleteResource(url, "", transId);
aaiClient.getAndDeleteResource(url, transId);
aaiClient.postResource(url, "", transId, mediaType);
aaiClient.putResource(url, "", transId, mediaType);
diff --git a/src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java b/src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java
index c653244..19e35ca 100644
--- a/src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java
+++ b/src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java
@@ -69,7 +69,7 @@ public class TestBabelServiceClient {
response.add(new BabelArtifact("", null, ""));
responseBody = new Gson().toJson(response);
- server = new Server(8080);
+ server = new Server(0);
server.setHandler(getMockHandler());
server.start();
}
@@ -81,13 +81,14 @@ public class TestBabelServiceClient {
@Test
public void testRestClient() throws BabelServiceClientException, IOException, URISyntaxException {
+ String url = server.getURI().toString();
Properties configProperties = new Properties();
configProperties.put("ml.babel.KEYSTORE_PASSWORD", "OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0");
configProperties.put("ml.babel.KEYSTORE_FILE", "src/test/resources/auth/aai-client-dummy.p12");
configProperties.put("ml.babel.TRUSTSTORE_PASSWORD", "OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0");
// In a real deployment this would be a different file (to the client keystore)
configProperties.put("ml.babel.TRUSTSTORE_FILE", "src/test/resources/auth/aai-client-dummy.p12");
- configProperties.put("ml.babel.BASE_URL", "http://localhost:8080/");
+ configProperties.put("ml.babel.BASE_URL", url);
configProperties.put("ml.babel.GENERATE_ARTIFACTS_URL", "generate");
BabelServiceClient client =
new HttpsBabelServiceClientFactory().create(new ModelLoaderConfig(configProperties, "."));
@@ -99,10 +100,13 @@ public class TestBabelServiceClient {
@Test
public void testRestClientHttp() throws BabelServiceClientException, IOException, URISyntaxException {
+ String url = server.getURI().toString();
Properties configProperties = new Properties();
configProperties.put("ml.babel.USE_HTTPS", "false");
- configProperties.put("ml.babel.BASE_URL", "http://localhost:8080/");
+ configProperties.put("ml.babel.BASE_URL", url);
configProperties.put("ml.babel.GENERATE_ARTIFACTS_URL", "generate");
+ configProperties.put("ml.aai.RESTCLIENT_CONNECT_TIMEOUT", "3000");
+ configProperties.put("ml.aai.RESTCLIENT_READ_TIMEOUT", "3000");
BabelServiceClient client =
new HttpsBabelServiceClientFactory().create(new ModelLoaderConfig(configProperties, "."));
List<BabelArtifact> result =