Repository: logging-log4j2
Updated Branches:
  refs/heads/master f3e9ea13f -> 78c6a1fca


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/78c6a1fc/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContainerInitializerTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContainerInitializerTest.java
 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContainerInitializerTest.java
index a4e6a6c..0cd3988 100644
--- 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContainerInitializerTest.java
+++ 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContainerInitializerTest.java
@@ -24,156 +24,125 @@ import javax.servlet.FilterRegistration;
 import javax.servlet.ServletContext;
 
 import org.apache.logging.log4j.util.Strings;
-import org.easymock.Capture;
-import org.easymock.EasyMock;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
 
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
+import static org.mockito.BDDMockito.willThrow;
+import static org.mockito.Mockito.mock;
 
+@RunWith(MockitoJUnitRunner.class)
 public class Log4jServletContainerInitializerTest {
+    @Mock
     private ServletContext servletContext;
+    @Mock
     private Log4jWebLifeCycle initializer;
+    @Captor
+    private ArgumentCaptor<Class<? extends Filter>> filterCaptor;
+    @Captor
+    private ArgumentCaptor<EventListener> listenerCaptor;
 
     private Log4jServletContainerInitializer containerInitializer;
 
     @Before
     public void setUp() {
-        this.servletContext = createStrictMock(ServletContext.class);
-        this.initializer = createStrictMock(Log4jWebLifeCycle.class);
-
         this.containerInitializer = new Log4jServletContainerInitializer();
     }
 
-    @After
-    public void tearDown() {
-        verify(this.servletContext, this.initializer);
-    }
-
     @Test
     public void testOnStartupWithServletVersion2_x() throws Exception {
-        expect(this.servletContext.getMajorVersion()).andReturn(2);
-
-        replay(this.servletContext, this.initializer);
+        given(servletContext.getMajorVersion()).willReturn(2);
 
         this.containerInitializer.onStartup(null, this.servletContext);
     }
 
     @Test
     public void testOnStartupWithServletVersion3_xEffectiveVersion2_x() throws 
Exception {
-        expect(this.servletContext.getMajorVersion()).andReturn(3);
-        expect(this.servletContext.getEffectiveMajorVersion()).andReturn(2);
-
-        replay(this.servletContext, this.initializer);
+        given(servletContext.getMajorVersion()).willReturn(3);
+        given(servletContext.getEffectiveMajorVersion()).willReturn(2);
 
         this.containerInitializer.onStartup(null, this.servletContext);
     }
 
     @Test
     public void 
testOnStartupWithServletVersion3_xEffectiveVersion3_xDisabledTrue() throws 
Exception {
-        expect(this.servletContext.getMajorVersion()).andReturn(3);
-        expect(this.servletContext.getEffectiveMajorVersion()).andReturn(3);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))
-                .andReturn("true");
-
-        replay(this.servletContext, this.initializer);
+        given(servletContext.getMajorVersion()).willReturn(3);
+        given(servletContext.getEffectiveMajorVersion()).willReturn(3);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))).willReturn(
+            "true");
 
         this.containerInitializer.onStartup(null, this.servletContext);
     }
 
     @Test
     public void 
testOnStartupWithServletVersion3_xEffectiveVersion3_xDisabledTRUE() throws 
Exception {
-        expect(this.servletContext.getMajorVersion()).andReturn(3);
-        expect(this.servletContext.getEffectiveMajorVersion()).andReturn(3);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))
-                .andReturn("TRUE");
-
-        replay(this.servletContext, this.initializer);
+        given(servletContext.getMajorVersion()).willReturn(3);
+        given(servletContext.getEffectiveMajorVersion()).willReturn(3);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))).willReturn(
+            "TRUE");
 
         this.containerInitializer.onStartup(null, this.servletContext);
     }
 
     @Test
     public void testOnStartupWithServletVersion3_xEffectiveVersion3_x() throws 
