/*
 * 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.util;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Tests the FileUtils class.
 */
public class FileUtilsTest {

    @Test
    public void testFileFromUriWithPlusCharactersInName() throws Exception {
        final String config = "target/test-classes/log4j+config+with+plus+characters.xml";
        final URI uri = new URI(config);
        final File file = FileUtils.fileFromUri(uri);
        assertEquals("log4j+config+with+plus+characters.xml", file.getName());
        assertTrue("file exists", file.exists());
    }

    @Test
    public void testFileFromUriWithPlusCharactersConvertedToSpacesIfFileDoesNotExist()
            throws Exception {
        final String config = "NON-EXISTING-PATH/this+file+does+not+exist.xml";
        final URI uri = new URI(config);
        final File file = FileUtils.fileFromUri(uri);
        assertEquals("this file does not exist.xml", file.getName());
        assertFalse("file does not exist", file.exists());
    }

    @Test
    public void testGetCorrectedFilePathUriWithoutBackslashes() throws URISyntaxException {
        final String config = "file:///path/to/something/on/unix";
        final URI uri = FileUtils.getCorrectedFilePathUri(config);

        assertNotNull("The URI should not be null.", uri);
        assertEquals("The URI is not correct.", "file:///path/to/something/on/unix", uri.toString());
    }

    @Test
    public void testGetCorrectedFilePathUriWithBackslashes() throws URISyntaxException {
        final String config = "file:///D:\\path\\to\\something/on/windows";
        final URI uri = FileUtils.getCorrectedFilePathUri(config);

        assertNotNull("The URI should not be null.", uri);
        assertEquals("The URI is not correct.", "file:///D:/path/to/something/on/windows", uri.toString());
    }
}

@@ -843,24 +843,203 @@
 il;%0A%0Aimport 
+static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport 
 java.io.File
@@ -1099,60 +1099,8 @@
 tion
-;%0Aimport java.net.URLEncoder;%0A%0Aimport org.junit.Test
 ;%0A%0Ai
@@ -1097,39 +1097,32 @@
 eption;%0A%0Aimport 
-static 
 org.junit.Assert
@@ -1119,16 +1119,12 @@
 nit.
-Assert.*
+Test
 ;%0A%0A/
@@ -1591,32 +1591,389 @@
 ists());%0A    %7D%0A%0A
+    @Test%0A    public void testFileExistsWithPlusCharactersInName() throws Exception %7B%0A        final String config = %22target/test-classes/log4j+config+with+plus+characters.xml%22;%0A        final File file = new File(config);%0A        assertEquals(%22log4j+config+with+plus+characters.xml%22, file.getName());%0A        assertTrue(%22file exists%22, file.exists());%0A    %7D%0A%0A
     @Test%0A    pu
@@ -2056,20 +2056,8 @@
 st()
-%0A           
  thr

Add a test to debug Jenkins build.