lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject [2/2] lucene-solr:master: SOLR-10120: Convert/migrate tests using EasyMock to Mockito
Date Sat, 18 Feb 2017 23:57:46 GMT
SOLR-10120: Convert/migrate tests using EasyMock to Mockito


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/cbf0f838
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/cbf0f838
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/cbf0f838

Branch: refs/heads/master
Commit: cbf0f8383b10fee0583e2b50188979b8a0583dc8
Parents: 68d4884
Author: Cao Manh Dat <datcm@apache.org>
Authored: Sun Feb 19 06:57:27 2017 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Sun Feb 19 06:57:27 2017 +0700

----------------------------------------------------------------------
 lucene/ivy-versions.properties                  |   1 -
 solr/CHANGES.txt                                |   2 +
 solr/NOTICE.txt                                 |  27 --
 solr/contrib/dataimporthandler/ivy.xml          |   4 +-
 .../dataimport/MockInitialContextFactory.java   |  18 +-
 .../handler/dataimport/TestJdbcDataSource.java  | 475 +++++++++----------
 solr/core/ivy.xml                               |   4 -
 .../org/apache/solr/cloud/ClusterStateTest.java |  21 +-
 ...verseerCollectionConfigSetProcessorTest.java | 213 +++------
 .../solr/core/BlobRepositoryMockingTest.java    |  69 +--
 .../org/apache/solr/core/CoreSorterTest.java    |  28 +-
 .../solr/handler/admin/TestCoreAdminApis.java   |  60 +--
 .../security/TestPKIAuthenticationPlugin.java   |  29 +-
 .../solr/servlet/SolrRequestParserTest.java     | 104 ++--
 solr/licenses/easymock-3.0.jar.sha1             |   1 -
 solr/licenses/easymock-LICENSE-MIT.txt          |  17 -
 solr/solrj/ivy.xml                              |   5 +-
 .../solrj/impl/CloudSolrClientCacheTest.java    |  24 +-
 18 files changed, 408 insertions(+), 694 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/lucene/ivy-versions.properties
----------------------------------------------------------------------
diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties
index 1c519d2..85a86d4 100644
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@ -255,7 +255,6 @@ org.codehaus.janino.version = 2.7.6
 
 /org.codehaus.woodstox/stax2-api = 3.1.4
 /org.codehaus.woodstox/woodstox-core-asl = 4.4.1
-/org.easymock/easymock = 3.0
 
 org.eclipse.jetty.version = 9.3.14.v20161028
 /org.eclipse.jetty/jetty-continuation = ${org.eclipse.jetty.version}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 19157ba..6f16724 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -217,6 +217,8 @@ Other Changes
 * SOLR-9890: factor out ShardResultTransformerUtils.[un]marshSortValue methods
   (Judith Silverman, Christine Poerschke)
 
+* SOLR-9966: Convert/migrate tests using EasyMock to Mockito (Cao Manh Dat,  Uwe Schindler)
+
 ==================  6.4.2 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/NOTICE.txt
----------------------------------------------------------------------
diff --git a/solr/NOTICE.txt b/solr/NOTICE.txt
index 9f60b87..54babbb 100644
--- a/solr/NOTICE.txt
+++ b/solr/NOTICE.txt
@@ -521,33 +521,6 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-This product includes tests written with EasyMock Copyright 2001-2007
-Tammo Freese (http://www.easymock.org/)
-
-==========================================================================
-The following license applies to easymock-2.2.jar
---------------------------------------------------------------------------
-EasyMock 2 License (MIT License)
-Copyright (c) 2001-2007 OFFIS, Tammo Freese.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of 
-this software and associated documentation files (the "Software"), to deal in 
-the Software without restriction, including without limitation the rights to 
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
-of the Software, and to permit persons to whom the Software is furnished to do 
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all 
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
-SOFTWARE. 
-
 =========================================================================
 ==     Restlet Notice                                                  ==
 =========================================================================

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/contrib/dataimporthandler/ivy.xml
----------------------------------------------------------------------
diff --git a/solr/contrib/dataimporthandler/ivy.xml b/solr/contrib/dataimporthandler/ivy.xml
index 38b80d7..ea138dd 100644
--- a/solr/contrib/dataimporthandler/ivy.xml
+++ b/solr/contrib/dataimporthandler/ivy.xml
@@ -25,8 +25,10 @@
   <dependencies>
     <dependency org="hsqldb" name="hsqldb" rev="${/hsqldb/hsqldb}" conf="test"/>
     <dependency org="org.apache.derby" name="derby" rev="${/org.apache.derby/derby}" conf="test"/>
-    <dependency org="org.easymock" name="easymock" rev="${/org.easymock/easymock}" conf="test"/>
 
+    <dependency org="org.mockito" name="mockito-core" rev="${/org.mockito/mockito-core}" conf="test"/>
+    <dependency org="net.bytebuddy" name="byte-buddy" rev="${/net.bytebuddy/byte-buddy}" conf="test"/>
+    <dependency org="org.objenesis" name="objenesis" rev="${/org.objenesis/objenesis}" conf="test"/>
     <exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/> 
   </dependencies>
 </ivy-module>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/MockInitialContextFactory.java
----------------------------------------------------------------------
diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/MockInitialContextFactory.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/MockInitialContextFactory.java
index ca6f13c..7568210 100644
--- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/MockInitialContextFactory.java
+++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/MockInitialContextFactory.java
@@ -23,33 +23,21 @@ import java.util.Map;
 import javax.naming.NamingException;
 import javax.naming.spi.InitialContextFactory;
 
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.easymock.IMocksControl;
+import static org.mockito.Mockito.*;
 
 public class MockInitialContextFactory implements InitialContextFactory {
   private static final Map<String, Object> objects = new HashMap<>();
-  private final IMocksControl mockControl;
   private final javax.naming.Context context;
 
   public MockInitialContextFactory() {
-    mockControl = EasyMock.createStrictControl();
-    context = mockControl.createMock(javax.naming.Context.class);
+    context = mock(javax.naming.Context.class);
 
     try {
-      EasyMock.expect(context.lookup((String) EasyMock.anyObject())).andAnswer(
-          new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-              return objects.get(EasyMock.getCurrentArguments()[0]);
-            }
-          }).anyTimes();
+      when(context.lookup(anyString())).thenAnswer(invocation -> objects.get(invocation.getArgument(0)));
 
     } catch (NamingException e) {
       throw new RuntimeException(e);
     }
-
-    mockControl.replay();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestJdbcDataSource.java
----------------------------------------------------------------------
diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestJdbcDataSource.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestJdbcDataSource.java
index 12e34be..df55b43 100644
--- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestJdbcDataSource.java
+++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestJdbcDataSource.java
@@ -35,13 +35,10 @@ import java.util.Properties;
 
 import javax.sql.DataSource;
 
-import org.apache.lucene.util.Constants;
 import org.apache.solr.handler.dataimport.JdbcDataSource.ResultSetIterator;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
+import static org.mockito.Mockito.*;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -60,7 +57,6 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
   private Driver driver;
   private DataSource dataSource;
   private Connection connection;
-  private IMocksControl mockControl;
   private JdbcDataSource jdbcDataSource = new JdbcDataSource();
   List<Map<String, String>> fields = new ArrayList<>();
 
@@ -70,11 +66,6 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
   Properties props = new Properties();
 
   String sysProp = System.getProperty("java.naming.factory.initial");
-  
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-  }
 
   @Override
   @Before
@@ -83,10 +74,9 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     System.setProperty("java.naming.factory.initial",
             MockInitialContextFactory.class.getName());
     
-    mockControl = EasyMock.createStrictControl();
-    driver = mockControl.createMock(Driver.class);
-    dataSource = mockControl.createMock(DataSource.class);
-    connection = mockControl.createMock(Connection.class);
+    driver = mock(Driver.class);
+    dataSource = mock(DataSource.class);
+    connection = mock(Connection.class);
     props.clear();
   }
 
@@ -99,7 +89,7 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
       System.setProperty("java.naming.factory.initial", sysProp);
     }
     super.tearDown();
-    mockControl.reset();
+    reset(driver, dataSource, connection);
   }
 
   @Test
@@ -108,16 +98,13 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
 
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
 
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
-    connection.setAutoCommit(false);
-//    connection.setHoldability(1);
-
-    mockControl.replay();
+    when(dataSource.getConnection()).thenReturn(connection);
 
     Connection conn = jdbcDataSource.createConnectionFactory(context, props)
             .call();
 
-    mockControl.verify();
+    verify(connection).setAutoCommit(false);
+    verify(dataSource).getConnection();
 
     assertSame("connection", conn, connection);
   }
@@ -131,17 +118,15 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     props.put("password", "4r3d");
     props.put("holdability", "HOLD_CURSORS_OVER_COMMIT");
 
-    EasyMock.expect(dataSource.getConnection("Fred", "4r3d")).andReturn(
+    when(dataSource.getConnection("Fred", "4r3d")).thenReturn(
             connection);
-    connection.setAutoCommit(false);
-    connection.setHoldability(1);
-
-    mockControl.replay();
 
     Connection conn = jdbcDataSource.createConnectionFactory(context, props)
             .call();
 
-    mockControl.verify();
+    verify(connection).setAutoCommit(false);
+    verify(connection).setHoldability(1);
+    verify(dataSource).getConnection("Fred", "4r3d");
 
     assertSame("connection", conn, connection);
   }
