From 95b23fd523f72ef52c8555ce6947294a43f099dd Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Fri, 28 Jun 2019 17:21:13 -0400 Subject: Adding logging to JUnit Turning on logging. Issue-ID: POLICY-1876 Change-Id: I82b04609a07f5d33c88c3e0068959de1e628cb38 Signed-off-by: Pamela Dragosh --- .../org/onap/policy/pap/test/XACMLPAPTest.java | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'ONAP-PAP-REST/src/test/java') diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java index 6ebc74a91..fd0c157fe 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java @@ -127,6 +127,7 @@ public class XACMLPAPTest { public void testInit() { httpServletRequest = Mockito.mock(HttpServletRequest.class); httpServletResponse = Mockito.mock(MockHttpServletResponse.class); + logger.info(httpServletResponse); Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers)); Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers)); CommonClassDaoImpl.setSessionfactory(sessionFactory); @@ -163,7 +164,8 @@ public class XACMLPAPTest { MockServletInputStream mockInput = new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); - + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -192,6 +194,8 @@ public class XACMLPAPTest { Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); setPolicyCreation(); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -215,6 +219,8 @@ public class XACMLPAPTest { Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); setPolicyCreation(); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -238,6 +244,8 @@ public class XACMLPAPTest { Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); setPolicyCreation(); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -257,6 +265,8 @@ public class XACMLPAPTest { new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -287,6 +297,8 @@ public class XACMLPAPTest { new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -318,6 +330,8 @@ public class XACMLPAPTest { new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -346,6 +360,8 @@ public class XACMLPAPTest { new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -369,6 +385,8 @@ public class XACMLPAPTest { new MockServletInputStream(PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -425,6 +443,8 @@ public class XACMLPAPTest { new MockServletInputStream(PolicyUtils.objectToJsonString(newPapPolicy).getBytes()); Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); + logger.info(httpServletRequest); + logger.info(httpServletResponse); pap.service(httpServletRequest, httpServletResponse); Mockito.verify(httpServletResponse).addHeader("operation", "create"); } @@ -897,14 +917,14 @@ public class XACMLPAPTest { try { Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput); } catch (IOException e) { - fail(); + fail(e.getMessage()); } try { pap.service(httpServletRequest, httpServletResponse); assertTrue(true); } catch (Exception e) { - fail(); + fail(e.getMessage()); } } -- cgit 1.2.3-korg