aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java66
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml19
2 files changed, 51 insertions, 34 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
index f3315b57eb..c3159f0e3b 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
@@ -58,7 +58,6 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
-
public class CatalogDBRestTest {
private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules";
@@ -748,32 +747,45 @@ public class CatalogDBRestTest {
@Test
public void testGetVFModulesBadQueryParam() throws JSONException, IOException {
- TestAppender.events.clear();
- HttpEntity<String> entity = new HttpEntity<String>(null, headers);
- headers.set("Accept", MediaType.APPLICATION_JSON);
-
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
- .queryParam("ADASD", "NEUTRON_BASIC");
-
- ResponseEntity<String> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.GET, entity, String.class);
-
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
- JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
-
-
- ILoggingEvent logEvent = TestAppender.events.get(0);
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(MsoLogger.BEGINTIME));
- assertNotNull(mdc.get(MsoLogger.ENDTIME));
- assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
- assertNotNull(mdc.get(MsoLogger.TIMER));
- assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));
- assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
- assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
- assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
- assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
+ TestAppender.events.clear();
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES))
+ .queryParam("ADASD", "NEUTRON_BASIC");
+
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value());
+ JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false);
+
+
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.ENDTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("500",mdc.get(MsoLogger.RESPONSECODE));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE));
+ assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
+ }
}
private String createURLWithPort(String uri) {
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml
index aceeda408b..715cef8db1 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml
@@ -1,12 +1,18 @@
<configuration>
-
+ <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
+ <property name="p_lvl" value="%level"/>
+ <property name="p_log" value="%logger"/>
+ <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/>
+ <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_thr" value="%thread"/>
+ <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level
- %logger{1024} - %msg%n
- </pattern>
+ <pattern>${pattern}</pattern>
</encoder>
</appender>
@@ -27,6 +33,7 @@
<logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false">
<appender-ref ref="STDOUT" />
+ <appender-ref ref="test" />
</logger>
<logger name="org.flywaydb" level="DEBUG" additivity="false">
@@ -38,12 +45,10 @@
<appender-ref ref="STDOUT" />
</logger>
- <logger name="AUDIT" level="info" additivity="true">
- <appender-ref ref="test" />
- </logger>
<root level="WARN">
<appender-ref ref="STDOUT" />
+ <appender-ref ref="test" />
</root>