@@ -149,41 +134,36 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
   @Test
   public void testRetrieveFromJndiWithCredentialsEncryptedAndResolved() throws Exception {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
-    
+
     String user = "Fred";
     String plainPassword = "MyPassword";
     String encryptedPassword = "U2FsdGVkX18QMjY0yfCqlfBMvAB4d3XkwY96L7gfO2o=";
     String propsNamespace = "exampleNamespace";
-    
+
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    
+
     props.put("user", "${" +propsNamespace +".user}");
     props.put("encryptKeyFile", "${" +propsNamespace +".encryptKeyFile}");
     props.put("password", "${" +propsNamespace +".password}");
-    
-    EasyMock.expect(dataSource.getConnection(user, plainPassword)).andReturn(
+
+    when(dataSource.getConnection(user, plainPassword)).thenReturn(
              connection);
-    
+
     Map<String,Object> values = new HashMap<>();
     values.put("user", user);
     values.put("encryptKeyFile", createEncryptionKeyFile());
     values.put("password", encryptedPassword);
     context.getVariableResolver().addNamespace(propsNamespace, values);
-    
-    jdbcDataSource.init(context, props);
-
-    connection.setAutoCommit(false);
-    //connection.setHoldability(1);
-
-    mockControl.replay();
 
+    jdbcDataSource.init(context, props);
     Connection conn = jdbcDataSource.getConnection();
 
-    mockControl.verify();
+    verify(connection).setAutoCommit(false);
+    verify(dataSource).getConnection(user, plainPassword);
 
     assertSame("connection", conn, connection);
   }
-  
+
   @Test
   public void testRetrieveFromJndiWithCredentialsWithEncryptedAndResolvedPwd() throws Exception {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
@@ -193,22 +173,18 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     properties.put("user", "Fred");
     properties.put("encryptKeyFile", "${foo.bar}");
     properties.put("password", "U2FsdGVkX18QMjY0yfCqlfBMvAB4d3XkwY96L7gfO2o=");
-    EasyMock.expect(dataSource.getConnection("Fred", "MyPassword")).andReturn(
+    when(dataSource.getConnection("Fred", "MyPassword")).thenReturn(
         connection);
-    
+
     Map<String,Object> values = new HashMap<>();
     values.put("bar", createEncryptionKeyFile());
     context.getVariableResolver().addNamespace("foo", values);
-    
-    jdbcDataSource.init(context, properties);
-    
-    connection.setAutoCommit(false);
-
-    mockControl.replay();
 
+    jdbcDataSource.init(context, properties);
     jdbcDataSource.getConnection();
 
-    mockControl.verify();
+    verify(connection).setAutoCommit(false);
+    verify(dataSource).getConnection("Fred", "MyPassword");
   }
 
   @Test
@@ -218,19 +194,17 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
 
     SQLException sqlException = new SQLException("fake");
-    EasyMock.expect(dataSource.getConnection()).andThrow(sqlException);
+    when(dataSource.getConnection()).thenThrow(sqlException);
 
-    mockControl.replay();
-    
     try {
       jdbcDataSource.createConnectionFactory(context, props).call();
     } catch (SQLException ex) {
       assertSame(sqlException, ex);
     }
-    
-    mockControl.verify();
+
+    verify(dataSource).getConnection();
   }
-  
+
   @Test
   public void testClosesConnectionWhenExceptionThrownOnSetAutocommit() throws Exception {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
@@ -238,42 +212,33 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
 
     SQLException sqlException = new SQLException("fake");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
-    connection.setAutoCommit(false);
-    EasyMock.expectLastCall().andThrow(sqlException);
-    connection.close();
-    mockControl.replay();
-    
+    when(dataSource.getConnection()).thenReturn(connection);
+    doThrow(sqlException).when(connection).setAutoCommit(false);
+
     try {
       jdbcDataSource.createConnectionFactory(context, props).call();
     } catch (DataImportHandlerException ex) {
       assertSame(sqlException, ex.getCause());
     }
-    
-    mockControl.verify();
+    verify(dataSource).getConnection();
+    verify(connection).setAutoCommit(false);
+    verify(connection).close();
   }
-  
+
   @Test
   public void testClosesStatementWhenExceptionThrownOnExecuteQuery() throws Exception {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
 
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+    when(dataSource.getConnection()).thenReturn(connection);
 
     jdbcDataSource.init(context, props);
 
-    connection.setAutoCommit(false);
-
     SQLException sqlException = new SQLException("fake");
-    Statement statement = mockControl.createMock(Statement.class);
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("query")).andThrow(sqlException);
-    statement.close();
-
-    mockControl.replay();
+    Statement statement = mock(Statement.class);
+    when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+        .thenReturn(statement);
+    when(statement.execute("query")).thenThrow(sqlException);
 
     try {
       jdbcDataSource.getData("query");
@@ -282,7 +247,13 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
       assertSame(sqlException, ex.getCause());
     }
 
-    mockControl.verify();
+    verify(dataSource).getConnection();
+    verify(connection).setAutoCommit(false);
+    verify(connection).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+    verify(statement).setFetchSize(500);
+    verify(statement).setMaxRows(0);
+    verify(statement).execute("query");
+    verify(statement).close();
   }
 
   @Test
@@ -290,26 +261,26 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
 
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+    when(dataSource.getConnection()).thenReturn(connection);
 
     jdbcDataSource.init(context, props);
 
-    connection.setAutoCommit(false);
-
-    Statement statement = mockControl.createMock(Statement.class);
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("query")).andReturn(false);
-    EasyMock.expect(statement.getUpdateCount()).andReturn(-1);
-    statement.close();
-
-    mockControl.replay();
+    Statement statement = mock(Statement.class);
+    when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+        .thenReturn(statement);
+    when(statement.execute("query")).thenReturn(false);
+    when(statement.getUpdateCount()).thenReturn(-1);
 
     jdbcDataSource.getData("query");
 
-    mockControl.verify();
+    verify(dataSource).getConnection();
+    verify(connection).setAutoCommit(false);
+    verify(connection).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+    verify(statement).setFetchSize(500);
+    verify(statement).setMaxRows(0);
+    verify(statement).execute("query");
+    verify(statement).getUpdateCount();
+    verify(statement).close();
   }
 
   @Test
@@ -318,35 +289,37 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
 
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+    when(dataSource.getConnection()).thenReturn(connection);
 
     jdbcDataSource.init(context, props);
 
-    connection.setAutoCommit(false);
-
-    Statement statement = mockControl.createMock(Statement.class);
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("query")).andReturn(true);
-    ResultSet resultSet = mockControl.createMock(ResultSet.class);
-    EasyMock.expect(statement.getResultSet()).andReturn(resultSet);
-    ResultSetMetaData metaData = mockControl.createMock(ResultSetMetaData.class);
-    EasyMock.expect(resultSet.getMetaData()).andReturn(metaData);
-    EasyMock.expect(metaData.getColumnCount()).andReturn(0);
-    statement.close();
-
-    mockControl.replay();
+    Statement statement = mock(Statement.class);
+    when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+        .thenReturn(statement);
+    when(statement.execute("query")).thenReturn(true);
+    ResultSet resultSet = mock(ResultSet.class);
+    when(statement.getResultSet()).thenReturn(resultSet);
+    ResultSetMetaData metaData = mock(ResultSetMetaData.class);
+    when(resultSet.getMetaData()).thenReturn(metaData);
+    when(metaData.getColumnCount()).thenReturn(0);
 
     Iterator<Map<String,Object>> data = jdbcDataSource.getData("query");
-    
+
     ResultSetIterator resultSetIterator = (ResultSetIterator) data.getClass().getDeclaredField("this$1").get(data);
     resultSetIterator.setResultSet(null);
 
     data.hasNext();
 
-    mockControl.verify();
+    verify(dataSource).getConnection();
+    verify(connection).setAutoCommit(false);
+    verify(connection).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+    verify(statement).setFetchSize(500);
+    verify(statement).setMaxRows(0);
+    verify(statement).execute("query");
+    verify(statement).getResultSet();
+    verify(statement).close();
+    verify(resultSet).getMetaData();
+    verify(metaData).getColumnCount();
   }
 
   @Test
@@ -355,34 +328,36 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
 
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+    when(dataSource.getConnection()).thenReturn(connection);
 
     jdbcDataSource.init(context, props);
 
-    connection.setAutoCommit(false);
-
-    Statement statement = mockControl.createMock(Statement.class);
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("query")).andReturn(true);
-    ResultSet resultSet = mockControl.createMock(ResultSet.class);
-    EasyMock.expect(statement.getResultSet()).andReturn(resultSet);
-    ResultSetMetaData metaData = mockControl.createMock(ResultSetMetaData.class);
-    EasyMock.expect(resultSet.getMetaData()).andReturn(metaData);
-    EasyMock.expect(metaData.getColumnCount()).andReturn(0);
-    resultSet.close();
-    statement.close();
-    connection.commit();
-    connection.close();
-
-    mockControl.replay();
+    Statement statement = mock(Statement.class);
+    when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+        .thenReturn(statement);
+    when(statement.execute("query")).thenReturn(true);
+    ResultSet resultSet = mock(ResultSet.class);
+    when(statement.getResultSet()).thenReturn(resultSet);
+    ResultSetMetaData metaData = mock(ResultSetMetaData.class);
+    when(resultSet.getMetaData()).thenReturn(metaData);
+    when(metaData.getColumnCount()).thenReturn(0);
 
     jdbcDataSource.getData("query");
     jdbcDataSource.close();
 
-    mockControl.verify();
+    verify(dataSource).getConnection();
+    verify(connection).setAutoCommit(false);
+    verify(connection).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+    verify(statement).setFetchSize(500);
+    verify(statement).setMaxRows(0);
+    verify(statement).execute("query");
+    verify(statement).getResultSet();
+    verify(resultSet).getMetaData();
+    verify(metaData).getColumnCount();
+    verify(resultSet).close();
+    verify(statement).close();
+    verify(connection).commit();
+    verify(connection).close();
   }
 
   @Test
