Search in sources :

Example 1 with SPIAuditorProvider

use of org.nhindirect.common.audit.provider.SPIAuditorProvider in project nhin-d by DirectProject.

the class SPIAuditorProviderTest method testCreateSingleAuditorFromSPI_NonNullConstructor_AssertMutliProviderAuditorCreated.

@Test
public void testCreateSingleAuditorFromSPI_NonNullConstructor_AssertMutliProviderAuditorCreated() throws Exception {
    setupSPIImplementation(LoggingAuditor.class);
    setupSPIImplementation(NoOpAuditor.class);
    SPIAuditorProvider prov = new SPIAuditorProvider(Auditor.class.getClassLoader());
    assertTrue(prov.isImplementationAvailable());
    assertNotNull(prov.get());
    assertTrue(prov.get() instanceof MultiProviderAuditor);
}
Also used : LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Auditor(org.nhindirect.common.audit.Auditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) NoOpAuditor(org.nhindirect.common.audit.impl.NoOpAuditor) MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) SPIAuditorProvider(org.nhindirect.common.audit.provider.SPIAuditorProvider) Test(org.junit.Test)

Example 2 with SPIAuditorProvider

use of org.nhindirect.common.audit.provider.SPIAuditorProvider in project nhin-d by DirectProject.

the class SPIAuditorProviderTest method testCreateSingleAuditorFromSPI_AssertAuditorInstanceOf.

@Test
public void testCreateSingleAuditorFromSPI_AssertAuditorInstanceOf() throws Exception {
    setupSPIImplementation(LoggingAuditor.class);
    SPIAuditorProvider prov = new SPIAuditorProvider();
    assertTrue(prov.isImplementationAvailable());
    assertNotNull(prov.get());
    assertTrue(prov.get() instanceof LoggingAuditor);
}
Also used : SPIAuditorProvider(org.nhindirect.common.audit.provider.SPIAuditorProvider) LoggingAuditor(org.nhindirect.common.audit.impl.LoggingAuditor) Test(org.junit.Test)

Example 3 with SPIAuditorProvider

use of org.nhindirect.common.audit.provider.SPIAuditorProvider in project nhin-d by DirectProject.

the class SPIAuditorProviderTest method testNoSPIAvailable_AssertNullAuditor.

@Test
public void testNoSPIAvailable_AssertNullAuditor() throws Exception {
    SPIAuditorProvider prov = new SPIAuditorProvider();
    assertFalse(prov.isImplementationAvailable());
    assertNull(prov.get());
}
Also used : SPIAuditorProvider(org.nhindirect.common.audit.provider.SPIAuditorProvider) Test(org.junit.Test)

Example 4 with SPIAuditorProvider

use of org.nhindirect.common.audit.provider.SPIAuditorProvider in project nhin-d by DirectProject.

the class AuditorFactory method createAuditor.

/**
	 * Creates an {@link Auditor} by searching for configured implementations using Java SPI.  If no implementation are found, a default
	 * instance using the configured logging sub-system is created.
	 * @return An new auditor instance.
	 */
public static synchronized Auditor createAuditor() {
    final SPIAuditorProvider spiProv = new SPIAuditorProvider();
    final Provider<Auditor> provider = spiProv.isImplementationAvailable() ? spiProv : new LoggingAuditorProvider();
    return createAuditor(provider);
}
Also used : LoggingAuditorProvider(org.nhindirect.common.audit.provider.LoggingAuditorProvider) SPIAuditorProvider(org.nhindirect.common.audit.provider.SPIAuditorProvider)

Example 5 with SPIAuditorProvider

use of org.nhindirect.common.audit.provider.SPIAuditorProvider in project nhin-d by DirectProject.

the class SPIAuditorProviderTest method testCreateSingleAuditorFromSPI_AssertMutliProviderAuditorCreated.

@Test
public void testCreateSingleAuditorFromSPI_AssertMutliProviderAuditorCreated() throws Exception {
    setupSPIImplementation(LoggingAuditor.class);
    setupSPIImplementation(NoOpAuditor.class);
    SPIAuditorProvider prov = new SPIAuditorProvider();
    assertTrue(prov.isImplementationAvailable());
    assertNotNull(prov.get());
    assertTrue(prov.get() instanceof MultiProviderAuditor);
}
Also used : MultiProviderAuditor(org.nhindirect.common.audit.impl.MultiProviderAuditor) SPIAuditorProvider(org.nhindirect.common.audit.provider.SPIAuditorProvider) Test(org.junit.Test)

Aggregations

SPIAuditorProvider (org.nhindirect.common.audit.provider.SPIAuditorProvider)6 Test (org.junit.Test)5 MultiProviderAuditor (org.nhindirect.common.audit.impl.MultiProviderAuditor)3 LoggingAuditor (org.nhindirect.common.audit.impl.LoggingAuditor)2 Auditor (org.nhindirect.common.audit.Auditor)1 NoOpAuditor (org.nhindirect.common.audit.impl.NoOpAuditor)1 LoggingAuditorProvider (org.nhindirect.common.audit.provider.LoggingAuditorProvider)1