/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.mail.internal.thread.context;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.xwiki.test.junit5.mockito.ComponentTest;
import org.xwiki.test.junit5.mockito.InjectMockComponents;

import com.xpn.xwiki.web.XWikiRequest;
import com.xpn.xwiki.web.XWikiServletRequestStub;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;

/**
 * Unit tests for {@link XWikiRequestCopier}.
 *
 * @version $Id$
 */
@ComponentTest
public class XWikiRequestCopierTest
{
    @InjectMockComponents
    private XWikiRequestCopier copier;

    XWikiServletRequestStub originalRequest;

    @BeforeEach
    public void beforeEach()
    {
        this.originalRequest = new XWikiServletRequestStub();
        this.originalRequest.setHost("host");
        this.originalRequest.setContextPath("contextPath");
        this.originalRequest.setScheme("scheme");
        this.originalRequest.setAttribute("attribute", "value");
        this.originalRequest.setServerName("server");
        this.originalRequest.setrequestURL(new StringBuffer("url"));
    }

    @Test
    public void copyRequest()
    {
        XWikiRequest copy = this.copier.copy(this.originalRequest);
        assertNotSame(this.originalRequest, copy);

        // Check that each value on the cloned request are equal.
        assertEquals(this.originalRequest.getHeader("x-forwarded-host"), copy.getHeader("x-forwarded-host"));
        assertEquals(this.originalRequest.getContextPath(), copy.getContextPath());
        assertEquals(this.originalRequest.getScheme(), copy.getScheme());
        assertEquals(this.originalRequest.getAttributeNames(), copy.getAttributeNames());
        assertEquals(this.originalRequest.getAttribute("attribute"), copy.getAttribute("attribute"));
        assertEquals(this.originalRequest.getServerName(), copy.getServerName());
        assertNotSame(this.originalRequest.getRequestURL(), copy.getRequestURL());
        assertEquals(this.originalRequest.getRequestURL().toString(), copy.getRequestURL().toString());
    }

    @Test
    public void copyContextWhenNull()
    {
        assertNull(this.copier.copy(null));
    }
}

@@ -1234,30 +1234,46 @@
 c org.junit.
+jupiter.api.
 Assert
+ions
 .assertEqual
@@ -1291,38 +1291,54 @@
 tatic org.junit.
+jupiter.api.
 Assert
+ions
 .assertNotSame;%0A
@@ -1361,22 +1361,38 @@
 g.junit.
+jupiter.api.
 Assert
+ions
 .assertN
@@ -1486,23 +1486,16 @@
 entTest%0A
-public 
 class XW
@@ -1515,16 +1515,16 @@
 ierTest%0A
+
 %7B%0A    @I
@@ -1645,27 +1645,20 @@
 oreEach%0A
+
     
-public 
 void bef
@@ -2092,39 +2092,32 @@
 %0A%0A    @Test%0A    
-public 
 void copyRequest
@@ -3065,15 +3065,8 @@
     
-public 
 void

Fix mix of JUnit4 and JUnit5 + apply best practices