@@ -391,109 +366,95 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
 
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+    when(dataSource.getConnection()).thenReturn(connection);
 
     jdbcDataSource.init(context, props);
 
-    connection.setAutoCommit(false);
-
-    Statement statement = mockControl.createMock(Statement.class);
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("query")).andReturn(true);
-    ResultSet resultSet = mockControl.createMock(ResultSet.class);
-    EasyMock.expect(statement.getResultSet()).andReturn(resultSet);
-    ResultSetMetaData metaData = mockControl.createMock(ResultSetMetaData.class);
-    EasyMock.expect(resultSet.getMetaData()).andReturn(metaData);
-    EasyMock.expect(metaData.getColumnCount()).andReturn(0);
-    resultSet.close();
-    statement.close();
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("other query")).andReturn(false);
-    EasyMock.expect(statement.getUpdateCount()).andReturn(-1);
-    statement.close();
-
-    mockControl.replay();
+    Statement statement = mock(Statement.class);
+    when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+        .thenReturn(statement);
+    when(statement.execute("query")).thenReturn(true);
+    ResultSet resultSet = mock(ResultSet.class);
+    when(statement.getResultSet()).thenReturn(resultSet);
+    ResultSetMetaData metaData = mock(ResultSetMetaData.class);
+    when(resultSet.getMetaData()).thenReturn(metaData);
+    when(metaData.getColumnCount()).thenReturn(0);
+    when(statement.execute("other query")).thenReturn(false);
+    when(statement.getUpdateCount()).thenReturn(-1);
 
     jdbcDataSource.getData("query");
     jdbcDataSource.getData("other query");
 
-    mockControl.verify();
+    verify(dataSource).getConnection();
+    verify(connection).setAutoCommit(false);
+    verify(connection, times(2)).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+    verify(statement, times(2)).setFetchSize(500);
+    verify(statement, times(2)).setMaxRows(0);
+    verify(statement).execute("query");
+    verify(statement).getResultSet();
+    verify(resultSet).getMetaData();
+    verify(metaData).getColumnCount();
+    verify(resultSet).close();
+    verify(statement, times(2)).close();
+    verify(statement).execute("other query");
   }
   
   @Test
   public void testMultipleResultsSets_UpdateCountUpdateCountResultSet() throws Exception {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+    when(dataSource.getConnection()).thenReturn(connection);
     jdbcDataSource.init(context, props);
-    connection.setAutoCommit(false);
 
-    Statement statement = mockControl.createMock(Statement.class);
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("query")).andReturn(false);
-    EasyMock.expect(statement.getUpdateCount()).andReturn(1);
-    EasyMock.expect(statement.getMoreResults()).andReturn(false);
-    EasyMock.expect(statement.getUpdateCount()).andReturn(1);
-    EasyMock.expect(statement.getMoreResults()).andReturn(true);
-    ResultSet resultSet = mockControl.createMock(ResultSet.class);
-    EasyMock.expect(statement.getResultSet()).andReturn(resultSet);
-    ResultSetMetaData metaData = mockControl.createMock(ResultSetMetaData.class);
-    EasyMock.expect(resultSet.getMetaData()).andReturn(metaData);
-    EasyMock.expect(metaData.getColumnCount()).andReturn(0);
-
-    mockControl.replay();
+    Statement statement = mock(Statement.class);
+    when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+        .thenReturn(statement);
+    when(statement.execute("query")).thenReturn(false);
+    when(statement.getUpdateCount()).thenReturn(1);
+    when(statement.getMoreResults()).thenReturn(false).thenReturn(true);
+    ResultSet resultSet = mock(ResultSet.class);
+    when(statement.getResultSet()).thenReturn(resultSet);
+    ResultSetMetaData metaData = mock(ResultSetMetaData.class);
+    when(resultSet.getMetaData()).thenReturn(metaData);
+    when(metaData.getColumnCount()).thenReturn(0);
 
     final ResultSetIterator resultSetIterator = jdbcDataSource.new ResultSetIterator("query");
     assertSame(resultSet, resultSetIterator.getResultSet());
 
