summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common/src
diff options
context:
space:
mode:
authorasgar <sammoham@in.ibm.com>2018-10-03 19:42:39 +0530
committerasgar <sammoham@in.ibm.com>2018-10-03 19:42:46 +0530
commita4633f87da4f97cc2ff72a806d9ea01cb0daeaa2 (patch)
tree14e4fb109949b25429a51eecfc41b3674b2a59fa /ecomp-portal-BE-common/src
parent1e3b5bdbea15453fb078ee49fe7de41efef4326f (diff)
added a test in CustomLogginFilterTest.java
Change-Id: Ib801f9ab42486d51fa64b6575124e5668a48c853 Issue-ID: PORTAL-427 Signed-off-by: Mohamed Asgar Samiulla <sammoham@in.ibm.com>
Diffstat (limited to 'ecomp-portal-BE-common/src')
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/CustomLoggingFilterTest.java74
1 files changed, 43 insertions, 31 deletions
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/CustomLoggingFilterTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/CustomLoggingFilterTest.java
index 1dba3167..be819498 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/CustomLoggingFilterTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/utils/CustomLoggingFilterTest.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright © 2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
* under the Apache License, Version 2.0 (the "License");
@@ -47,35 +49,45 @@ import ch.qos.logback.core.spi.FilterReply;
public class CustomLoggingFilterTest {
- @Test
- public void decideTest(){
- ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
- Mockito.when(event.getLevel()).thenReturn(Level.ERROR);
- Mockito.when(event.getThreadName()).thenReturn("UEBConsumerThread");
- Mockito.when(event.getLoggerName()).thenReturn("org.onap.nsa");
- CustomLoggingFilter customLoggingFilter = new CustomLoggingFilter();
- FilterReply reply = customLoggingFilter.decide(event);
- Assert.assertEquals( FilterReply.DENY, reply);
- }
-
- @Test
- public void decideNEUTRALTest(){
- ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
- Mockito.when(event.getLevel()).thenReturn(Level.ERROR);
- Mockito.when(event.getThreadName()).thenReturn("UEBConsumerThread");
- Mockito.when(event.getLoggerName()).thenReturn("test");
- CustomLoggingFilter customLoggingFilter = new CustomLoggingFilter();
- FilterReply reply = customLoggingFilter.decide(event);
- Assert.assertEquals( FilterReply.NEUTRAL, reply);
- }
-
- @Test
- public void decideExceptionTest(){
- ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
- Mockito.when(event.getLevel()).thenReturn(Level.ERROR);
- Mockito.when(event.getThreadName()).thenReturn("UEBConsumerThread");
- CustomLoggingFilter customLoggingFilter = new CustomLoggingFilter();
- FilterReply reply = customLoggingFilter.decide(event);
- Assert.assertEquals( FilterReply.NEUTRAL, reply);
- }
+ @Test
+ public void decideTest(){
+ ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
+ Mockito.when(event.getLevel()).thenReturn(Level.ERROR);
+ Mockito.when(event.getThreadName()).thenReturn("UEBConsumerThread");
+ Mockito.when(event.getLoggerName()).thenReturn("org.onap.nsa");
+ CustomLoggingFilter customLoggingFilter = new CustomLoggingFilter();
+ FilterReply reply = customLoggingFilter.decide(event);
+ Assert.assertEquals( FilterReply.DENY, reply);
+ }
+
+ @Test
+ public void decideNEUTRALTest(){
+ ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
+ Mockito.when(event.getLevel()).thenReturn(Level.ERROR);
+ Mockito.when(event.getThreadName()).thenReturn("UEBConsumerThread");
+ Mockito.when(event.getLoggerName()).thenReturn("test");
+ CustomLoggingFilter customLoggingFilter = new CustomLoggingFilter();
+ FilterReply reply = customLoggingFilter.decide(event);
+ Assert.assertEquals( FilterReply.NEUTRAL, reply);
+ }
+
+ @Test
+ public void decideExceptionTest(){
+ ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
+ Mockito.when(event.getLevel()).thenReturn(Level.ERROR);
+ Mockito.when(event.getThreadName()).thenReturn("UEBConsumerThread");
+ CustomLoggingFilter customLoggingFilter = new CustomLoggingFilter();
+ FilterReply reply = customLoggingFilter.decide(event);
+ Assert.assertEquals( FilterReply.NEUTRAL, reply);
+ }
+
+ @Test
+ public void decideExceptionTestWithLevelWarn(){
+ ILoggingEvent event = Mockito.mock(ILoggingEvent.class);
+ Mockito.when(event.getLevel()).thenReturn(Level.WARN);
+ Mockito.when(event.getThreadName()).thenReturn("org.apache.http");
+ CustomLoggingFilter customLoggingFilter = new CustomLoggingFilter();
+ FilterReply reply = customLoggingFilter.decide(event);
+ Assert.assertEquals( FilterReply.NEUTRAL, reply);
+ }
}