Model distribution fails with model-loader 1.13.5
[aai/model-loader.git] / src / test / java / org / onap / aai / modelloader / restclient / TestBabelServiceClient.java
index 51c5642..77e1594 100644 (file)
@@ -43,9 +43,9 @@ import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.AbstractHandler;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 import org.onap.aai.modelloader.service.HttpsBabelServiceClientFactory;
@@ -61,7 +61,7 @@ public class TestBabelServiceClient {
     private Server server;
     private String responseBody;
 
-    @Before
+    @BeforeEach
     public void startJetty() throws Exception {
         List<BabelArtifact> response = new ArrayList<>();
         response.add(new BabelArtifact("", null, ""));
@@ -69,26 +69,29 @@ 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();
     }
 
-    @After
+    @AfterEach
     public void stopJetty() throws Exception {
         server.stop();
     }
 
     @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");
+        configProperties.put("ml.aai.RESTCLIENT_CONNECT_TIMEOUT", "12000");
+        configProperties.put("ml.aai.RESTCLIENT_READ_TIMEOUT", "12000");
         BabelServiceClient client =
                 new HttpsBabelServiceClientFactory().create(new ModelLoaderConfig(configProperties, "."));
         List<BabelArtifact> result =
@@ -99,10 +102,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 =