use of org.ff4j.audit.EventPublisher in project ff4j by ff4j.
the class FF4jTest method monitoringAudit.
@Test
public void monitoringAudit() {
// Given
FF4j ff4j = new FF4j();
ff4j.setEventPublisher(new EventPublisher());
ff4j.setEventRepository(new InMemoryEventRepository());
ff4j.removeCurrentContext();
ff4j.getCurrentContext();
// When
ff4j.stop();
// When
ff4j.setEventPublisher(null);
ff4j.getEventPublisher();
ff4j.stop();
// When
Event evt = new Event("f1", EventConstants.TARGET_FEATURE, "f2", EventConstants.ACTION_CHECK_OK);
Assert.assertNotNull(evt.toJson());
Assert.assertNotNull(evt.toString());
// When
EventPublisher ep = new EventPublisher();
new EventPublisher(ep.getRepository(), null);
ep.setRepository(new InMemoryEventRepository());
// Then
Assert.assertNotNull(ep.getRepository());
}
use of org.ff4j.audit.EventPublisher in project ff4j by ff4j.
the class AbstractEventRepositoryTest method setUp.
/**
* {@inheritDoc}
*/
@Before
public void setUp() throws Exception {
repo = initRepository();
publisher = new EventPublisher(repo);
features = new ArrayList<Feature>(new InMemoryFeatureStore("ff4j.xml").readAll().values());
}
use of org.ff4j.audit.EventPublisher in project ff4j by ff4j.
the class EventWorkerTest method testErrorOnSubmitEventPublisher.
@Test
public void testErrorOnSubmitEventPublisher() {
// Given
EventRepository er = mock(EventRepository.class);
Event evt = new Event(SOURCE_JAVA, TARGET_FEATURE, "F1", ACTION_CHECK_OFF);
doThrow(new RuntimeException("Erreur")).when(er).saveEvent(evt);
EventPublisher evtPublisher = new EventPublisher(er);
evtPublisher.publish(evt);
Assert.assertNotNull(evt);
}
use of org.ff4j.audit.EventPublisher in project ff4j by ff4j.
the class FF4j method init.
/**
* Initialization of background components.
*/
private synchronized void init() {
// Execution Context
FlippingExecutionContext context = new FlippingExecutionContext();
this.currentExecutionContext.set(context);
// Event Publisher
if (eventPublisher == null) {
eventPublisher = new EventPublisher(eventRepository);
this.shutdownEventPublisher = true;
}
// Audit is enabled, proxified stores for auditing
if (isEnableAudit()) {
if (fstore != null && !(fstore instanceof FeatureStoreAuditProxy)) {
this.fstore = new FeatureStoreAuditProxy(this, fstore);
}
if (pStore != null && !(pStore instanceof PropertyStoreAuditProxy)) {
this.pStore = new PropertyStoreAuditProxy(this, pStore);
}
} else {
// Audit is disabled but could have been enabled before... removing PROXY if relevant
if (fstore != null && fstore instanceof FeatureStoreAuditProxy) {
this.fstore = ((FeatureStoreAuditProxy) fstore).getTarget();
}
if (pStore != null && pStore instanceof PropertyStoreAuditProxy) {
this.pStore = ((PropertyStoreAuditProxy) pStore).getTarget();
}
}
// Flag as OK
this.initialized = true;
}
Aggregations