Exception {
-        final FilterRegistration.Dynamic registration = 
createStrictMock(FilterRegistration.Dynamic.class);
-
-        final Capture<EventListener> listenerCapture = EasyMock.newCapture();
-        final Capture<Class<? extends Filter>> filterCapture = 
EasyMock.newCapture();
-
-        expect(this.servletContext.getMajorVersion()).andReturn(3);
-        expect(this.servletContext.getEffectiveMajorVersion()).andReturn(3);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))
-                .andReturn(null);
-        expect(this.servletContext.addFilter(eq("log4jServletFilter"), 
capture(filterCapture))).andReturn(registration);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(this.initializer);
-        this.initializer.start();
-        expectLastCall();
-        this.initializer.setLoggerContext();
-        expectLastCall();
-        this.servletContext.addListener(capture(listenerCapture));
-        expectLastCall();
-        registration.setAsyncSupported(true);
-        expectLastCall();
-        
registration.addMappingForUrlPatterns(eq(EnumSet.allOf(DispatcherType.class)), 
eq(false), eq("/*"));
-        expectLastCall();
-
-        replay(this.servletContext, this.initializer, registration);
-
-        this.containerInitializer.onStartup(null, this.servletContext);
-
-        assertNotNull("The listener should not be null.", 
listenerCapture.getValue());
+        final FilterRegistration.Dynamic registration = 
mock(FilterRegistration.Dynamic.class);
+        given(servletContext.getMajorVersion()).willReturn(3);
+        given(servletContext.getEffectiveMajorVersion()).willReturn(3);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))).willReturn(
+            null);
+        given(servletContext.addFilter(eq("log4jServletFilter"), 
filterCaptor.capture())).willReturn(registration);
+        
given(servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).willReturn(initializer);
+
+        containerInitializer.onStartup(null, servletContext);
+
+        then(initializer).should().start();
+        then(initializer).should().setLoggerContext();
+        then(servletContext).should().addListener(listenerCaptor.capture());
+        then(registration).should().setAsyncSupported(eq(true));
+        
then(registration).should().addMappingForUrlPatterns(eq(EnumSet.allOf(DispatcherType.class)),
 eq(false), eq("/*"));
+
+        assertNotNull("The listener should not be null.", 
listenerCaptor.getValue());
         assertSame("The listener is not correct.", 
Log4jServletContextListener.class,
-                listenerCapture.getValue().getClass());
-
-        assertNotNull("The filter should not be null.", 
filterCapture.getValue());
-        assertSame("The filter is not correct.", Log4jServletFilter.class, 
filterCapture.getValue());
+            listenerCaptor.getValue().getClass());
 
-        verify(registration);
+        assertNotNull("The filter should not be null.", 
filterCaptor.getValue());
+        assertSame("The filter is not correct.", Log4jServletFilter.class, 
filterCaptor.getValue());
     }
 
     @Test
     public void testOnStartupCanceledDueToPreExistingFilter() throws Exception 
{
-        final Capture<Class<? extends Filter>> filterCapture = 
EasyMock.newCapture();
-
-        expect(this.servletContext.getMajorVersion()).andReturn(3);
-        expect(this.servletContext.getEffectiveMajorVersion()).andReturn(3);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))
-                .andReturn("false");
-        expect(this.servletContext.addFilter(eq("log4jServletFilter"), 
capture(filterCapture))).andReturn(null);
-
-        replay(this.servletContext, this.initializer);
+        given(servletContext.getMajorVersion()).willReturn(3);
+        given(servletContext.getEffectiveMajorVersion()).willReturn(3);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))).willReturn(
+            "false");
+        given(servletContext.addFilter(eq("log4jServletFilter"), 
filterCaptor.capture())).willReturn(null);
 
         this.containerInitializer.onStartup(null, this.servletContext);
 
