From 3ab1a07662db324be9cdb76a5acfcbc2cbbd85cf Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Sat, 4 Nov 2017 19:37:28 +0100 Subject: [PATCH] SOLR-11606: Disable tests automatically if Mockito does not work with Java runtime (Java 10) --- build.xml | 37 ++++++++++++------- solr/CHANGES.txt | 3 ++ .../dataimport/TestJdbcDataSource.java | 6 +++ .../TestReversedWildcardFilterFactory.java | 1 + .../org/apache/solr/cloud/AssignTest.java | 2 + ...rseerCollectionConfigSetProcessorTest.java | 2 + .../org/apache/solr/cloud/OverseerTest.java | 1 + .../overseer/TestClusterStateMutator.java | 7 ++++ .../solr/cloud/rule/ImplicitSnitchTest.java | 5 +++ .../solr/core/BlobRepositoryMockingTest.java | 7 ++++ .../org/apache/solr/core/CoreSorterTest.java | 2 + .../solr/handler/admin/TestCoreAdminApis.java | 2 + .../reporters/SolrGangliaReporterTest.java | 2 + .../apache/solr/schema/SchemaWatcherTest.java | 3 ++ .../schema/TestManagedSchemaThreadSafety.java | 1 + .../security/TestPKIAuthenticationPlugin.java | 2 + .../solr/servlet/SolrRequestParserTest.java | 1 + ...ssificationUpdateProcessorFactoryTest.java | 2 + .../ClassificationUpdateProcessorTest.java | 1 + ...ExistingDocumentsProcessorFactoryTest.java | 7 ++++ .../solrj/impl/CloudSolrClientCacheTest.java | 7 ++++ .../java/org/apache/solr/SolrTestCaseJ4.java | 16 ++++++++ 22 files changed, 103 insertions(+), 14 deletions(-) diff --git a/build.xml b/build.xml index 5335957bea0..9db8312f383 100755 --- a/build.xml +++ b/build.xml @@ -186,20 +186,26 @@ } def checkLicenseHeaderPrecedes = { f, description, contentPattern, commentPattern, text, ratDocument -> - def contentMatcher = contentPattern.matcher(text); - if (contentMatcher.find()) { - def contentStartPos = contentMatcher.start(); - def commentMatcher = commentPattern.matcher(text); - while (commentMatcher.find()) { - if (isLicense(commentMatcher, ratDocument)) { - if (commentMatcher.start() < contentStartPos) { - break; // This file is all good, so break loop: license header precedes 'description' definition - } else { - reportViolation(f, description+' declaration precedes license header'); - } + def contentMatcher = contentPattern.matcher(text); + if (contentMatcher.find()) { + def contentStartPos = contentMatcher.start(); + def commentMatcher = commentPattern.matcher(text); + while (commentMatcher.find()) { + if (isLicense(commentMatcher, ratDocument)) { + if (commentMatcher.start() < contentStartPos) { + break; // This file is all good, so break loop: license header precedes 'description' definition + } else { + reportViolation(f, description+' declaration precedes license header'); } } } + } + } + + def checkMockitoAssume = { f, text -> + if (text.contains("mockito") && !text.contains("assumeWorkingMockito()")) { + reportViolation(f, 'File uses Mockito but has no assumeWorkingMockito() call'); + } } def checkForUnescapedSymbolSubstitutions = { f, text -> @@ -265,18 +271,21 @@ ratDocument.getMetaData().value(MetaData.RAT_URL_LICENSE_FAMILY_NAME))); } } - if (f.toString().endsWith('.java')) { + if (f.name.endsWith('.java')) { if (text.contains('org.slf4j.LoggerFactory')) { if (!validLoggerPattern.matcher(text).find()) { reportViolation(f, 'invalid logging pattern [not private static final, uses static class name]'); } } checkLicenseHeaderPrecedes(f, 'package', packagePattern, javaCommentPattern, text, ratDocument); + if (f.name.contains("Test")) { + checkMockitoAssume(f, text); + } } - if (f.toString().endsWith('.xml') || f.toString().endsWith('.xml.template')) { + if (f.name.endsWith('.xml') || f.name.endsWith('.xml.template')) { checkLicenseHeaderPrecedes(f, '', xmlTagPattern, xmlCommentPattern, text, ratDocument); } - if (f.toString().endsWith('.adoc')) { + if (f.name.endsWith('.adoc')) { checkForUnescapedSymbolSubstitutions(f, text); } }; diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 1bb4e5bfd38..746935a72ca 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -139,6 +139,9 @@ Other Changes * SOLR-11603: Remove unused (public) LTRScoringModel.hasParams() method. (Christine Poerschke) +* SOLR-11606: Disable tests automatically if Mockito does not work with Java runtime (Java 10). + (Uwe Schindler) + ================== 7.1.0 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. 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 e9908f983af..e44e7f934b2 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 @@ -40,6 +40,7 @@ import org.apache.solr.handler.dataimport.JdbcDataSource.ResultSetIterator; 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; @@ -68,6 +69,11 @@ public class TestJdbcDataSource extends AbstractDataImportHandlerTestCase { String sysProp = System.getProperty("java.naming.factory.initial"); + @BeforeClass + public static void beforeClass() { + assumeWorkingMockito(); + } + @Override @Before public void setUp() throws Exception { diff --git a/solr/core/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java b/solr/core/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java index f7a49ace265..447b8303967 100644 --- a/solr/core/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java +++ b/solr/core/src/test/org/apache/solr/analysis/TestReversedWildcardFilterFactory.java @@ -53,6 +53,7 @@ public class TestReversedWildcardFilterFactory extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { + assumeWorkingMockito(); initCore("solrconfig.xml","schema-reversed.xml"); } diff --git a/solr/core/src/test/org/apache/solr/cloud/AssignTest.java b/solr/core/src/test/org/apache/solr/cloud/AssignTest.java index d0273cbcd84..21c001c4e6e 100644 --- a/solr/core/src/test/org/apache/solr/cloud/AssignTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/AssignTest.java @@ -62,6 +62,8 @@ public class AssignTest extends SolrTestCaseJ4 { @Test public void testAssignNode() throws Exception { + assumeWorkingMockito(); + SolrZkClient zkClient = mock(SolrZkClient.class); Map zkClientData = new HashMap<>(); when(zkClient.setData(anyString(), any(), anyInt(), anyBoolean())).then(invocation -> { 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 7abd8d3167c..b6e7415c9ed 100644 --- a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java @@ -122,6 +122,8 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 { @BeforeClass public static void setUpOnce() throws Exception { + assumeWorkingMockito(); + workQueueMock = mock(OverseerTaskQueue.class); runningMapMock = mock(DistributedMap.class); completedMapMock = mock(DistributedMap.class); diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java index 527a28b3613..7259d389a2a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java @@ -238,6 +238,7 @@ public class OverseerTest extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { + assumeWorkingMockito(); initCore(); } diff --git a/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java b/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java index 311e14df060..672c78707ab 100644 --- a/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java +++ b/solr/core/src/test/org/apache/solr/cloud/overseer/TestClusterStateMutator.java @@ -27,10 +27,17 @@ import org.apache.solr.common.cloud.ImplicitDocRouter; import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.util.Utils; +import org.junit.BeforeClass; import static org.mockito.Mockito.*; public class TestClusterStateMutator extends SolrTestCaseJ4 { + + @BeforeClass + public static void beforeClass() { + assumeWorkingMockito(); + } + public void testCreateCollection() throws Exception { ClusterState clusterState = new ClusterState(-1, Collections.emptySet(), Collections.emptyMap()); DistribStateManager mockStateManager = mock(DistribStateManager.class); diff --git a/solr/core/src/test/org/apache/solr/cloud/rule/ImplicitSnitchTest.java b/solr/core/src/test/org/apache/solr/cloud/rule/ImplicitSnitchTest.java index 709555f330b..a57f40a5acc 100644 --- a/solr/core/src/test/org/apache/solr/cloud/rule/ImplicitSnitchTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/rule/ImplicitSnitchTest.java @@ -23,6 +23,7 @@ import java.util.Map; import com.google.common.collect.Sets; import org.apache.lucene.util.LuceneTestCase; +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.SolrException; import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.rule.ImplicitSnitch; @@ -134,6 +135,8 @@ public class ImplicitSnitchTest extends LuceneTestCase { @Test public void testGetTags_withAllHostNameRequestedTags_returns_all_Tags() throws Exception { + SolrTestCaseJ4.assumeWorkingMockito(); + String node = "serv01.dc01.london.uk.apache.org:8983_solr"; SnitchContext context = new ServerSnitchContext(null, node, new HashMap<>(),null); @@ -153,6 +156,8 @@ public class ImplicitSnitchTest extends LuceneTestCase { @Test public void testGetTags_withHostNameRequestedTag_ip3_returns_1_tag() throws Exception { + SolrTestCaseJ4.assumeWorkingMockito(); + String node = "serv01.dc01.london.uk.apache.org:8983_solr"; SnitchContext context = new ServerSnitchContext(null, node, new HashMap<>(),null); 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 b6f0d097dfd..7b4dc06b16b 100644 --- a/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java +++ b/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java @@ -25,8 +25,10 @@ import java.nio.charset.Charset; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.io.IOUtils; +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.SolrException; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import static org.mockito.Mockito.*; @@ -53,6 +55,11 @@ public class BlobRepositoryMockingTest { ByteBuffer blobData = ByteBuffer.wrap(BLOBSTR.getBytes(UTF8)); boolean blobFetched = false; String blobKey = ""; + + @BeforeClass + public static void beforeClass() { + SolrTestCaseJ4.assumeWorkingMockito(); + } @Before public void setUp() throws IllegalAccessException, NoSuchFieldException { 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 eedc652dc15..bb8bb678bfd 100644 --- a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java +++ b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java @@ -101,6 +101,8 @@ public class CoreSorterTest extends SolrTestCaseJ4 { } private CoreContainer getMockContainer() { + assumeWorkingMockito(); + CoreContainer mockCC = mock(CoreContainer.class); ZkController mockZKC = mock(ZkController.class); ClusterState mockClusterState = mock(ClusterState.class); 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 9477563adaf..dcaa64a9f5a 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 @@ -70,6 +70,8 @@ public class TestCoreAdminApis extends SolrTestCaseJ4 { } public static CoreContainer getCoreContainerMock(final Map in,Map out ) { + assumeWorkingMockito(); + 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()); diff --git a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrGangliaReporterTest.java b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrGangliaReporterTest.java index eca414cd8ff..23230cd8042 100644 --- a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrGangliaReporterTest.java +++ b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrGangliaReporterTest.java @@ -45,6 +45,8 @@ import static org.mockito.Mockito.*; public class SolrGangliaReporterTest extends SolrTestCaseJ4 { @Test public void testReporter() throws Exception { + assumeWorkingMockito(); + Path home = Paths.get(TEST_HOME()); // define these properties, they are used in solrconfig.xml System.setProperty("solr.test.sys.prop1", "propone"); diff --git a/solr/core/src/test/org/apache/solr/schema/SchemaWatcherTest.java b/solr/core/src/test/org/apache/solr/schema/SchemaWatcherTest.java index 4d46aad2dd8..729ec53c601 100644 --- a/solr/core/src/test/org/apache/solr/schema/SchemaWatcherTest.java +++ b/solr/core/src/test/org/apache/solr/schema/SchemaWatcherTest.java @@ -17,6 +17,7 @@ package org.apache.solr.schema; +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.schema.ZkIndexSchemaReader.SchemaWatcher; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher.Event.EventType; @@ -35,6 +36,8 @@ public class SchemaWatcherTest { @Before public void setUp() throws Exception { + SolrTestCaseJ4.assumeWorkingMockito(); + mockSchemaReader = mock(ZkIndexSchemaReader.class); schemaWatcher = new SchemaWatcher(mockSchemaReader); } diff --git a/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java b/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java index a00129a17c5..46f58a171fe 100644 --- a/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java +++ b/solr/core/src/test/org/apache/solr/schema/TestManagedSchemaThreadSafety.java @@ -135,6 +135,7 @@ public class TestManagedSchemaThreadSafety extends SolrTestCaseJ4 { } private ZkController createZkController(SolrZkClient client) throws KeeperException, InterruptedException { + assumeWorkingMockito(); CoreContainer mockAlwaysUpCoreContainer = mock(CoreContainer.class, Mockito.withSettings().defaultAnswer(Mockito.CALLS_REAL_METHODS)); 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 25952775a85..a7dadcd7605 100644 --- a/solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java +++ b/solr/core/src/test/org/apache/solr/security/TestPKIAuthenticationPlugin.java @@ -70,6 +70,8 @@ public class TestPKIAuthenticationPlugin extends SolrTestCaseJ4 { } public void test() throws Exception { + assumeWorkingMockito(); + AtomicReference principal = new AtomicReference<>(); String nodeName = "node_x_233"; 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 c8303036910..917b1b4bc81 100644 --- a/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java +++ b/solr/core/src/test/org/apache/solr/servlet/SolrRequestParserTest.java @@ -62,6 +62,7 @@ public class SolrRequestParserTest extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { + assumeWorkingMockito(); initCore("solrconfig.xml", "schema.xml"); parser = new SolrRequestParsers( h.getCore().getSolrConfig() ); } diff --git a/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorFactoryTest.java index fe22918ded7..ad39b6ff71b 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorFactoryTest.java @@ -104,6 +104,8 @@ public class ClassificationUpdateProcessorFactoryTest extends SolrTestCaseJ4 { @Test public void init_unsupportedFilterQuery_shouldThrowExceptionWithDetailedMessage() { + assumeWorkingMockito(); + UpdateRequestProcessor mockProcessor = mock(UpdateRequestProcessor.class); SolrQueryRequest mockRequest = mock(SolrQueryRequest.class); SolrQueryResponse mockResponse = mock(SolrQueryResponse.class); diff --git a/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.java index df2e7aa9e14..2a9055a9e20 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/ClassificationUpdateProcessorTest.java @@ -61,6 +61,7 @@ public class ClassificationUpdateProcessorTest extends SolrTestCaseJ4 { @BeforeClass public static void beforeClass() throws Exception { + assumeWorkingMockito(); System.setProperty("enable.update.log", "false"); initCore("solrconfig-classification.xml", "schema-classification.xml"); } diff --git a/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java b/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java index 7e17f715da4..63069df2139 100644 --- a/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java +++ b/solr/core/src/test/org/apache/solr/update/processor/SkipExistingDocumentsProcessorFactoryTest.java @@ -26,6 +26,7 @@ import java.io.IOException; import com.google.common.collect.ImmutableMap; import org.apache.lucene.util.BytesRef; +import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.util.NamedList; @@ -34,6 +35,7 @@ import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.update.AddUpdateCommand; import org.apache.solr.update.processor.SkipExistingDocumentsProcessorFactory.SkipExistingDocumentsUpdateProcessor; +import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; @@ -41,6 +43,11 @@ public class SkipExistingDocumentsProcessorFactoryTest { private BytesRef docId = new BytesRef(); private SolrQueryRequest defaultRequest = new LocalSolrQueryRequest(null, new NamedList()); + + @BeforeClass + public static void beforeClass() { + SolrTestCaseJ4.assumeWorkingMockito(); + } // Tests for logic in the factory diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java index cfcfcd6227e..e666e495552 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java @@ -36,11 +36,18 @@ import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.DocCollection; import org.apache.solr.common.util.NamedList; +import org.junit.BeforeClass; + import static org.mockito.Mockito.*; import static java.nio.charset.StandardCharsets.UTF_8; public class CloudSolrClientCacheTest extends SolrTestCaseJ4 { + + @BeforeClass + public static void beforeClass() { + assumeWorkingMockito(); + } public void testCaching() throws Exception { String collName = "gettingstarted"; diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index 9d9a9dc55bf..3b1c4692cfa 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -31,6 +31,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.invoke.MethodHandles; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.ServerSocket; @@ -60,9 +61,11 @@ import java.util.Map.Entry; import java.util.concurrent.TimeUnit; import com.carrotsearch.randomizedtesting.RandomizedContext; +import com.carrotsearch.randomizedtesting.RandomizedTest; import com.carrotsearch.randomizedtesting.TraceFormatting; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule; + import org.apache.commons.io.FileUtils; import org.apache.http.client.HttpClient; import org.apache.lucene.analysis.MockAnalyzer; @@ -328,6 +331,19 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase { StartupLoggingUtils.changeLogLevel(initialRootLogLevel); } + /** Assumes that Mockito/Bytebuddy is available and can be used to mock classes (e.g., fails if Java version is too new). */ + public static void assumeWorkingMockito() { + // we use reflection here, because we do not have ByteBuddy/Mockito in all modules and the test framework! + try { + Class.forName("net.bytebuddy.ClassFileVersion").getMethod("ofThisVm").invoke(null); + } catch (InvocationTargetException e) { + RandomizedTest.assumeNoException("SOLR-11606: ByteBuddy used by Mockito is not working with this JVM version.", + e.getTargetException()); + } catch (ReflectiveOperationException e) { + fail("ByteBuddy and Mockito are not available on classpath: " + e.toString()); + } + } + /** * @return null if ok else error message */