Attempt to fix the verify job problem
[clamp.git] / src / test / java / org / onap / clamp / clds / it / HttpsItCase.java
index 81b6b83..90a2401 100644 (file)
@@ -29,14 +29,12 @@ import java.io.File;
 import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.nio.charset.Charset;
-
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
-
 import org.apache.commons.io.FileUtils;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -47,6 +45,7 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.web.client.RestTemplate;
@@ -57,6 +56,7 @@ import org.springframework.web.client.RestTemplate;
 @RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
 @TestPropertySource(locations = "classpath:https/https-test.properties")
+@DirtiesContext
 public class HttpsItCase {
 
     @Value("${server.port}")
@@ -76,12 +76,12 @@ public class HttpsItCase {
 
                 @Override
                 public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType)
-                    throws java.security.cert.CertificateException {
+                        throws java.security.cert.CertificateException {
                 }
 
                 @Override
                 public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType)
-                    throws java.security.cert.CertificateException {
+                        throws java.security.cert.CertificateException {
                 }
 
                 @Override
@@ -89,9 +89,7 @@ public class HttpsItCase {
                     return null;
                 }
             };
-            ctx.init(null, new TrustManager[] {
-                tm
-            }, null);
+            ctx.init(null, new TrustManager[] { tm }, null);
             SSLContext.setDefault(ctx);
         } catch (Exception ex) {
             ex.printStackTrace();
@@ -109,13 +107,13 @@ public class HttpsItCase {
             }
         });
         template.setRequestFactory(factory);
-        ResponseEntity<String> entity = template
-            .getForEntity("http://localhost:" + this.httpPort + "/designer/index.html", String.class);
+        ResponseEntity<String> entity = template.getForEntity("http://localhost:" + this.httpPort + "/swagger.html",
+                String.class);
         assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
         ResponseEntity<String> httpsEntity = template
-            .getForEntity("https://localhost:" + this.httpsPort + "/designer/index.html", String.class);
+                .getForEntity("https://localhost:" + this.httpsPort + "/swagger.html", String.class);
         assertThat(httpsEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
-        assertThat(httpsEntity.getBody()).contains("CLDS");
+        assertThat(httpsEntity.getBody()).contains("Clamp Rest API");
     }
 
     @Test
@@ -130,11 +128,11 @@ public class HttpsItCase {
         });
         template.setRequestFactory(factory);
         ResponseEntity<String> httpsEntity = template
-            .getForEntity("https://localhost:" + this.httpsPort + "/restservices/clds/v1/api-doc", String.class);
+                .getForEntity("https://localhost:" + this.httpsPort + "/restservices/clds/api-doc", String.class);
         assertThat(httpsEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
         assertThat(httpsEntity.getBody()).contains("swagger");
-        FileUtils.writeStringToFile(
-                new File("docs/swagger/swagger.json"), httpsEntity.getBody(), Charset.defaultCharset());
+        FileUtils.writeStringToFile(new File("docs/swagger/swagger.json"), httpsEntity.getBody(),
+                Charset.defaultCharset());
     }
 
     /**
@@ -151,7 +149,7 @@ public class HttpsItCase {
 
         @Override
         protected void prepareConnection(final HttpURLConnection connection, final String httpMethod)
-            throws IOException {
+                throws IOException {
             if (connection instanceof HttpsURLConnection) {
                 ((HttpsURLConnection) connection).setHostnameVerifier(this.verifier);
             }