Search in sources :

Example 1 with AuditLogEvent

use of com.dexels.navajo.events.types.AuditLogEvent in project navajo by Dexels.

the class NavajoEventRegistryTest method testPublishAsynchronousEvent.

@Test
public void testPublishAsynchronousEvent() {
    final Object semaphore = new Object();
    NavajoEventRegistry instance = NavajoEventRegistry.getInstance();
    instance.addListener(AuditLogEvent.class, new NavajoListener() {

        @Override
        public void onNavajoEvent(NavajoEvent ne) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                logger.error("Error: ", e);
            }
            message = "Received AuditLogEvent!";
            System.err.println(message);
            synchronized (semaphore) {
                semaphore.notify();
            }
        }
    });
    message = null;
    instance.publishAsynchronousEvent(new AuditLogEvent("", "", Level.INFO));
    // Should still be null....
    Assert.assertNull(message);
    synchronized (semaphore) {
        try {
            semaphore.wait(2000);
        } catch (InterruptedException e) {
            logger.error("Error: ", e);
        }
    }
    // Now it should have a value...
    Assert.assertEquals(message, "Received AuditLogEvent!");
}
Also used : AuditLogEvent(com.dexels.navajo.events.types.AuditLogEvent) Test(org.junit.Test)

Example 2 with AuditLogEvent

use of com.dexels.navajo.events.types.AuditLogEvent in project navajo by Dexels.

the class NavajoEventRegistryTest method testPublishEvent.

@Test
public void testPublishEvent() {
    NavajoEventRegistry instance = NavajoEventRegistry.getInstance();
    instance.addListener(AuditLogEvent.class, new NavajoListener() {

        @Override
        public void onNavajoEvent(NavajoEvent ne) {
            message = "Received AuditLogEvent!";
            System.err.println(message);
        }
    });
    instance.publishEvent(new AuditLogEvent("", "", Level.INFO));
    Assert.assertEquals(message, "Received AuditLogEvent!");
}
Also used : AuditLogEvent(com.dexels.navajo.events.types.AuditLogEvent) Test(org.junit.Test)

Example 3 with AuditLogEvent

use of com.dexels.navajo.events.types.AuditLogEvent in project navajo by Dexels.

the class AuditLog method store.

@Override
public void store() throws MappableException, UserException {
    AuditLogEvent ale = new AuditLogEvent(AUDIT_MESSAGE_USER, getMessage(), getLevel());
    ale.setAccessId(accessId);
    publishEvent(ale);
}
Also used : AuditLogEvent(com.dexels.navajo.events.types.AuditLogEvent)

Example 4 with AuditLogEvent

use of com.dexels.navajo.events.types.AuditLogEvent in project navajo by Dexels.

the class AuditLog method log.

public static final void log(String subsystem, final String message, Throwable t, Level level, String accessId) {
    logToSlf(message, t, level);
    AuditLogEvent ale = new AuditLogEvent(subsystem.toUpperCase(), message, level);
    ale.setAccessId(accessId);
    publishEvent(ale);
}
Also used : AuditLogEvent(com.dexels.navajo.events.types.AuditLogEvent)

Example 5 with AuditLogEvent

use of com.dexels.navajo.events.types.AuditLogEvent in project navajo by Dexels.

the class AuditLog method log.

public static final void log(final String subsystem, final String message, Level level, String accessId) {
    logToSlf(message, subsystem, level);
    AuditLogEvent ale = new AuditLogEvent(subsystem.toUpperCase(), message, level);
    ale.setAccessId(accessId);
    publishEvent(ale);
}
Also used : AuditLogEvent(com.dexels.navajo.events.types.AuditLogEvent)

Aggregations

AuditLogEvent (com.dexels.navajo.events.types.AuditLogEvent)7 Test (org.junit.Test)2 ResultSetMap (com.dexels.navajo.adapter.sqlmap.ResultSetMap)1 NavajoException (com.dexels.navajo.document.NavajoException)1 MappableException (com.dexels.navajo.script.api.MappableException)1 UserException (com.dexels.navajo.script.api.UserException)1 ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1