/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache license, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the license for the specific language governing permissions and
 * limitations under the license.
 */
package org.apache.logging.log4j.core.appender.rolling;

import static org.junit.Assert.assertTrue;

import java.io.File;
import java.util.Arrays;
import java.util.Collection;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.junit.InitialLoggerContext;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

/**
 *
 */
@RunWith(Parameterized.class)
public class RollingAppenderSizeTest {

    private static final String DIR = "target/rolling1";

    private final String fileExtension;

    private Logger logger;

    @Parameterized.Parameters
    public static Collection<Object[]> data() {
        return Arrays.asList(
                new Object[][]{
                        { "log4j-rolling-gz.xml", ".gz" },
                        { "log4j-rolling-zip.xml", ".zip" }
                }
        );
    }

    @Rule
    public InitialLoggerContext init;

    public RollingAppenderSizeTest(final String configFile, final String fileExtension) {
        this.fileExtension = fileExtension;
        this.init = new InitialLoggerContext(configFile);
    }

    @Before
    public void setUp() throws Exception {
        deleteDir();
        this.logger = this.init.getLogger(RollingAppenderSizeTest.class.getName());
    }

    @After
    public void tearDown() throws Exception {
        deleteDir();
    }

    @Test
    public void testAppender() throws Exception {
        for (int i=0; i < 100; ++i) {
            logger.debug("This is test message number " + i);
        }
        final File dir = new File(DIR);
        assertTrue("Directory not created", dir.exists() && dir.listFiles().length > 0);
        final File[] files = dir.listFiles();
        assertTrue("No files created", files.length > 0);
        boolean found = false;
        for (final File file : files) {
            if (file.getName().endsWith(fileExtension)) {
                found = true;
                break;
            }
        }
        assertTrue("No compressed files found", found);
    }

    private static void deleteDir() {
        final File dir = new File(DIR);
        if (dir.exists()) {
            final File[] files = dir.listFiles();
            for (final File file : files) {
                file.delete();
            }
            dir.delete();
        }
    }
}

@@ -855,52 +855,8 @@
 g;%0A%0A
-import static org.junit.Assert.assertTrue;%0A%0A
 impo
@@ -926,17 +926,16 @@
 ection;%0A
-%0A
 import o
@@ -1043,17 +1043,92 @@
 g.junit.
-*
+After;%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.Test
 ;%0Aimport
@@ -1195,16 +1195,60 @@
 rized;%0A%0A
+import static org.junit.Assert.assertTrue;%0A%0A
 /**%0A *%0A 
@@ -2045,37 +2045,16 @@
 ption %7B%0A
-        deleteDir();%0A
         

Fix RollingAppenderSizeTest.