logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Adding JUnit tests for CsvParameterLayoutTest
Date Thu, 21 Apr 2016 16:00:51 GMT
Yes, thank you Kamal for pointing this out! JUnit's parameterized features
is *awesome*.

http://junit.sourceforge.net/javadoc/org/junit/runners/Parameterized.html


Gary

On Thu, Apr 21, 2016 at 6:12 AM, Kamal Mettananda <lkamal@gmail.com> wrote:

> Hi Remko
>
> I am still new here, but thought of giving some input from a Junit
> parameterization point of view.
>
> It seems we can parameterize the ConfigurationFactory of
> CsvParameterLayoutTest using something like below to provide two
> Configurations as parameters.
>
> @RunWith(value = Parameterized.class)
> public class CsvParameterLayoutTest {
>
>     ConfigurationFactory cf = null;
>
>     public CsvParameterLayoutTest(ConfigurationFactory newcf) {
>         cf = newcf;
>         setupClass();
>     }
>
>     @Parameterized.Parameters(name = "{index}: configuration factory =
> {0}")
>     public static Iterable<Object[]> data1() {
>         return Arrays.asList(new Object[][] {
>                 {
>                         new BasicConfigurationFactory()
>                 },
>                 {
>                         new AsyncBasicConfigurationFactory()
>                 }
>         });
>     }
>
>    //@BeforeClass
>     public static void setupClass() {
>         ThreadContext.clearAll();
>         ConfigurationFactory.setConfigurationFactory(cf);
>         System.out.println("================ " + cf.getClass().getName());
>         final LoggerContext ctx = LoggerContext.getContext();
>         ctx.reconfigure();
>     }
>
>     ....
> }
>
> Hope this will help.
>
> Thanks
>
> ---------------------------------------
> Kamal Mettananda
> www.digizol.com
>
>
> On Thu, Apr 21, 2016 at 5:09 PM, Remko Popma <remko.popma@gmail.com>
> wrote:
>
>> I would like to re-run the CsvParameterlayoutTest
>> 1. with its current configuration
>> 2. with a configuration that uses <AsyncRoot> instead of <Root>
>> 3. with all loggers asynchronous by setting system property
>> Log4jContextSelector to
>> org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
>>
>> I can just copy the test code and do the above in the setup, but I was
>> wondering if there is no way to parameterize the test to accomplish this?
>>
>> Remko
>>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
View raw message