summaryrefslogtreecommitdiffstats
path: root/aai-schema-service/src/test/java/org
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2019-04-10 13:46:17 -0400
committerKajur, Harish (vk250x) <vk250x@att.com>2019-04-10 14:46:50 -0400
commit3501e74711a2e91ce84d0b4cbc989738f96e0891 (patch)
treecd99b4bbd91a775bec46a4a6a686e191bcfe6d0c /aai-schema-service/src/test/java/org
parentd52076b0c1cb20eae678cfcf534988d3d0618c34 (diff)
Add additional logging statements1.0.2
Fix the metaspace issue Respond to an invalid content-type appropriately Add getTool.sh to the scripts Issue-ID: AAI-2326 Change-Id: Ib4764ba71be78816e549f59ccbdab8ccb14dc4c0 Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-schema-service/src/test/java/org')
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java56
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java30
2 files changed, 74 insertions, 12 deletions
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
index 53a3e14..231fecc 100644
--- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
@@ -47,6 +47,7 @@ import static org.junit.Assert.assertThat;
@TestPropertySource(locations = "classpath:application-test.properties")
@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
@Import(SchemaServiceTestConfiguration.class)
+
@RunWith(SpringRunner.class)
public class SchemaServiceTest {
@@ -86,7 +87,7 @@ public class SchemaServiceTest {
headers.add("X-TransactionId", "JUNIT");
headers.add("Authorization", "Basic " + authorization);
httpEntity = new HttpEntity(headers);
- baseUrl = "https://localhost:" + randomPort;
+ baseUrl = "http://localhost:" + randomPort;
}
@Test
@@ -126,6 +127,59 @@ public class SchemaServiceTest {
}
@Test
+ public void testInvalidSchemaAndEdges(){
+
+ headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_XML));
+ headers.setContentType(MediaType.APPLICATION_XML);
+ headers.add("Real-Time", "true");
+ headers.add("X-FromAppId", "JUNIT");
+ headers.add("X-TransactionId", "JUNIT");
+ headers.add("Authorization", "Basic " + authorization);
+ httpEntity = new HttpEntity(headers);
+
+ ResponseEntity responseEntity;
+
+ responseEntity = restTemplate.exchange(
+ baseUrl + "/aai/schema-service/v1/nodes?version=blah",
+ HttpMethod.GET,
+ httpEntity,
+ String.class
+ );
+ System.out.println(" "+responseEntity.getBody());
+ assertThat(responseEntity.getStatusCodeValue(), is(400));
+
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ httpEntity = new HttpEntity(headers);
+
+ responseEntity = restTemplate.exchange(
+ baseUrl + "/aai/schema-service/v1/edgerules?version=blah",
+ HttpMethod.GET,
+ httpEntity,
+ String.class
+ );
+
+ assertThat(responseEntity.getStatusCodeValue(), is(400));
+ }
+
+ @Test
+ public void testVersions(){
+
+ ResponseEntity responseEntity;
+
+ responseEntity = restTemplate.exchange(
+ baseUrl + "/aai/schema-service/v1/versions",
+ HttpMethod.GET,
+ httpEntity,
+ String.class
+ );
+ assertThat(responseEntity.getStatusCodeValue(), is(200));
+
+
+ }
+
+ @Test
public void testGetStoredQueriesSuccess(){
ResponseEntity responseEntity;
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
index 5d4c187..1e2de5e 100644
--- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
@@ -58,30 +58,38 @@ public class SchemaServiceTestConfiguration {
@Bean
RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception {
- char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray();
- char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray();
- String keyStore = env.getProperty("server.ssl.key-store");
- String trustStore = env.getProperty("server.ssl.trust-store");
- SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
+ RestTemplate restTemplate = null;
- if(env.acceptsProfiles("two-way-ssl")){
- sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword);
- }
+ if(env.acceptsProfiles("one-way-ssl", "two-way-ssl")) {
+ char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray();
+ char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray();
+
+ String keyStore = env.getProperty("server.ssl.key-store");
+ String trustStore = env.getProperty("server.ssl.trust-store");
+ SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
+
+ if (env.acceptsProfiles("two-way-ssl")) {
+ sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword);
+ }
- SSLContext sslContext = sslContextBuilder
+ SSLContext sslContext = sslContextBuilder
.loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword)
.build();
- HttpClient client = HttpClients.custom()
+ HttpClient client = HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier((s, sslSession) -> true)
.build();
- RestTemplate restTemplate = builder
+ restTemplate = builder
.requestFactory(new HttpComponentsClientHttpRequestFactory(client))
.build();
+ }else {
+ restTemplate = builder.build();
+ }
+
restTemplate.setErrorHandler(new ResponseErrorHandler() {
@Override