logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kamal Mettananda <lka...@gmail.com>
Subject Re: Adding JUnit tests for CsvParameterLayoutTest
Date Thu, 21 Apr 2016 13:12:58 GMT
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
>

Mime
View raw message