-        assertNotNull("The filter should not be null.", 
filterCapture.getValue());
-        assertSame("The filter is not correct.", Log4jServletFilter.class, 
filterCapture.getValue());
+        assertNotNull("The filter should not be null.", 
filterCaptor.getValue());
+        assertSame("The filter is not correct.", Log4jServletFilter.class, 
filterCaptor.getValue());
     }
 
     @Test
     public void testOnStartupFailedDueToInitializerFailure() throws Exception {
-        final FilterRegistration.Dynamic registration = 
createStrictMock(FilterRegistration.Dynamic.class);
-
-        final Capture<Class<? extends Filter>> filterCapture = 
EasyMock.newCapture();
+        final FilterRegistration.Dynamic registration = 
mock(FilterRegistration.Dynamic.class);
         final IllegalStateException exception = new 
IllegalStateException(Strings.EMPTY);
-
-        expect(this.servletContext.getMajorVersion()).andReturn(3);
-        expect(this.servletContext.getEffectiveMajorVersion()).andReturn(3);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))
-                .andReturn("balderdash");
-        expect(this.servletContext.addFilter(eq("log4jServletFilter"), 
capture(filterCapture))).andReturn(registration);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(this.initializer);
-        this.initializer.start();
-        expectLastCall().andThrow(exception);
-
-        replay(this.servletContext, this.initializer, registration);
+        given(servletContext.getMajorVersion()).willReturn(3);
+        given(servletContext.getEffectiveMajorVersion()).willReturn(3);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_AUTO_INITIALIZATION_DISABLED))).willReturn(
+            "balderdash");
+        given(servletContext.addFilter(eq("log4jServletFilter"), 
filterCaptor.capture())).willReturn(registration);
+        
given(servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).willReturn(initializer);
+        willThrow(exception).given(initializer).start();
 
         try {
             this.containerInitializer.onStartup(null, this.servletContext);
@@ -182,9 +151,8 @@ public class Log4jServletContainerInitializerTest {
             assertSame("The exception is not correct.", exception, e);
         }
 
-        assertNotNull("The filter should not be null.", 
filterCapture.getValue());
-        assertSame("The filter is not correct.", Log4jServletFilter.class, 
filterCapture.getValue());
-
-        verify(registration);
+        then(initializer).should().start();
+        assertNotNull("The filter should not be null.", 
filterCaptor.getValue());
+        assertSame("The filter is not correct.", Log4jServletFilter.class, 
filterCaptor.getValue());
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/78c6a1fc/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContextListenerTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContextListenerTest.java
 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContextListenerTest.java
index a1d90ff..7be7b9c 100644
--- 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContextListenerTest.java
+++ 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletContextListenerTest.java
@@ -20,73 +20,51 @@ import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 
 import org.apache.logging.log4j.util.Strings;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
 import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
+import static org.mockito.BDDMockito.willThrow;
 
+@RunWith(MockitoJUnitRunner.class)
 public class Log4jServletContextListenerTest {
+    @Mock
     private ServletContextEvent event;
+    @Mock
     private ServletContext servletContext;
+    @Mock
     private Log4jWebLifeCycle initializer;
 
     private Log4jServletContextListener listener;
 
     @Before
     public void setUp() {
-        this.event = createStrictMock(ServletContextEvent.class);
-        this.servletContext = createStrictMock(ServletContext.class);
-        this.initializer = createStrictMock(Log4jWebLifeCycle.class);
-
         this.listener = new Log4jServletContextListener();
-    }
-
-    @After
-    public void tearDown() {
-        verify(this.event, this.servletContext, this.initializer);
+        given(event.getServletContext()).willReturn(servletContext);
+        
given(servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).willReturn(initializer);
     }
 
     @Test
     public void testInitAndDestroy() throws Exception {
-        expect(this.event.getServletContext()).andReturn(this.servletContext);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(this.initializer);
-        this.initializer.start();
-        expectLastCall();
-        this.initializer.setLoggerContext();
-        expectLastCall();
-
-        replay(this.event, this.servletContext, this.initializer);
-
         this.listener.contextInitialized(this.event);
 
-        verify(this.event, this.servletContext, this.initializer);
-        reset(this.event, this.servletContext, this.initializer);
-
-        this.initializer.clearLoggerContext();
-        expectLastCall();
-        this.initializer.stop();
-        expectLastCall();
-
-        replay(this.event, this.servletContext, this.initializer);
+        then(initializer).should().start();
+        then(initializer).should().setLoggerContext();
 
         this.listener.contextDestroyed(this.event);
+
+        then(initializer).should().clearLoggerContext();
+        then(initializer).should().stop();
     }
 
     @Test
     public void testInitFailure() throws Exception {
-        expect(this.event.getServletContext()).andReturn(this.servletContext);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(this.initializer);
-        this.initializer.start();
-        expectLastCall().andThrow(new IllegalStateException(Strings.EMPTY));
-
-        replay(this.event, this.servletContext, this.initializer);
+        willThrow(new 
IllegalStateException(Strings.EMPTY)).given(initializer).start();
 
         try {
             this.listener.contextInitialized(this.event);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/78c6a1fc/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletFilterTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletFilterTest.java
 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletFilterTest.java
index bf6a84f..1fb72a3 100644
--- 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletFilterTest.java
+++ 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jServletFilterTest.java
@@ -22,131 +22,87 @@ import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.same;
-import static org.easymock.EasyMock.verify;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.same;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
+import static org.mockito.Mockito.reset;
 
+@RunWith(MockitoJUnitRunner.class)
 public class Log4jServletFilterTest {
+    @Mock
     private FilterConfig filterConfig;
+    @Mock
     private ServletContext servletContext;
+    @Mock
     private Log4jWebLifeCycle initializer;
+    @Mock
+    private ServletRequest request;
+    @Mock
+    private ServletResponse response;
+    @Mock
+    private FilterChain chain;
 
     private Log4jServletFilter filter;
 
     @Before
     public void setUp() {
-        this.filterConfig = createStrictMock(FilterConfig.class);
-        this.servletContext = createStrictMock(ServletContext.class);
-        this.initializer = createStrictMock(Log4jWebLifeCycle.class);
-
+        given(filterConfig.getServletContext()).willReturn(servletContext);
+        
given(servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).willReturn(initializer);
         this.filter = new Log4jServletFilter();
     }
 
-    @After
-    public void tearDown() {
-        verify(this.filterConfig, this.servletContext, this.initializer);
-    }
-
     @Test
     public void testInitAndDestroy() throws Exception {
-        
expect(this.filterConfig.getServletContext()).andReturn(this.servletContext);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(this.initializer);
-        this.initializer.clearLoggerContext();
-        expectLastCall();
-
-        replay(this.filterConfig, this.servletContext, this.initializer);
-
         this.filter.init(this.filterConfig);
 
-        verify(this.filterConfig, this.servletContext, this.initializer);
-        reset(this.filterConfig, this.servletContext, this.initializer);
-
-        this.initializer.setLoggerContext();
-        expectLastCall();
-
-        replay(this.filterConfig, this.servletContext, this.initializer);
+        then(initializer).should().clearLoggerContext();
 
         this.filter.destroy();
+
+        then(initializer).should().setLoggerContext();
     }
 
     @Test(expected = IllegalStateException.class)
     public void testDestroy() {
-        replay(this.filterConfig, this.servletContext, this.initializer);
-
         this.filter.destroy();
     }
 
     @Test
     public void testDoFilterFirstTime() throws Exception {
-        
expect(this.filterConfig.getServletContext()).andReturn(this.servletContext);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(this.initializer);
-        this.initializer.clearLoggerContext();
-        expectLastCall();
-
-        replay(this.filterConfig, this.servletContext, this.initializer);
-
         this.filter.init(this.filterConfig);
 
-        verify(this.filterConfig, this.servletContext, this.initializer);
-        reset(this.filterConfig, this.servletContext, this.initializer);
-
-        final ServletRequest request = createStrictMock(ServletRequest.class);
-        final ServletResponse response = 
createStrictMock(ServletResponse.class);
-        final FilterChain chain = createStrictMock(FilterChain.class);
-
-        
expect(request.getAttribute(Log4jServletFilter.ALREADY_FILTERED_ATTRIBUTE)).andReturn(null);
-        
request.setAttribute(eq(Log4jServletFilter.ALREADY_FILTERED_ATTRIBUTE), 
eq(Boolean.TRUE));
-        expectLastCall();
-        this.initializer.setLoggerContext();
-        expectLastCall();
-        chain.doFilter(same(request), same(response));
-        expectLastCall();
-        this.initializer.clearLoggerContext();
-        expectLastCall();
+        then(initializer).should().clearLoggerContext();
+        reset(initializer);
 
-        replay(this.filterConfig, this.servletContext, this.initializer, 
request, response, chain);
+        
given(request.getAttribute(Log4jServletFilter.ALREADY_FILTERED_ATTRIBUTE)).willReturn(null);
 
         this.filter.doFilter(request, response, chain);
 
-        verify(request, response, chain);
+        
then(request).should().setAttribute(eq(Log4jServletFilter.ALREADY_FILTERED_ATTRIBUTE),
 eq(true));
+        then(initializer).should().setLoggerContext();
+        then(chain).should().doFilter(same(request), same(response));
+        then(chain).shouldHaveNoMoreInteractions();
+        then(initializer).should().clearLoggerContext();
     }
 
     @Test
     public void testDoFilterSecondTime() throws Exception {
-        
expect(this.filterConfig.getServletContext()).andReturn(this.servletContext);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(this.initializer);
-        this.initializer.clearLoggerContext();
-        expectLastCall();
-
-        replay(this.filterConfig, this.servletContext, this.initializer);
-
         this.filter.init(this.filterConfig);
 
-        verify(this.filterConfig, this.servletContext, this.initializer);
-        reset(this.filterConfig, this.servletContext, this.initializer);
-
-        final ServletRequest request = createStrictMock(ServletRequest.class);
-        final ServletResponse response = 
createStrictMock(ServletResponse.class);
-        final FilterChain chain = createStrictMock(FilterChain.class);
-
-        
expect(request.getAttribute(Log4jServletFilter.ALREADY_FILTERED_ATTRIBUTE)).andReturn(true);
-        expectLastCall();
-        chain.doFilter(same(request), same(response));
-        expectLastCall();
+        then(initializer).should().clearLoggerContext();
 
-        replay(this.filterConfig, this.servletContext, this.initializer, 
request, response, chain);
+        
given(request.getAttribute(Log4jServletFilter.ALREADY_FILTERED_ATTRIBUTE)).willReturn(true);
 
         this.filter.doFilter(request, response, chain);
 
-        verify(request, response, chain);
+        then(chain).should().doFilter(same(request), same(response));
+        then(chain).shouldHaveNoMoreInteractions();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/78c6a1fc/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java
 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java
index 8ed6046..7949e49 100644
--- 
a/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java
+++ 
b/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java
@@ -20,71 +20,56 @@ import javax.servlet.ServletContext;
 
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.impl.ContextAnchor;
-import org.easymock.Capture;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
 
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
 
+@RunWith(MockitoJUnitRunner.class)
 public class Log4jWebInitializerImplTest {
+    @Mock
     private ServletContext servletContext;
+    @Captor
+    private ArgumentCaptor<Log4jWebLifeCycle> initializerCaptor;
+    @Captor
+    private ArgumentCaptor<org.apache.logging.log4j.spi.LoggerContext> 
loggerContextCaptor;
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
 
     private Log4jWebInitializerImpl initializerImpl;
 
     @Before
     public void setUp() {
-        final Capture<Log4jWebLifeCycle> initializerCapture = 
EasyMock.newCapture();
-
-        this.servletContext = createStrictMock(ServletContext.class);
-        
expect(this.servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).andReturn(null);
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.SUPPORT_ATTRIBUTE), 
capture(initializerCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
+        
given(servletContext.getAttribute(Log4jWebSupport.SUPPORT_ATTRIBUTE)).willReturn(null);
 
         final Log4jWebLifeCycle initializer = 
WebLoggerContextUtils.getWebLifeCycle(this.servletContext);
 
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.SUPPORT_ATTRIBUTE),
 initializerCaptor.capture());
         assertNotNull("The initializer should not be null.", initializer);
-        assertSame("The capture is not correct.", initializer, 
initializerCapture.getValue());
+        assertSame("The capture is not correct.", initializer, 
initializerCaptor.getValue());
         assertTrue("The initializer is not correct.", initializer instanceof 
Log4jWebInitializerImpl);
-        verify(this.servletContext);
-        reset(this.servletContext);
 
         this.initializerImpl = (Log4jWebInitializerImpl) initializer;
     }
 
-    @After
-    public void tearDown() {
-        verify(this.servletContext);
-    }
-
     @Test
     public void testDeinitializeBeforeInitialize() {
-        replay(this.servletContext);
-
-        try {
-            this.initializerImpl.stop();
-            fail("Expected an IllegalStateException.");
-        } catch (final IllegalStateException ignore) {
-
-        }
+        expectedException.expect(IllegalStateException.class);
+        this.initializerImpl.stop();
     }
 
     @Test
     public void testSetLoggerContextBeforeInitialize() {
-        replay(this.servletContext);
-
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.setLoggerContext();
@@ -94,8 +79,6 @@ public class Log4jWebInitializerImplTest {
 
     @Test
     public void testClearLoggerContextBeforeInitialize() {
-        replay(this.servletContext);
-
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.clearLoggerContext();
@@ -105,32 +88,17 @@ public class Log4jWebInitializerImplTest {
 
     @Test
     public void 
testInitializeWithNoParametersThenSetLoggerContextThenDeinitialize() throws 
Exception {
-        final Capture<Object> loggerContextCapture = EasyMock.newCapture();
-
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn(null);
-        
expect(this.servletContext.getServletContextName()).andReturn("helloWorld01");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE), 
capture(loggerContextCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
-
-        assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn(null);
+        
given(servletContext.getServletContextName()).willReturn("helloWorld01");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
 
         this.initializerImpl.start();
 
-        assertNotNull("The context attribute should not be null.", 
loggerContextCapture.getValue());
-        assertTrue("The context attribute is not correct.",
-                loggerContextCapture.getValue() instanceof 
org.apache.logging.log4j.spi.LoggerContext);
-        final org.apache.logging.log4j.spi.LoggerContext loggerContext =
-                
(org.apache.logging.log4j.spi.LoggerContext)loggerContextCapture.getValue();
-
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE),
 loggerContextCaptor.capture());
+        assertNotNull("The context attribute should not be null.", 
loggerContextCaptor.getValue());
+        final org.apache.logging.log4j.spi.LoggerContext loggerContext = 
loggerContextCaptor.getValue();
 
         assertNull("The context should still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
@@ -144,19 +112,9 @@ public class Log4jWebInitializerImplTest {
 
         assertNull("The context should be null again.", 
ContextAnchor.THREAD_CONTEXT.get());
 
-        verify(this.servletContext);
-        reset(this.servletContext);
-
-        this.servletContext.removeAttribute(Log4jWebSupport.CONTEXT_ATTRIBUTE);
-        expectLastCall();
-
-        replay(this.servletContext);
-
         this.initializerImpl.stop();
 
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
+        
then(servletContext).should().removeAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE));
 
         assertNull("The context should again still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
@@ -167,33 +125,19 @@ public class Log4jWebInitializerImplTest {
 
     @Test
     public void 
testInitializeWithClassLoaderNoParametersThenSetLoggerContextThenDeinitialize() 
throws Exception {
-        final Capture<Object> loggerContextCapture = EasyMock.newCapture();
-
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn("false");
-        
expect(this.servletContext.getServletContextName()).andReturn("helloWorld02");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        
expect(this.servletContext.getClassLoader()).andReturn(this.getClass().getClassLoader());
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE), 
capture(loggerContextCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
-
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn("false");
+        
given(servletContext.getServletContextName()).willReturn("helloWorld02");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
+        
given(servletContext.getClassLoader()).willReturn(getClass().getClassLoader());
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.start();
 
-        assertNotNull("The context attribute should not be null.", 
loggerContextCapture.getValue());
-        assertTrue("The context attribute is not correct.",
-                loggerContextCapture.getValue() instanceof 
org.apache.logging.log4j.spi.LoggerContext);
-        final org.apache.logging.log4j.spi.LoggerContext loggerContext =
-                
(org.apache.logging.log4j.spi.LoggerContext)loggerContextCapture.getValue();
-
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE),
 loggerContextCaptor.capture());
+        assertNotNull("The context attribute should not be null.", 
loggerContextCaptor.getValue());
+        final org.apache.logging.log4j.spi.LoggerContext loggerContext = 
loggerContextCaptor.getValue();
 
         assertNull("The context should still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
@@ -207,19 +151,9 @@ public class Log4jWebInitializerImplTest {
 
         assertNull("The context should be null again.", 
ContextAnchor.THREAD_CONTEXT.get());
 
-        verify(this.servletContext);
-        reset(this.servletContext);
-
-        this.servletContext.removeAttribute(Log4jWebSupport.CONTEXT_ATTRIBUTE);
-        expectLastCall();
-
-        replay(this.servletContext);
-
         this.initializerImpl.stop();
 
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
+        
then(servletContext).should().removeAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE));
 
         assertNull("The context should again still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
@@ -230,168 +164,95 @@ public class Log4jWebInitializerImplTest {
 
     @Test
     public void testInitializeIsIdempotent() throws Exception {
-        final Capture<Object> loggerContextCapture = EasyMock.newCapture();
-
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn("nothing");
-        
expect(this.servletContext.getServletContextName()).andReturn("helloWorld03");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        
expect(this.servletContext.getClassLoader()).andReturn(this.getClass().getClassLoader());
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE), 
capture(loggerContextCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
-
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn("nothing");
+        
given(servletContext.getServletContextName()).willReturn("helloWorld03");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
+        
given(servletContext.getClassLoader()).willReturn(getClass().getClassLoader());
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.start();
 
-        assertNotNull("The context attribute should not be null.", 
loggerContextCapture.getValue());
-        assertTrue("The context attribute is not correct.",
-                loggerContextCapture.getValue() instanceof 
org.apache.logging.log4j.spi.LoggerContext);
-
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE),
 loggerContextCaptor.capture());
+        assertNotNull("The context attribute should not be null.", 
loggerContextCaptor.getValue());
 
         this.initializerImpl.start();
         this.initializerImpl.start();
         this.initializerImpl.start();
-
-        verify(this.servletContext);
-        reset(this.servletContext);
-
-        this.servletContext.removeAttribute(Log4jWebSupport.CONTEXT_ATTRIBUTE);
-        expectLastCall();
-
-        replay(this.servletContext);
-
         this.initializerImpl.stop();
+
+        
then(servletContext).should().removeAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE));
     }
 
     @Test
     public void testInitializeFailsAfterDeinitialize() throws Exception {
-        final Capture<Object> loggerContextCapture = EasyMock.newCapture();
-
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn(null);
-        
expect(this.servletContext.getServletContextName()).andReturn("helloWorld04");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        
expect(this.servletContext.getClassLoader()).andReturn(this.getClass().getClassLoader());
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE), 
capture(loggerContextCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
-
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn(null);
+        
given(servletContext.getServletContextName()).willReturn("helloWorld04");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
+        
given(servletContext.getClassLoader()).willReturn(getClass().getClassLoader());
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.start();
 
-        assertNotNull("The context attribute should not be null.", 
loggerContextCapture.getValue());
-        assertTrue("The context attribute is not correct.",
-                loggerContextCapture.getValue() instanceof 
org.apache.logging.log4j.spi.LoggerContext);
-
-        verify(this.servletContext);
-        reset(this.servletContext);
-
-        this.servletContext.removeAttribute(Log4jWebSupport.CONTEXT_ATTRIBUTE);
-        expectLastCall();
-
-        replay(this.servletContext);
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE),
 loggerContextCaptor.capture());
+        assertNotNull("The context attribute should not be null.", 
loggerContextCaptor.getValue());
 
         this.initializerImpl.stop();
 
-        try {
-            this.initializerImpl.start();
-            fail("Expected an IllegalStateException.");
-        } catch (final IllegalStateException ignore) {
+        
then(servletContext).should().removeAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE));
 
-        }
+        expectedException.expect(IllegalStateException.class);
+        this.initializerImpl.start();
     }
 
     @Test
     public void testDeinitializeIsIdempotent() throws Exception {
-        final Capture<Object> loggerContextCapture = EasyMock.newCapture();
-
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn(null);
-        
expect(this.servletContext.getServletContextName()).andReturn("helloWorld05");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        
expect(this.servletContext.getClassLoader()).andReturn(this.getClass().getClassLoader());
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE), 
capture(loggerContextCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
-
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn(null);
+        
given(servletContext.getServletContextName()).willReturn("helloWorld05");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
+        
given(servletContext.getClassLoader()).willReturn(getClass().getClassLoader());
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.start();
 
-        assertNotNull("The context attribute should not be null.", 
loggerContextCapture.getValue());
-        assertTrue("The context attribute is not correct.",
-                loggerContextCapture.getValue() instanceof 
org.apache.logging.log4j.spi.LoggerContext);
-
-        verify(this.servletContext);
-        reset(this.servletContext);
-
-        this.servletContext.removeAttribute(Log4jWebSupport.CONTEXT_ATTRIBUTE);
-        expectLastCall();
-
-        replay(this.servletContext);
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE),
 loggerContextCaptor.capture());
+        assertNotNull("The context attribute should not be null.", 
loggerContextCaptor.getValue());
 
         this.initializerImpl.stop();
         this.initializerImpl.stop();
         this.initializerImpl.stop();
+        
then(servletContext).should().removeAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE));
     }
 
     @Test
     public void testInitializeUsingJndiSelectorFails() throws Exception {
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn("true");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        replay(this.servletContext);
-
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn("true");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
-        try {
-            this.initializerImpl.start();
-            fail("Expected an IllegalStateException.");
-        } catch (final IllegalStateException ignore) {
-            // ignore
-        }
+        expectedException.expect(IllegalStateException.class);
+        this.initializerImpl.start();
     }
 
     @Test
     public void testInitializeUsingJndiSelector() throws Exception {
-        final Capture<Object> loggerContextCapture = EasyMock.newCapture();
-
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn("helloWorld6");
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn("true");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE), 
capture(loggerContextCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
-
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn("helloWorld06");
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn("true");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.start();
 
-        assertNull("The context attribute should be null.", 
loggerContextCapture.getValue());
-
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE),
 loggerContextCaptor.capture());
