GeeCON Prague 2014*
The moose likes Testing and the fly likes Tips for testing a Spring SLF4J/Logback logging component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Testing
Bookmark "Tips for testing a Spring SLF4J/Logback logging component" Watch "Tips for testing a Spring SLF4J/Logback logging component" New topic
Author

Tips for testing a Spring SLF4J/Logback logging component

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi Guys,

As per the requirements for my current project I have developed a reusable enterprise logging component.
I have created a Spring project (Logging-core) which contains amongst other things :

Logger.java (A Spring Singleton).

In this class I have provided instance methods that wrap each of the available SLF4J logging invocations/overloads.

The Logger instance has a reference to 2 other singleton Spring components :

1. LoggerContextConsumer.java (Spring singleton that monitors a JMS Destination for messages providing application specific configuration for the containing Logger instance)
2. LoggerMessageProducer (Spring singleton that publishes all Log Messages in JSON format to a JMS Destination)

In this project I have a dependency on the SLF4J-api and logback-classic.
I have specified that logback use the JNDI context selector to lookup the contextName.
Each application that intends to use this reusable component needs to provide a JNDI entry for the contextName.

I would like ideas on unit/integration tests that I should create to verify that the component is configured as I intended.

For example :
Should I not create tests to assert that existing application code utilising JCL,JUL or SLF4J has it's calls correctly bridged over slf4j to logback, and if so what should my approach be?
How should I go about testing the JNDI context-selection with multiple applications deployed in the JVM? Should I use something like Arquillian? (We are deploying to Jetty)
I have not synchronized access to any of the method calls on my Logger singleton... what should I watch out for her?

Thanks in advance for the advice...








===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
 
GeeCON Prague 2014
 
subject: Tips for testing a Spring SLF4J/Logback logging component