From 95dafe8eaedf270c639adf0e51481f0172d2b808 Mon Sep 17 00:00:00 2001 From: jrh3 Date: Wed, 23 Aug 2017 09:40:28 -0400 Subject: Add access.log to jetty server Added a single line to the code that creates the jetty server so that it will log messages in access.log format. Also added lines to various logback.xml files to actually write the output from the jetty server to the access.log. Made some revisions per comments: - removed spaces around parameters - added "Out" suffix - changed suffix of archived files - changed size to 1MB Modified logback*.xml files to include jetty "access log" content in the already-existing network.log. Issue-Id: POLICY-161 Change-Id: I3e3769c06a22aaffea0e09abbec3387cc62f246f Signed-off-by: jrh3 --- .../persistence/JpaDroolsSessionConnectorTest.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'feature-session-persistence') diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java index c16a1bbd..792e6f8b 100644 --- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java +++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/JpaDroolsSessionConnectorTest.java @@ -22,12 +22,17 @@ package org.onap.policy.drools.persistence; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import org.junit.After; @@ -86,6 +91,45 @@ public class JpaDroolsSessionConnectorTest { assertEquals("{name=nameY, id=20}", conn.get("nameY").toString()); } + + @Test(expected = RuntimeException.class) + public void testGet_NewEx() { + EntityManagerFactory emf = mock(EntityManagerFactory.class); + EntityManager em = mock(EntityManager.class); + + when(emf.createEntityManager()).thenReturn(em); + when(em.getTransaction()).thenThrow(new RuntimeException("expected exception")); + + conn = new JpaDroolsSessionConnector(emf); + conn.get("xyz"); + } + + @Test(expected = RuntimeException.class) + public void testGet_FindEx() { + EntityManagerFactory emf = mock(EntityManagerFactory.class); + EntityManager em = mock(EntityManager.class); + EntityTransaction tr = mock(EntityTransaction.class); + + when(emf.createEntityManager()).thenReturn(em); + when(em.getTransaction()).thenReturn(tr); + when(em.find(any(), any())).thenThrow(new RuntimeException("expected exception")); + + new JpaDroolsSessionConnector(emf).get("xyz"); + } + + @Test(expected = RuntimeException.class) + public void testGet_FindEx_CloseEx() { + EntityManagerFactory emf = mock(EntityManagerFactory.class); + EntityManager em = mock(EntityManager.class); + EntityTransaction tr = mock(EntityTransaction.class); + + when(emf.createEntityManager()).thenReturn(em); + when(em.getTransaction()).thenReturn(tr); + when(em.find(any(), any())).thenThrow(new RuntimeException("expected exception")); + doThrow(new RuntimeException("expected exception #2")).when(em).close(); + + new JpaDroolsSessionConnector(emf).get("xyz"); + } @Test public void testReplace_Existing() { -- cgit 1.2.3-korg