+        assertNull("The context attribute should be null.", 
loggerContextCaptor.getValue());
 
         assertNull("The context should still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
@@ -403,16 +264,8 @@ public class Log4jWebInitializerImplTest {
 
         assertNull("The context should be null again.", 
ContextAnchor.THREAD_CONTEXT.get());
 
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
-
         this.initializerImpl.stop();
 
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
-
         assertNull("The context should again still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.setLoggerContext();
@@ -422,65 +275,37 @@ public class Log4jWebInitializerImplTest {
 
     @Test
     public void testWrapExecutionWithNoParameters() throws Exception {
-        final Capture<Object> loggerContextCapture = EasyMock.newCapture();
-
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
-        
expect(this.servletContext.getInitParameter(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))
-                .andReturn(null);
-        
expect(this.servletContext.getServletContextName()).andReturn("helloWorld01");
-        
expect(this.servletContext.getResourcePaths("/WEB-INF/")).andReturn(null);
-        
this.servletContext.setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE), 
capture(loggerContextCapture));
-        expectLastCall();
-
-        replay(this.servletContext);
-
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONTEXT_NAME))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.LOG4J_CONFIG_LOCATION))).willReturn(null);
+        
given(servletContext.getInitParameter(eq(Log4jWebSupport.IS_LOG4J_CONTEXT_SELECTOR_NAMED))).willReturn(null);
+        
given(servletContext.getServletContextName()).willReturn("helloWorld07");
+        given(servletContext.getResourcePaths("/WEB-INF/")).willReturn(null);
         assertNull("The context should be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
         this.initializerImpl.start();
 
-        assertNotNull("The context attribute should not be null.", 
loggerContextCapture.getValue());
-        assertTrue("The context attribute is not correct.",
-                loggerContextCapture.getValue() instanceof 
org.apache.logging.log4j.spi.LoggerContext);
-        final org.apache.logging.log4j.spi.LoggerContext loggerContext =
-                
(org.apache.logging.log4j.spi.LoggerContext)loggerContextCapture.getValue();
-
-        verify(this.servletContext);
-        reset(this.servletContext);
+        
then(servletContext).should().setAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE),
 loggerContextCaptor.capture());
