use of nl.nn.adapterframework.lifecycle.MessageEventListener in project iaf by ibissource.
the class IbisContextTest method nullClassLoader.
@Test
public void nullClassLoader() {
String configurationName = "ConfigWithNullClassLoader";
try (IbisContext context = new IbisTestContext(configurationName, TestClassLoader.class)) {
context.init(false);
assertEquals("TestConfiguration", context.getApplicationName());
assertEquals(0, context.getIbisManager().getConfigurations().size());
MessageEventListener events = context.getBean("MessageEventListener", MessageEventListener.class);
MessageKeeperMessage message = events.getMessageKeeper().getMessage(events.getMessageKeeper().size() - 2);
assertNotNull("unable to find MessageKeeperMessage", message);
assertThat(message.getMessageText(), Matchers.endsWith("error configuring ClassLoader for configuration [ConfigWithNullClassLoader]: (ClassLoaderException) test-exception"));
}
}
use of nl.nn.adapterframework.lifecycle.MessageEventListener in project iaf by ibissource.
the class ApiTestBase method setUp.
@Before
public void setUp() throws Exception {
// Remove old instance if present
ApplicationWarnings.removeInstance();
M resource = createJaxRsResource();
checkContextFields(resource);
jaxRsResource = spy(resource);
MockServletContext servletContext = new MockServletContext();
MockServletConfig servletConfig = new MockServletConfig(servletContext, "JAX-RS-MockDispatcher");
jaxRsResource.servletConfig = servletConfig;
jaxRsResource.securityContext = mock(SecurityContext.class);
IbisContext ibisContext = mock(IbisContext.class);
configuration = new TestConfiguration();
IbisManager ibisManager = configuration.getIbisManager();
ibisManager.setIbisContext(ibisContext);
doReturn(ibisManager).when(ibisContext).getIbisManager();
doReturn(ibisContext).when(jaxRsResource).getIbisContext();
doReturn(configuration.getBean("applicationWarnings")).when(ibisContext).getBean(eq("applicationWarnings"), any());
// we don't test the messages
doReturn(new MessageEventListener()).when(ibisContext).getBean(eq("MessageEventListener"), any());
registerAdapter(configuration);
dispatcher.register(jaxRsResource);
}
use of nl.nn.adapterframework.lifecycle.MessageEventListener in project iaf by ibissource.
the class ServerStatistics method getServerConfiguration.
@GET
@PermitAll
@Path("/server/warnings")
@Produces(MediaType.APPLICATION_JSON)
public Response getServerConfiguration() throws ApiException {
Map<String, Object> returnMap = new HashMap<String, Object>();
ApplicationWarnings globalConfigWarnings = getIbisContext().getBean("applicationWarnings", ApplicationWarnings.class);
MessageEventListener eventListener = getIbisContext().getBean("MessageEventListener", MessageEventListener.class);
long totalErrorStoreCount = 0;
boolean showCountErrorStore = AppConstants.getInstance().getBoolean("errorStore.count.show", true);
if (!showCountErrorStore)
totalErrorStoreCount = -1;
for (Configuration configuration : getIbisManager().getConfigurations()) {
Map<String, Object> configurationsMap = new HashMap<String, Object>();
// Configuration specific exceptions
if (configuration.getConfigurationException() != null) {
String message = configuration.getConfigurationException().getMessage();
configurationsMap.put("exception", message);
}
if (configuration.isActive()) {
// ErrorStore count
if (showCountErrorStore) {
long esr = 0;
for (Adapter adapter : configuration.getRegisteredAdapters()) {
for (Receiver<?> receiver : adapter.getReceivers()) {
IMessageBrowser<?> errorStorage = receiver.getMessageBrowser(ProcessState.ERROR);
if (errorStorage != null) {
try {
esr += errorStorage.getMessageCount();
} catch (Exception e) {
// error("error occured on getting number of errorlog records for adapter ["+adapter.getName()+"]",e);
log.warn("Assuming there are no errorlog records for adapter [" + adapter.getName() + "]");
}
}
}
}
totalErrorStoreCount += esr;
configurationsMap.put("errorStoreCount", esr);
}
// Configuration specific warnings
ConfigurationWarnings configWarns = configuration.getConfigurationWarnings();
if (configWarns != null && configWarns.size() > 0) {
configurationsMap.put("warnings", configWarns.getWarnings());
}
// Configuration specific messages
MessageKeeper messageKeeper = eventListener.getMessageKeeper(configuration.getName());
if (messageKeeper != null) {
List<Object> messages = mapMessageKeeperMessages(messageKeeper);
if (!messages.isEmpty()) {
configurationsMap.put("messages", messages);
}
}
}
returnMap.put(configuration.getName(), configurationsMap);
}
// Total ErrorStore Count
returnMap.put("totalErrorStoreCount", totalErrorStoreCount);
// Global warnings
if (globalConfigWarnings.size() > 0) {
List<Object> warnings = new ArrayList<>();
for (int j = 0; j < globalConfigWarnings.size(); j++) {
warnings.add(globalConfigWarnings.get(j));
}
returnMap.put("warnings", warnings);
}
// Global messages
MessageKeeper messageKeeper = eventListener.getMessageKeeper();
List<Object> messages = mapMessageKeeperMessages(messageKeeper);
if (!messages.isEmpty()) {
returnMap.put("messages", messages);
}
Response.ResponseBuilder response = null;
// Calculate the ETag on last modified date of user resource
EntityTag etag = new EntityTag(returnMap.hashCode() + "");
// Verify if it matched with etag available in http request
response = rsRequest.evaluatePreconditions(etag);
// If ETag matches the response will be non-null;
if (response != null) {
return response.tag(etag).build();
}
response = Response.status(Response.Status.OK).entity(returnMap).tag(etag);
return response.build();
}
Aggregations