Revision: bde20e986b8a
Branch: default
Author: gm2552
Date: Fri Dec 12 20:31:58 2014 UTC
Log: Fixing issues with RDBMS auditing.
https://code.google.com/p/nhin-d/source/detail?r=bde20e986b8a
Added:
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSDaoImpl.java
Modified:
/java/direct-common-audit/pom.xml
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSAuditor.java
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSDao.java
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/provider/RDBMSAuditorProvider.java
/java/direct-common-audit/src/main/resources/auditStore.xml
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/RDBMSAuditorProviderTest.java
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditorBaseTest.java
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getEventsTest.java
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getLastEventTest.java
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_writeEventTest.java
/java/direct-common-audit/src/test/resources/auditStore-test.xml
=======================================
--- /dev/null
+++
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSDaoImpl.java
Fri Dec 12 20:31:58 2014 UTC
@@ -0,0 +1,184 @@
+package org.nhindirect.common.audit.impl;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.UUID;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nhindirect.common.audit.AuditContext;
+import org.nhindirect.common.audit.AuditEvent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * DOA implementation for audit events.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+@Repository
+public class RDBMSDaoImpl implements RDBMSDao
+{
+ private final Log LOGGER =
LogFactory.getFactory().getInstance(RDBMSDaoImpl.class);
+
+ @PersistenceContext
+ @Autowired
+ private EntityManager entityManager;
+
+ public RDBMSDaoImpl()
+ {
+
+ }
+
+ ///CLOVER:OFF
+ public RDBMSDaoImpl(EntityManager entityManager)
+ {
+ this();
+
+ setEntityManager(entityManager);
+ }
+ ///CLOVER:ON
+
+ /**
+ * Sets the entity manager for access to the underlying data store medium.
+ * @param entityManager The entity manager.
+ */
+ ///CLOVER:OFF
+ public void setEntityManager(EntityManager entityManager)
+ {
+ this.entityManager = entityManager;
+ }
+ ///CLOVER:ON
+
+ /**
+ * Validate that we have a connection to the DAO
+ */
+ protected void validateState()
+ {
+ if (entityManager == null)
+ throw new IllegalStateException("entityManger has not been
initialized");
+ }
+
+ @Override
+ @Transactional(readOnly = false)
+ public void writeRDBMSEvent(UUID eventId, Calendar eventTimeStamp,
+ String principal, AuditEvent event,
+ Collection<? extends AuditContext> contexts)
+ {
+ try
+ {
+ validateState();
+
+ final org.nhindirect.common.audit.impl.entity.AuditEvent newEvent =
+ new org.nhindirect.common.audit.impl.entity.AuditEvent();
+
+ newEvent.setEventName(event.getName());
+ newEvent.setEventType(event.getType());
+
+ newEvent.setEventTime(Calendar.getInstance(Locale.getDefault()));
+ newEvent.setPrincipal(principal);
+ newEvent.setUUID(eventId.toString());
+
+ if (contexts != null)
+ {
+ final Collection<org.nhindirect.common.audit.impl.entity.AuditContext>
entityContexts = newEvent.getAuditContexts();
+ for (AuditContext context : contexts)
+ {
+ final org.nhindirect.common.audit.impl.entity.AuditContext newContext
=
+ new org.nhindirect.common.audit.impl.entity.AuditContext();
+
+ newContext.setContextName(context.getContextName());
+ newContext.setContextValue(context.getContextValue());
+ newContext.setAuditEvent(newEvent);
+ entityContexts.add(newContext);
+ }
+ }
+ entityManager.persist(newEvent);
+ entityManager.flush();
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed to write audit event to RDBMS store: " +
e.getMessage(), e);
+ }
+
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public Integer getRDBMSEventCount()
+ {
+ try
+ {
+ validateState();
+
+ final Query select = entityManager.createQuery("SELECT count(ae)
from AuditEvent ae");
+
+ return new Integer(((Long)select.getSingleResult()).intValue());
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed to write audit event count: " + e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public Collection<org.nhindirect.common.audit.impl.entity.AuditEvent>
getRDBMSEvents(Integer eventCount)
+ {
+ try
+ {
+ final Query select =
+ entityManager.createQuery("SELECT ae from AuditEvent ae ORDER BY
ae.eventTime desc").setMaxResults(eventCount);
+
+ @SuppressWarnings("unchecked")
+ final Collection<org.nhindirect.common.audit.impl.entity.AuditEvent> rs
= select.getResultList();
+
+ // lazy fetching
+ for (org.nhindirect.common.audit.impl.entity.AuditEvent event :
rs)
+ event.getAuditContexts().size();
+
+ return rs;
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed get audit events: " + e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ @Transactional(readOnly = false)
+ public void rDBMSclear()
+ {
+ // truncating the tables
+
+ try
+ {
+ Query delete =
+ entityManager.createQuery("delete from AuditContext");
+
+ delete.executeUpdate();
+
+ delete =
+ entityManager.createQuery("delete from AuditEvent");
+
+ delete.executeUpdate();
+
+ entityManager.flush();
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed clear audit events: " + e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+
+}
=======================================
--- /java/direct-common-audit/pom.xml Tue Oct 7 00:14:54 2014 UTC
+++ /java/direct-common-audit/pom.xml Fri Dec 12 20:31:58 2014 UTC
@@ -50,7 +50,7 @@
<dependency>
<groupId>org.nhind</groupId>
<artifactId>direct-common</artifactId>
- <version>1.3</version>
+ <version>1.4.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
@@ -193,7 +193,7 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
+ <artifactId>slf4j-jdk14</artifactId>
<version>1.6.1</version>
<type>jar</type>
<scope>test</scope>
=======================================
---
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSAuditor.java
Mon Apr 7 14:57:28 2014 UTC
+++
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSAuditor.java
Fri Dec 12 20:31:58 2014 UTC
@@ -24,7 +24,6 @@
import java.lang.management.ManagementFactory;
import java.util.Calendar;
import java.util.Collection;
-import java.util.Locale;
import java.util.UUID;
import java.util.Vector;
@@ -39,9 +38,6 @@
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,8 +47,6 @@
import org.nhindirect.common.audit.AuditorMBean;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
/**
* Implementation of the DirectProject RI auditor that writes records to a
configurable database.
@@ -60,61 +54,44 @@
* @author Greg Meyer
* @since 1.0
*/
-@Repository
-public class RDBMSAuditor extends AbstractAuditor implements RDBMSDao
+public class RDBMSAuditor extends AbstractAuditor implements AuditorMBean
{
private final Log LOGGER =
LogFactory.getFactory().getInstance(RDBMSAuditor.class);
-
- @PersistenceContext
- @Autowired
- private EntityManager entityManager;
private String[] itemNames;
private CompositeType eventType;
+ @Autowired
+ protected RDBMSDao dao;
+
/**
* Constructor
*/
public RDBMSAuditor()
- {
+ {
+ super();
// register the auditor as an MBean
+
registerMBean();
}
+
+ /**
+ * Constructor
+ */
+ public RDBMSAuditor(RDBMSDao dao)
+ {
+ this();
+ // register the auditor as an MBean
+
+ setDao(dao);
+ }
- /**
- * Constructor
- * @param entityManager Entity manager for accessing the underlying
data store medium
- */
- ///CLOVER:OFF
- public RDBMSAuditor(EntityManager entityManager)
+
+ public void setDao(RDBMSDao dao)
{
- super();
-
- setEntityManager(entityManager);
+ this.dao = dao;
}
- ///CLOVER:ON
- /**
- * Sets the entity manager for access to the underlying data store medium.
- * @param entityManager The entity manager.
- */
- ///CLOVER:OFF
- public void setEntityManager(EntityManager entityManager)
- {
- this.entityManager = entityManager;
- }
- ///CLOVER:ON
-
- /**
- * Validate that we have a connection to the DAO
- */
- protected void validateState()
- {
- if (entityManager == null)
- throw new IllegalStateException("entityManger has not been
initialized");
- }
-
-
/*
* Register the MBean
*/
@@ -160,39 +137,10 @@
* {@inheritDoc}
*/
@Override
- @Transactional(readOnly = false)
public void writeEvent(UUID eventId, Calendar eventTimeStamp,
String principal, AuditEvent event, Collection<? extends AuditContext>
contexts)
{
- validateState();
-
- final org.nhindirect.common.audit.impl.entity.AuditEvent newEvent =
- new org.nhindirect.common.audit.impl.entity.AuditEvent();
-
- newEvent.setEventName(event.getName());
- newEvent.setEventType(event.getType());
-
- newEvent.setEventTime(Calendar.getInstance(Locale.getDefault()));
- newEvent.setPrincipal(principal);
- newEvent.setUUID(eventId.toString());
-
- if (contexts != null)
- {
- final Collection<org.nhindirect.common.audit.impl.entity.AuditContext>
entityContexts = newEvent.getAuditContexts();
- for (AuditContext context : contexts)
- {
- final org.nhindirect.common.audit.impl.entity.AuditContext newContext =
- new org.nhindirect.common.audit.impl.entity.AuditContext();
-
- newContext.setContextName(context.getContextName());
- newContext.setContextValue(context.getContextValue());
- newContext.setAuditEvent(newEvent);
- entityContexts.add(newContext);
- }
- }
-
- entityManager.persist(newEvent);
- entityManager.flush();
+ this.dao.writeRDBMSEvent(eventId, eventTimeStamp, principal, event,
contexts);
}
@@ -200,20 +148,14 @@
* {@inheritDoc}
*/
@Override
- @Transactional(readOnly = true)
public Integer getEventCount()
{
- validateState();
-
- final Query select = entityManager.createQuery("SELECT count(ae) from
AuditEvent ae");
-
- return new Integer(((Long)select.getSingleResult()).intValue());
+ return this.dao.getRDBMSEventCount();
}
/**
* {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
@Override
public CompositeData[] getEvents(Integer eventCount)
{
@@ -222,10 +164,7 @@
final Vector<CompositeData> retVal = new Vector<CompositeData>();
- final Query select =
- entityManager.createQuery("SELECT ae from AuditEvent ae ORDER BY
ae.eventTime desc").setMaxResults(eventCount);
-
- final
Collection<org.nhindirect.common.audit.impl.entity.AuditEvent> rs =
select.getResultList();
+ final
Collection<org.nhindirect.common.audit.impl.entity.AuditEvent> rs =
this.dao.getRDBMSEvents(eventCount);
if (rs.size() == 0)
return null;
@@ -283,19 +222,6 @@
@Override
public void clear()
{
- // truncating the tables
-
- Query delete =
- entityManager.createQuery("delete from AuditContext");
-
- delete.executeUpdate();
-
- delete =
- entityManager.createQuery("delete from AuditEvent");
-
- delete.executeUpdate();
-
- entityManager.flush();
-
+ this.dao.rDBMSclear();
}
}
=======================================
---
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSDao.java
Mon Apr 7 14:57:28 2014 UTC
+++
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/impl/RDBMSDao.java
Fri Dec 12 20:31:58 2014 UTC
@@ -21,15 +21,26 @@
package org.nhindirect.common.audit.impl;
-import org.nhindirect.common.audit.Auditor;
-import org.nhindirect.common.audit.AuditorMBean;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.UUID;
+
+import org.nhindirect.common.audit.AuditContext;
+import org.nhindirect.common.audit.AuditEvent;
/**
- * Aggregate interface for a DirectProject auditor and MBean specific to
the database auditor implementation.
+ * DAO interface for reading and writing audit info to the RDBMS.
* @author Greg Meyer
* @since 1.0
*/
-public interface RDBMSDao extends Auditor, AuditorMBean
+public interface RDBMSDao
{
+ public void writeRDBMSEvent(UUID eventId, Calendar eventTimeStamp,
+ String principal, AuditEvent event, Collection<? extends AuditContext>
contexts);
+ public Integer getRDBMSEventCount();
+
+ public Collection<org.nhindirect.common.audit.impl.entity.AuditEvent>
getRDBMSEvents(Integer eventCount);
+
+ public void rDBMSclear();
}
=======================================
---
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/provider/RDBMSAuditorProvider.java
Mon Apr 7 14:57:28 2014 UTC
+++
/java/direct-common-audit/src/main/java/org/nhindirect/common/audit/provider/RDBMSAuditorProvider.java
Fri Dec 12 20:31:58 2014 UTC
@@ -21,13 +21,10 @@
package org.nhindirect.common.audit.provider;
+
import java.util.Arrays;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
import org.nhindirect.common.audit.Auditor;
-import org.nhindirect.common.audit.impl.RDBMSAuditor;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -42,7 +39,8 @@
{
private static final String DEFAULT_APPLICATION_CONTEXT_FILE
= "auditStore.xml";
- private final EntityManager entityManager;
+ private final String springConfigLocation;
+ protected Auditor auditor = null;
/**
* Default constructor. Uses the default file auditStore.xml to pull the
Sring configuration.
@@ -58,7 +56,23 @@
*/
public RDBMSAuditorProvider(String springConfigLocation)
{
+ this.springConfigLocation = springConfigLocation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized Auditor get()
+ {
+ if (auditor == null)
+ auditor = createAuditor();
+ return auditor;
+ }
+
+ protected Auditor createAuditor()
+ {
final String fileLoc = (springConfigLocation == null ||
springConfigLocation.isEmpty()) ? DEFAULT_APPLICATION_CONTEXT_FILE :
springConfigLocation;
final ClassLoader loader = new
AggregateClassLoader(Arrays.asList(Thread.currentThread().getContextClassLoader()),
@@ -67,6 +81,7 @@
try
{
+
final ClassPathXmlApplicationContext ctx = new
ClassPathXmlApplicationContext(fileLoc)
{
protected void initBeanDefinitionReader(XmlBeanDefinitionReader
reader)
@@ -78,38 +93,12 @@
}
};
-
-
- final EntityManagerFactory factory =
ctx.getBean(EntityManagerFactory.class);
-
- entityManager = factory.createEntityManager();
+
+ return (Auditor)ctx.getBean("auditor");
}
catch (Exception e)
{
- throw new IllegalStateException("Entity manager could not be found in
Spring configuration.", e);
+ throw new IllegalStateException("Auditor could not be found in Spring
configuration.", e);
}
}
-
-
- /**
- * Constructor with the pre-configured entity manager.
- * @param fileLoc The pre-configured entity manager.
- */
- public RDBMSAuditorProvider(EntityManager entityManager)
- {
- if (entityManager == null)
- throw new IllegalArgumentException("Entity manager null");
-
- this.entityManager = entityManager;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Auditor get()
- {
- return new RDBMSAuditor(entityManager);
- }
}
=======================================
--- /java/direct-common-audit/src/main/resources/auditStore.xml Wed Mar 26
16:24:00 2014 UTC
+++ /java/direct-common-audit/src/main/resources/auditStore.xml Fri Dec 12
20:31:58 2014 UTC
@@ -10,8 +10,8 @@
http://www.springframework.org/schema/tx/spring-tx.xsd"
default-autowire="byName">
- <tx:annotation-driven transaction-manager="transactionManager" />
-
+ <tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true"/>
+ <context:component-scan base-package="org.nhindirect.common.audit.impl" />
<context:property-placeholder
location="classpath:properties/auditStore.properties"/>
@@ -19,6 +19,8 @@
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>
+ <bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
+
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
@@ -41,8 +43,9 @@
<property name="username" value='${auditStore.db.username}' />
<property name="password" value='${auditStore.db.password}' />
</bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager" />
-
- <bean id="auditor"
class="org.nhindirect.common.audit.impl.RDBMSAuditor"/>
-
+ <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="entityManagerFactory"/>
+ </bean>
+
+ <bean id="auditor" class="org.nhindirect.common.audit.impl.RDBMSAuditor"
/>
</beans>
=======================================
---
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/RDBMSAuditorProviderTest.java
Wed Mar 26 16:24:00 2014 UTC
+++
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/RDBMSAuditorProviderTest.java
Fri Dec 12 20:31:58 2014 UTC
@@ -3,11 +3,8 @@
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
-import javax.persistence.EntityManagerFactory;
-
import org.junit.Test;
import org.nhindirect.common.audit.provider.RDBMSAuditorProvider;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
public class RDBMSAuditorProviderTest
{
@@ -33,7 +30,8 @@
boolean exceptionOccured = false;
try
{
- new RDBMSAuditorProvider("auditStoreBogus.xml");
+ final RDBMSAuditorProvider provider = new
RDBMSAuditorProvider("auditStoreBogus.xml");
+ provider.get();
}
catch (IllegalStateException e)
{
@@ -43,18 +41,17 @@
assertTrue(exceptionOccured);
}
+
@Test
- public void testCreateWithEntityManager_assertCreated() throws Exception
+ public void testCreateWithSpecificFile_assertCreatedAndWriteEvent()
throws Exception
{
+ final RDBMSAuditorProvider provider = new
RDBMSAuditorProvider("auditStore.xml");
- final ClassPathXmlApplicationContext ctx = new
ClassPathXmlApplicationContext("auditStore.xml");
-
-
- final EntityManagerFactory factory =
ctx.getBean(EntityManagerFactory.class);
-
-
- final RDBMSAuditorProvider provider = new
RDBMSAuditorProvider(factory.createEntityManager());
-
- assertNotNull(provider.get());
+ final Auditor auditor = provider.get();
+ assertNotNull(auditor);
+ final AuditEvent auditEvent = new AuditEvent("name1", "value1");
+
+ auditor.audit("testPin", auditEvent, null);
+
}
}
=======================================
---
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditorBaseTest.java
Wed Mar 19 20:21:03 2014 UTC
+++
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditorBaseTest.java
Fri Dec 12 20:31:58 2014 UTC
@@ -15,7 +15,7 @@
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations =
{ "file:src/test/resources/auditStore-test.xml" })
+@ContextConfiguration(locations =
{ "file:src/main/resources/auditStore.xml" })
@TransactionConfiguration(transactionManager = "transactionManager",
defaultRollback = true)
@Transactional
public abstract class RDBMSAuditorBaseTest
@@ -23,6 +23,9 @@
@Autowired
protected RDBMSDao auditor;
+
+ protected RDBMSAuditor auditorImpl;
+
private static final String derbyHomeLoc = "/target/data";
static
@@ -46,13 +49,15 @@
{
clearAuditEvent();
+ auditorImpl = new RDBMSAuditor();
+ auditorImpl.setDao(auditor);
}
protected void clearAuditEvent()
{
- auditor.clear();
+ auditor.rDBMSclear();
- assertEquals((Integer)0, auditor.getEventCount());
+ assertEquals((Integer)0, auditor.getRDBMSEventCount());
}
}
=======================================
---
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getEventsTest.java
Wed Mar 19 20:21:03 2014 UTC
+++
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getEventsTest.java
Fri Dec 12 20:31:58 2014 UTC
@@ -28,10 +28,10 @@
DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
- auditor.audit(PRINCIPAL, event1);
- auditor.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
- CompositeData[] events = auditor.getEvents(2);
+ CompositeData[] events = auditorImpl.getEvents(2);
assertNotNull(events);
assertEquals(2, events.length);
@@ -60,10 +60,10 @@
DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
- auditor.audit(PRINCIPAL, event1);
- auditor.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
- CompositeData[] events = auditor.getEvents(5);
+ CompositeData[] events = auditorImpl.getEvents(5);
assertNotNull(events);
assertEquals(2, events.length);
@@ -91,10 +91,10 @@
DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
- auditor.audit(PRINCIPAL, event1);
- auditor.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
- CompositeData[] events = auditor.getEvents(1);
+ CompositeData[] events = auditorImpl.getEvents(1);
assertNotNull(events);
assertEquals(1, events.length);
@@ -116,7 +116,7 @@
public void testGetEvents_NoRecordsAvailable_NoRecordsFound()
{
- CompositeData[] events = auditor.getEvents(1);
+ CompositeData[] events = auditorImpl.getEvents(1);
assertNull(events);
}
@@ -130,10 +130,10 @@
DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
- auditor.audit(PRINCIPAL, event1);
- auditor.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
- CompositeData[] events = auditor.getEvents(0);
+ CompositeData[] events = auditorImpl.getEvents(0);
assertNull(events);
=======================================
---
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getLastEventTest.java
Wed Mar 19 20:21:03 2014 UTC
+++
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getLastEventTest.java
Fri Dec 12 20:31:58 2014 UTC
@@ -21,9 +21,9 @@
final AuditEvent auditEvent = new AuditEvent("name1", "value1");
- this.auditor.audit("testPin", auditEvent, null);
+ this.auditorImpl.audit("testPin", auditEvent, null);
- final CompositeData lastMessage = auditor.getLastEvent();
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
assertNotNull(lastMessage);
@@ -46,9 +46,9 @@
final DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
final DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
- this.auditor.audit("testPin", auditEvent, Arrays.asList(context1,
context2));
+ this.auditorImpl.audit("testPin", auditEvent,
Arrays.asList(context1, context2));
- final CompositeData lastMessage = auditor.getLastEvent();
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
assertNotNull(lastMessage);
@@ -69,7 +69,7 @@
public void testGetLastEventTest_noEntries_assertNull() throws Exception
{
- final CompositeData lastMessage = auditor.getLastEvent();
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
assertNull(lastMessage);
=======================================
---
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_writeEventTest.java
Wed Mar 19 20:21:03 2014 UTC
+++
/java/direct-common-audit/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_writeEventTest.java
Fri Dec 12 20:31:58 2014 UTC
@@ -19,10 +19,10 @@
{
final AuditEvent auditEvent = new AuditEvent("name1", "value1");
-
- this.auditor.audit("testPin", auditEvent, null);
- final CompositeData lastMessage = auditor.getLastEvent();
+ this.auditorImpl.audit("testPin", auditEvent, null);
+
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
assertNotNull(lastMessage);
@@ -45,9 +45,9 @@
final DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
final DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
- this.auditor.audit("testPin", auditEvent, Arrays.asList(context1,
context2));
+ this.auditorImpl.audit("testPin", auditEvent, Arrays.asList(context1,
context2));
- final CompositeData lastMessage = auditor.getLastEvent();
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
assertNotNull(lastMessage);
=======================================
--- /java/direct-common-audit/src/test/resources/auditStore-test.xml Mon
Apr 7 14:57:28 2014 UTC
+++ /java/direct-common-audit/src/test/resources/auditStore-test.xml Fri
Dec 12 20:31:58 2014 UTC
@@ -50,6 +50,4 @@
<property name="password" value='${auditStore.db.password}' />
</bean>
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager" />
-
- <bean id="auditor" class="org.nhindirect.common.audit.impl.RDBMSAuditor"/>
</beans>