+        assertNotNull("The context attribute should not be null.", 
loggerContextCaptor.getValue());
+        final org.apache.logging.log4j.spi.LoggerContext loggerContext = 
loggerContextCaptor.getValue();
 
         assertNull("The context should still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 
-        final Runnable runnable = createStrictMock(Runnable.class);
-        runnable.run();
-        expectLastCall().andAnswer(new IAnswer<Void>() {
+        final Runnable runnable = new Runnable() {
             @Override
-            public Void answer() {
+            public void run() {
                 final LoggerContext context = 
ContextAnchor.THREAD_CONTEXT.get();
                 assertNotNull("The context should not be null.", context);
                 assertSame("The context is not correct.", loggerContext, 
context);
-                return null;
             }
-        });
-
-        replay(this.servletContext, runnable);
+        };
 
         this.initializerImpl.wrapExecution(runnable);
 
         assertNull("The context should be null again.", 
ContextAnchor.THREAD_CONTEXT.get());
 
-        verify(this.servletContext, runnable);
-        reset(this.servletContext);
-
-        this.servletContext.removeAttribute(Log4jWebSupport.CONTEXT_ATTRIBUTE);
-        expectLastCall();
-
-        replay(this.servletContext);
-
         this.initializerImpl.stop();
 
-        verify(this.servletContext);
-        reset(this.servletContext);
-        replay(this.servletContext);
+        
then(servletContext).should().removeAttribute(eq(Log4jWebSupport.CONTEXT_ATTRIBUTE));
 
         assertNull("The context should again still be null.", 
ContextAnchor.THREAD_CONTEXT.get());
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/78c6a1fc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index be4d7e4..86051d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -224,6 +224,7 @@
     <!-- Allow Clirr severity to be overriden by the command-line option 
-DminSeverity=level -->
     <minSeverity>info</minSeverity>
     <jctoolsVersion>1.2.1</jctoolsVersion>
+    <mockitoVersion>2.2.7</mockitoVersion>
   </properties>
   <pluginRepositories>
     <pluginRepository>
@@ -653,9 +654,9 @@
         <scope>test</scope>
       </dependency>
       <dependency>
-        <groupId>org.easymock</groupId>
-        <artifactId>easymock</artifactId>
-        <version>3.4</version>
+        <groupId>org.mockito</groupId>
+        <artifactId>mockito-core</artifactId>
+        <version>${mockitoVersion}</version>
         <scope>test</scope>
       </dependency>
       <dependency>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/78c6a1fc/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4e0eb6e..56bf22f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -42,6 +42,9 @@
       <action issue="LOG4J2-1647" dev="mattsicker" type="update">
         Update Commons Lang from 3.4 to 4.5.
       </action>
+      <action issue="LOG4J2-1646" dev="mattsicker" type="update">
+        Migrate to Mockito 2.x in unit tests.
+      </action>
     </release>
     <release version="2.7" date="2016-10-02" description="GA Release 2.7">
       <action issue="LOG4J2-1618" dev="rpopma" type="fix" due-to="Raman Gupta">

Reply via email to