-    mockControl.verify();
-
+    verify(connection).setAutoCommit(false);
+    verify(connection).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+    verify(statement).setFetchSize(500);
+    verify(statement).setMaxRows(0);
+    verify(statement).execute("query");
+    verify(statement, times(2)).getUpdateCount();
+    verify(statement, times(2)).getMoreResults();
   }
 
   @Test
   public void testMultipleResultsSets_ResultSetResultSet() throws Exception {
     MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
     props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-    EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+    when(dataSource.getConnection()).thenReturn(connection);
     jdbcDataSource.init(context, props);
     connection.setAutoCommit(false);
 
-    Statement statement = mockControl.createMock(Statement.class);
-    EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-        .andReturn(statement);
-    statement.setFetchSize(500);
-    statement.setMaxRows(0);
-    EasyMock.expect(statement.execute("query")).andReturn(true);
-    ResultSet resultSet1 = mockControl.createMock(ResultSet.class);
-    EasyMock.expect(statement.getResultSet()).andReturn(resultSet1);
-    ResultSetMetaData metaData1 = mockControl.createMock(ResultSetMetaData.class);
-    EasyMock.expect(resultSet1.getMetaData()).andReturn(metaData1);
-    EasyMock.expect(metaData1.getColumnCount()).andReturn(0);
-    EasyMock.expect(resultSet1.next()).andReturn(false);
-    resultSet1.close();
-    EasyMock.expect(statement.getMoreResults()).andReturn(true);
-    ResultSet resultSet2 = mockControl.createMock(ResultSet.class);
-    EasyMock.expect(statement.getResultSet()).andReturn(resultSet2);
-    ResultSetMetaData metaData2 = mockControl.createMock(ResultSetMetaData.class);
-    EasyMock.expect(resultSet2.getMetaData()).andReturn(metaData2);
-    EasyMock.expect(metaData2.getColumnCount()).andReturn(0);
-    EasyMock.expect(resultSet2.next()).andReturn(true);
-    EasyMock.expect(resultSet2.next()).andReturn(false);
-    resultSet2.close();
-    EasyMock.expect(statement.getMoreResults()).andReturn(false);
-    EasyMock.expect(statement.getUpdateCount()).andReturn(-1);
-    statement.close();
-
-    mockControl.replay();
+    Statement statement = mock(Statement.class);
+    when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+        .thenReturn(statement);
+    when(statement.execute("query")).thenReturn(true);
+    ResultSet resultSet1 = mock(ResultSet.class);
+    ResultSet resultSet2 = mock(ResultSet.class);
+    when(statement.getResultSet()).thenReturn(resultSet1).thenReturn(resultSet2).thenReturn(null);
+    when(statement.getMoreResults()).thenReturn(true).thenReturn(false);
+    ResultSetMetaData metaData1 = mock(ResultSetMetaData.class);
+    when(resultSet1.getMetaData()).thenReturn(metaData1);
+    when(metaData1.getColumnCount()).thenReturn(0);
+    when(resultSet1.next()).thenReturn(false);
+    ResultSetMetaData metaData2 = mock(ResultSetMetaData.class);
+    when(resultSet2.getMetaData()).thenReturn(metaData2);
+    when(metaData2.getColumnCount()).thenReturn(0);
+    when(resultSet2.next()).thenReturn(true).thenReturn(false);
+    when(statement.getUpdateCount()).thenReturn(-1);
 
     final ResultSetIterator resultSetIterator = jdbcDataSource.new ResultSetIterator("query");
     assertSame(resultSet1, resultSetIterator.getResultSet());
@@ -501,76 +462,92 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase {
     assertSame(resultSet2, resultSetIterator.getResultSet());
     assertFalse(resultSetIterator.hasnext());
 
-    mockControl.verify();
-
+    verify(dataSource).getConnection();
+    verify(connection, times(2)).setAutoCommit(false);
+    verify(connection).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+    verify(statement).setFetchSize(500);
+    verify(statement).setMaxRows(0);
+    verify(statement).execute("query");
+    verify(statement, times(2)).getResultSet();
+    verify(resultSet1).getMetaData();
+    verify(metaData1).getColumnCount();
+    verify(resultSet1).next();
+    verify(resultSet1).close();
+    verify(resultSet2).getMetaData();
+    verify(metaData2).getColumnCount();
+    verify(resultSet2, times(2)).next();
+    verify(resultSet2).close();
+    verify(statement, times(2)).getMoreResults();
+    verify(statement).getUpdateCount();
+    verify(statement).close();
   }
-  
+
   @Test
   public void testRetrieveFromDriverManager() throws Exception {
     DriverManager.registerDriver(driver);
     try {
-    EasyMock.expect(
-            driver.connect((String) EasyMock.notNull(), (Properties) EasyMock
-                    .notNull())).andReturn(connection);
-    connection.setAutoCommit(false);
-    connection.setHoldability(1);
+      when(driver.connect(notNull(),notNull())).thenReturn(connection);
 
-    props.put(JdbcDataSource.DRIVER, driver.getClass().getName());
-    props.put(JdbcDataSource.URL, "jdbc:fakedb");
-    props.put("holdability", "HOLD_CURSORS_OVER_COMMIT");
-    mockControl.replay();
+      props.put(JdbcDataSource.DRIVER, driver.getClass().getName());
+      props.put(JdbcDataSource.URL, "jdbc:fakedb");
+      props.put("holdability", "HOLD_CURSORS_OVER_COMMIT");
 
-    Connection conn = jdbcDataSource.createConnectionFactory(context, props)
-            .call();
+      Connection conn = jdbcDataSource.createConnectionFactory(context, props)
+              .call();
 
-    mockControl.verify();
+      verify(connection).setAutoCommit(false);
+      verify(connection).setHoldability(1);
 
-    assertSame("connection", conn, connection);
+      assertSame("connection", conn, connection);
     } catch(Exception e) {
       throw e;
     } finally {
       DriverManager.deregisterDriver(driver);
     }
   }
-  
-  
+
+
   @Test
   public void testEmptyResultSet() throws Exception {
       MockInitialContextFactory.bind("java:comp/env/jdbc/JndiDB", dataSource);
 
       props.put(JdbcDataSource.JNDI_NAME, "java:comp/env/jdbc/JndiDB");
-      EasyMock.expect(dataSource.getConnection()).andReturn(connection);
+      when(dataSource.getConnection()).thenReturn(connection);
 
       jdbcDataSource.init(context, props);
 
-      connection.setAutoCommit(false);
-
-      Statement statement = mockControl.createMock(Statement.class);
-      EasyMock.expect(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
-          .andReturn(statement);
-      statement.setFetchSize(500);
-      statement.setMaxRows(0);
-      EasyMock.expect(statement.execute("query")).andReturn(true);
-      ResultSet resultSet = mockControl.createMock(ResultSet.class);
-      EasyMock.expect(statement.getResultSet()).andReturn(resultSet);
-      ResultSetMetaData metaData = mockControl.createMock(ResultSetMetaData.class);
-      EasyMock.expect(resultSet.getMetaData()).andReturn(metaData);
-      EasyMock.expect(metaData.getColumnCount()).andReturn(0);
-      EasyMock.expect(resultSet.next()).andReturn(false);
-      resultSet.close();
-      EasyMock.expect(statement.getMoreResults()).andReturn(false);
-      EasyMock.expect(statement.getUpdateCount()).andReturn(-1);
-      statement.close();
-
-      mockControl.replay();
+      Statement statement = mock(Statement.class);
+      when(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY))
+          .thenReturn(statement);
+      when(statement.execute("query")).thenReturn(true);
+      ResultSet resultSet = mock(ResultSet.class);
+      when(statement.getResultSet()).thenReturn(resultSet);
+      ResultSetMetaData metaData = mock(ResultSetMetaData.class);
+      when(resultSet.getMetaData()).thenReturn(metaData);
+      when(metaData.getColumnCount()).thenReturn(0);
+      when(resultSet.next()).thenReturn(false);
+      when(statement.getMoreResults()).thenReturn(false);
+      when(statement.getUpdateCount()).thenReturn(-1);
 
       Iterator<Map<String,Object>> resultSetIterator = jdbcDataSource.getData("query");
       resultSetIterator.hasNext();
       resultSetIterator.hasNext();
 
-      mockControl.verify();
+      verify(connection).setAutoCommit(false);
+      verify(connection).createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+      verify(statement).setFetchSize(500);
+      verify(statement).setMaxRows(0);
+      verify(statement).execute("query");
+      verify(statement).getResultSet();
+      verify(resultSet).getMetaData();
+      verify(metaData).getColumnCount();
+      verify(resultSet).next();
+      verify(resultSet).close();
+      verify(statement).getMoreResults();
+      verify(statement).getUpdateCount();
+      verify(statement).close();
   }
-  
+
   @Test
   @Ignore("Needs a Mock database server to work")
   public void testBasic() throws Exception {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/ivy.xml
----------------------------------------------------------------------
diff --git a/solr/core/ivy.xml b/solr/core/ivy.xml
index dc58ad5..a91d73a 100644
--- a/solr/core/ivy.xml
+++ b/solr/core/ivy.xml
@@ -51,10 +51,6 @@
     <dependency org="org.slf4j" name="slf4j-log4j12" rev="${/org.slf4j/slf4j-log4j12}" conf="compile"/>
     <dependency org="org.slf4j" name="jcl-over-slf4j" rev="${/org.slf4j/jcl-over-slf4j}" conf="compile"/>
 
-    <!-- TODO: Nuke those 2 deps, please!!!! -->
-    <dependency org="org.easymock" name="easymock" rev="${/org.easymock/easymock}" conf="test"/>
-    <dependency org="cglib" name="cglib-nodep" rev="${/cglib/cglib-nodep}" conf="test"/>
-
     <dependency org="org.mockito" name="mockito-core" rev="${/org.mockito/mockito-core}" conf="test"/>
     <dependency org="net.bytebuddy" name="byte-buddy" rev="${/net.bytebuddy/byte-buddy}" conf="test"/>
     <dependency org="org.objenesis" name="objenesis" rev="${/org.objenesis/objenesis}" conf="test"/>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java b/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java
index 5911cbe..b38d459 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ClusterStateTest.java
@@ -21,27 +21,16 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.lucene.util.Constants;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.cloud.ClusterState;
 import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.DocRouter;
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.Replica;
-import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.util.Utils;
-import org.easymock.EasyMock;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.easymock.EasyMock.createMock;
-
 public class ClusterStateTest extends SolrTestCaseJ4 {
-  
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-  }
 
   @Test
   public void testStoreAndRead() throws Exception {
@@ -64,8 +53,7 @@ public class ClusterStateTest extends SolrTestCaseJ4 {
     slices.put("shard2", slice2);
     collectionStates.put("collection1", new DocCollection("collection1", slices, null, DocRouter.DEFAULT));
     collectionStates.put("collection2", new DocCollection("collection2", slices, null, DocRouter.DEFAULT));
-    ZkStateReader zkStateReaderMock = getMockZkStateReader(collectionStates.keySet());
-    
+
     ClusterState clusterState = new ClusterState(-1,liveNodes, collectionStates);
     byte[] bytes = Utils.toJSON(clusterState);
     // System.out.println("#################### " + new String(bytes));
@@ -90,11 +78,4 @@ public class ClusterStateTest extends SolrTestCaseJ4 {
     assertEquals("Should not have collections", 0, loadedClusterState.getCollectionsMap().size());
   }
 
-  public static ZkStateReader getMockZkStateReader(final Set<String> collections) {
-    ZkStateReader mock = createMock(ZkStateReader.class);
-    EasyMock.reset(mock);
-    EasyMock.replay(mock);
-
-    return mock;
-  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
index d9f53af..635292a 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
@@ -21,12 +21,9 @@ import java.util.*;
 import java.util.Map.Entry;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import java.util.function.Predicate;
 
-import org.apache.lucene.util.Constants;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrResponse;
-import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.cloud.Overseer.LeaderStatus;
 import org.apache.solr.cloud.OverseerTaskQueue.QueueEvent;
 import org.apache.solr.common.cloud.ClusterState;
@@ -42,21 +39,17 @@ import org.apache.solr.common.util.Utils;
 import org.apache.solr.handler.component.ShardHandler;
 import org.apache.solr.handler.component.ShardHandlerFactory;
 import org.apache.solr.handler.component.ShardRequest;
-import org.apache.solr.handler.component.ShardResponse;
 import org.apache.solr.util.TimeOut;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.Watcher;
-import org.easymock.Capture;
-import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.mockito.ArgumentCaptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.easymock.EasyMock.*;
+import static org.mockito.Mockito.*;
 
 public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
 
@@ -107,16 +100,15 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
 
   @BeforeClass
   public static void setUpOnce() throws Exception {
-    assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-    workQueueMock = createMock(OverseerTaskQueue.class);
-    runningMapMock = createMock(DistributedMap.class);
-    completedMapMock = createMock(DistributedMap.class);
-    failureMapMock = createMock(DistributedMap.class);
-    shardHandlerFactoryMock = createMock(ShardHandlerFactory.class);
-    shardHandlerMock = createMock(ShardHandler.class);
-    zkStateReaderMock = createMock(ZkStateReader.class);
-    clusterStateMock = createMock(ClusterState.class);
-    solrZkClientMock = createMock(SolrZkClient.class);
+    workQueueMock = mock(OverseerTaskQueue.class);
+    runningMapMock = mock(DistributedMap.class);
+    completedMapMock = mock(DistributedMap.class);
+    failureMapMock = mock(DistributedMap.class);
+    shardHandlerFactoryMock = mock(ShardHandlerFactory.class);
+    shardHandlerMock = mock(ShardHandler.class);
+    zkStateReaderMock = mock(ZkStateReader.class);
+    clusterStateMock = mock(ClusterState.class);
+    solrZkClientMock = mock(SolrZkClient.class);
   }
   
   @AfterClass
@@ -157,14 +149,8 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
   }
   
   protected Set<String> commonMocks(int liveNodesCount) throws Exception {
-    shardHandlerFactoryMock.getShardHandler();
-    expectLastCall().andAnswer(() -> {
-      log.info("SHARDHANDLER");
-      return shardHandlerMock;
-    }).anyTimes();
-    
-    workQueueMock.peekTopN(EasyMock.anyInt(), anyObject(Predicate.class), EasyMock.anyLong());
-    expectLastCall().andAnswer(() -> {
+    when(shardHandlerFactoryMock.getShardHandler()).thenReturn(shardHandlerMock);
+    when(workQueueMock.peekTopN(anyInt(), any(), anyLong())).thenAnswer(invocation -> {
       Object result;
       int count = 0;
       while ((result = queue.peek()) == null) {
@@ -174,112 +160,68 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
       }
 
       return Arrays.asList(result);
-    }).anyTimes();
+    });
 
-    workQueueMock.getTailId();
-    expectLastCall().andAnswer(() -> {
+    when(workQueueMock.getTailId()).thenAnswer(invocation -> {
       Object result = null;
       Iterator iter = queue.iterator();
       while(iter.hasNext()) {
         result = iter.next();
       }
       return result==null ? null : ((QueueEvent)result).getId();
-    }).anyTimes();
+    });
 
-    workQueueMock.peek(true);
-    expectLastCall().andAnswer(() -> {
+    when(workQueueMock.peek(true)).thenAnswer(invocation -> {
       Object result;
       while ((result = queue.peek()) == null) {
         Thread.sleep(1000);
       }
       return result;
-    }).anyTimes();
-    
-    workQueueMock.remove(anyObject(QueueEvent.class));
-    expectLastCall().andAnswer(() -> {
-      queue.remove(getCurrentArguments()[0]);
+    });
+
+    doAnswer(invocation -> {
+      queue.remove(invocation.getArgument(0));
       return null;
-    }).anyTimes();
-    
-    workQueueMock.poll();
-    expectLastCall().andAnswer(() -> queue.poll()).anyTimes();
-    
-    zkStateReaderMock.getZkClient();
-    expectLastCall().andAnswer(() -> solrZkClientMock).anyTimes();
-    
-    zkStateReaderMock.getClusterState();
-    expectLastCall().andAnswer(() -> clusterStateMock).anyTimes();
+    }).when(workQueueMock).remove(any());
+
+    when(workQueueMock.poll()).thenAnswer(invocation -> {
+      queue.poll();
+      return null;
+    });
 
-    zkStateReaderMock.updateClusterState();
+    when(zkStateReaderMock.getZkClient()).thenReturn(solrZkClientMock);
+    when(zkStateReaderMock.getClusterState()).thenReturn(clusterStateMock);
 
-    clusterStateMock.getCollections();
-    expectLastCall().andAnswer(() -> collectionsSet).anyTimes();
+    when(clusterStateMock.getCollections()).thenReturn(collectionsSet);
     final Set<String> liveNodes = new HashSet<>();
     for (int i = 0; i < liveNodesCount; i++) {
       final String address = "localhost:" + (8963 + i) + "_solr";
       liveNodes.add(address);
       
-      zkStateReaderMock.getBaseUrlForNodeName(address);
-      expectLastCall().andAnswer(() -> {
-        // This works as long as this test does not use a
-        // webapp context with an underscore in it
-        return address.replaceAll("_", "/");
-      }).anyTimes();
-      
+      when(zkStateReaderMock.getBaseUrlForNodeName(address)).thenAnswer(invocation -> address.replaceAll("_", "/"));
     }
 
-    zkStateReaderMock.getClusterProperty("legacyCloud", "true");
-    expectLastCall().andAnswer(() -> "true");
+    when(zkStateReaderMock.getClusterProperty("legacyCloud", "true")).thenReturn("true");
 
-    solrZkClientMock.getZkClientTimeout();
-    expectLastCall().andAnswer(() -> 30000).anyTimes();
+    when(solrZkClientMock.getZkClientTimeout()).thenReturn(30000);
     
-    clusterStateMock.hasCollection(anyObject(String.class));
-    expectLastCall().andAnswer(() -> {
-      String key = (String) getCurrentArguments()[0];
+    when(clusterStateMock.hasCollection(anyString())).thenAnswer(invocation -> {
+      String key = invocation.getArgument(0);
       return collectionsSet.contains(key);
-    }).anyTimes();
+    });
 
-
-    clusterStateMock.getLiveNodes();
-    expectLastCall().andAnswer(() -> liveNodes).anyTimes();
-    solrZkClientMock.create(anyObject(String.class), anyObject(byte[].class), anyObject(CreateMode.class), anyBoolean());
-    expectLastCall().andAnswer(() -> {
-      String key = (String) getCurrentArguments()[0];
+    when(clusterStateMock.getLiveNodes()).thenReturn(liveNodes);
+    when(solrZkClientMock.create(any(), any(), any(), anyBoolean())).thenAnswer(invocation -> {
+      String key = invocation.getArgument(0);
       zkMap.put(key, null);
-      handleCreateCollMessage((byte[]) getCurrentArguments()[1]);
-      return key;
-    }).anyTimes();
-
-    solrZkClientMock.makePath(anyObject(String.class), anyObject(byte[].class), anyBoolean());
-    expectLastCall().andAnswer(() -> {
-      String key = (String) getCurrentArguments()[0];
-      return key;
-    }).anyTimes();
-
-    solrZkClientMock.makePath(anyObject(String.class), anyObject(byte[].class), anyObject(CreateMode.class), anyBoolean());
-    expectLastCall().andAnswer(() -> {
-      String key = (String) getCurrentArguments()[0];
-      return key;
-    }).anyTimes();
-    
-    solrZkClientMock.makePath(anyObject(String.class), anyObject(byte[].class), anyObject(CreateMode.class), anyObject(Watcher.class), anyBoolean());
-    expectLastCall().andAnswer(() -> {
-      String key = (String) getCurrentArguments()[0];
-      return key;
-    }).anyTimes();
-    
-    solrZkClientMock.makePath(anyObject(String.class), anyObject(byte[].class), anyObject(CreateMode.class), anyObject(Watcher.class), anyBoolean(), anyBoolean(), anyInt());
-    expectLastCall().andAnswer(() -> {
-      String key = (String) getCurrentArguments()[0];
+      handleCreateCollMessage(invocation.getArgument(1));
       return key;
-    }).anyTimes();
+    });
 
-    solrZkClientMock.exists(anyObject(String.class),anyBoolean());
-    expectLastCall().andAnswer(() -> {
-      String key = (String) getCurrentArguments()[0];
+    when(solrZkClientMock.exists(any(String.class), anyBoolean())).thenAnswer(invocation -> {
+      String key = invocation.getArgument(0);
       return zkMap.containsKey(key);
-    }).anyTimes();
+    });
     
     zkMap.put("/configs/myconfig", null);
     
@@ -306,32 +248,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
     thread.interrupt();
     thread.join();
   }
-  
-  private class SubmitCapture {
-    public Capture<ShardRequest> shardRequestCapture = new Capture<>();
-    public Capture<String> nodeUrlsWithoutProtocolPartCapture = new Capture<>();
-    public Capture<ModifiableSolrParams> params = new Capture<>();
-  }
-  
-  protected List<SubmitCapture> mockShardHandlerForCreateJob(
-      Integer numberOfSlices, Integer numberOfReplica) {
-    List<SubmitCapture> submitCaptures = new ArrayList<>();
-    for (int i = 0; i < (numberOfSlices * numberOfReplica); i++) {
-      SubmitCapture submitCapture = new SubmitCapture();
-      shardHandlerMock.submit(capture(submitCapture.shardRequestCapture),
-          capture(submitCapture.nodeUrlsWithoutProtocolPartCapture),
-          capture(submitCapture.params));
-      expectLastCall();
-      submitCaptures.add(submitCapture);
-      ShardResponse shardResponseWithoutException = new ShardResponse();
-      shardResponseWithoutException.setSolrResponse(new QueryResponse());
-      expect(shardHandlerMock.takeCompletedOrError()).andReturn(
-          shardResponseWithoutException);
-    }
-    expect(shardHandlerMock.takeCompletedOrError()).andReturn(null);
-    return submitCaptures;
-  }
-  
+
   protected void issueCreateJob(Integer numberOfSlices,
       Integer replicationFactor, Integer maxShardsPerNode, List<String> createNodeList, boolean sendCreateNodeList, boolean createNodeSetShuffle) {
     Map<String,Object> propMap = Utils.makeMap(
@@ -360,7 +277,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
     queue.add(qe);
   }
   
-  protected void verifySubmitCaptures(List<SubmitCapture> submitCaptures,
+  protected void verifySubmitCaptures(
       Integer numberOfSlices, Integer numberOfReplica, Collection<String> createNodes, boolean dontShuffleCreateNodeSet) {
     List<String> coreNames = new ArrayList<>();
     Map<String,Map<String,Integer>> sliceToNodeUrlsWithoutProtocolPartToNumberOfShardsRunningMapMap = new HashMap<>();
@@ -373,9 +290,17 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
       nodeUrlWithoutProtocolPartForLiveNodes.add(nodeUrlWithoutProtocolPart);
     }
     final Map<String,String> coreName_TO_nodeUrlWithoutProtocolPartForLiveNodes_map = new HashMap<>();
-    
-    for (SubmitCapture submitCapture : submitCaptures) {
-      ShardRequest shardRequest = submitCapture.shardRequestCapture.getValue();
+
+    ArgumentCaptor<ShardRequest> shardRequestCaptor = ArgumentCaptor.forClass(ShardRequest.class);
+    ArgumentCaptor<String> nodeUrlsWithoutProtocolPartCaptor = ArgumentCaptor.forClass(String.class);
+    ArgumentCaptor<ModifiableSolrParams> paramsCaptor = ArgumentCaptor.forClass(ModifiableSolrParams.class);
+    verify(shardHandlerMock, times(numberOfReplica * numberOfSlices))
+        .submit(shardRequestCaptor.capture(), nodeUrlsWithoutProtocolPartCaptor.capture(), paramsCaptor.capture());
+    log.info("Datcmzz " + shardRequestCaptor.getAllValues().size());
+    for (int i = 0; i < shardRequestCaptor.getAllValues().size(); i++) {
+      ShardRequest shardRequest = shardRequestCaptor.getAllValues().get(i);
+      String nodeUrlsWithoutProtocolPartCapture = nodeUrlsWithoutProtocolPartCaptor.getAllValues().get(i);
+      ModifiableSolrParams params = paramsCaptor.getAllValues().get(i);
       assertEquals(CoreAdminAction.CREATE.toString(),
           shardRequest.params.get(CoreAdminParams.ACTION));
       // assertEquals(shardRequest.params, submitCapture.params);
@@ -392,7 +317,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
       assertEquals(ADMIN_PATH, shardRequest.params.get("qt"));
       assertEquals(1, shardRequest.purpose);
       assertEquals(1, shardRequest.shards.length);
-      assertEquals(submitCapture.nodeUrlsWithoutProtocolPartCapture.getValue(),
+      assertEquals(nodeUrlsWithoutProtocolPartCapture,
           shardRequest.shards[0]);
       assertTrue("Shard " + coreName + " created on wrong node "
           + shardRequest.shards[0],
@@ -523,21 +448,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
     }
     
     if (random().nextBoolean()) Collections.shuffle(createNodeList, OverseerCollectionMessageHandler.RANDOM);
-    
-    List<SubmitCapture> submitCaptures = null;
-    if (collectionExceptedToBeCreated) {
-      submitCaptures = mockShardHandlerForCreateJob(numberOfSlices,
-          replicationFactor);
-    }
-    
-    replay(solrZkClientMock);
-    replay(zkStateReaderMock);
-    replay(workQueueMock);
-    replay(clusterStateMock);
-    replay(shardHandlerFactoryMock);
-    replay(shardHandlerMock);
-    
-    
+
     underTest = new OverseerCollectionConfigSetProcessorToBeTested(zkStateReaderMock,
         "1234", shardHandlerFactoryMock, ADMIN_PATH, workQueueMock, runningMapMock,
         completedMapMock, failureMapMock);
@@ -552,15 +463,13 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
     final boolean dontShuffleCreateNodeSet = (createNodeListToSend != null) && sendCreateNodeList && random().nextBoolean();
     issueCreateJob(numberOfSlices, replicationFactor, maxShardsPerNode, createNodeListToSend, sendCreateNodeList, !dontShuffleCreateNodeSet);
     waitForEmptyQueue(10000);
-    
+
     if (collectionExceptedToBeCreated) {
       assertNotNull(lastProcessMessageResult.getResponse().toString(), lastProcessMessageResult);
     }
-    verify(shardHandlerFactoryMock);
-    verify(shardHandlerMock);
 
     if (collectionExceptedToBeCreated) {
-      verifySubmitCaptures(submitCaptures, numberOfSlices, replicationFactor,
+      verifySubmitCaptures(numberOfSlices, replicationFactor,
           createNodeList, dontShuffleCreateNodeSet);
     }
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java b/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java
index 355cb61..b6f0d09 100644
--- a/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java
+++ b/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java
@@ -25,18 +25,11 @@ import java.nio.charset.Charset;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.lucene.util.Constants;
-import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.common.SolrException;
-import org.easymock.EasyMock;
-import org.junit.After;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
+import static org.mockito.Mockito.*;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -47,18 +40,12 @@ public class BlobRepositoryMockingTest {
   private static final Charset UTF8 = Charset.forName("UTF-8");
   private static final String[][] PARSED = new String[][]{{"foo", "bar", "baz"}, {"bang", "boom", "bash"}};
   private static final String BLOBSTR = "foo,bar,baz\nbang,boom,bash";
-  private CoreContainer mockContainer = EasyMock.createMock(CoreContainer.class);
+  private CoreContainer mockContainer = mock(CoreContainer.class);
   @SuppressWarnings("unchecked")
-  private ConcurrentHashMap<String, BlobRepository.BlobContent> mapMock = EasyMock.createMock(ConcurrentHashMap.class);
-  @SuppressWarnings("unchecked")
-  private BlobRepository.Decoder<Object> decoderMock = EasyMock.createMock(BlobRepository.Decoder.class);;
-  @SuppressWarnings("unchecked")
-  private BlobRepository.BlobContent<Object> blobContentMock = EasyMock.createMock(BlobRepository.BlobContent.class);
+  private ConcurrentHashMap<String, BlobRepository.BlobContent> mapMock = mock(ConcurrentHashMap.class);
   
   private Object[] mocks = new Object[] {
       mockContainer,
-      decoderMock,
-      blobContentMock,
       mapMock
   };
   
@@ -67,16 +54,11 @@ public class BlobRepositoryMockingTest {
   boolean blobFetched = false;
   String blobKey = "";
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    LuceneTestCase.assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-  }
-  
   @Before
   public void setUp() throws IllegalAccessException, NoSuchFieldException {
     blobFetched = false;
     blobKey = "";
-    EasyMock.reset(mocks);
+    reset(mocks);
     repository = new BlobRepository(mockContainer) {
       @Override
       ByteBuffer fetchBlob(String key) {
@@ -93,53 +75,49 @@ public class BlobRepositoryMockingTest {
     };
   }
 
-  @After
-  public void tearDown() {
-    EasyMock.verify(mocks);
-  }
-
   @Test (expected = SolrException.class)
   public void testCloudOnly() {
-    expect(mockContainer.isZooKeeperAware()).andReturn(false);
-    EasyMock.replay(mocks);
-    BlobRepository.BlobContentRef ref = repository.getBlobIncRef("foo!");
+    when(mockContainer.isZooKeeperAware()).thenReturn(false);
+    try {
+      BlobRepository.BlobContentRef ref = repository.getBlobIncRef("foo!");
+    } catch (SolrException e) {
+      verify(mockContainer).isZooKeeperAware();
+      throw e;
+    }
   }
 
   @SuppressWarnings("unchecked")
   @Test
   public void testGetBlobIncrRefString() {
-    expect(mockContainer.isZooKeeperAware()).andReturn(true);
-    expect(mapMock.get("foo!")).andReturn(null);
-    expect(mapMock.put(eq("foo!"), anyObject(BlobRepository.BlobContent.class))).andReturn(null);
-    EasyMock.replay(mocks);
+    when(mockContainer.isZooKeeperAware()).thenReturn(true);
     BlobRepository.BlobContentRef ref = repository.getBlobIncRef("foo!");
     assertTrue("foo!".equals(blobKey));
     assertTrue(blobFetched);
     assertNotNull(ref.blob);
     assertEquals(blobData, ref.blob.get());
-  }  
-  
+    verify(mockContainer).isZooKeeperAware();
+    verify(mapMock).get("foo!");
+    verify(mapMock).put(eq("foo!"), any(BlobRepository.BlobContent.class));
+  }
+
   @SuppressWarnings("unchecked")
   @Test
   public void testCachedAlready() {
-    expect(mockContainer.isZooKeeperAware()).andReturn(true);
-    expect(mapMock.get("foo!")).andReturn(new BlobRepository.BlobContent<BlobRepository>("foo!", blobData));
-    EasyMock.replay(mocks);
+    when(mockContainer.isZooKeeperAware()).thenReturn(true);
+    when(mapMock.get("foo!")).thenReturn(new BlobRepository.BlobContent<BlobRepository>("foo!", blobData));
     BlobRepository.BlobContentRef ref = repository.getBlobIncRef("foo!");
     assertEquals("",blobKey);
     assertFalse(blobFetched);
     assertNotNull(ref.blob);
     assertEquals(blobData, ref.blob.get());
+    verify(mockContainer).isZooKeeperAware();
+    verify(mapMock).get("foo!");
   }
 
   @SuppressWarnings("unchecked")
   @Test
   public void testGetBlobIncrRefStringDecoder() {
-    expect(mockContainer.isZooKeeperAware()).andReturn(true);
-    expect(mapMock.get("foo!mocked")).andReturn(null);
-    expect(mapMock.put(eq("foo!mocked"), anyObject(BlobRepository.BlobContent.class))).andReturn(null);
-    
-    EasyMock.replay(mocks);
+    when(mockContainer.isZooKeeperAware()).thenReturn(true);
     BlobRepository.BlobContentRef ref = repository.getBlobIncRef("foo!", new BlobRepository.Decoder<Object>() {
       @Override
       public Object decode(InputStream inputStream) {
@@ -163,6 +141,9 @@ public class BlobRepositoryMockingTest {
     assertTrue(blobFetched);
     assertNotNull(ref.blob);
     assertEquals(PARSED, ref.blob.get());
+    verify(mockContainer).isZooKeeperAware();
+    verify(mapMock).get("foo!mocked");
+    verify(mapMock).put(eq("foo!mocked"), any(BlobRepository.BlobContent.class));
   }
 
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
index f0c4b8c..eedc652 100644
--- a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
+++ b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
@@ -27,7 +27,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
-import org.apache.lucene.util.Constants;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.cloud.CloudDescriptor;
 import org.apache.solr.cloud.ZkController;
@@ -36,24 +35,15 @@ import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.CoreSorter.CountsForEachShard;
 import org.apache.solr.util.MockCoreContainer;
-import org.junit.BeforeClass;
 
 import static java.util.stream.Collectors.toList;
 import static org.apache.solr.core.CoreSorter.getShardName;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
+import static org.mockito.Mockito.*;
 
 public class CoreSorterTest extends SolrTestCaseJ4 {
   Map<String, Boolean> nodes = new LinkedHashMap<>();
   Set<String> liveNodes = new HashSet<>();
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-  }
-  
   public void testComparator() {
     List<CountsForEachShard> l = new ArrayList<>();
     //                           DOWN LIVE  MY
@@ -111,15 +101,13 @@ public class CoreSorterTest extends SolrTestCaseJ4 {
   }
 
   private CoreContainer getMockContainer() {
-    CoreContainer mockCC = createMock(CoreContainer.class);
-    ZkController mockZKC = createMock(ZkController.class);
-    ClusterState mockClusterState = createMock(ClusterState.class);
-    reset(mockCC, mockZKC, mockClusterState);
-    expect(mockCC.isZooKeeperAware()).andReturn(Boolean.TRUE).anyTimes();
-    expect(mockCC.getZkController()).andReturn(mockZKC).anyTimes();
-    expect(mockClusterState.getLiveNodes()).andReturn(liveNodes).anyTimes();
-    expect(mockZKC.getClusterState()).andReturn(mockClusterState).anyTimes();
-    replay(mockCC, mockZKC, mockClusterState);
+    CoreContainer mockCC = mock(CoreContainer.class);
+    ZkController mockZKC = mock(ZkController.class);
+    ClusterState mockClusterState = mock(ClusterState.class);
+    when(mockCC.isZooKeeperAware()).thenReturn(true);
+    when(mockCC.getZkController()).thenReturn(mockZKC);
+    when(mockClusterState.getLiveNodes()).thenReturn(liveNodes);
+    when(mockZKC.getClusterState()).thenReturn(mockClusterState);
     return mockCC;
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/src/test/org/apache/solr/handler/admin/TestCoreAdminApis.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/TestCoreAdminApis.java b/solr/core/src/test/org/apache/solr/handler/admin/TestCoreAdminApis.java
index 2df88dc..96d1f55 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/TestCoreAdminApis.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/TestCoreAdminApis.java
@@ -24,27 +24,19 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.lucene.util.Constants;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.api.Api;
 import org.apache.solr.api.ApiBag;
-import org.easymock.EasyMock;
-import org.junit.BeforeClass;
+import org.apache.solr.core.PluginBag;
+import org.apache.solr.request.SolrRequestHandler;
 
 import static org.apache.solr.common.util.Utils.fromJSONString;
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.getCurrentArguments;
+import static org.mockito.Mockito.*;
 
 public class TestCoreAdminApis extends SolrTestCaseJ4 {
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-  }
-
   public void testCalls() throws Exception {
     Map<String, Object[]> calls = new HashMap<>();
     CoreContainer mockCC = getCoreContainerMock(calls, new HashMap<>());
@@ -80,41 +72,33 @@ public class TestCoreAdminApis extends SolrTestCaseJ4 {
   }
 
   public static CoreContainer getCoreContainerMock(final Map<String, Object[]> in,Map<String,Object> out ) {
-    CoreContainer mockCC = EasyMock.createMock(CoreContainer.class);
-    EasyMock.reset(mockCC);
-    mockCC.create(anyObject(String.class), anyObject(Path.class) , anyObject(Map.class), anyBoolean());
-    EasyMock.expectLastCall().andAnswer(() -> {
-      in.put("create", getCurrentArguments());
+    CoreContainer mockCC = mock(CoreContainer.class);
+    when(mockCC.create(any(String.class), any(Path.class) , any(Map.class), anyBoolean())).thenAnswer(invocationOnMock -> {
+      in.put("create", invocationOnMock.getArguments());
       return null;
-    }).anyTimes();
-    mockCC.swap(anyObject(String.class), anyObject(String.class));
-    EasyMock.expectLastCall().andAnswer(() -> {
-      in.put("swap", getCurrentArguments());
-      return null;
-    }).anyTimes();
+    });
 
-    mockCC.rename(anyObject(String.class), anyObject(String.class));
-    EasyMock.expectLastCall().andAnswer(() -> {
-      in.put("rename", getCurrentArguments());
+    doAnswer(invocationOnMock -> {
+      in.put("swap", invocationOnMock.getArguments());
       return null;
-    }).anyTimes();
+    }).when(mockCC).swap(any(String.class), any(String.class));
 
-    mockCC.unload(anyObject(String.class), anyBoolean(),
-        anyBoolean(), anyBoolean());
-    EasyMock.expectLastCall().andAnswer(() -> {
-      in.put("unload", getCurrentArguments());
+    doAnswer(invocationOnMock -> {
+      in.put("rename", invocationOnMock.getArguments());
       return null;
-    }).anyTimes();
+    }).when(mockCC).rename(any(String.class), any(String.class));
 
-    mockCC.getCoreRootDirectory();
-    EasyMock.expectLastCall().andAnswer(() -> Paths.get("coreroot")).anyTimes();
-    mockCC.getContainerProperties();
-    EasyMock.expectLastCall().andAnswer(() -> new Properties()).anyTimes();
 
-    mockCC.getRequestHandlers();
-    EasyMock.expectLastCall().andAnswer(() -> out.get("getRequestHandlers")).anyTimes();
+    doAnswer(invocationOnMock -> {
+      in.put("unload", invocationOnMock.getArguments());
+      return null;
+    }).when(mockCC).unload(any(String.class), anyBoolean(),
+        anyBoolean(), anyBoolean());
+
+    when(mockCC.getCoreRootDirectory()).thenReturn(Paths.get("coreroot"));
+    when(mockCC.getContainerProperties()).thenReturn(new Properties());
 
-    EasyMock.replay(mockCC);
+    when(mockCC.getRequestHandlers()).thenReturn((PluginBag<SolrRequestHandler>) out.get("getRequestHandlers"));
     return mockCC;
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java b/solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java
index f602b1b..a5a279f 100644
--- a/solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java
+++ b/solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.http.Header;
 import org.apache.http.auth.BasicUserPrincipal;
 import org.apache.http.message.BasicHttpRequest;
-import org.apache.lucene.util.Constants;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.core.CoreContainer;
@@ -36,10 +35,7 @@ import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrRequestInfo;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.util.CryptoKeys;
-import org.easymock.EasyMock;
-import org.junit.BeforeClass;
-
-import static org.easymock.EasyMock.getCurrentArguments;
+import static org.mockito.Mockito.*;
 
 public class TestPKIAuthenticationPlugin extends SolrTestCaseJ4 {
 
@@ -73,11 +69,6 @@ public class TestPKIAuthenticationPlugin extends SolrTestCaseJ4 {
     }
   }
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-  }
-  
   public void test() throws Exception {
     AtomicReference<Principal> principal = new AtomicReference<>();
     String nodeName = "node_x_233";
@@ -157,22 +148,14 @@ public class TestPKIAuthenticationPlugin extends SolrTestCaseJ4 {
   }
 
   private HttpServletRequest createMockRequest(final AtomicReference<Header> header) {
-    HttpServletRequest mockReq = EasyMock.createMock(HttpServletRequest.class);
-    EasyMock.reset(mockReq);
-    mockReq.getHeader(EasyMock.anyObject(String.class));
-    EasyMock.expectLastCall().andAnswer(() -> {
-      if (PKIAuthenticationPlugin.HEADER.equals(getCurrentArguments()[0])) {
+    HttpServletRequest mockReq = mock(HttpServletRequest.class);
+    when(mockReq.getHeader(any(String.class))).then(invocation -> {
+      if (PKIAuthenticationPlugin.HEADER.equals(invocation.getArgument(0))) {
         if (header.get() == null) return null;
         return header.get().getValue();
       } else return null;
-    }).anyTimes();
-    mockReq.getUserPrincipal();
-    EasyMock.expectLastCall().andAnswer(() -> null).anyTimes();
-
-    mockReq.getRequestURI();
-    EasyMock.expectLastCall().andAnswer(() -> "/collection1/select").anyTimes();
-
-    EasyMock.replay(mockReq);
+    });
+    when(mockReq.getRequestURI()).thenReturn("/collection1/select");
     return mockReq;
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java b/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
index a34febc..c830303 100644
--- a/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
+++ b/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
@@ -16,11 +16,6 @@
  */
 package org.apache.solr.servlet;
 
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -42,7 +37,6 @@ import javax.servlet.http.HttpServletRequest;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
-import org.apache.lucene.util.Constants;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.CommonParams;
@@ -55,7 +49,7 @@ import org.apache.solr.servlet.SolrRequestParsers.MultipartRequestParser;
 import org.apache.solr.servlet.SolrRequestParsers.FormDataRequestParser;
 import org.apache.solr.servlet.SolrRequestParsers.RawRequestParser;
 import org.apache.solr.servlet.SolrRequestParsers.StandardRequestParser;
-import org.easymock.EasyMock;
+import static org.mockito.Mockito.*;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -68,8 +62,6 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    assumeFalse("SOLR-9893: EasyMock does not work with Java 9", Constants.JRE_IS_MINIMUM_JAVA9);
-    
     initCore("solrconfig.xml", "schema.xml");
     parser = new SolrRequestParsers( h.getCore().getSolrConfig() );
   }
@@ -240,11 +232,10 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
     
     for( String contentType : ct ) {
       HttpServletRequest request = getMock("/solr/select", contentType, postBytes.length);
-      expect(request.getMethod()).andReturn("POST").anyTimes();
-      expect(request.getQueryString()).andReturn(getParams).anyTimes();
-      expect(request.getInputStream()).andReturn(new ByteServletInputStream(postBytes));
-      replay(request);
-      
+      when(request.getMethod()).thenReturn("POST");
+      when(request.getQueryString()).thenReturn(getParams);
+      when(request.getInputStream()).thenReturn(new ByteServletInputStream(postBytes));
+
       MultipartRequestParser multipart = new MultipartRequestParser( 2048 );
       RawRequestParser raw = new RawRequestParser();
       FormDataRequestParser formdata = new FormDataRequestParser( 2048 );
@@ -255,6 +246,8 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
       assertEquals( "contentType: "+contentType, "hello", p.get("q") );
       assertEquals( "contentType: "+contentType, "\u00FC", p.get("qt") );
       assertArrayEquals( "contentType: "+contentType, new String[]{"foo","bar"}, p.getParams("dup") );
+
+      verify(request).getInputStream();
     }
   }
 
@@ -300,10 +293,9 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
     
     // Set up the expected behavior
     HttpServletRequest request = getMock("/solr/select", contentType, postBytes.length);
-    expect(request.getMethod()).andReturn("POST").anyTimes();
-    expect(request.getQueryString()).andReturn(getParams).anyTimes();
-    expect(request.getInputStream()).andReturn(new ByteServletInputStream(postBytes));
-    replay(request);
+    when(request.getMethod()).thenReturn("POST");
+    when(request.getQueryString()).thenReturn(getParams);
+    when(request.getInputStream()).thenReturn(new ByteServletInputStream(postBytes));
     
     MultipartRequestParser multipart = new MultipartRequestParser( 2048 );
     RawRequestParser raw = new RawRequestParser();
@@ -316,6 +308,8 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
     assertEquals( "contentType: "+contentType, "\u00FC", p.get("qt") );
     assertEquals( "contentType: "+contentType, "\u00FC", p.get("qt2") );
     assertArrayEquals( "contentType: "+contentType, new String[]{"foo","\u00FC","bar"}, p.getParams("dup") );
+
+    verify(request).getInputStream();
   }
   
   @Test
@@ -329,11 +323,9 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
       large.append('&').append(large);
     }
     HttpServletRequest request = getMock("/solr/select", "application/x-www-form-urlencoded", -1);
-    expect(request.getMethod()).andReturn("POST").anyTimes();
-    expect(request.getQueryString()).andReturn(null).anyTimes();
-    expect(request.getInputStream()).andReturn(new ByteServletInputStream(large.toString().getBytes(StandardCharsets.US_ASCII)));
-    replay(request);
-    
+    when(request.getMethod()).thenReturn("POST");
+    when(request.getInputStream()).thenReturn(new ByteServletInputStream(large.toString().getBytes(StandardCharsets.US_ASCII)));
+
     FormDataRequestParser formdata = new FormDataRequestParser( limitKBytes );    
     try {
       formdata.parseParamsAndFillStreams(request, new ArrayList<ContentStream>());
@@ -342,15 +334,16 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
       assertTrue(solre.getMessage().contains("upload limit"));
       assertEquals(400, solre.code());
     }
+
+    verify(request).getInputStream();
   }
   
   @Test
   public void testParameterIncompatibilityException1() throws Exception
   {
     HttpServletRequest request = getMock("/solr/select", "application/x-www-form-urlencoded", 100);
-    expect(request.getQueryString()).andReturn(null).anyTimes();
     // we emulate Jetty that returns empty stream when parameters were parsed before:
-    expect(request.getInputStream()).andReturn(new ServletInputStream() {
+    when(request.getInputStream()).thenReturn(new ServletInputStream() {
       @Override public int read() { return -1; }
 
       @Override
@@ -368,8 +361,7 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
 
       }
     });
-    replay(request);
-    
+
     FormDataRequestParser formdata = new FormDataRequestParser( 2048 );    
     try {
       formdata.parseParamsAndFillStreams(request, new ArrayList<ContentStream>());
@@ -378,18 +370,17 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
       assertTrue(solre.getMessage().startsWith("Solr requires that request parameters"));
       assertEquals(500, solre.code());
     }
+    verify(request).getInputStream();
   }
   
   @Test
   public void testParameterIncompatibilityException2() throws Exception
   {
     HttpServletRequest request = getMock("/solr/select", "application/x-www-form-urlencoded", 100);
-    expect(request.getMethod()).andReturn("POST").anyTimes();
-    expect(request.getQueryString()).andReturn(null).anyTimes();
+    when(request.getMethod()).thenReturn("POST");
     // we emulate Tomcat that throws IllegalStateException when parameters were parsed before:
-    expect(request.getInputStream()).andThrow(new IllegalStateException());
-    replay(request);
-    
+    when(request.getInputStream()).thenThrow(new IllegalStateException());
+
     FormDataRequestParser formdata = new FormDataRequestParser( 2048 );    
     try {
       formdata.parseParamsAndFillStreams(request, new ArrayList<ContentStream>());
@@ -398,23 +389,23 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
       assertTrue(solre.getMessage().startsWith("Solr requires that request parameters"));
       assertEquals(500, solre.code());
     }
+    verify(request).getInputStream();
   }
   
   @Test
   public void testAddHttpRequestToContext() throws Exception {
     HttpServletRequest request = getMock("/solr/select", null, -1);
-    expect(request.getMethod()).andReturn("GET").anyTimes();
-    expect(request.getQueryString()).andReturn("q=title:solr").anyTimes();
+    when(request.getMethod()).thenReturn("GET");
+    when(request.getQueryString()).thenReturn("q=title:solr");
     Map<String, String> headers = new HashMap<>();
     headers.put("X-Forwarded-For", "10.0.0.1");
-    expect(request.getHeaderNames()).andReturn(new Vector<>(headers.keySet()).elements()).anyTimes();
+    when(request.getHeaderNames()).thenReturn(new Vector<>(headers.keySet()).elements());
     for(Map.Entry<String,String> entry:headers.entrySet()) {
       Vector<String> v = new Vector<>();
       v.add(entry.getValue());
-      expect(request.getHeaders(entry.getKey())).andReturn(v.elements()).anyTimes();
+      when(request.getHeaders(entry.getKey())).thenReturn(v.elements());
     }
-    replay(request);
-    
+
     SolrRequestParsers parsers = new SolrRequestParsers(h.getCore().getSolrConfig());
     assertFalse(parsers.isAddRequestHeadersToContext());
     SolrQueryRequest solrReq = parsers.parse(h.getCore(), "/select", request);
@@ -429,10 +420,7 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
 
   public void testPostMissingContentType() throws Exception {
     HttpServletRequest request = getMock();
-    expect(request.getMethod()).andReturn("POST").anyTimes();
-    expect(request.getQueryString()).andReturn(null).anyTimes();
-    expect(request.getHeader(anyObject())).andReturn(null).anyTimes();
-    replay(request);
+    when(request.getMethod()).thenReturn("POST");
 
     SolrRequestParsers parsers = new SolrRequestParsers(h.getCore().getSolrConfig());
     try {
@@ -470,20 +458,16 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
     String contentType = "application/x-www-form-urlencoded";
     int contentLength = -1;  // does this mean auto-detect?
 
-    HttpServletRequest request = createMock(HttpServletRequest.class);
-    expect(request.getHeader("User-Agent")).andReturn(userAgent).anyTimes();
-    expect(request.getHeader("Content-Length")).andReturn(null).anyTimes();
-    expect(request.getRequestURI()).andReturn(uri).anyTimes();
-    expect(request.getContentType()).andReturn(contentType).anyTimes();
-    expect(request.getContentLength()).andReturn(contentLength).anyTimes();
-    expect(request.getAttribute(SolrRequestParsers.REQUEST_TIMER_SERVLET_ATTRIBUTE)).andReturn(null).anyTimes();
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    when(request.getHeader("User-Agent")).thenReturn(userAgent);
+    when(request.getRequestURI()).thenReturn(uri);
+    when(request.getContentType()).thenReturn(contentType);
+    when(request.getContentLength()).thenReturn(contentLength);
 
-    expect(request.getMethod()).andReturn(method).anyTimes();
+    when(request.getMethod()).thenReturn(method);
     // we dont pass a content-length to let the security mechanism limit it:
-    expect(request.getQueryString()).andReturn("foo=1&bar=2").anyTimes();
-    expect(request.getInputStream()).andReturn(new ByteServletInputStream(body.getBytes(StandardCharsets.US_ASCII)));
-    expect(request.getAttribute(EasyMock.anyObject(String.class))).andReturn(null).anyTimes();
-    replay(request);
+    when(request.getQueryString()).thenReturn("foo=1&bar=2");
+    when(request.getInputStream()).thenReturn(new ByteServletInputStream(body.getBytes(StandardCharsets.US_ASCII)));
 
     SolrRequestParsers parsers = new SolrRequestParsers(h.getCore().getSolrConfig());
     SolrQueryRequest req = parsers.parse(h.getCore(), "/select", request);
@@ -506,21 +490,19 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 {
     }
 
     req.close();
+    verify(request).getInputStream();
   }
 
 
   public HttpServletRequest getMock() {
     return getMock("/solr/select", null, -1);
-    // return getMock("/solr/select", "application/x-www-form-urlencoded");
   }
 
   public HttpServletRequest getMock(String uri, String contentType, int contentLength) {
-    HttpServletRequest request = createMock(HttpServletRequest.class);
-    expect(request.getHeader("User-Agent")).andReturn(null).anyTimes();
-    expect(request.getRequestURI()).andReturn(uri).anyTimes();
-    expect(request.getContentType()).andReturn(contentType).anyTimes();
-    expect(request.getContentLength()).andReturn(contentLength).anyTimes();
-    expect(request.getAttribute(EasyMock.anyObject(String.class))).andReturn(null).anyTimes();
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    when(request.getRequestURI()).thenReturn(uri);
+    when(request.getContentType()).thenReturn(contentType);
+    when(request.getContentLength()).thenReturn(contentLength);
     return request;
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbf0f838/solr/licenses/easymock-3.0.jar.sha1
----------------------------------------------------------------------
diff --git a/solr/licenses/easymock-3.0.jar.sha1 b/solr/licenses/easymock-3.0.jar.sha1
deleted file mode 100644
index e31ee54..0000000
--- a/solr/licenses/easymock-3.0.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-f28a4c31c330f95c9acbf1108cea19952b5c496f


Mime
View raw message