You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/10/20 19:46:13 UTC
[solr] 02/02: SOLR-16311: Simplify assert statements (#953)
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 89f0baa74210f50bafbedf8ce969e9866cf3aa40
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Thu Oct 20 14:05:22 2022 -0400
SOLR-16311: Simplify assert statements (#953)
* Simplify assert statements
* remove unused imports
* Address remaining assert simplifications
* Fix bad replacements in TestSQLHandler
* Fix SolrInputDocumentReaderTest setup
* Fix redundant casts in SpellCheckComponentTest
* Fix redundant cast in ArrayEvaluatorTest
* Fix cast in SchemaTest
* Simplify casts in stream/sql tests and fix asserts
* Simplify raw assert in tests
Co-authored-by: Kevin Risden <kr...@apache.org>
---
.../org/apache/solr/BasicFunctionalityTest.java | 14 +-
.../src/test/org/apache/solr/CursorPagingTest.java | 2 +-
.../src/test/org/apache/solr/OutputWriterTest.java | 2 +-
.../org/apache/solr/TestDistributedSearch.java | 29 +-
.../test/org/apache/solr/TestRandomDVFaceting.java | 9 +-
.../test/org/apache/solr/TestRandomFaceting.java | 8 +-
.../apache/solr/cloud/CollectionsAPISolrJTest.java | 2 +-
.../test/org/apache/solr/cloud/DeleteNodeTest.java | 4 +-
.../org/apache/solr/cloud/DeleteReplicaTest.java | 4 +-
.../DistribDocExpirationUpdateProcessorTest.java | 6 +-
.../solr/cloud/DistribJoinFromCollectionTest.java | 6 +-
.../solr/cloud/DistributedVersionInfoTest.java | 3 +-
.../solr/cloud/HttpPartitionOnCommitTest.java | 10 +-
.../org/apache/solr/cloud/HttpPartitionTest.java | 13 +-
.../cloud/LeaderFailoverAfterPartitionTest.java | 10 +-
.../solr/cloud/LeaderVoteWaitTimeoutTest.java | 3 +-
.../test/org/apache/solr/cloud/OverseerTest.java | 8 +-
.../solr/cloud/ParallelCommitExecutionTest.java | 2 +-
.../apache/solr/cloud/ReplicationFactorTest.java | 11 +-
.../solr/cloud/SegmentTerminateEarlyTestState.java | 44 +-
.../org/apache/solr/cloud/SolrCLIZkUtilsTest.java | 2 +-
.../apache/solr/cloud/SolrCloudExampleTest.java | 10 +-
.../apache/solr/cloud/TestCloudConsistency.java | 3 +-
.../TestCloudPhrasesIdentificationComponent.java | 2 +-
.../org/apache/solr/cloud/TestCloudPivotFacet.java | 4 +-
.../solr/cloud/TestCloudPseudoReturnFields.java | 8 +-
.../solr/cloud/TestCloudSearcherWarming.java | 9 +-
.../org/apache/solr/cloud/TestConfigSetsAPI.java | 29 +-
.../solr/cloud/TestMiniSolrCloudClusterSSL.java | 4 +-
.../solr/cloud/TestOnReconnectListenerSupport.java | 2 +-
.../apache/solr/cloud/TestRandomFlRTGCloud.java | 5 +-
.../cloud/TestStressCloudBlindAtomicUpdates.java | 6 +-
.../solr/cloud/TestStressInPlaceUpdates.java | 2 +-
.../solr/cloud/TestTlogReplayVsRecovery.java | 4 +-
.../org/apache/solr/cloud/TestTlogReplica.java | 2 +-
.../TestTolerantUpdateProcessorRandomCloud.java | 12 +-
.../SimpleCollectionCreateDeleteTest.java | 6 +-
.../cloud/api/collections/SplitByPrefixTest.java | 8 +-
.../cluster/events/ClusterEventProducerTest.java | 3 +-
.../plugins/AffinityPlacementFactoryTest.java | 2 +-
.../solr/common/cloud/ZkDynamicConfigTest.java | 4 +-
.../solr/core/BlobRepositoryMockingTest.java | 10 +-
.../test/org/apache/solr/core/CoreSorterTest.java | 4 +-
.../solr/core/ExitableDirectoryReaderTest.java | 4 +-
.../test/org/apache/solr/core/PluginInfoTest.java | 12 +-
.../org/apache/solr/core/QueryResultKeyTest.java | 17 +-
.../org/apache/solr/core/RequestHandlersTest.java | 2 +-
.../org/apache/solr/core/ResourceLoaderTest.java | 6 +-
.../src/test/org/apache/solr/core/SOLR749Test.java | 6 +-
.../test/org/apache/solr/core/SolrCoreTest.java | 25 +-
.../src/test/org/apache/solr/core/TestConfig.java | 27 +-
.../org/apache/solr/core/TestCoreContainer.java | 5 +-
.../org/apache/solr/core/TestCoreDiscovery.java | 12 +-
.../apache/solr/core/TestCorePropertiesReload.java | 4 +-
.../apache/solr/core/TestMergePolicyConfig.java | 2 +-
.../apache/solr/core/TestQuerySenderListener.java | 10 +-
.../apache/solr/core/TestSolrDeletionPolicy1.java | 2 +-
.../apache/solr/core/TestSolrDeletionPolicy2.java | 13 +-
.../solr/core/backup/BackupFilePathsTest.java | 7 +-
.../solr/core/snapshots/TestSolrCoreSnapshots.java | 2 +-
.../handler/BinaryUpdateRequestHandlerTest.java | 2 +-
.../handler/FieldAnalysisRequestHandlerTest.java | 8 +-
.../org/apache/solr/handler/JsonLoaderTest.java | 22 +-
.../solr/handler/PingRequestHandlerTest.java | 4 +-
.../apache/solr/handler/ReplicationTestHelper.java | 18 +-
.../solr/handler/TestReplicationHandler.java | 24 +-
.../solr/handler/TestSampleDocumentsLoader.java | 11 +-
.../solr/handler/TestStressThreadBackup.java | 2 -
.../solr/handler/V2ClusterAPIMappingTest.java | 5 +-
.../solr/handler/V2UpdateAPIMappingTest.java | 5 +-
.../solr/handler/XmlUpdateRequestHandlerTest.java | 2 +-
.../solr/handler/admin/LukeRequestHandlerTest.java | 2 +-
.../solr/handler/admin/MetricsHandlerTest.java | 6 +-
.../handler/admin/SecurityConfHandlerTest.java | 2 +-
.../solr/handler/admin/SolrEnvironmentTest.java | 6 +-
.../solr/handler/admin/ThreadDumpHandlerTest.java | 12 +-
.../solr/handler/admin/V2ApiMappingTest.java | 5 +-
.../admin/V2CollectionBackupsAPIMappingTest.java | 2 +-
.../handler/admin/V2CollectionsAPIMappingTest.java | 11 +-
.../solr/handler/admin/V2CoresAPIMappingTest.java | 10 +-
.../admin/api/V2CollectionAPIMappingTest.java | 14 +-
.../handler/admin/api/V2CoreAPIMappingTest.java | 6 +-
.../handler/admin/api/V2NodeAPIMappingTest.java | 6 +-
.../handler/admin/api/V2ShardsAPIMappingTest.java | 18 +-
.../component/DistributedDebugComponentTest.java | 2 +-
.../DistributedFacetPivotLongTailTest.java | 2 +-
.../DistributedFacetPivotSmallAdvancedTest.java | 5 +-
.../component/DistributedFacetPivotSmallTest.java | 4 +-
.../DistributedQueryComponentOptimizationTest.java | 5 +-
.../DistributedSpellCheckComponentTest.java | 3 +-
.../component/DistributedSuggestComponentTest.java | 3 +-
.../PhrasesIdentificationComponentTest.java | 2 +-
.../handler/component/ShardsAllowListTest.java | 2 +-
.../handler/component/SpellCheckComponentTest.java | 10 +-
.../solr/handler/component/StatsComponentTest.java | 20 +-
.../solr/handler/component/TermsComponentTest.java | 8 +-
.../component/TestTrackingShardHandlerFactory.java | 4 +-
.../handler/designer/ManagedSchemaDiffTest.java | 33 +-
.../solr/handler/export/TestExportWriter.java | 6 +-
.../solr/handler/loader/JavabinLoaderTest.java | 2 +-
.../solr/handler/tagger/RandomizedTaggerTest.java | 2 +-
.../org/apache/solr/handler/tagger/TaggerTest.java | 4 +-
.../apache/solr/handler/tagger/TaggerTestCase.java | 2 +-
.../apache/solr/internal/csv/CSVParserTest.java | 31 +-
.../apache/solr/internal/csv/CSVPrinterTest.java | 2 +-
.../apache/solr/internal/csv/CSVStrategyTest.java | 18 +-
.../internal/csv/ExtendedBufferedReaderTest.java | 53 +-
.../apache/solr/legacy/TestLegacyFieldReuse.java | 1 -
.../apache/solr/legacy/TestLegacyNumericUtils.java | 10 +-
.../solr/legacy/TestNumericRangeQuery32.java | 4 +-
.../solr/metrics/DelegateRegistryTimerTest.java | 6 +-
.../org/apache/solr/metrics/MetricsConfigTest.java | 4 +-
.../metrics/reporters/SolrJmxReporterTest.java | 2 +-
.../solr/parser/SolrQueryParserBaseTest.java | 23 +-
.../apache/solr/request/TestIntervalFaceting.java | 6 +-
.../solr/request/macro/TestMacroExpander.java | 2 +-
.../solr/response/TestRetrieveFieldsOptimizer.java | 5 +-
.../solr/response/TestSolrQueryResponse.java | 8 +-
.../transform/TestSubQueryTransformer.java | 2 +-
.../apache/solr/schema/ChangedSchemaMergeTest.java | 2 +-
.../test/org/apache/solr/schema/CopyFieldTest.java | 18 +-
.../apache/solr/schema/DenseVectorFieldTest.java | 11 +-
.../schema/OpenExchangeRatesOrgProviderTest.java | 2 +-
.../test/org/apache/solr/schema/PolyFieldTest.java | 2 +-
.../apache/solr/schema/PreAnalyzedFieldTest.java | 2 +-
.../schema/SchemaVersionSpecificBehaviorTest.java | 6 +-
.../org/apache/solr/schema/TestPointFields.java | 70 +-
.../solr/schema/TestSchemalessBufferedUpdates.java | 2 +-
.../apache/solr/schema/TestSortableTextField.java | 9 +-
.../org/apache/solr/search/MergeStrategyTest.java | 6 +-
.../apache/solr/search/RankQueryTestPlugin.java | 7 +-
.../org/apache/solr/search/ReturnFieldsTest.java | 7 +-
.../apache/solr/search/SolrIndexSearcherTest.java | 2 +-
.../apache/solr/search/SortSpecParsingTest.java | 28 +-
.../org/apache/solr/search/TestCaffeineCache.java | 6 +-
.../solr/search/TestCollapseQParserPlugin.java | 10 +-
.../test/org/apache/solr/search/TestDocSet.java | 2 +-
.../solr/search/TestExtendedDismaxParser.java | 19 +-
.../apache/solr/search/TestFilteredDocIdSet.java | 9 +-
.../test/org/apache/solr/search/TestFiltering.java | 6 +-
.../apache/solr/search/TestHashQParserPlugin.java | 20 +-
.../org/apache/solr/search/TestIndexSearcher.java | 12 +-
.../org/apache/solr/search/TestQueryUtils.java | 12 +-
.../search/TestRandomCollapseQParserPlugin.java | 9 +-
.../org/apache/solr/search/TestRangeQuery.java | 4 +-
.../solr/search/TestReRankQParserPlugin.java | 4 +-
.../org/apache/solr/search/TestRealTimeGet.java | 2 +-
.../test/org/apache/solr/search/TestRecovery.java | 10 +-
.../org/apache/solr/search/TestStressLucene.java | 4 +-
.../org/apache/solr/search/TestStressRecovery.java | 6 +-
.../org/apache/solr/search/TestStressReorder.java | 2 +-
.../apache/solr/search/TestStressUserVersions.java | 4 +-
.../org/apache/solr/search/TestStressVersions.java | 2 +-
...stributedFacetSimpleRefinementLongTailTest.java | 4 +-
.../solr/search/facet/RangeFacetCloudTest.java | 4 +-
.../search/facet/TestCloudJSONFacetJoinDomain.java | 19 +-
.../solr/search/facet/TestCloudJSONFacetSKG.java | 17 +-
.../search/facet/TestCloudJSONFacetSKGEquiv.java | 19 +-
.../apache/solr/search/facet/TestJsonFacets.java | 6 +-
.../solr/search/function/TestFunctionQuery.java | 14 +-
.../function/TestMinMaxOnMultiValuedField.java | 2 +-
.../apache/solr/search/function/TestOrdValues.java | 8 +-
.../function/distance/DistanceFunctionTest.java | 2 +-
.../org/apache/solr/search/join/BJQParserTest.java | 6 +-
.../solr/search/join/TestNestedDocsSort.java | 2 +-
.../solr/search/join/TestScoreJoinQPNoScore.java | 2 +-
.../join/another/BJQFilterAccessibleTest.java | 3 +-
.../similarities/TestClassicSimilarityFactory.java | 4 +-
.../org/apache/solr/servlet/CacheHeaderTest.java | 2 +-
.../solr/servlet/TestRequestRateLimiter.java | 2 +-
.../spelling/ConjunctionSolrSpellCheckerTest.java | 3 +-
.../solr/spelling/DirectSolrSpellCheckerTest.java | 5 +-
.../solr/spelling/FileBasedSpellCheckerTest.java | 45 +-
.../solr/spelling/IndexBasedSpellCheckerTest.java | 124 +-
.../solr/spelling/SpellCheckCollatorTest.java | 51 +-
.../spelling/SpellPossibilityIteratorTest.java | 27 +-
.../solr/spelling/SpellingQueryConverterTest.java | 39 +-
.../spelling/WordBreakSolrSpellCheckerTest.java | 102 +-
.../solr/spelling/suggest/SuggesterTest.java | 2 +-
.../apache/solr/uninverting/TestFieldCache.java | 14 +-
.../solr/uninverting/TestFieldCacheSortRandom.java | 2 +-
.../uninverting/TestFieldCacheVsDocValues.java | 2 +-
.../solr/uninverting/TestLegacyFieldCache.java | 10 +-
.../solr/update/DirectUpdateHandlerTest.java | 5 +-
.../apache/solr/update/DocumentBuilderTest.java | 5 +-
.../apache/solr/update/MaxSizeAutoCommitTest.java | 19 +-
.../test/org/apache/solr/update/PeerSyncTest.java | 18 +-
.../PeerSyncWithIndexFingerprintCachingTest.java | 3 +-
.../org/apache/solr/update/SoftAutoCommitTest.java | 7 +-
.../apache/solr/update/SolrIndexConfigTest.java | 4 +-
.../solr/update/TestInPlaceUpdatesDistrib.java | 29 +-
.../solr/update/TestInPlaceUpdatesStandalone.java | 2 +-
.../solr/update/TestNestedUpdateProcessor.java | 6 +-
.../org/apache/solr/update/UpdateParamsTest.java | 8 +-
.../update/processor/AtomicUpdateJavabinTest.java | 2 +-
.../CategoryRoutedAliasUpdateProcessorTest.java | 2 +-
.../DimensionalRoutedAliasUpdateProcessorTest.java | 2 +-
.../update/processor/NestedAtomicUpdateTest.java | 7 +-
.../SkipExistingDocumentsProcessorFactoryTest.java | 4 +-
.../update/processor/TestCloudDeduplication.java | 2 +-
.../processor/TestDocBasedVersionConstraints.java | 2 +-
.../TimeRoutedAliasUpdateProcessorTest.java | 10 +-
.../processor/TrackingUpdateProcessorFactory.java | 4 +-
.../org/apache/solr/util/OrderedExecutorTest.java | 2 +-
.../org/apache/solr/util/SimplePostToolTest.java | 22 +-
.../org/apache/solr/util/SolrCliUptimeTest.java | 5 +-
.../apache/solr/util/TestSolrCLIRunExample.java | 7 +-
.../src/test/org/apache/solr/util/TestUtils.java | 2 +-
.../hll/BigEndianAscendingWordSerializerTest.java | 25 +-
.../org/apache/solr/util/hll/BitVectorTest.java | 16 +-
.../org/apache/solr/util/hll/ExplicitHLLTest.java | 2 +-
.../apache/solr/util/hll/HLLSerializationTest.java | 8 +-
.../org/apache/solr/util/hll/NumberUtilTest.java | 63 +-
.../solr/analytics/ExpressionFactoryTest.java | 36 +-
.../mapping/AbsoluteValueFunctionTest.java | 8 +-
.../function/mapping/AddFunctionTest.java | 4 +-
.../function/mapping/AndFunctionTest.java | 24 +-
.../function/mapping/CeilingFunctionTest.java | 4 +-
.../function/mapping/ConcatFunctionTest.java | 24 +-
.../function/mapping/DivideFunctionTest.java | 8 +-
.../function/mapping/EqualFunctionTest.java | 48 +-
.../function/mapping/FillMissingFunctionTest.java | 28 +-
.../function/mapping/FilterFunctionTest.java | 100 +-
.../function/mapping/FloorFunctionTest.java | 4 +-
.../function/mapping/GTEFunctionTest.java | 28 +-
.../analytics/function/mapping/GTFunctionTest.java | 28 +-
.../analytics/function/mapping/IfFunctionTest.java | 8 +-
.../function/mapping/LTEFunctionTest.java | 28 +-
.../analytics/function/mapping/LTFunctionTest.java | 28 +-
.../function/mapping/LogFunctionTest.java | 10 +-
.../function/mapping/MultFunctionTest.java | 4 +-
.../function/mapping/NegateFunctionTest.java | 14 +-
.../analytics/function/mapping/OrFunctionTest.java | 24 +-
.../function/mapping/PowerFunctionTest.java | 8 +-
.../function/mapping/RemoveFunctionTest.java | 54 +-
.../function/mapping/ReplaceFunctionTest.java | 38 +-
.../function/mapping/RoundFunctionTest.java | 4 +-
.../function/mapping/StringCastFunctionTest.java | 2 +-
.../function/mapping/SubtractFunctionTest.java | 8 +-
.../legacy/expression/LegacyFunctionTest.java | 2 +-
.../legacy/facet/LegacyFieldFacetCloudTest.java | 473 +++---
.../legacy/facet/LegacyFieldFacetTest.java | 481 +++---
.../util/OldAnalyticsRequestConverterUnitTest.java | 2 +-
.../analytics/value/CastingAnalyticsValueTest.java | 2 +-
.../value/CastingBooleanValueStreamTest.java | 4 +-
.../analytics/value/CastingBooleanValueTest.java | 8 +-
.../value/CastingDoubleValueStreamTest.java | 4 +-
.../analytics/value/CastingDoubleValueTest.java | 6 +-
.../value/CastingFloatValueStreamTest.java | 6 +-
.../analytics/value/CastingFloatValueTest.java | 8 +-
.../analytics/value/CastingIntValueStreamTest.java | 10 +-
.../solr/analytics/value/CastingIntValueTest.java | 12 +-
.../value/CastingLongValueStreamTest.java | 6 +-
.../solr/analytics/value/CastingLongValueTest.java | 8 +-
.../value/CastingStringValueStreamTest.java | 2 +-
.../analytics/value/CastingStringValueTest.java | 4 +-
.../solr/analytics/value/ConstantValueTest.java | 8 +-
.../ClusteringComponentDistributedTest.java | 3 +-
.../clustering/ClusteringComponentTest.java | 5 +-
.../extraction/ExtractingRequestHandlerTest.java | 42 +-
.../handler/extraction/ParseContextConfigTest.java | 2 +-
.../repository/HdfsBackupRepositoryTest.java | 19 +-
.../hdfs/cloud/MoveReplicaHdfsFailoverTest.java | 2 +-
.../apache/solr/hdfs/search/TestRecoveryHdfs.java | 2 +-
.../solr/hdfs/store/HdfsLockFactoryTest.java | 8 +-
.../solr/hdfs/store/blockcache/BlockCacheTest.java | 3 +-
...geIdentifierUpdateProcessorFactoryTestCase.java | 2 +-
.../processor/SolrInputDocumentReaderTest.java | 8 +-
.../org/apache/solr/ltr/TestLTRQParserPlugin.java | 8 +-
.../org/apache/solr/ltr/TestLTRScoringQuery.java | 12 +-
.../solr/ltr/TestParallelWeightCreation.java | 4 +-
.../TestFeatureExtractionFromMultipleSegments.java | 4 +-
.../interleaving/TestLTRQParserInterleaving.java | 6 +-
.../apache/solr/ltr/norm/TestMinMaxNormalizer.java | 5 +-
.../solr/ltr/norm/TestStandardNormalizer.java | 5 +-
.../solr/ltr/store/rest/TestModelManager.java | 7 +-
.../apache/solr/handler/sql/TestSQLHandler.java | 1158 +++++++-------
.../prometheus/collector/MetricSamplesTest.java | 5 +-
.../exporter/MetricsQueryTemplateTest.java | 7 +-
.../query-guide/examples/JsonRequestApiTest.java | 4 +-
.../apache/solr/common/cloud/SolrZkClientTest.java | 6 +-
.../apache/solr/client/solrj/SolrExampleTests.java | 89 +-
.../solr/client/solrj/SolrExampleTestsBase.java | 17 +-
.../apache/solr/client/solrj/SolrQueryTest.java | 103 +-
.../solr/client/solrj/TestLBHttp2SolrClient.java | 7 +-
.../solr/client/solrj/TestLBHttpSolrClient.java | 7 +-
.../embedded/SolrExampleStreamingHttp2Test.java | 3 +-
.../solrj/embedded/SolrExampleStreamingTest.java | 3 +-
.../solrj/embedded/TestEmbeddedSolrServer.java | 13 +-
.../client/solrj/impl/BasicHttpSolrClientTest.java | 2 +-
.../solrj/impl/CloudHttp2SolrClientTest.java | 2 +-
.../client/solrj/impl/CloudSolrClientTest.java | 2 +-
.../impl/ConcurrentUpdateHttp2SolrClientTest.java | 15 +-
.../solrj/impl/ConcurrentUpdateSolrClientTest.java | 15 +-
.../client/solrj/impl/Http2SolrClientTest.java | 2 +-
.../solr/client/solrj/impl/HttpClientUtilTest.java | 8 +-
.../solrj/impl/HttpSolrClientBuilderTest.java | 6 +-
.../impl/HttpSolrClientSSLAuthConPoolTest.java | 2 +-
.../client/solrj/impl/LBHttp2SolrClientTest.java | 7 +-
.../solrj/impl/LBHttpSolrClientBuilderTest.java | 4 +-
.../client/solrj/impl/LBHttpSolrClientTest.java | 6 +-
.../solr/client/solrj/impl/LBSolrClientTest.java | 7 +-
.../solrj/impl/SolrPortAwareCookieSpecTest.java | 19 +-
.../solrj/impl/TestCloudSolrClientConnections.java | 2 +-
.../client/solrj/io/graph/GraphExpressionTest.java | 357 +++--
.../solr/client/solrj/io/graph/GraphTest.java | 10 +-
.../apache/solr/client/solrj/io/sql/JdbcTest.java | 26 +-
.../solrj/io/stream/CloudAuthStreamTest.java | 2 +-
.../client/solrj/io/stream/JDBCStreamTest.java | 2 +-
.../client/solrj/io/stream/MathExpressionTest.java | 810 +++++-----
.../solrj/io/stream/StreamDecoratorTest.java | 869 ++++++-----
.../solrj/io/stream/StreamExpressionTest.java | 1634 ++++++++++----------
.../io/stream/StreamExpressionToExpessionTest.java | 6 +-
.../stream/StreamExpressionToExplanationTest.java | 77 +-
.../solr/client/solrj/io/stream/StreamingTest.java | 386 ++---
.../io/stream/eval/AbsoluteValueEvaluatorTest.java | 23 +-
.../solrj/io/stream/eval/AddEvaluatorTest.java | 91 +-
.../solrj/io/stream/eval/AndEvaluatorTest.java | 37 +-
.../solrj/io/stream/eval/AppendEvaluatorTest.java | 11 +-
.../io/stream/eval/ArcCosineEvaluatorTest.java | 7 +-
.../solrj/io/stream/eval/ArcSineEvaluatorTest.java | 7 +-
.../io/stream/eval/ArcTangentEvaluatorTest.java | 7 +-
.../solrj/io/stream/eval/ArrayEvaluatorTest.java | 76 +-
.../solrj/io/stream/eval/CeilingEvaluatorTest.java | 7 +-
.../io/stream/eval/CoalesceEvaluatorTest.java | 17 +-
.../io/stream/eval/ConversionEvaluatorsTest.java | 10 +-
.../io/stream/eval/CorrelationEvaluatorTest.java | 3 +-
.../solrj/io/stream/eval/CosineEvaluatorTest.java | 7 +-
.../io/stream/eval/CubedRootEvaluatorTest.java | 7 +-
.../eval/CumulativeProbabilityEvaluatorTest.java | 3 +-
.../solrj/io/stream/eval/DivideEvaluatorTest.java | 19 +-
.../solrj/io/stream/eval/EqualToEvaluatorTest.java | 85 +-
.../io/stream/eval/ExclusiveOrEvaluatorTest.java | 37 +-
.../io/stream/eval/FieldValueEvaluatorTest.java | 56 +-
.../solrj/io/stream/eval/FloorEvaluatorTest.java | 7 +-
.../eval/GreaterThanEqualToEvaluatorTest.java | 81 +-
.../io/stream/eval/GreaterThanEvaluatorTest.java | 81 +-
.../stream/eval/HyperbolicCosineEvaluatorTest.java | 7 +-
.../stream/eval/HyperbolicSineEvaluatorTest.java | 7 +-
.../solrj/io/stream/eval/LengthEvaluatorTest.java | 17 +-
.../stream/eval/LessThanEqualToEvaluatorTest.java | 85 +-
.../io/stream/eval/LessThanEvaluatorTest.java | 81 +-
.../solrj/io/stream/eval/ModuloEvaluatorTest.java | 11 +-
.../io/stream/eval/MultiplyEvaluatorTest.java | 43 +-
.../io/stream/eval/NaturalLogEvaluatorTest.java | 9 +-
.../io/stream/eval/NormalizeEvaluatorTest.java | 3 +-
.../solrj/io/stream/eval/NotEvaluatorTest.java | 17 +-
.../solrj/io/stream/eval/OrEvaluatorTest.java | 37 +-
.../solrj/io/stream/eval/PowerEvaluatorTest.java | 27 +-
.../io/stream/eval/RawValueEvaluatorTest.java | 25 +-
.../io/stream/eval/RecursiveEvaluatorTest.java | 7 +-
.../solrj/io/stream/eval/ReverseEvaluatorTest.java | 7 +-
.../solrj/io/stream/eval/RoundEvaluatorTest.java | 7 +-
.../solrj/io/stream/eval/SineEvaluatorTest.java | 7 +-
.../io/stream/eval/SquareRootEvaluatorTest.java | 7 +-
.../io/stream/eval/SubtractEvaluatorTest.java | 37 +-
.../solrj/io/stream/eval/TangentEvaluatorTest.java | 7 +-
.../io/stream/eval/TemporalEvaluatorsTest.java | 22 +-
.../solrj/io/stream/eval/UuidEvaluatorTest.java | 3 +-
.../solrj/io/stream/expr/InjectionDefenseTest.java | 6 +-
.../io/stream/metrics/WeightedSumMetricTest.java | 12 +-
.../solrj/io/stream/ops/ConcatOperationTest.java | 149 +-
.../client/solrj/io/stream/ops/OperationsTest.java | 55 +-
.../solr/client/solrj/request/SchemaTest.java | 4 +-
.../solr/client/solrj/request/SolrPingTest.java | 5 +-
.../solr/client/solrj/request/TestLukeRequest.java | 4 +-
.../client/solrj/request/TestUpdateRequest.java | 25 +-
.../solrj/request/TestUpdateRequestCodec.java | 25 +-
...DirectJsonQueryRequestFacetingEmbeddedTest.java | 8 +-
...ectJsonQueryRequestFacetingIntegrationTest.java | 8 +-
.../JsonQueryRequestFacetingIntegrationTest.java | 8 +-
.../solrj/response/AnlysisResponseBaseTest.java | 2 +-
.../client/solrj/response/TermsResponseTest.java | 9 +-
.../solrj/response/TestClusteringResponse.java | 11 +-
.../solrj/response/TestSpellCheckResponse.java | 15 +-
.../ShufflingReplicaListTransformerTest.java | 2 +-
.../org/apache/solr/common/SolrDocumentTest.java | 8 +-
.../solr/common/TestToleratedUpdateError.java | 18 +-
.../apache/solr/common/util/TestJavaBinCodec.java | 2 +-
.../solr/common/util/TestNamedListCodec.java | 20 +-
.../org/apache/solr/common/util/TestPathTrie.java | 4 +-
.../org/apache/solr/common/util/URLUtilTest.java | 7 +-
.../solr/common/util/Utf8CharSequenceTest.java | 8 +-
solr/solrj/src/test/org/noggit/TestJSONParser.java | 2 +-
.../apache/solr/BaseDistributedSearchTestCase.java | 7 +-
.../solr/cloud/AbstractFullDistribZkTestBase.java | 7 +-
386 files changed, 5497 insertions(+), 5691 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
index 03c3a24244b..b4bdfb3c733 100644
--- a/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
+++ b/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
@@ -552,8 +552,8 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
f = ischema.getField("test_notv");
luf = f.createField("test");
- assertTrue(!f.storeTermVector());
- assertTrue(!luf.fieldType().storeTermVectors());
+ assertFalse(f.storeTermVector());
+ assertFalse(luf.fieldType().storeTermVectors());
f = ischema.getField("test_postv");
luf = f.createField("test");
@@ -619,8 +619,8 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
assertEquals(p.get("ss"), "SSS");
assertEquals(!!p.getBool("bt"), !p.getBool("bf"));
- assertEquals(p.getBool("foo", true), true);
- assertEquals(p.getBool("foo", false), false);
+ assertTrue(p.getBool("foo", true));
+ assertFalse(p.getBool("foo", false));
assertEquals(!!p.getBool("bt"), !p.getBool("bf"));
NamedList<String> more = new NamedList<>();
@@ -764,8 +764,8 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
DocList dl = ((ResultContext) rsp.getResponse()).getDocList();
Document d = req.getSearcher().doc(dl.iterator().nextDoc());
// ensure field in fl is not lazy
- assertFalse(((Field) d.getField("test_hlt")).getClass().getSimpleName().equals("LazyField"));
- assertFalse(((Field) d.getField("title")).getClass().getSimpleName().equals("LazyField"));
+ assertNotEquals("LazyField", ((Field) d.getField("test_hlt")).getClass().getSimpleName());
+ assertNotEquals("LazyField", ((Field) d.getField("title")).getClass().getSimpleName());
req.close();
}
@@ -814,7 +814,7 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
di = dl.iterator();
Document d2 = req.getSearcher().doc(di.nextDoc());
// ensure same doc, same lazy field now
- assertTrue("Doc was not cached", d1 == d2);
+ assertSame("Doc was not cached", d1, d2);
IndexableField[] values2 = d2.getFields("test_hlt");
assertEquals(values1.length, values2.length);
for (int i = 0; i < values1.length; i++) {
diff --git a/solr/core/src/test/org/apache/solr/CursorPagingTest.java b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
index 78328a190ab..7e5e9131f06 100644
--- a/solr/core/src/test/org/apache/solr/CursorPagingTest.java
+++ b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
@@ -1313,7 +1313,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
/** Given a set of id, picks some, semi-randomly, to use for elevation */
public static int[] pickElevations(final int numToElevate, final SentinelIntSet ids) {
- assert numToElevate < ids.size();
+ assertTrue(numToElevate < ids.size());
final int[] results = new int[numToElevate];
int slot = 0;
for (int key : ids.keys) {
diff --git a/solr/core/src/test/org/apache/solr/OutputWriterTest.java b/solr/core/src/test/org/apache/solr/OutputWriterTest.java
index 6760c84b6b3..13eb69d9014 100644
--- a/solr/core/src/test/org/apache/solr/OutputWriterTest.java
+++ b/solr/core/src/test/org/apache/solr/OutputWriterTest.java
@@ -72,7 +72,7 @@ public class OutputWriterTest extends SolrTestCaseJ4 {
qrw = h.getCore().getResponseWriters().getRegistry().get("xml");
assertTrue("Should not be a lazy class", qrw.isLoaded());
- assertTrue("Should not be a lazy class", qrw.getClass() == PluginBag.PluginHolder.class);
+ assertSame("Should not be a lazy class", qrw.getClass(), PluginBag.PluginHolder.class);
}
////////////////////////////////////////////////////////////////////////////
diff --git a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
index 2d33dced1a2..a00c321f92a 100644
--- a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
+++ b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
@@ -1145,7 +1145,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
Double val = (Double) svals.get(s);
assertFalse("stat shouldn't be NaN: " + s, val.isNaN());
assertFalse("stat shouldn't be Inf: " + s, val.isInfinite());
- assertFalse("stat shouldn't be 0: " + s, val.equals(0.0D));
+ assertNotEquals("stat shouldn't be 0: " + s, 0.0D, val, 0.0);
} else {
// count or missing
assertTrue(
@@ -1155,7 +1155,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
"stat should be a Long: " + s + " -> " + svals.get(s).getClass(),
svals.get(s) instanceof Long);
Long val = (Long) svals.get(s);
- assertFalse("stat shouldn't be 0: " + s, val.equals(0L));
+ assertNotEquals("stat shouldn't be 0: " + s, 0L, (long) val);
}
}
}
@@ -1287,7 +1287,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
// things we explicit expect because we asked for them
// NOTE: min is expected to be null even though requested because of no values
- assertEquals("wrong min", null, s.getMin());
+ assertNull("wrong min", s.getMin());
assertTrue("mean should be NaN", ((Double) s.getMean()).isNaN());
assertEquals("wrong stddev", 0.0D, s.getStddev(), 0.0D);
@@ -1842,9 +1842,10 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
+ counts.size(),
counts.size(),
pairs.length / 2);
- assertTrue(
+ assertEquals(
"Variable len param must be an even number, it was: " + pairs.length,
- (pairs.length % 2) == 0);
+ 0,
+ (pairs.length % 2));
for (int pairs_idx = 0, counts_idx = 0;
pairs_idx < pairs.length;
pairs_idx += 2, counts_idx++) {
@@ -1876,9 +1877,10 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
+ counts.size(),
counts.size(),
pairs.length / 2);
- assertTrue(
+ assertEquals(
"Variable len param must be an even number, it was: " + pairs.length,
- (pairs.length % 2) == 0);
+ 0,
+ (pairs.length % 2));
for (int pairs_idx = 0, counts_idx = 0;
pairs_idx < pairs.length;
pairs_idx += 2, counts_idx++) {
@@ -2013,13 +2015,12 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
+ " header set if a shard is down",
Boolean.TRUE,
rsp.getHeader().get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY));
- assertTrue(
- "Expected to find error in the down shard info: " + info,
- info.get("error") != null);
+ assertNotNull(
+ "Expected to find error in the down shard info: " + info, info.get("error"));
} else {
- assertTrue(
+ assertNotNull(
"Expected timeAllowedError or to find shardAddress in the up shard info: " + info,
- info.get("shardAddress") != null);
+ info.get("shardAddress"));
}
} else {
assertEquals(
@@ -2029,9 +2030,9 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
+ rsp,
Boolean.TRUE,
rsp.getHeader().get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY));
- assertTrue(
+ assertNotNull(
"Expected to find error in the down shard info: " + info.toString(),
- info.get("error") != null);
+ info.get("error"));
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/TestRandomDVFaceting.java b/solr/core/src/test/org/apache/solr/TestRandomDVFaceting.java
index 05479263a3f..1287b9ff4a7 100644
--- a/solr/core/src/test/org/apache/solr/TestRandomDVFaceting.java
+++ b/solr/core/src/test/org/apache/solr/TestRandomDVFaceting.java
@@ -53,17 +53,14 @@ public class TestRandomDVFaceting extends SolrTestCaseJ4 {
initCore("solrconfig-basic.xml", "schema-docValuesFaceting.xml");
- assertEquals(
+ assertFalse(
"DocValues: Schema assumptions are broken",
- false,
h.getCore().getLatestSchema().getField("foo_i").hasDocValues());
- assertEquals(
+ assertTrue(
"DocValues: Schema assumptions are broken",
- true,
h.getCore().getLatestSchema().getField("foo_i_dv").hasDocValues());
- assertEquals(
+ assertTrue(
"DocValues: Schema assumptions are broken",
- true,
h.getCore().getLatestSchema().getField("foo_i_p").hasDocValues());
assertEquals(
diff --git a/solr/core/src/test/org/apache/solr/TestRandomFaceting.java b/solr/core/src/test/org/apache/solr/TestRandomFaceting.java
index de8505bc4d7..63cbe0ea8d9 100644
--- a/solr/core/src/test/org/apache/solr/TestRandomFaceting.java
+++ b/solr/core/src/test/org/apache/solr/TestRandomFaceting.java
@@ -96,12 +96,12 @@ public class TestRandomFaceting extends SolrTestCaseJ4 {
// TODO: doubles, multi-floats, ints with precisionStep>0, booleans
types.add(new FldType("small_tf", ZERO_ONE, new FVal(-4, 5)));
- assert trieFields.matcher("small_tf").matches();
- assert !trieFields.matcher("small_f").matches();
+ assertTrue(trieFields.matcher("small_tf").matches());
+ assertFalse(trieFields.matcher("small_f").matches());
types.add(new FldType("foo_ti", ZERO_ONE, new IRange(-2, indexSize)));
- assert trieFields.matcher("foo_ti").matches();
- assert !trieFields.matcher("foo_i").matches();
+ assertTrue(trieFields.matcher("foo_ti").matches());
+ assertFalse(trieFields.matcher("foo_i").matches());
types.add(
new FldType(
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
index 1a99f66f2aa..0c1ed2ee46a 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
@@ -595,7 +595,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
Replica newReplica = grabNewReplica(response, getCollectionState(collectionName));
assertEquals(0, response.getStatus());
assertTrue(response.isSuccess());
- assertTrue(newReplica.getNodeName().equals(node));
+ assertEquals(newReplica.getNodeName(), node);
// Test DELETEREPLICA
response =
diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteNodeTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteNodeTest.java
index a4f6c35be5a..9f8c33e60f7 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DeleteNodeTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteNodeTest.java
@@ -110,9 +110,9 @@ public class DeleteNodeTest extends SolrCloudTestCase {
"####### DocCollection after: {}", cloudClient.getClusterState().getCollection(coll));
}
if (shouldFail) {
- assertTrue(String.valueOf(rsp), rsp.getRequestStatus() == RequestStatusState.FAILED);
+ assertSame(String.valueOf(rsp), rsp.getRequestStatus(), RequestStatusState.FAILED);
} else {
- assertFalse(String.valueOf(rsp), rsp.getRequestStatus() == RequestStatusState.FAILED);
+ assertNotSame(String.valueOf(rsp), rsp.getRequestStatus(), RequestStatusState.FAILED);
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
index 3696f4c104b..60a31677adf 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
@@ -176,7 +176,7 @@ public class DeleteReplicaTest extends SolrCloudTestCase {
Replica newLeader = cluster.getZkStateReader().getLeaderRetry(collectionName, "shard1");
- assertFalse(leader.equals(newLeader));
+ assertNotEquals(leader, newLeader);
// Confirm that the instance and data directory were deleted by default
assertFalse(
@@ -326,7 +326,7 @@ public class DeleteReplicaTest extends SolrCloudTestCase {
JettySolrRunner leaderJetty = getJettyForReplica(leader);
Replica replica1 =
shard1.getReplicas(replica -> !replica.getName().equals(leader.getName())).get(0);
- assertFalse(replica1.getName().equals(leader.getName()));
+ assertNotEquals(replica1.getName(), leader.getName());
JettySolrRunner replica1Jetty = getJettyForReplica(replica1);
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java
index 52caba7ebfa..d49b4e61dd8 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistribDocExpirationUpdateProcessorTest.java
@@ -75,7 +75,7 @@ public class DistribDocExpirationUpdateProcessorTest extends SolrCloudTestCase {
/** Modifies the request to inlcude authentication params if needed, returns the request */
private <T extends SolrRequest<?>> T setAuthIfNeeded(T req) {
if (null != USER) {
- assert null != PASS;
+ assertNotNull(PASS);
req.setBasicAuthCredentials(USER, PASS);
}
return req;
@@ -384,8 +384,8 @@ public class DistribDocExpirationUpdateProcessorTest extends SolrCloudTestCase {
final String coreName,
final long indexVersion,
final long numDocs) {
- assert null != shardName;
- assert null != coreName;
+ assertNotNull(shardName);
+ assertNotNull(coreName);
this.shardName = shardName;
this.coreName = coreName;
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
index a577ff021de..305b28c34d6 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
@@ -150,7 +150,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase {
new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
QueryResponse rsp = new QueryResponse(client.request(qr), client);
SolrDocumentList hits = rsp.getResults();
- assertTrue("Expected 1 doc, got " + hits, hits.getNumFound() == 1);
+ assertEquals("Expected 1 doc, got " + hits, 1, hits.getNumFound());
SolrDocument doc = hits.get(0);
assertEquals(toDocId, doc.getFirstValue("id"));
assertEquals("b", doc.getFirstValue("get_s"));
@@ -176,7 +176,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase {
new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
final QueryResponse rsp = new QueryResponse(client.request(qr), client);
final SolrDocumentList hits = rsp.getResults();
- assertTrue("Expected 1 doc", hits.getNumFound() == 1);
+ assertEquals("Expected 1 doc", 1, hits.getNumFound());
SolrDocument doc = hits.get(0);
assertEquals(toDocId, doc.getFirstValue("id"));
assertEquals("b", doc.getFirstValue("get_s"));
@@ -198,7 +198,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase {
new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
final QueryResponse rsp = new QueryResponse(client.request(qr), client);
final SolrDocumentList hits = rsp.getResults();
- assertTrue("Expected no hits", hits.getNumFound() == 0);
+ assertEquals("Expected no hits", 0, hits.getNumFound());
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java b/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java
index 2e95e685c17..41933370a4e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java
@@ -367,8 +367,7 @@ public class DistributedVersionInfoTest extends SolrCloudTestCase {
NamedList<?> rsp = solr.request(qr);
SolrDocument doc = (SolrDocument) rsp.get("doc");
String match = JSONTestUtil.matchObj("/id", doc, docId);
- assertTrue(
- "Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match == null);
+ assertNull("Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match);
Long vers = (Long) doc.getFirstValue("_version_");
assertNotNull(vers);
diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
index 6006784744c..84048086eb1 100644
--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
@@ -77,14 +77,15 @@ public class HttpPartitionOnCommitTest extends BasicDistributedZkTest {
cloudClient.setDefaultCollection(testCollectionName);
List<Replica> notLeaders = ensureAllReplicasAreActive(testCollectionName, "shard1", 2, 2, 30);
- assertTrue(
+ assertEquals(
"Expected 1 replicas for collection "
+ testCollectionName
+ " but found "
+ notLeaders.size()
+ "; clusterState: "
+ printClusterStateInfo(),
- notLeaders.size() == 1);
+ 1,
+ notLeaders.size());
if (log.isInfoEnabled()) {
log.info("All replicas active for {}", testCollectionName);
@@ -131,14 +132,15 @@ public class HttpPartitionOnCommitTest extends BasicDistributedZkTest {
cloudClient.setDefaultCollection(testCollectionName);
List<Replica> notLeaders = ensureAllReplicasAreActive(testCollectionName, "shard1", 1, 3, 30);
- assertTrue(
+ assertEquals(
"Expected 2 replicas for collection "
+ testCollectionName
+ " but found "
+ notLeaders.size()
+ "; clusterState: "
+ printClusterStateInfo(),
- notLeaders.size() == 2);
+ 2,
+ notLeaders.size());
log.info("All replicas active for {}", testCollectionName);
diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
index 67867a7ebd7..c97b89e5c64 100644
--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
@@ -364,14 +364,15 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
List<Replica> notLeaders =
ensureAllReplicasAreActive(testCollectionName, "shard1", 1, 3, maxWaitSecsToSeeAllActive);
- assertTrue(
+ assertEquals(
"Expected 2 replicas for collection "
+ testCollectionName
+ " but found "
+ notLeaders.size()
+ "; clusterState: "
+ printClusterStateInfo(testCollectionName),
- notLeaders.size() == 2);
+ 2,
+ notLeaders.size());
JettySolrRunner leaderJetty =
getJettyOnPort(getReplicaPort(getShardLeader(testCollectionName, "shard1", 1000)));
@@ -425,14 +426,15 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
List<Replica> notLeaders =
ensureAllReplicasAreActive(testCollectionName, "shard1", 1, 2, maxWaitSecsToSeeAllActive);
- assertTrue(
+ assertEquals(
"Expected 1 replicas for collection "
+ testCollectionName
+ " but found "
+ notLeaders.size()
+ "; clusterState: "
+ printClusterStateInfo(testCollectionName),
- notLeaders.size() == 1);
+ 1,
+ notLeaders.size());
Replica leader = ZkStateReader.from(cloudClient).getLeaderRetry(testCollectionName, "shard1");
assertNotNull(
@@ -599,8 +601,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
protected void assertDocExists(SolrClient solr, String docId) throws Exception {
NamedList<?> rsp = realTimeGetDocId(solr, docId);
String match = JSONTestUtil.matchObj("/id", rsp.get("doc"), docId);
- assertTrue(
- "Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match == null);
+ assertNull("Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match);
}
private NamedList<Object> realTimeGetDocId(SolrClient solr, String docId)
diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java
index 6dd13539a8e..2c4972262e3 100644
--- a/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderFailoverAfterPartitionTest.java
@@ -66,14 +66,15 @@ public class LeaderFailoverAfterPartitionTest extends HttpPartitionTest {
List<Replica> notLeaders =
ensureAllReplicasAreActive(testCollectionName, "shard1", 1, 3, maxWaitSecsToSeeAllActive);
- assertTrue(
+ assertEquals(
"Expected 2 replicas for collection "
+ testCollectionName
+ " but found "
+ notLeaders.size()
+ "; clusterState: "
+ printClusterStateInfo(testCollectionName),
- notLeaders.size() == 2);
+ 2,
+ notLeaders.size());
// ok, now introduce a network partition between the leader and the replica
SocketProxy proxy0 = null;
@@ -159,12 +160,13 @@ public class LeaderFailoverAfterPartitionTest extends HttpPartitionTest {
+ printClusterStateInfo(testCollectionName),
newLeader);
- assertTrue(
+ assertNotEquals(
"Expected node "
+ shouldNotBeNewLeaderNode
+ " to NOT be the new leader b/c it was out-of-sync with the old leader! ClusterState: "
+ printClusterStateInfo(testCollectionName),
- !shouldNotBeNewLeaderNode.equals(newLeader.getNodeName()));
+ shouldNotBeNewLeaderNode,
+ newLeader.getNodeName());
proxy0.reopen();
diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderVoteWaitTimeoutTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderVoteWaitTimeoutTest.java
index f8cac78ef84..a8c127718c8 100644
--- a/solr/core/src/test/org/apache/solr/cloud/LeaderVoteWaitTimeoutTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderVoteWaitTimeoutTest.java
@@ -330,8 +330,7 @@ public class LeaderVoteWaitTimeoutTest extends SolrCloudTestCase {
private void assertDocExists(SolrClient solr, String docId) throws Exception {
NamedList<?> rsp = realTimeGetDocId(solr, docId);
String match = JSONTestUtil.matchObj("/id", rsp.get("doc"), docId);
- assertTrue(
- "Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match == null);
+ assertNull("Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match);
}
private NamedList<Object> realTimeGetDocId(SolrClient solr, String docId)
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 2ff85c4acb4..3dc5aef4a97 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
@@ -975,9 +975,9 @@ public class OverseerTest extends SolrTestCaseJ4 {
assertTrue(
COLLECTION + " should remain after removal of the last core",
reader.getClusterState().hasCollection(COLLECTION));
- assertTrue(
+ assertNull(
core_node + " should be gone after publishing the null state",
- null == reader.getClusterState().getCollection(COLLECTION).getReplica(core_node));
+ reader.getClusterState().getCollection(COLLECTION).getReplica(core_node));
} finally {
close(mockController);
close(overseerClient);
@@ -1150,8 +1150,8 @@ public class OverseerTest extends SolrTestCaseJ4 {
Thread.sleep(50);
}
- assertTrue(showQpeek(workQueue), workQueue.peek() == null);
- assertTrue(showQpeek(q), q.peek() == null);
+ assertNull(showQpeek(workQueue), workQueue.peek());
+ assertNull(showQpeek(q), q.peek());
} finally {
close(overseerClient);
close(reader);
diff --git a/solr/core/src/test/org/apache/solr/cloud/ParallelCommitExecutionTest.java b/solr/core/src/test/org/apache/solr/cloud/ParallelCommitExecutionTest.java
index ef74e192583..a786ea0bc05 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ParallelCommitExecutionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ParallelCommitExecutionTest.java
@@ -102,7 +102,7 @@ public class ParallelCommitExecutionTest extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java b/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
index 6b24cc7341d..37cd2f99328 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
@@ -114,7 +114,7 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
List<Replica> replicas =
ensureAllReplicasAreActive(testCollectionName, shardId, numShards, replicationFactor, 30);
- assertTrue("Expected active 1 replicas for " + testCollectionName, replicas.size() == 1);
+ assertEquals("Expected active 1 replicas for " + testCollectionName, 1, replicas.size());
List<SolrInputDocument> batch = new ArrayList<>(10);
for (int i = 0; i < 15; i++) {
@@ -149,7 +149,7 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
// so now kill the replica of shard2 and verify the achieved rf is only 1
List<Replica> shard2Replicas =
ensureAllReplicasAreActive(testCollectionName, "shard2", numShards, replicationFactor, 30);
- assertTrue("Expected active 1 replicas for " + testCollectionName, replicas.size() == 1);
+ assertEquals("Expected active 1 replicas for " + testCollectionName, 1, replicas.size());
getProxyForReplica(shard2Replicas.get(0)).close();
@@ -277,14 +277,15 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
Integer batchRf = (Integer) hdr.get(UpdateRequest.REPFACT);
// Note that this also tests if we're wonky and return an achieved rf greater than the number
// of live replicas.
- assertTrue(
+ assertEquals(
"Expected rf="
+ expectedRf
+ " for batch but got "
+ batchRf
+ "; clusterState: "
+ printClusterStateInfo(),
- batchRf == expectedRf);
+ (int) batchRf,
+ expectedRf);
}
}
@@ -300,7 +301,7 @@ public class ReplicationFactorTest extends AbstractFullDistribZkTestBase {
List<Replica> replicas =
ensureAllReplicasAreActive(testCollectionName, shardId, numShards, replicationFactor, 30);
- assertTrue("Expected 2 active replicas for " + testCollectionName, replicas.size() == 2);
+ assertEquals("Expected 2 active replicas for " + testCollectionName, 2, replicas.size());
log.info("Indexing docId=1");
int rf = sendDoc(1);
diff --git a/solr/core/src/test/org/apache/solr/cloud/SegmentTerminateEarlyTestState.java b/solr/core/src/test/org/apache/solr/cloud/SegmentTerminateEarlyTestState.java
index 0a0e659963d..6166cb31224 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SegmentTerminateEarlyTestState.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SegmentTerminateEarlyTestState.java
@@ -95,7 +95,7 @@ class SegmentTerminateEarlyTestState {
void queryTimestampDescending(CloudSolrClient cloudSolrClient) throws Exception {
TestSegmentSorting.assertFalse(maxTimestampDocKeys.isEmpty());
- TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
+ TestSegmentSorting.assertEquals("numDocs=" + numDocs + " is not even", 0, (numDocs % 2));
final Long oddFieldValue = (long) (maxTimestampDocKeys.iterator().next() % 2);
final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.desc);
@@ -132,7 +132,7 @@ class SegmentTerminateEarlyTestState {
void queryTimestampDescendingSegmentTerminateEarlyYes(
CloudSolrClient cloudSolrClient, boolean appendKeyDescendingToSort) throws Exception {
TestSegmentSorting.assertFalse(maxTimestampDocKeys.isEmpty());
- TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
+ TestSegmentSorting.assertEquals("numDocs=" + numDocs + " is not even", 0, (numDocs % 2));
final Long oddFieldValue = (long) (maxTimestampDocKeys.iterator().next() % 2);
final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.desc);
@@ -171,11 +171,11 @@ class SegmentTerminateEarlyTestState {
"responseHeader.segmentTerminatedEarly missing in " + rsp.getResponseHeader(),
rsp.getResponseHeader()
.get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
- TestSegmentSorting.assertTrue(
+ TestSegmentSorting.assertEquals(
"responseHeader.segmentTerminatedEarly missing/false in " + rsp.getResponseHeader(),
- Boolean.TRUE.equals(
- rsp.getResponseHeader()
- .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
+ Boolean.TRUE,
+ rsp.getResponseHeader()
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
// check shards info
final Object shardsInfo = rsp.getResponse().get(ShardParams.SHARDS_INFO);
if (!Boolean.TRUE.equals(shardsInfoWanted)) {
@@ -202,7 +202,7 @@ class SegmentTerminateEarlyTestState {
void queryTimestampDescendingSegmentTerminateEarlyNo(
CloudSolrClient cloudSolrClient, boolean appendKeyDescendingToSort) throws Exception {
TestSegmentSorting.assertFalse(maxTimestampDocKeys.isEmpty());
- TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
+ TestSegmentSorting.assertEquals("numDocs=" + numDocs + " is not even", 0, (numDocs % 2));
final Long oddFieldValue = (long) (maxTimestampDocKeys.iterator().next() % 2);
final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.desc);
@@ -239,11 +239,11 @@ class SegmentTerminateEarlyTestState {
"responseHeader.segmentTerminatedEarly present in " + rsp.getResponseHeader(),
rsp.getResponseHeader()
.get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
- TestSegmentSorting.assertFalse(
+ TestSegmentSorting.assertNotEquals(
"responseHeader.segmentTerminatedEarly present/true in " + rsp.getResponseHeader(),
- Boolean.TRUE.equals(
- rsp.getResponseHeader()
- .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
+ Boolean.TRUE,
+ rsp.getResponseHeader()
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
// check shards info
final Object shardsInfo = rsp.getResponse().get(ShardParams.SHARDS_INFO);
if (!Boolean.TRUE.equals(shardsInfoWanted)) {
@@ -268,7 +268,7 @@ class SegmentTerminateEarlyTestState {
void queryTimestampDescendingSegmentTerminateEarlyYesGrouped(
CloudSolrClient cloudSolrClient, boolean appendKeyDescendingToSort) throws Exception {
TestSegmentSorting.assertFalse(maxTimestampDocKeys.isEmpty());
- TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
+ TestSegmentSorting.assertEquals("numDocs=" + numDocs + " is not even", 0, (numDocs % 2));
final Long oddFieldValue = (long) (maxTimestampDocKeys.iterator().next() % 2);
final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
query.setSort(TIMESTAMP_FIELD, SolrQuery.ORDER.desc);
@@ -276,7 +276,7 @@ class SegmentTerminateEarlyTestState {
query.setFields(KEY_FIELD, ODD_FIELD, TIMESTAMP_FIELD);
query.setRows(1);
query.set(CommonParams.SEGMENT_TERMINATE_EARLY, true);
- TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not quad-able", (numDocs % 4) == 0);
+ TestSegmentSorting.assertEquals("numDocs=" + numDocs + " is not quad-able", 0, (numDocs % 4));
query.add("group.field", QUAD_FIELD);
query.set("group", true);
final QueryResponse rsp = cloudSolrClient.query(query);
@@ -303,17 +303,17 @@ class SegmentTerminateEarlyTestState {
}
// check segmentTerminatedEarly flag
// at present segmentTerminateEarly cannot be used with grouped queries
- TestSegmentSorting.assertFalse(
+ TestSegmentSorting.assertNotEquals(
"responseHeader.segmentTerminatedEarly present/true in " + rsp.getResponseHeader(),
- Boolean.TRUE.equals(
- rsp.getResponseHeader()
- .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
+ Boolean.TRUE,
+ rsp.getResponseHeader()
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
}
void queryTimestampAscendingSegmentTerminateEarlyYes(
CloudSolrClient cloudSolrClient, boolean appendKeyDescendingToSort) throws Exception {
TestSegmentSorting.assertFalse(minTimestampDocKeys.isEmpty());
- TestSegmentSorting.assertTrue("numDocs=" + numDocs + " is not even", (numDocs % 2) == 0);
+ TestSegmentSorting.assertEquals("numDocs=" + numDocs + " is not even", 0, (numDocs % 2));
final Long oddFieldValue = (long) (minTimestampDocKeys.iterator().next() % 2);
final SolrQuery query = new SolrQuery(ODD_FIELD + ":" + oddFieldValue);
// a sort order that is _not_ compatible with the merge sort order
@@ -348,10 +348,10 @@ class SegmentTerminateEarlyTestState {
rsp.getResponseHeader()
.get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
// segmentTerminateEarly cannot be used with incompatible sort orders
- TestSegmentSorting.assertTrue(
+ TestSegmentSorting.assertEquals(
"responseHeader.segmentTerminatedEarly missing/true in " + rsp.getResponseHeader(),
- Boolean.FALSE.equals(
- rsp.getResponseHeader()
- .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY)));
+ Boolean.FALSE,
+ rsp.getResponseHeader()
+ .get(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY));
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/SolrCLIZkUtilsTest.java b/solr/core/src/test/org/apache/solr/cloud/SolrCLIZkUtilsTest.java
index 0844a14a1b2..2442ab1a4bd 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SolrCLIZkUtilsTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SolrCLIZkUtilsTest.java
@@ -940,7 +940,7 @@ public class SolrCLIZkUtilsTest extends SolrCloudTestCase {
tool.runTool(
SolrCLI.processCommandLineArgs(
SolrCLI.joinCommonAndToolOptions(tool.getOptions()), args));
- assertFalse("Should fail when trying to remove /.", res == 0);
+ assertNotEquals("Should fail when trying to remove /.", 0, res);
}
// Check that all children of fileRoot are children of zkRoot and vice-versa
diff --git a/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java b/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
index ea8627b3dd6..0a688acabbf 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
@@ -200,7 +200,7 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
SolrCLI.HealthcheckTool tool = new SolrCLI.HealthcheckTool();
CommandLine cli =
SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(tool.getOptions()), args);
- assertTrue("Healthcheck action failed!", tool.runTool(cli) == 0);
+ assertEquals("Healthcheck action failed!", 0, tool.runTool(cli));
}
protected void doTestDeleteAction(String testCollectionName, String solrUrl) throws Exception {
@@ -212,9 +212,9 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
SolrCLI.DeleteTool tool = new SolrCLI.DeleteTool();
CommandLine cli =
SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(tool.getOptions()), args);
- assertTrue("Delete action failed!", tool.runTool(cli) == 0);
- assertTrue(
- !SolrCLI.safeCheckCollectionExists(
+ assertEquals("Delete action failed!", 0, tool.runTool(cli));
+ assertFalse(
+ SolrCLI.safeCheckCollectionExists(
solrUrl, testCollectionName)); // it should not exist anymore
}
@@ -248,7 +248,7 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
CommandLine cli =
SolrCLI.processCommandLineArgs(SolrCLI.joinCommonAndToolOptions(tool.getOptions()), args);
log.info("Sending set-property '{}'={} to SolrCLI.ConfigTool.", prop, maxTime);
- assertTrue("Set config property failed!", tool.runTool(cli) == 0);
+ assertEquals("Set config property failed!", 0, tool.runTool(cli));
configJson = SolrCLI.getJson(configUrl);
maxTimeFromConfig = SolrCLI.atPath("/config/updateHandler/autoSoftCommit/maxTime", configJson);
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java
index 88f629018ff..464225e193d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudConsistency.java
@@ -339,8 +339,7 @@ public class TestCloudConsistency extends SolrCloudTestCase {
private void assertDocExists(SolrClient solr, String docId) throws Exception {
NamedList<?> rsp = realTimeGetDocId(solr, docId);
String match = JSONTestUtil.matchObj("/id", rsp.get("doc"), docId);
- assertTrue(
- "Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match == null);
+ assertNull("Doc with id=" + docId + " not found due to: " + match + "; rsp=" + rsp, match);
}
private NamedList<Object> realTimeGetDocId(SolrClient solr, String docId)
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java
index 2e4b47e2c22..6de4be97b52 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java
@@ -202,7 +202,7 @@ public class TestCloudPhrasesIdentificationComponent extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java
index c4b372ceb99..124da0b7913 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java
@@ -369,8 +369,6 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase {
} else {
// regular stats, compare everything...
-
- assert actualStats != null;
try {
String msg = " of " + statsKey;
@@ -672,7 +670,7 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase {
* @see #useFieldRandomizedFactor
*/
private static boolean useField() {
- assert 0 < useFieldRandomizedFactor;
+ assertTrue(0 < useFieldRandomizedFactor);
return 0 != TestUtil.nextInt(random(), 0, useFieldRandomizedFactor);
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java
index 1bc10314931..519727f136d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java
@@ -176,10 +176,8 @@ public class TestCloudPseudoReturnFields extends SolrCloudTestCase {
Boolean.TRUE,
frsp.getField().get("multiValued"));
} catch (SolrServerException e) {
- assertEquals(
- "Couldn't fetch field for '" + name + "' ... schema changed out from under us?",
- null,
- e);
+ assertNull(
+ "Couldn't fetch field for '" + name + "' ... schema changed out from under us?", e);
}
}
@@ -982,7 +980,7 @@ public class TestCloudPseudoReturnFields extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java
index b9a52eef896..a03e3666ea8 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudSearcherWarming.java
@@ -299,12 +299,9 @@ public class TestCloudSearcherWarming extends SolrCloudTestCase {
if (jettySolrRunner.getNodeName().equals(replica.getNodeName())) {
SolrDispatchFilter solrDispatchFilter = jettySolrRunner.getSolrDispatchFilter();
try (SolrCore core = solrDispatchFilter.getCores().getCore(coreName)) {
- if (core.getSolrConfig().useColdSearcher) {
- log.error(
- "useColdSearcher is enabled! It should not be enabled for this test!");
- assert false;
- return false;
- }
+ assertFalse(
+ "useColdSearcher is enabled! It should not be enabled for this test!",
+ core.getSolrConfig().useColdSearcher);
if (log.isInfoEnabled()) {
log.info("Found SolrCore: {}, id: {}", core.getName(), core);
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
index 58f13026645..11e8b0f22fb 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
@@ -41,7 +41,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -400,18 +399,16 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
}
// check the value in properties are correct
- Iterator<? extends Map.Entry<String, ?>> it = properties.iterator();
- while (it.hasNext()) {
- Map.Entry<String, ?> entry = it.next();
+ for (Map.Entry<String, ?> entry : properties) {
String newValue = newProps != null ? newProps.get(entry.getKey()) : null;
String oldValue = oldProps != null ? oldProps.get(entry.getKey()) : null;
if (newValue != null) {
- assertTrue(newValue.equals(entry.getValue()));
+ assertEquals(newValue, entry.getValue());
} else if (oldValue != null) {
- assertTrue(oldValue.equals(entry.getValue()));
+ assertEquals(oldValue, entry.getValue());
} else {
// not in either
- assert (false);
+ fail();
}
}
}
@@ -1367,24 +1364,22 @@ public class TestConfigSetsAPI extends SolrCloudTestCase {
assertTrue(
"managed-schema.xml file should have been uploaded",
zkClient.exists("/configs/" + configSetName + suffix + "/managed-schema.xml", true));
- assertTrue(
+ assertArrayEquals(
"managed-schema.xml file contents on zookeeper are not exactly same as that of the file uploaded in config",
- Arrays.equals(
- zkClient.getData(
- "/configs/" + configSetName + suffix + "/managed-schema.xml", null, null, true),
- readFile("solr/configsets/upload/" + configSetName + "/managed-schema.xml")));
+ zkClient.getData(
+ "/configs/" + configSetName + suffix + "/managed-schema.xml", null, null, true),
+ readFile("solr/configsets/upload/" + configSetName + "/managed-schema.xml"));
assertTrue(
"solrconfig.xml file should have been uploaded",
zkClient.exists("/configs/" + configSetName + suffix + "/solrconfig.xml", true));
byte data[] = zkClient.getData("/configs/" + configSetName + suffix, null, null, true);
// assertEquals("{\"trusted\": false}", new String(data, StandardCharsets.UTF_8));
- assertTrue(
+ assertArrayEquals(
"solrconfig.xml file contents on zookeeper are not exactly same as that of the file uploaded in config",
- Arrays.equals(
- zkClient.getData(
- "/configs/" + configSetName + suffix + "/solrconfig.xml", null, null, true),
- readFile("solr/configsets/upload/" + configSetName + "/solrconfig.xml")));
+ zkClient.getData(
+ "/configs/" + configSetName + suffix + "/solrconfig.xml", null, null, true),
+ readFile("solr/configsets/upload/" + configSetName + "/solrconfig.xml"));
}
private long uploadConfigSet(
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterSSL.java b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterSSL.java
index bea102c605b..a93ee2fd171 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterSSL.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestMiniSolrCloudClusterSSL.java
@@ -67,7 +67,7 @@ public class TestMiniSolrCloudClusterSSL extends SolrTestCaseJ4 {
static {
try {
DEFAULT_SSL_CONTEXT = SSLContext.getDefault();
- assert null != DEFAULT_SSL_CONTEXT;
+ assertNotNull(DEFAULT_SSL_CONTEXT);
} catch (Exception e) {
throw new RuntimeException(
"Unable to initialize 'Default' SSLContext Algorithm, JVM is borked", e);
@@ -401,7 +401,7 @@ public class TestMiniSolrCloudClusterSSL extends SolrTestCaseJ4 {
final SSLConnectionSocketFactory sslFactory =
clientConfig.buildClientSSLConnectionSocketFactory();
- assert null != sslFactory;
+ assertNotNull(sslFactory);
final Registry<ConnectionSocketFactory> socketFactoryReg =
RegistryBuilder.<ConnectionSocketFactory>create()
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestOnReconnectListenerSupport.java b/solr/core/src/test/org/apache/solr/cloud/TestOnReconnectListenerSupport.java
index 0567e0ae71f..12959741d59 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestOnReconnectListenerSupport.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestOnReconnectListenerSupport.java
@@ -116,7 +116,7 @@ public class TestOnReconnectListenerSupport extends AbstractFullDistribZkTestBas
}
// they shouldn't be equal after reload
- assertTrue(!leaderCoreId.equals(reloadedLeaderCoreId));
+ assertNotEquals(leaderCoreId, reloadedLeaderCoreId);
listeners = zkController.getCurrentOnReconnectListeners();
assertNotNull("ZkController returned null OnReconnect listeners", listeners);
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
index b4eb112a3c2..012d2477498 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
@@ -504,7 +504,6 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
}
}
} else {
- assert 1 == idsToRequest.size();
params.add("id", idsToRequest.get(0));
}
@@ -644,7 +643,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
}
@@ -1360,7 +1359,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
final SolrInputDocument expected,
final SolrDocument actual,
final String wt) {
- assertEquals(fl, null, actual.getFirstValue(fieldName));
+ assertNull(fl, actual.getFirstValue(fieldName));
return Collections.emptySet();
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java
index 652bfb140dd..468940441d2 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java
@@ -359,7 +359,7 @@ public class TestStressCloudBlindAtomicUpdates extends SolrCloudTestCase {
// check all the final index contents match our expectations
int incorrectDocs = 0;
for (int id = 0; id < numDocsInIndex; id += DOC_ID_INCR) {
- assert 0 == id % DOC_ID_INCR : "WTF? " + id;
+ assertEquals("WTF? " + id, 0, id % DOC_ID_INCR);
final long expect = expected[id / DOC_ID_INCR].longValue();
@@ -421,7 +421,7 @@ public class TestStressCloudBlindAtomicUpdates extends SolrCloudTestCase {
}
private void doRandomAtomicUpdate(int docId) throws Exception {
- assert 0 == docId % DOC_ID_INCR : "WTF? " + docId;
+ assertEquals("WTF? " + docId, 0, docId % DOC_ID_INCR);
final int delta = TestUtil.nextInt(rand, -1000, 1000);
log.info("worker={}, docId={}, delta={}", workerId, docId, delta);
@@ -521,7 +521,7 @@ public class TestStressCloudBlindAtomicUpdates extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
ZkStateReader.from(client).forceUpdateCollection(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestStressInPlaceUpdates.java b/solr/core/src/test/org/apache/solr/cloud/TestStressInPlaceUpdates.java
index 760f3e58097..d16ecacce5a 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestStressInPlaceUpdates.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestStressInPlaceUpdates.java
@@ -600,7 +600,7 @@ public class TestStressInPlaceUpdates extends AbstractFullDistribZkTestBase {
public DocInfo(long version, int val1, long val2) {
// must either be real positive version, or negative deleted version/indicator
- assert version != 0;
+ assertNotEquals(0, version);
this.version = version;
this.intFieldValue = val1;
this.longFieldValue = val2;
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java
index a6ca6604ed7..5c29a30e800 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplayVsRecovery.java
@@ -281,7 +281,7 @@ public class TestTlogReplayVsRecovery extends SolrCloudTestCase {
assertEquals(0, rsp.getStatus());
String match = JSONTestUtil.matchObj("/id", rsp.getResponse().get("doc"), docId);
- assertTrue(
+ assertNull(
"Doc with id="
+ docId
+ " not found in "
@@ -290,6 +290,6 @@ public class TestTlogReplayVsRecovery extends SolrCloudTestCase {
+ match
+ "; rsp="
+ rsp,
- match == null);
+ match);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
index a195a9fcb59..45586dd4858 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
@@ -214,7 +214,7 @@ public class TestTlogReplica extends SolrCloudTestCase {
0,
docCollection.getReplicas(EnumSet.of(Replica.Type.PULL)).size());
for (Slice s : docCollection.getSlices()) {
- assertTrue(s.getLeader().getType() == Replica.Type.TLOG);
+ assertSame(s.getLeader().getType(), Replica.Type.TLOG);
List<String> shardElectionNodes =
cluster
.getZkClient()
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorRandomCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorRandomCloud.java
index 7bfcf85bea2..a2fac59809e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorRandomCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTolerantUpdateProcessorRandomCloud.java
@@ -241,15 +241,16 @@ public class TestTolerantUpdateProcessorRandomCloud extends SolrCloudTestCase {
(hiBound < 0) ? maxDocId : hiBound - 1);
if (lo != hi) {
- assert lo < hi : "lo=" + lo + " hi=" + hi;
+ assertTrue("lo=" + lo + " hi=" + hi, lo < hi);
// NOTE: clear & set are exclusive of hi, so we use "}" in range query accordingly
q = "id_i:[" + lo + " TO " + hi + "}";
expectedDocIds.clear(lo, hi);
docsAffectedThisRequest.set(lo, hi);
} else {
// edge case: special case DBQ of one doc
- assert (lo == rangeAxis && hi == rangeAxis)
- : "lo=" + lo + " axis=" + rangeAxis + " hi=" + hi;
+ assertTrue(
+ "lo=" + lo + " axis=" + rangeAxis + " hi=" + hi,
+ lo == rangeAxis && hi == rangeAxis);
q = "id_i:[" + lo + " TO " + lo + "]"; // have to be inclusive of both ends
expectedDocIds.clear(lo);
docsAffectedThisRequest.set(lo);
@@ -319,9 +320,10 @@ public class TestTolerantUpdateProcessorRandomCloud extends SolrCloudTestCase {
final int max = atLeast(100);
BitSet bits = new BitSet(max + 1);
for (int i = 0; i <= max; i++) {
- assertFalse(
+ assertNotEquals(
"how is bitset already full? iter=" + i + " card=" + bits.cardinality() + "/max=" + max,
- bits.cardinality() == max + 1);
+ bits.cardinality(),
+ max + 1);
final int nextBit = randomUnsetBit(random(), bits, max);
assertTrue("nextBit shouldn't be negative yet: " + nextBit, 0 <= nextBit);
assertTrue("nextBit can't exceed max: " + nextBit, nextBit <= max);
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
index 948e901b645..b06ab9bbd66 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
@@ -100,7 +100,7 @@ public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestB
CollectionAdminRequest.createCollection(collectionName, 1, 1)
.setCreateNodeSet(notOverseerNode);
request = create.process(cloudClient).getResponse();
- assertTrue("Collection creation should not have failed", request.get("success") != null);
+ assertNotNull("Collection creation should not have failed", request.get("success"));
}
}
@@ -175,9 +175,9 @@ public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestB
NamedList<Object> requestWithSharedConfig =
createWithSharedConfig.process(cloudClient).getResponse();
- assertTrue(
+ assertNotNull(
"The collection with shared config set should have been created",
- requestWithSharedConfig.get("success") != null);
+ requestWithSharedConfig.get("success"));
assertTrue(
"The new collection should exist after a successful creation",
getZkClient()
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java
index 3c228f3841e..3991c1d229b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java
@@ -218,7 +218,7 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
Slice slice2 = slices2.iterator().next();
assertTrue(slices1.size() == 1 && slices2.size() == 1);
- assertTrue(slice1 != slice2);
+ assertNotSame(slice1, slice2);
//
// now let's add enough documents to the first prefix to get it split out on its own
@@ -251,7 +251,7 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
slice2 = slices2.iterator().next();
assertTrue(slices1.size() == 1 && slices2.size() == 1);
- assertTrue(slice1 != slice2);
+ assertNotSame(slice1, slice2);
// Now if we call split (with splitByPrefix) on a shard that has a single prefix, it should
// split it in half
@@ -274,7 +274,7 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
collection.getRouter().getSearchSlicesSingle(uniquePrefixes.get(0).key, null, collection);
slice1 = slices1.iterator().next();
- assertTrue(slices1.size() == 2);
+ assertEquals(2, slices1.size());
//
// split one more time, this time on a partial prefix/bucket
@@ -296,7 +296,7 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
slices1 =
collection.getRouter().getSearchSlicesSingle(uniquePrefixes.get(0).key, null, collection);
- assertTrue(slices1.size() == 3);
+ assertEquals(3, slices1.size());
// System.err.println("### STATE=" +
// cluster.getSolrClient().getZkStateReader().getClusterState().getCollection(COLLECTION_NAME));
diff --git a/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java b/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java
index 4f007b73708..5813fb9512c 100644
--- a/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/events/ClusterEventProducerTest.java
@@ -261,10 +261,9 @@ public class ClusterEventProducerTest extends SolrCloudTestCase {
ClusterEvent.EventType.CLUSTER_PROPERTIES_CHANGED,
event.getType());
propertiesChanged = (ClusterPropertiesChangedEvent) event;
- assertEquals(
+ assertNull(
"new properties should not have 'ext.foo' property: "
+ propertiesChanged.getNewClusterProperties(),
- null,
propertiesChanged.getNewClusterProperties().get("ext.foo"));
}
diff --git a/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
index 40d04aa8e64..04c3af33f3b 100644
--- a/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
+++ b/solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java
@@ -806,7 +806,7 @@ public class AffinityPlacementFactoryTest extends SolrTestCaseJ4 {
PlacementPlan pp = plugin.computePlacement(placementRequest, placementContext);
assertEquals(4, pp.getReplicaPlacements().size());
for (ReplicaPlacement rp : pp.getReplicaPlacements()) {
- assertFalse("should not put any replicas on " + smallNode, rp.getNode().equals(smallNode));
+ assertNotEquals("should not put any replicas on " + smallNode, rp.getNode(), smallNode);
}
}
diff --git a/solr/core/src/test/org/apache/solr/common/cloud/ZkDynamicConfigTest.java b/solr/core/src/test/org/apache/solr/common/cloud/ZkDynamicConfigTest.java
index cf331ee2da7..e260a8a9981 100644
--- a/solr/core/src/test/org/apache/solr/common/cloud/ZkDynamicConfigTest.java
+++ b/solr/core/src/test/org/apache/solr/common/cloud/ZkDynamicConfigTest.java
@@ -56,9 +56,9 @@ public class ZkDynamicConfigTest extends SolrTestCaseJ4 {
// client address/port optional if clientPort specified in static config file (back-compat mode)
assertEquals("participant", parsed.getServers().get(3).role);
- assertEquals(null, parsed.getServers().get(3).clientPortAddress);
+ assertNull(parsed.getServers().get(3).clientPortAddress);
assertEquals("zoo4", parsed.getServers().get(3).resolveClientPortAddress());
- assertEquals(null, parsed.getServers().get(3).clientPort);
+ assertNull(parsed.getServers().get(3).clientPort);
}
@Test(expected = SolrException.class)
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 d9237a47c29..8ad5ee12b76 100644
--- a/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java
+++ b/solr/core/src/test/org/apache/solr/core/BlobRepositoryMockingTest.java
@@ -17,11 +17,6 @@
package org.apache.solr.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -44,7 +39,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-public class BlobRepositoryMockingTest {
+public class BlobRepositoryMockingTest extends SolrTestCaseJ4 {
private static final Charset UTF8 = StandardCharsets.UTF_8;
private static final String[][] PARSED =
@@ -71,7 +66,8 @@ public class BlobRepositoryMockingTest {
}
@Before
- public void setUp() {
+ public void setUp() throws Exception {
+ super.setUp();
blobFetched = false;
blobKey = "";
reset(mocks);
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 9ca486a2b13..9eca696f0e0 100644
--- a/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
+++ b/solr/core/src/test/org/apache/solr/core/CoreSorterTest.java
@@ -154,11 +154,11 @@ public class CoreSorterTest extends SolrTestCaseJ4 {
for (Map.Entry<CountsForEachShard, List<CoreDescriptor>> entry : myCountsToDescs.entrySet()) {
for (CoreDescriptor descriptor : entry.getValue()) {
CountsForEachShard prev = myDescsToCounts.put(descriptor, entry.getKey());
- assert prev == null; // sanity check
+ assertNull(prev); // sanity check
}
}
- assert myCountsToDescs.size() == perShardCounts.size(); // just a sanity check
+ assertEquals(myCountsToDescs.size(), perShardCounts.size()); // just a sanity check
CoreContainer mockCC = mock(CoreContainer.class);
{
diff --git a/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java b/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
index 2493dd6d3a1..1ceb9636b20 100644
--- a/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
+++ b/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
@@ -151,9 +151,9 @@ public class ExitableDirectoryReaderTest extends SolrTestCaseJ4 {
assertEquals("Should have exactly " + NUM_DOCS, (long) (body.get("numFound")), NUM_DOCS);
header = (Map<?, ?>) (res.get("responseHeader"));
- assertTrue(
+ assertNull(
"Should NOT have partial results",
- header.get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY) == null);
+ header.get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY));
}
// When looking at a problem raised on the user's list I ran across this anomaly with timeAllowed
diff --git a/solr/core/src/test/org/apache/solr/core/PluginInfoTest.java b/solr/core/src/test/org/apache/solr/core/PluginInfoTest.java
index 57e63a7984b..d57c650e967 100644
--- a/solr/core/src/test/org/apache/solr/core/PluginInfoTest.java
+++ b/solr/core/src/test/org/apache/solr/core/PluginInfoTest.java
@@ -78,7 +78,7 @@ public class PluginInfoTest extends DOMUtilTestBase {
Node nodeWithAName = getNode("<plugin name=\"myName\" />", "plugin");
PluginInfo pi2 = new PluginInfo(nodeWithAName, "Node with a Name", true, false);
- assertTrue(pi2.name.equals("myName"));
+ assertEquals("myName", pi2.name);
}
@Test
@@ -99,7 +99,7 @@ public class PluginInfoTest extends DOMUtilTestBase {
Node nodeWithAClass = getNode("<plugin class=\"myName\" />", "plugin");
PluginInfo pi2 = new PluginInfo(nodeWithAClass, "Node with a Class", false, true);
- assertTrue(pi2.className.equals("myName"));
+ assertEquals("myName", pi2.className);
}
@Test
@@ -133,7 +133,7 @@ public class PluginInfoTest extends DOMUtilTestBase {
public void testHasChildren() throws Exception {
Node node = getNode(configWith2Children, "plugin");
PluginInfo pi = new PluginInfo(node, "node with 2 Children", false, false);
- assertTrue(pi.children.size() == 2);
+ assertEquals(2, pi.children.size());
}
@Test
@@ -145,7 +145,7 @@ public class PluginInfoTest extends DOMUtilTestBase {
PluginInfo notExistent = pi.getChild("doesnotExist");
assertNull(notExistent);
assertTrue(childInfo instanceof PluginInfo);
- assertTrue((Integer) childInfo.initArgs.get("index") == 0);
+ assertEquals(0, (int) (Integer) childInfo.initArgs.get("index"));
Node node2 = getNode(configWithNoChildren, "plugin");
PluginInfo pi2 = new PluginInfo(node2, "with No Children", false, false);
PluginInfo noChild = pi2.getChild("long");
@@ -157,7 +157,7 @@ public class PluginInfoTest extends DOMUtilTestBase {
Node node = getNode(configWith2Children, "plugin");
PluginInfo pi = new PluginInfo(node, "with children", false, false);
List<PluginInfo> children = pi.getChildren("child");
- assertTrue(children.size() == 2);
+ assertEquals(2, children.size());
for (PluginInfo childInfo : children) {
assertNotNull(childInfo);
assertTrue(childInfo instanceof PluginInfo);
@@ -168,6 +168,6 @@ public class PluginInfoTest extends DOMUtilTestBase {
public void testInitArgsCount() throws Exception {
Node node = getNode(configWithNoChildren, "plugin");
PluginInfo pi = new PluginInfo(node, "from static", true, false);
- assertTrue(pi.initArgs.size() == node.getChildNodes().getLength());
+ assertEquals(pi.initArgs.size(), node.getChildNodes().getLength());
}
}
diff --git a/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java b/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java
index d766c5d8837..e5f53892b24 100644
--- a/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java
+++ b/solr/core/src/test/org/apache/solr/core/QueryResultKeyTest.java
@@ -90,12 +90,12 @@ public class QueryResultKeyTest extends SolrTestCaseJ4 {
assertEquals(fq_ac, fq_aa);
assertEquals(fq_ac, fq_ab);
- assertTrue(!fq_aa.equals(fq_zz));
- assertTrue(!fq_ab.equals(fq_zz));
- assertTrue(!fq_ac.equals(fq_zz));
- assertTrue(!fq_zz.equals(fq_aa));
- assertTrue(!fq_zz.equals(fq_ab));
- assertTrue(!fq_zz.equals(fq_ac));
+ assertNotEquals(fq_aa, fq_zz);
+ assertNotEquals(fq_ab, fq_zz);
+ assertNotEquals(fq_ac, fq_zz);
+ assertNotEquals(fq_zz, fq_aa);
+ assertNotEquals(fq_zz, fq_ab);
+ assertNotEquals(fq_zz, fq_ac);
List<Query> filters1 = Arrays.asList(fq_aa, fq_ab);
List<Query> filters2 = Arrays.asList(fq_zz, fq_ac);
@@ -134,7 +134,6 @@ public class QueryResultKeyTest extends SolrTestCaseJ4 {
assertKeyNotEquals(aa, bb);
}
}
- assert minIters <= iter;
}
public void testMinExactCount() {
@@ -166,8 +165,8 @@ public class QueryResultKeyTest extends SolrTestCaseJ4 {
/** does bi-directional check that the keys are <em>not</em> equals */
public void assertKeyNotEquals(QueryResultKey key1, QueryResultKey key2) {
- assertTrue(!key1.equals(key2));
- assertTrue(!key2.equals(key1));
+ assertNotEquals(key1, key2);
+ assertNotEquals(key2, key1);
}
/**
diff --git a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java
index 80d8c1f9c62..7ac9d6a107e 100644
--- a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java
+++ b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java
@@ -131,6 +131,6 @@ public class RequestHandlersTest extends SolrTestCaseJ4 {
Long updateTime = (Long) updateStats.get("UPDATE./update.totalTime");
Long termTime = (Long) termStats.get("QUERY./terms.totalTime");
- assertFalse("RequestHandlers should not share statistics!", updateTime.equals(termTime));
+ assertNotEquals("RequestHandlers should not share statistics!", updateTime, termTime);
}
}
diff --git a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
index 9a49035e796..1e81af74233 100644
--- a/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
+++ b/solr/core/src/test/org/apache/solr/core/ResourceLoaderTest.java
@@ -27,7 +27,6 @@ import java.nio.charset.CharacterCodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -166,11 +165,12 @@ public class ResourceLoaderTest extends SolrTestCaseJ4 {
assertEquals(
"Should have been able to read 3 bytes from bomStream", 3, bomStream.read(firstBytes));
- assertTrue(
+ assertArrayEquals(
"This test only works if "
+ fileWithBom
+ " contains a BOM -- it appears someone removed it.",
- Arrays.equals(bomExpected, firstBytes));
+ bomExpected,
+ firstBytes);
} finally {
try {
bomStream.close();
diff --git a/solr/core/src/test/org/apache/solr/core/SOLR749Test.java b/solr/core/src/test/org/apache/solr/core/SOLR749Test.java
index cdc5e63dbd4..7af7beb55bb 100644
--- a/solr/core/src/test/org/apache/solr/core/SOLR749Test.java
+++ b/solr/core/src/test/org/apache/solr/core/SOLR749Test.java
@@ -38,15 +38,15 @@ public class SOLR749Test extends SolrTestCaseJ4 {
public void testConstruction() {
SolrCore core = h.getCore();
- assertTrue("core is null and it shouldn't be", core != null);
+ assertNotNull("core is null and it shouldn't be", core);
QParserPlugin parserPlugin = core.getQueryPlugin(QParserPlugin.DEFAULT_QTYPE);
- assertTrue("parserPlugin is null and it shouldn't be", parserPlugin != null);
+ assertNotNull("parserPlugin is null and it shouldn't be", parserPlugin);
assertTrue(
"parserPlugin is not an instanceof " + FooQParserPlugin.class,
parserPlugin instanceof FooQParserPlugin);
ValueSourceParser vsp = core.getValueSourceParser("boost");
- assertTrue("vsp is null and it shouldn't be", vsp != null);
+ assertNotNull("vsp is null and it shouldn't be", vsp);
assertTrue(
"vsp is not an instanceof " + DummyValueSourceParser.class,
vsp instanceof DummyValueSourceParser);
diff --git a/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java b/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
index a84eec13a99..b7cd61e99e7 100644
--- a/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
+++ b/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
@@ -158,17 +158,17 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
assertEquals(core.getRequestHandlers().get(path), handler1);
core.close();
cores.shutdown();
- assertTrue("Handler not closed", handler1.closed == true);
+ assertTrue("Handler not closed", handler1.closed);
}
@Test
public void testRefCount() {
SolrCore core = h.getCore();
- assertTrue("Refcount != 1", core.getOpenCount() == 1);
+ assertEquals("Refcount != 1", 1, core.getOpenCount());
final CoreContainer cores = h.getCoreContainer();
SolrCore c1 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
- assertTrue("Refcount != 2", core.getOpenCount() == 2);
+ assertEquals("Refcount != 2", 2, core.getOpenCount());
ClosingRequestHandler handler1 = new ClosingRequestHandler();
handler1.inform(core);
@@ -181,26 +181,26 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
SolrCore c2 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
c1.close();
assertTrue("Refcount < 1", core.getOpenCount() >= 1);
- assertTrue("Handler is closed", handler1.closed == false);
+ assertFalse("Handler is closed", handler1.closed);
c1 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
assertTrue("Refcount < 2", core.getOpenCount() >= 2);
- assertTrue("Handler is closed", handler1.closed == false);
+ assertFalse("Handler is closed", handler1.closed);
c2.close();
assertTrue("Refcount < 1", core.getOpenCount() >= 1);
- assertTrue("Handler is closed", handler1.closed == false);
+ assertFalse("Handler is closed", handler1.closed);
c1.close();
cores.shutdown();
- assertTrue("Refcount != 0", core.getOpenCount() == 0);
+ assertEquals("Refcount != 0", 0, core.getOpenCount());
assertTrue("Handler not closed", core.isClosed() && handler1.closed == true);
}
@Test
public void testRefCountMT() throws Exception {
SolrCore core = h.getCore();
- assertTrue("Refcount != 1", core.getOpenCount() == 1);
+ assertEquals("Refcount != 1", 1, core.getOpenCount());
final ClosingRequestHandler handler1 = new ClosingRequestHandler();
handler1.inform(core);
@@ -239,7 +239,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
yieldInt(l);
assertTrue("Refcount > 17", core.getOpenCount() <= 17);
yieldInt(l);
- assertTrue("Handler is closed", handler1.closed == false);
+ assertFalse("Handler is closed", handler1.closed);
yieldInt(l);
core.close();
core = null;
@@ -260,7 +260,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
}
cores.shutdown();
- assertTrue("Refcount != 0", core.getOpenCount() == 0);
+ assertEquals("Refcount != 0", 0, core.getOpenCount());
assertTrue("Handler not closed", core.isClosed() && handler1.closed == true);
service.shutdown();
@@ -292,8 +292,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
assertEquals(
"wrong config for slowQueryThresholdMillis", 2000, solrConfig.slowQueryThresholdMillis);
assertEquals("wrong config for maxBooleanClauses", 1024, solrConfig.booleanQueryMaxClauseCount);
- assertEquals(
- "wrong config for enableLazyFieldLoading", true, solrConfig.enableLazyFieldLoading);
+ assertTrue("wrong config for enableLazyFieldLoading", solrConfig.enableLazyFieldLoading);
assertEquals("wrong config for queryResultWindowSize", 10, solrConfig.queryResultWindowSize);
}
@@ -311,7 +310,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
// make up for the fact that opening a searcher in this empty core is very fast by opening new
// searchers continuously to increase the likelihood for race.
SolrCore core = h.getCore();
- assertTrue("Refcount != 1", core.getOpenCount() == 1);
+ assertEquals("Refcount != 1", 1, core.getOpenCount());
executor.execute(new NewSearcherRunnable(core));
// Since we called getCore() vs getCoreInc() and don't own a refCount, the container should
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfig.java b/solr/core/src/test/org/apache/solr/core/TestConfig.java
index 6e5a3a24220..2c17cbf1e1a 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfig.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfig.java
@@ -31,7 +31,6 @@ import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.IndexSchemaFactory;
import org.apache.solr.search.CacheConfig;
import org.apache.solr.update.SolrIndexConfig;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -164,7 +163,7 @@ public class TestConfig extends SolrTestCaseJ4 {
SolrIndexConfig sic = sc.indexConfig;
++numDefaultsTested;
- assertEquals("default useCompoundFile", false, sic.useCompoundFile);
+ assertFalse("default useCompoundFile", sic.useCompoundFile);
++numDefaultsTested;
assertEquals("default maxBufferedDocs", -1, sic.maxBufferedDocs);
@@ -221,16 +220,14 @@ public class TestConfig extends SolrTestCaseJ4 {
public void testConvertAutoCommitMaxSizeStringToBytes() {
// Valid values
- Assert.assertEquals(300, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300"));
- Assert.assertEquals(307200, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300k"));
- Assert.assertEquals(307200, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300K"));
- Assert.assertEquals(314572800, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300m"));
- Assert.assertEquals(314572800, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300M"));
- Assert.assertEquals(
- 322122547200L, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300g"));
- Assert.assertEquals(
- 322122547200L, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300G"));
- Assert.assertEquals(-1, SolrConfig.convertHeapOptionStyleConfigStringToBytes(""));
+ assertEquals(300, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300"));
+ assertEquals(307200, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300k"));
+ assertEquals(307200, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300K"));
+ assertEquals(314572800, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300m"));
+ assertEquals(314572800, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300M"));
+ assertEquals(322122547200L, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300g"));
+ assertEquals(322122547200L, SolrConfig.convertHeapOptionStyleConfigStringToBytes("300G"));
+ assertEquals(-1, SolrConfig.convertHeapOptionStyleConfigStringToBytes(""));
// Invalid values
RuntimeException thrown =
@@ -256,9 +253,9 @@ public class TestConfig extends SolrTestCaseJ4 {
public void testMaxSizeSettingWithoutAutoCommit() throws Exception {
SolrConfig solrConfig =
new SolrConfig(TEST_PATH().resolve("collection1"), "bad-solrconfig-no-autocommit-tag.xml");
- Assert.assertEquals(-1, solrConfig.getUpdateHandlerInfo().autoCommitMaxSizeBytes);
- Assert.assertEquals(-1, solrConfig.getUpdateHandlerInfo().autoCommmitMaxDocs);
- Assert.assertEquals(-1, solrConfig.getUpdateHandlerInfo().autoCommmitMaxTime);
+ assertEquals(-1, solrConfig.getUpdateHandlerInfo().autoCommitMaxSizeBytes);
+ assertEquals(-1, solrConfig.getUpdateHandlerInfo().autoCommmitMaxDocs);
+ assertEquals(-1, solrConfig.getUpdateHandlerInfo().autoCommmitMaxTime);
}
// sanity check that sys properties are working as expected
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
index d27bff8fbd8..1fde25d409c 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
@@ -51,7 +51,6 @@ import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.util.ModuleUtils;
import org.hamcrest.MatcherAssert;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -455,7 +454,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
SolrDispatchFilter.SOLR_INSTALL_DIR_ATTRIBUTE, tmpRoot.toAbsolutePath().toString());
final CoreContainer cc1 = init(tmpRoot, "<solr></solr>");
try {
- Assert.assertThrows(
+ assertThrows(
SolrResourceNotFoundException.class,
() -> cc1.loader.openResource("moduleLibFile").close());
} finally {
@@ -471,7 +470,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
}
SolrException ex =
- Assert.assertThrows(
+ assertThrows(
SolrException.class,
() -> init(tmpRoot, "<solr><str name=\"modules\">nope</str></solr>"));
assertEquals("No module with name nope", ex.getMessage());
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
index 971928978c0..5aa4ef6cc96 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
@@ -129,13 +129,15 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
long status = container.getStatus();
- assertTrue("Load complete flag should be set", (status & LOAD_COMPLETE) == LOAD_COMPLETE);
- assertTrue(
+ assertEquals("Load complete flag should be set", LOAD_COMPLETE, (status & LOAD_COMPLETE));
+ assertEquals(
"Core discovery should be complete",
- (status & CORE_DISCOVERY_COMPLETE) == CORE_DISCOVERY_COMPLETE);
- assertTrue(
+ CORE_DISCOVERY_COMPLETE,
+ (status & CORE_DISCOVERY_COMPLETE));
+ assertEquals(
"Initial core loading should be complete",
- (status & INITIAL_CORE_LOAD_COMPLETE) == INITIAL_CORE_LOAD_COMPLETE);
+ INITIAL_CORE_LOAD_COMPLETE,
+ (status & INITIAL_CORE_LOAD_COMPLETE));
return container;
}
diff --git a/solr/core/src/test/org/apache/solr/core/TestCorePropertiesReload.java b/solr/core/src/test/org/apache/solr/core/TestCorePropertiesReload.java
index af838144fb7..c2fe57d39ac 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCorePropertiesReload.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCorePropertiesReload.java
@@ -45,7 +45,7 @@ public class TestCorePropertiesReload extends SolrTestCaseJ4 {
SolrCore core = h.getCore();
CoreDescriptor coreDescriptor = core.getCoreDescriptor();
String testProp = coreDescriptor.getCoreProperty("test", null);
- assertTrue(testProp.equals("Before reload"));
+ assertEquals("Before reload", testProp);
// Re-write the properties file
Properties props = new Properties();
@@ -57,7 +57,7 @@ public class TestCorePropertiesReload extends SolrTestCaseJ4 {
coreDescriptor = core.getCoreDescriptor();
testProp = coreDescriptor.getCoreProperty("test", null);
- assertTrue(testProp.equals("After reload"));
+ assertEquals("After reload", testProp);
}
private void writeProperties(Properties props) throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
index ab5acbda0db..126c2219134 100644
--- a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
+++ b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
@@ -69,7 +69,7 @@ public class TestMergePolicyConfig extends SolrTestCaseJ4 {
public void testDefaultMergePolicyConfig() throws Exception {
initCore("solrconfig-mergepolicy-defaults.xml", "schema-minimal.xml");
IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore());
- assertEquals(false, iwc.getUseCompoundFile());
+ assertFalse(iwc.getUseCompoundFile());
TieredMergePolicy tieredMP = assertAndCast(TieredMergePolicy.class, iwc.getMergePolicy());
assertEquals(TieredMergePolicy.DEFAULT_NO_CFS_RATIO, tieredMP.getNoCFSRatio(), 0.0D);
diff --git a/solr/core/src/test/org/apache/solr/core/TestQuerySenderListener.java b/solr/core/src/test/org/apache/solr/core/TestQuerySenderListener.java
index a37ce82f4a5..c61e0d2f0e5 100644
--- a/solr/core/src/test/org/apache/solr/core/TestQuerySenderListener.java
+++ b/solr/core/src/test/org/apache/solr/core/TestQuerySenderListener.java
@@ -78,9 +78,10 @@ public class TestQuerySenderListener extends SolrTestCaseJ4 {
{
String evt = mock.req.getParams().get(EventParams.EVENT);
assertNotNull("Event is null", evt);
- assertTrue(
+ assertEquals(
evt + " is not equal to " + EventParams.FIRST_SEARCHER,
- evt.equals(EventParams.FIRST_SEARCHER) == true);
+ EventParams.FIRST_SEARCHER,
+ evt);
assertU(adoc("id", "1"));
assertU(commit());
@@ -91,9 +92,10 @@ public class TestQuerySenderListener extends SolrTestCaseJ4 {
newSearcher -> {
String evt = mock.req.getParams().get(EventParams.EVENT);
assertNotNull("Event is null", evt);
- assertTrue(
+ assertEquals(
evt + " is not equal to " + EventParams.NEW_SEARCHER,
- evt.equals(EventParams.NEW_SEARCHER) == true);
+ EventParams.NEW_SEARCHER,
+ evt);
return null;
});
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java b/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java
index 47a0ad3a6ba..75efcb3b508 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java
@@ -109,6 +109,6 @@ public class TestSolrDeletionPolicy1 extends SolrTestCaseJ4 {
assertQ("return all docs", req("id:[0 TO 6]"), "*[count(//doc)=6]");
commits = delPolicy.getCommits();
- assertTrue(!commits.containsKey(ic.getGeneration()));
+ assertFalse(commits.containsKey(ic.getGeneration()));
}
}
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy2.java b/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy2.java
index b072721c8e4..74a2301d07b 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy2.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy2.java
@@ -35,19 +35,18 @@ public class TestSolrDeletionPolicy2 extends SolrTestCaseJ4 {
FakeDeletionPolicy f = (FakeDeletionPolicy) delPolicy.getWrappedDeletionPolicy();
- assertTrue("value1".equals(f.getVar1()));
- assertTrue("value2".equals(f.getVar2()));
+ assertEquals("value1", f.getVar1());
+ assertEquals("value2", f.getVar2());
assertU(adoc("id", String.valueOf(1), "name", "name" + String.valueOf(1)));
- assertTrue(
- System.getProperty("onInit").equals("test.org.apache.solr.core.FakeDeletionPolicy.onInit"));
+ assertEquals(
+ "test.org.apache.solr.core.FakeDeletionPolicy.onInit", System.getProperty("onInit"));
assertU(commit());
assertQ("return all docs", req("id:[0 TO 1]"), "*[count(//doc)=1]");
- assertTrue(
- System.getProperty("onCommit")
- .equals("test.org.apache.solr.core.FakeDeletionPolicy.onCommit"));
+ assertEquals(
+ "test.org.apache.solr.core.FakeDeletionPolicy.onCommit", System.getProperty("onCommit"));
System.clearProperty("onInit");
System.clearProperty("onCommit");
diff --git a/solr/core/src/test/org/apache/solr/core/backup/BackupFilePathsTest.java b/solr/core/src/test/org/apache/solr/core/backup/BackupFilePathsTest.java
index 06dde0c0eb9..8b382ac7a4e 100644
--- a/solr/core/src/test/org/apache/solr/core/backup/BackupFilePathsTest.java
+++ b/solr/core/src/test/org/apache/solr/core/backup/BackupFilePathsTest.java
@@ -16,16 +16,13 @@
*/
package org.apache.solr.core.backup;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.util.List;
import java.util.Optional;
+import org.apache.solr.SolrTestCase;
import org.junit.Test;
/** Unit tests for {@link BackupFilePaths} */
-public class BackupFilePathsTest {
+public class BackupFilePathsTest extends SolrTestCase {
@Test
public void testGetBackupPropsName() {
diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
index 93d74aecfbd..ed4788f63c3 100644
--- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
+++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java
@@ -276,7 +276,7 @@ public class TestSolrCoreSnapshots extends SolrCloudTestCase {
// Verify that the index directory contains only 1 index commit (which is not the same as the
// snapshotted commit).
Collection<IndexCommit> commits = listCommits(metaData.getIndexDirPath());
- assertTrue(commits.size() == 1);
+ assertEquals(1, commits.size());
assertFalse(
commits.stream()
.filter(x -> x.getGeneration() == metaData.getGenerationNumber())
diff --git a/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java
index 1e74ce58842..11bcd7cf96f 100644
--- a/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/BinaryUpdateRequestHandlerTest.java
@@ -64,7 +64,7 @@ public class BinaryUpdateRequestHandlerTest extends SolrTestCaseJ4 {
csl.load(req, rsp, cs, p);
AddUpdateCommand add = p.addCommands.get(0);
System.out.println(add.solrDoc);
- assertEquals(false, add.overwrite);
+ assertFalse(add.overwrite);
assertEquals(100, add.commitWithin);
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
index 45f19dae200..b6f8cbd1f34 100644
--- a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
@@ -192,7 +192,7 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
@SuppressWarnings({"rawtypes"})
NamedList<NamedList> result =
handler.handleAnalysisRequest(request, h.getCore().getLatestSchema());
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
@SuppressWarnings({"rawtypes"})
NamedList<NamedList> fieldTypes = result.get("field_types");
@@ -521,7 +521,7 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
@SuppressWarnings({"rawtypes"})
NamedList<NamedList> result =
handler.handleAnalysisRequest(request, h.getCore().getLatestSchema());
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
@SuppressWarnings({"unchecked", "rawtypes"})
NamedList<NamedList> fieldTypes = result.get("field_types");
@@ -561,7 +561,7 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
@SuppressWarnings({"rawtypes"})
NamedList<NamedList> result =
handler.handleAnalysisRequest(request, h.getCore().getLatestSchema());
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
@SuppressWarnings({"unchecked", "rawtypes"})
NamedList<NamedList> fieldTypes = result.get("field_types");
@@ -645,7 +645,7 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
@SuppressWarnings({"rawtypes"})
NamedList<NamedList> result =
handler.handleAnalysisRequest(request, h.getCore().getLatestSchema());
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
@SuppressWarnings({"rawtypes"})
NamedList<NamedList> fieldTypes = result.get("field_types");
diff --git a/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java b/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
index ca4067c6ebe..cba62c4fd54 100644
--- a/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
@@ -467,7 +467,7 @@ public class JsonLoaderTest extends SolrTestCaseJ4 {
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(add.commitWithin, -1);
- assertEquals(add.overwrite, true);
+ assertTrue(add.overwrite);
assertEquals("SolrInputDocument(fields: [id=1, val_s={add=foo}])", add.solrDoc.toString());
req.close();
@@ -706,47 +706,47 @@ public class JsonLoaderTest extends SolrTestCaseJ4 {
assertEquals(9, p.deleteCommands.size());
DeleteUpdateCommand delete = p.deleteCommands.get(0);
assertEquals(delete.id, "10");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.commitWithin, -1);
delete = p.deleteCommands.get(1);
assertEquals(delete.id, "20");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.commitWithin, -1);
delete = p.deleteCommands.get(2);
assertEquals(delete.id, "30");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.commitWithin, -1);
delete = p.deleteCommands.get(3);
assertEquals(delete.id, "40");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.commitWithin, -1);
delete = p.deleteCommands.get(4);
assertEquals(delete.id, "50");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.getVersion(), 12345L);
delete = p.deleteCommands.get(5);
assertEquals(delete.id, "60");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.getVersion(), 67890L);
delete = p.deleteCommands.get(6);
assertEquals(delete.id, "70");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.getVersion(), 77777L);
delete = p.deleteCommands.get(7);
- assertEquals(delete.id, null);
+ assertNull(delete.id);
assertEquals(delete.query, "id:80");
assertEquals(delete.getVersion(), 88888L);
delete = p.deleteCommands.get(8);
assertEquals(delete.id, "90");
- assertEquals(delete.query, null);
+ assertNull(delete.query);
assertEquals(delete.getRoute(), "shard1");
assertEquals(delete.getVersion(), 88888L);
@@ -815,7 +815,7 @@ public class JsonLoaderTest extends SolrTestCaseJ4 {
@Test
public void testChildDocWithoutId() throws Exception {
final String json = DUP_KEYS_ANON_CHILD_DOCS_JSON.replace("\"id\": \"3\",\n", "");
- assert !json.equals(DUP_KEYS_ANON_CHILD_DOCS_JSON);
+ assertFalse(json.equals(DUP_KEYS_ANON_CHILD_DOCS_JSON));
checkTwoAnonymousChildDocs(json, false);
}
diff --git a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java
index 29b085c6049..a904a438ba4 100644
--- a/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/PingRequestHandlerTest.java
@@ -87,7 +87,7 @@ public class PingRequestHandlerTest extends SolrTestCaseJ4 {
public void testEnablingServer() throws Exception {
- assertTrue(!healthcheckFile.exists());
+ assertFalse(healthcheckFile.exists());
// first make sure that ping responds back that the service is disabled
SolrQueryResponse sqr = makeRequest(handler, req());
@@ -116,7 +116,7 @@ public class PingRequestHandlerTest extends SolrTestCaseJ4 {
public void testDisablingServer() throws Exception {
- assertTrue(!healthcheckFile.exists());
+ assertFalse(healthcheckFile.exists());
healthcheckFile.createNewFile();
diff --git a/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java b/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java
index a6523454389..ab4743f189a 100644
--- a/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java
+++ b/solr/core/src/test/org/apache/solr/handler/ReplicationTestHelper.java
@@ -16,9 +16,6 @@
*/
package org.apache.solr.handler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -111,7 +108,7 @@ public final class ReplicationTestHelper {
Long maxVersionClient2 = getVersion(client2);
if (maxVersionClient1 > 0 && maxVersionClient2 > 0) {
- assertEquals(maxVersionClient1, maxVersionClient2);
+ SolrTestCaseJ4.assertEquals(maxVersionClient1, maxVersionClient2);
}
// check vs /replication?command=indexversion call
@@ -123,13 +120,13 @@ public final class ReplicationTestHelper {
NamedList<Object> resp = client1.request(req);
assertReplicationResponseSucceeded(resp);
Long version = (Long) resp.get("indexversion");
- assertEquals(maxVersionClient1, version);
+ SolrTestCaseJ4.assertEquals(maxVersionClient1, version);
// check vs /replication?command=indexversion call
resp = client2.request(req);
assertReplicationResponseSucceeded(resp);
version = (Long) resp.get("indexversion");
- assertEquals(maxVersionClient2, version);
+ SolrTestCaseJ4.assertEquals(maxVersionClient2, version);
}
@SuppressWarnings({"unchecked"})
@@ -202,15 +199,16 @@ public final class ReplicationTestHelper {
@SuppressWarnings("unchecked")
NamedList<Object> details = (NamedList<Object>) res.get("details");
- assertNotNull("null details", details);
+ SolrTestCaseJ4.assertNotNull("null details", details);
return details;
}
public static void assertReplicationResponseSucceeded(NamedList<?> response) {
- assertNotNull("null response from server", response);
- assertNotNull("Expected replication response to have 'status' field", response.get("status"));
- assertEquals("OK", response.get("status"));
+ SolrTestCaseJ4.assertNotNull("null response from server", response);
+ SolrTestCaseJ4.assertNotNull(
+ "Expected replication response to have 'status' field", response.get("status"));
+ SolrTestCaseJ4.assertEquals("OK", response.get("status"));
}
public static void pullFromTo(String srcUrl, String destUrl) throws IOException {
diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
index 4a894b25052..ccb342ee316 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
@@ -877,7 +877,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// compare results
String cmp =
BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
// index fetch from the follower to the leader
@@ -896,7 +896,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
leaderQueryRsp = rQuery(nDocs + 3, "*:*", leaderClient);
leaderQueryResult = (SolrDocumentList) leaderQueryRsp.get("response");
cmp = BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
assertVersions(leaderClient, followerClient);
@@ -910,7 +910,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
leaderQueryRsp = rQuery(nDocs + 3, "*:*", leaderClient);
leaderQueryResult = (SolrDocumentList) leaderQueryRsp.get("response");
cmp = BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
assertVersions(leaderClient, followerClient);
@@ -932,7 +932,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
leaderQueryRsp = rQuery(nDocs + 3, "*:*", leaderClient);
leaderQueryResult = (SolrDocumentList) leaderQueryRsp.get("response");
cmp = BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
assertVersions(leaderClient, followerClient);
pullFromTo(followerJetty, leaderJetty);
@@ -945,7 +945,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
leaderQueryRsp = rQuery(nDocs + 3, "*:*", leaderClient);
leaderQueryResult = (SolrDocumentList) leaderQueryRsp.get("response");
cmp = BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
assertVersions(leaderClient, followerClient);
@@ -1031,7 +1031,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// compare results
String cmp =
BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
assertVersions(leaderClient, followerClient);
@@ -1080,7 +1080,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
livePaths.toString() + ":" + livePaths.size(),
3 == livePaths.size() || 4 == livePaths.size());
} else {
- assertTrue(livePaths.toString() + ":" + livePaths.size(), 3 == livePaths.size());
+ assertEquals(livePaths.toString() + ":" + livePaths.size(), 3, livePaths.size());
}
// :TODO: assert that one of the paths is a subpath of hte other
@@ -1093,7 +1093,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
if (afterReload) {
assertTrue("found:" + cnt + Arrays.asList(new File(ddir).list()), 1 == cnt || 2 == cnt);
} else {
- assertTrue("found:" + cnt + Arrays.asList(new File(ddir).list()), 1 == cnt);
+ assertEquals("found:" + cnt + Arrays.asList(new File(ddir).list()), 1, cnt);
}
}
}
@@ -1239,7 +1239,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// compare results
String cmp =
BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
}
@Test
@@ -1298,7 +1298,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// compare results
String cmp =
BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
} finally {
resetFactory();
@@ -1348,7 +1348,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// compare results
String cmp =
BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
Object version = getIndexVersion(leaderClient).get("indexversion");
@@ -1394,7 +1394,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
// compare results
String cmp =
BaseDistributedSearchTestCase.compare(leaderQueryResult, followerQueryResult, 0, null);
- assertEquals(null, cmp);
+ assertNull(cmp);
// start config files replication test
// clear leader index
diff --git a/solr/core/src/test/org/apache/solr/handler/TestSampleDocumentsLoader.java b/solr/core/src/test/org/apache/solr/handler/TestSampleDocumentsLoader.java
index bfb3d3960a9..6ecb27c7f02 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestSampleDocumentsLoader.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSampleDocumentsLoader.java
@@ -17,15 +17,10 @@
package org.apache.solr.handler;
-import static org.apache.solr.handler.designer.DefaultSampleDocumentsLoader.CSV_MULTI_VALUE_DELIM_PARAM;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.IOException;
import java.util.List;
+import org.apache.solr.SolrTestCase;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -40,7 +35,7 @@ import org.apache.solr.util.ExternalPaths;
import org.junit.Before;
import org.junit.Test;
-public class TestSampleDocumentsLoader {
+public class TestSampleDocumentsLoader extends SolrTestCase {
SampleDocumentsLoader loader;
File exampleDir;
@@ -63,7 +58,7 @@ public class TestSampleDocumentsLoader {
@Test
public void testCsv() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
- params.set(CSV_MULTI_VALUE_DELIM_PARAM, "\\|");
+ params.set(DefaultSampleDocumentsLoader.CSV_MULTI_VALUE_DELIM_PARAM, "\\|");
List<SolrInputDocument> docs =
loadTestDocs(params, new File(exampleDir, "films/films.csv"), -1, 1100);
boolean foundIt = false;
diff --git a/solr/core/src/test/org/apache/solr/handler/TestStressThreadBackup.java b/solr/core/src/test/org/apache/solr/handler/TestStressThreadBackup.java
index b01e3ecec66..ac560e6863a 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestStressThreadBackup.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestStressThreadBackup.java
@@ -243,8 +243,6 @@ public class TestStressThreadBackup extends SolrCloudTestCase {
// and how few iterations we have left
if (3 < namedSnapshots.size()
&& random().nextInt(3 + numBackupIters - i) < random().nextInt(namedSnapshots.size())) {
-
- assert 0 < namedSnapshots.size() : "Something broke the conditional";
final String snapshotName = namedSnapshots.poll();
final String backupName = "backup_as_of_" + snapshotName;
log.info("Creating {} from {} in iter={}", backupName, snapshotName, i);
diff --git a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
index c405a0551c8..9eb5bb845bd 100644
--- a/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/V2ClusterAPIMappingTest.java
@@ -17,11 +17,9 @@
package org.apache.solr.handler;
-import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
import static org.apache.solr.cloud.api.collections.CollectionHandlingUtils.REQUESTID;
import static org.apache.solr.common.params.CommonParams.ACTION;
import static org.apache.solr.common.params.CommonParams.NAME;
-import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -31,6 +29,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.api.Api;
import org.apache.solr.api.ApiBag;
import org.apache.solr.common.params.CollectionParams;
@@ -49,7 +48,7 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
/** Unit tests for the v2 to v1 API mappings found in {@link ClusterAPI} */
-public class V2ClusterAPIMappingTest {
+public class V2ClusterAPIMappingTest extends SolrTestCaseJ4 {
private ApiBag apiBag;
private ArgumentCaptor<SolrQueryRequest> queryRequestCaptor;
private CollectionsHandler mockCollectionsHandler;
diff --git a/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
index 2c8d11fed48..ae4b31c9d9d 100644
--- a/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/V2UpdateAPIMappingTest.java
@@ -17,9 +17,7 @@
package org.apache.solr.handler;
-import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
import static org.apache.solr.common.params.CommonParams.PATH;
-import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import com.google.common.collect.Maps;
@@ -27,6 +25,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.api.Api;
import org.apache.solr.api.ApiBag;
import org.apache.solr.common.util.CommandOperation;
@@ -39,7 +38,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
/** Unit tests for the v2 to v1 mapping logic in {@link UpdateAPI} */
-public class V2UpdateAPIMappingTest {
+public class V2UpdateAPIMappingTest extends SolrTestCaseJ4 {
private ApiBag apiBag;
private UpdateRequestHandler mockUpdateHandler;
diff --git a/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java
index 2297a3f6618..da3adaa75b3 100644
--- a/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java
@@ -99,7 +99,7 @@ public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 {
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(100, add.commitWithin);
- assertEquals(false, add.overwrite);
+ assertFalse(add.overwrite);
req.close();
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
index 870c603113b..8b2461b5c98 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/LukeRequestHandlerTest.java
@@ -257,7 +257,7 @@ public class LukeRequestHandlerTest extends SolrTestCaseJ4 {
field("title") + "/arr[@name='copyDests']/str[.='title_stemmed']",
dynfield("bar_copydest_*") + "/arr[@name='copySources']/str[.='foo_copysource_*']",
dynfield("foo_copysource_*") + "/arr[@name='copyDests']/str[.='bar_copydest_*']");
- assertEquals(xml, null, r);
+ assertNull(xml, r);
}
public void testCatchAllCopyField() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
index 53145352b1a..dd4eeb2d73e 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
@@ -736,15 +736,13 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
"solr.core.collection1:QUERY./dumphandler.dumphandlergauge"),
resp);
- assertEquals(
- null,
+ assertNull(
resp.getValues()
._getStr(
Arrays.asList(
"metrics", "solr.core.collection1:QUERY./dumphandler.dumphandlergauge", "d_k1"),
null));
- assertEquals(
- null,
+ assertNull(
resp.getValues()
._getStr(
Arrays.asList(
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java
index a35c8120953..c9335b2a7b6 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/SecurityConfHandlerTest.java
@@ -153,7 +153,7 @@ public class SecurityConfHandlerTest extends SolrTestCaseJ4 {
assertEquals(1, permissions.size());
for (Map permission : permissions) {
- assertFalse("some-permission".equals(permission.get("name")));
+ assertNotEquals("some-permission", permission.get("name"));
}
// -ve test security edit is a well-known permission, only role attribute should be provided
command =
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/SolrEnvironmentTest.java b/solr/core/src/test/org/apache/solr/handler/admin/SolrEnvironmentTest.java
index a5668bb4518..bfc02ba34a6 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/SolrEnvironmentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/SolrEnvironmentTest.java
@@ -17,13 +17,11 @@
package org.apache.solr.handler.admin;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
+import org.apache.solr.SolrTestCase;
import org.apache.solr.common.SolrException;
import org.junit.Test;
-public class SolrEnvironmentTest {
+public class SolrEnvironmentTest extends SolrTestCase {
@Test(expected = SolrException.class)
public void parseWrongKey() {
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/ThreadDumpHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/ThreadDumpHandlerTest.java
index 93250636f38..962092db5fc 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/ThreadDumpHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/ThreadDumpHandlerTest.java
@@ -117,7 +117,7 @@ public class ThreadDumpHandlerTest extends SolrTestCaseJ4 {
// (which *MAY* also be waiting on doneWithTestLatch, but may not have reached that line
// yet)
NamedList<?> monitorOwnerThreadInfo = getThreadInfo(rsp, "test-thread-monitor-owner");
- assert monitorOwnerThreadInfo != null;
+ assertNotNull(monitorOwnerThreadInfo);
assertTrue(
"Thread monitor ownerT: ",
monitorOwnerThreadInfo
@@ -145,7 +145,7 @@ public class ThreadDumpHandlerTest extends SolrTestCaseJ4 {
// same monitor owner 'ownerT'
final NamedList<?> monitorOwnerThreadInfo =
getThreadInfo(rsp, "test-thread-monitor-owner");
- assert monitorOwnerThreadInfo != null;
+ assertNotNull(monitorOwnerThreadInfo);
assertTrue(
"Same thread ownerT: ",
monitorOwnerThreadInfo
@@ -155,7 +155,7 @@ public class ThreadDumpHandlerTest extends SolrTestCaseJ4 {
// blocked thread 'blockedT', waiting on the monitor
final NamedList<?> blockedThreadInfo =
getThreadInfo(rsp, "test-thread-monitor-blocked");
- assert blockedThreadInfo != null;
+ assertNotNull(blockedThreadInfo);
assertTrue(
"blocked thread blockedT waiting on the monitor: ",
blockedThreadInfo._getStr("state", "").contains("BLOCKED")
@@ -245,7 +245,7 @@ public class ThreadDumpHandlerTest extends SolrTestCaseJ4 {
// yet)
final NamedList<?> lockOwnerThreadInfo =
getThreadInfo(rsp, "test-thread-sync-lock-owner");
- assert lockOwnerThreadInfo != null;
+ assertNotNull(lockOwnerThreadInfo);
assertTrue(
"Thread lock:",
lockOwnerThreadInfo._getStr("synchronizers-locked", "").contains("ReentrantLock"));
@@ -271,7 +271,7 @@ public class ThreadDumpHandlerTest extends SolrTestCaseJ4 {
// lock owner 'ownerT'
final NamedList<?> lockOwnerThreadInfo =
getThreadInfo(rsp, "test-thread-sync-lock-owner");
- assert lockOwnerThreadInfo != null;
+ assertNotNull(lockOwnerThreadInfo);
assertTrue(
"Thread locked: ",
lockOwnerThreadInfo
@@ -281,7 +281,7 @@ public class ThreadDumpHandlerTest extends SolrTestCaseJ4 {
// blocked thread 'blockedT', waiting on the lock
final NamedList<?> blockedThreadInfo =
getThreadInfo(rsp, "test-thread-sync-lock-blocked");
- assert blockedThreadInfo != null;
+ assertNotNull(blockedThreadInfo);
assertTrue(
"Waiting on the lock: ",
blockedThreadInfo._getStr("state", "").contains("WAITING")
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
index 38f9220344d..1cdbdc9f0fb 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/V2ApiMappingTest.java
@@ -206,9 +206,8 @@ public abstract class V2ApiMappingTest<T extends RequestHandlerBase> extends Sol
protected AnnotatedApi assertAnnotatedApiExistsFor(String method, String path) {
final AnnotatedApi api = getAnnotatedApiFor(method, path);
- assertTrue(
- "Expected to find API mapping for [" + method + " " + path + "] but none found!",
- api != null);
+ assertNotNull(
+ "Expected to find API mapping for [" + method + " " + path + "] but none found!", api);
return api;
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionBackupsAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionBackupsAPIMappingTest.java
index 57cb85d95fb..a4ff7d2ebe2 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionBackupsAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionBackupsAPIMappingTest.java
@@ -66,7 +66,7 @@ public class V2CollectionBackupsAPIMappingTest extends V2ApiMappingTest<Collecti
assertEquals("someRepository", v1Params.get(CoreAdminParams.BACKUP_REPOSITORY));
assertEquals(123, v1Params.getPrimitiveInt(CoreAdminParams.BACKUP_ID));
assertEquals(456, v1Params.getPrimitiveInt(CoreAdminParams.MAX_NUM_BACKUP_POINTS));
- assertEquals(true, v1Params.getPrimitiveBool(CoreAdminParams.BACKUP_PURGE_UNUSED));
+ assertTrue(v1Params.getPrimitiveBool(CoreAdminParams.BACKUP_PURGE_UNUSED));
assertEquals("requestTrackingId", v1Params.get(CommonAdminParams.ASYNC));
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionsAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionsAPIMappingTest.java
index bf0b2db17cb..230bf604f73 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionsAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/V2CollectionsAPIMappingTest.java
@@ -104,13 +104,12 @@ public class V2CollectionsAPIMappingTest extends V2ApiMappingTest<CollectionsHan
assertEquals(
"localhost:8983_solr,localhost:7574_solr",
v1Params.get(CollectionAdminParams.CREATE_NODE_SET_PARAM));
- assertEquals(
- true, v1Params.getPrimitiveBool(CollectionAdminParams.CREATE_NODE_SET_SHUFFLE_PARAM));
+ assertTrue(v1Params.getPrimitiveBool(CollectionAdminParams.CREATE_NODE_SET_SHUFFLE_PARAM));
assertEquals("bar", v1Params.get("property.foo"));
assertEquals("bar2", v1Params.get("property.foo2"));
assertEquals("requestTrackingId", v1Params.get(CommonAdminParams.ASYNC));
- assertEquals(false, v1Params.getPrimitiveBool(CommonAdminParams.WAIT_FOR_FINAL_STATE));
- assertEquals(false, v1Params.getPrimitiveBool(CollectionAdminParams.PER_REPLICA_STATE));
+ assertFalse(v1Params.getPrimitiveBool(CommonAdminParams.WAIT_FOR_FINAL_STATE));
+ assertFalse(v1Params.getPrimitiveBool(CollectionAdminParams.PER_REPLICA_STATE));
assertEquals(1, v1Params.getPrimitiveInt(CollectionAdminParams.NUM_SHARDS));
}
@@ -239,10 +238,10 @@ public class V2CollectionsAPIMappingTest extends V2ApiMappingTest<CollectionsHan
assertEquals("collectionName", v1Params.get(BackupManager.COLLECTION_NAME_PROP));
assertEquals("/some/location/uri", v1Params.get(CoreAdminParams.BACKUP_LOCATION));
assertEquals("someRepository", v1Params.get(CoreAdminParams.BACKUP_REPOSITORY));
- assertEquals(true, v1Params.getPrimitiveBool(CollectionAdminParams.FOLLOW_ALIASES));
+ assertTrue(v1Params.getPrimitiveBool(CollectionAdminParams.FOLLOW_ALIASES));
assertEquals("copy-files", v1Params.get(CollectionAdminParams.INDEX_BACKUP_STRATEGY));
assertEquals("someSnapshotName", v1Params.get(CoreAdminParams.COMMIT_NAME));
- assertEquals(true, v1Params.getPrimitiveBool(CoreAdminParams.BACKUP_INCREMENTAL));
+ assertTrue(v1Params.getPrimitiveBool(CoreAdminParams.BACKUP_INCREMENTAL));
assertEquals("requestTrackingId", v1Params.get(CommonAdminParams.ASYNC));
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java
index fe847b20d89..6c692880ec8 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/V2CoresAPIMappingTest.java
@@ -111,8 +111,8 @@ public class V2CoresAPIMappingTest extends V2ApiMappingTest<CoreAdminHandler> {
assertEquals("some-schema-file-name", v1Params.get(SCHEMA));
assertEquals("some-config-file-name", v1Params.get(CONFIG));
assertEquals("someConfigSetName", v1Params.get(CONFIGSET));
- assertEquals(true, v1Params.getPrimitiveBool(LOAD_ON_STARTUP));
- assertEquals(true, v1Params.getPrimitiveBool(TRANSIENT));
+ assertTrue(v1Params.getPrimitiveBool(LOAD_ON_STARTUP));
+ assertTrue(v1Params.getPrimitiveBool(TRANSIENT));
assertEquals("someShardName", v1Params.get(SHARD));
assertEquals("someCollectionName", v1Params.get(COLLECTION));
assertEquals("TLOG", v1Params.get(REPLICA_TYPE));
@@ -121,7 +121,7 @@ public class V2CoresAPIMappingTest extends V2ApiMappingTest<CoreAdminHandler> {
assertEquals("role1,role2", v1Params.get(ROLES));
assertEquals("val1", v1Params.get("property.prop1"));
assertEquals("val2", v1Params.get("property.prop2"));
- assertEquals(true, v1Params.getPrimitiveBool(NEW_COLLECTION));
+ assertTrue(v1Params.getPrimitiveBool(NEW_COLLECTION));
assertEquals("requestTrackingId", v1Params.get(ASYNC));
}
@@ -133,7 +133,7 @@ public class V2CoresAPIMappingTest extends V2ApiMappingTest<CoreAdminHandler> {
assertEquals(STATUS.name().toLowerCase(Locale.ROOT), v1Params.get(ACTION));
assertEquals("someCore", v1Params.get(CORE));
- assertEquals(true, v1Params.getPrimitiveBool(INDEX_INFO));
+ assertTrue(v1Params.getPrimitiveBool(INDEX_INFO));
}
@Test
@@ -143,6 +143,6 @@ public class V2CoresAPIMappingTest extends V2ApiMappingTest<CoreAdminHandler> {
assertEquals(STATUS.name().toLowerCase(Locale.ROOT), v1Params.get(ACTION));
assertNull("Expected 'core' parameter to be null", v1Params.get(CORE));
- assertEquals(true, v1Params.getPrimitiveBool(INDEX_INFO));
+ assertTrue(v1Params.getPrimitiveBool(INDEX_INFO));
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/V2CollectionAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/V2CollectionAPIMappingTest.java
index 7724f530588..e57e6d4829f 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/V2CollectionAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/V2CollectionAPIMappingTest.java
@@ -97,7 +97,7 @@ public class V2CollectionAPIMappingTest extends V2ApiMappingTest<CollectionsHand
CollectionParams.CollectionAction.MODIFYCOLLECTION.lowerName, v1Params.get(ACTION));
assertEquals("collName", v1Params.get(COLLECTION));
assertEquals(123, v1Params.getPrimitiveInt(ZkStateReader.REPLICATION_FACTOR));
- assertEquals(true, v1Params.getPrimitiveBool(ZkStateReader.READ_ONLY));
+ assertTrue(v1Params.getPrimitiveBool(ZkStateReader.READ_ONLY));
assertEquals("techproducts_config", v1Params.get(COLL_CONF));
assertEquals("requestTrackingId", v1Params.get(ASYNC));
assertEquals("bar", v1Params.get("property.foo"));
@@ -138,10 +138,10 @@ public class V2CollectionAPIMappingTest extends V2ApiMappingTest<CollectionsHand
assertEquals("someTargetNode", v1Params.get("targetNode"));
assertEquals("someReplica", v1Params.get("replica"));
assertEquals("someShard", v1Params.get("shard"));
- assertEquals(true, v1Params.getPrimitiveBool("waitForFinalState"));
+ assertTrue(v1Params.getPrimitiveBool("waitForFinalState"));
assertEquals(123, v1Params.getPrimitiveInt("timeout"));
- assertEquals(true, v1Params.getPrimitiveBool("inPlaceMove"));
- assertEquals(true, v1Params.getPrimitiveBool("followAliases"));
+ assertTrue(v1Params.getPrimitiveBool("inPlaceMove"));
+ assertTrue(v1Params.getPrimitiveBool("followAliases"));
}
@Test
@@ -163,7 +163,7 @@ public class V2CollectionAPIMappingTest extends V2ApiMappingTest<CollectionsHand
assertEquals("someTargetCollection", v1Params.get("target.collection"));
assertEquals("someSplitKey", v1Params.get("split.key"));
assertEquals(123, v1Params.getPrimitiveInt("forward.timeout"));
- assertEquals(true, v1Params.getPrimitiveBool("followAliases"));
+ assertTrue(v1Params.getPrimitiveBool("followAliases"));
assertEquals("requestTrackingId", v1Params.get(ASYNC));
}
@@ -183,8 +183,8 @@ public class V2CollectionAPIMappingTest extends V2ApiMappingTest<CollectionsHand
CollectionParams.CollectionAction.BALANCESHARDUNIQUE.lowerName, v1Params.get(ACTION));
assertEquals("collName", v1Params.get(COLLECTION));
assertEquals("somePropertyToBalance", v1Params.get("property"));
- assertEquals(false, v1Params.getPrimitiveBool("onlyactivenodes"));
- assertEquals(true, v1Params.getPrimitiveBool("shardUnique"));
+ assertFalse(v1Params.getPrimitiveBool("onlyactivenodes"));
+ assertTrue(v1Params.getPrimitiveBool("shardUnique"));
}
@Test
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java
index fc5ffb51a9e..e6ecf9fd903 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/V2CoreAPIMappingTest.java
@@ -215,9 +215,9 @@ public class V2CoreAPIMappingTest extends V2ApiMappingTest<CoreAdminHandler> {
assertEquals("someNodeName", v1Params.get("nodeName"));
assertEquals("someCoreNodeName", v1Params.get(CORE_NODE_NAME));
assertEquals("someState", v1Params.get(ZkStateReader.STATE_PROP));
- assertEquals(true, v1Params.getPrimitiveBool("checkLive"));
- assertEquals(true, v1Params.getPrimitiveBool("onlyIfLeader"));
- assertEquals(true, v1Params.getPrimitiveBool("onlyIfLeaderActive"));
+ assertTrue(v1Params.getPrimitiveBool("checkLive"));
+ assertTrue(v1Params.getPrimitiveBool("onlyIfLeader"));
+ assertTrue(v1Params.getPrimitiveBool("onlyIfLeaderActive"));
}
@Test
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
index caa3882302f..fb133c63297 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/V2NodeAPIMappingTest.java
@@ -17,10 +17,7 @@
package org.apache.solr.handler.admin.api;
-import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
import static org.apache.solr.common.params.CommonParams.ACTION;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -32,6 +29,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.api.Api;
import org.apache.solr.api.ApiBag;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -55,7 +53,7 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
/** Unit tests for the v2 to v1 mapping for /node/ APIs. */
-public class V2NodeAPIMappingTest {
+public class V2NodeAPIMappingTest extends SolrTestCaseJ4 {
private ApiBag apiBag;
private ArgumentCaptor<SolrQueryRequest> queryRequestCaptor;
private CoreAdminHandler mockCoresHandler;
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/api/V2ShardsAPIMappingTest.java b/solr/core/src/test/org/apache/solr/handler/admin/api/V2ShardsAPIMappingTest.java
index 895b95a348d..a76de226675 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/api/V2ShardsAPIMappingTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/api/V2ShardsAPIMappingTest.java
@@ -150,12 +150,12 @@ public class V2ShardsAPIMappingTest extends V2ApiMappingTest<CollectionsHandler>
assertEquals("someSplitKey", v1Params.get(SPLIT_KEY));
assertEquals(123, v1Params.getPrimitiveInt(NUM_SUB_SHARDS));
assertEquals("some_fuzz_value", v1Params.get(SPLIT_FUZZ));
- assertEquals(true, v1Params.getPrimitiveBool(TIMING));
- assertEquals(true, v1Params.getPrimitiveBool(SPLIT_BY_PREFIX));
- assertEquals(true, v1Params.getPrimitiveBool(FOLLOW_ALIASES));
+ assertTrue(v1Params.getPrimitiveBool(TIMING));
+ assertTrue(v1Params.getPrimitiveBool(SPLIT_BY_PREFIX));
+ assertTrue(v1Params.getPrimitiveBool(FOLLOW_ALIASES));
assertEquals("rewrite", v1Params.get(SPLIT_METHOD));
assertEquals("some_async_id", v1Params.get(ASYNC));
- assertEquals(true, v1Params.getPrimitiveBool(WAIT_FOR_FINAL_STATE));
+ assertTrue(v1Params.getPrimitiveBool(WAIT_FOR_FINAL_STATE));
assertEquals("foo1", v1Params.get("property.foo"));
assertEquals("bar1", v1Params.get("property.bar"));
}
@@ -185,9 +185,9 @@ public class V2ShardsAPIMappingTest extends V2ApiMappingTest<CollectionsHandler>
assertEquals("collName", v1Params.get(COLLECTION));
assertEquals("shard1", v1Params.get(SHARD_ID_PROP));
assertEquals("foo,bar,baz", v1Params.get(CREATE_NODE_SET_PARAM));
- assertEquals(true, v1Params.getPrimitiveBool(FOLLOW_ALIASES));
+ assertTrue(v1Params.getPrimitiveBool(FOLLOW_ALIASES));
assertEquals("some_async_id", v1Params.get(ASYNC));
- assertEquals(true, v1Params.getPrimitiveBool(WAIT_FOR_FINAL_STATE));
+ assertTrue(v1Params.getPrimitiveBool(WAIT_FOR_FINAL_STATE));
assertEquals(123, v1Params.getPrimitiveInt(REPLICATION_FACTOR));
assertEquals(456, v1Params.getPrimitiveInt(NRT_REPLICAS));
assertEquals(789, v1Params.getPrimitiveInt(TLOG_REPLICAS));
@@ -231,10 +231,10 @@ public class V2ShardsAPIMappingTest extends V2ApiMappingTest<CollectionsHandler>
assertEquals("dir1", v1Params.get("instanceDir"));
assertEquals("dir2", v1Params.get("dataDir"));
assertEquals("dir3", v1Params.get("ulogDir"));
- assertEquals(true, v1Params.getPrimitiveBool(FOLLOW_ALIASES));
+ assertTrue(v1Params.getPrimitiveBool(FOLLOW_ALIASES));
assertEquals("some_async_id", v1Params.get(ASYNC));
- assertEquals(true, v1Params.getPrimitiveBool(WAIT_FOR_FINAL_STATE));
- assertEquals(true, v1Params.getPrimitiveBool("skipNodeAssignment"));
+ assertTrue(v1Params.getPrimitiveBool(WAIT_FOR_FINAL_STATE));
+ assertTrue(v1Params.getPrimitiveBool("skipNodeAssignment"));
assertEquals("tlog", v1Params.get("type"));
assertEquals("foo1", v1Params.get("property.foo"));
assertEquals("bar1", v1Params.get("property.bar"));
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
index bf95cbbc302..58cbe43717d 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
@@ -464,7 +464,7 @@ public class DistributedDebugComponentTest extends SolrJettyTestBase {
for (String element : elements) {
String value = namedList.get(element);
assertNotNull("Expected element '" + element + "' but was not found", value);
- assertTrue("Expected element '" + element + "' but was empty", !value.isEmpty());
+ assertFalse("Expected element '" + element + "' but was empty", value.isEmpty());
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.java
index 69060841a6a..2afc6ea3b8b 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotLongTailTest.java
@@ -161,7 +161,7 @@ public class DistributedFacetPivotLongTailTest extends BaseDistributedSearchTest
}
{ // even w/o the long tail, we should have still asked shard2 to refine bbb0
pivot = pivots.get(5);
- assertTrue(pivot.toString(), pivot.getValue().equals("bbb0"));
+ assertEquals(pivot.toString(), "bbb0", pivot.getValue());
assertEquals(pivot.toString(), 101, pivot.getCount());
// basic check of refined stats
FieldStatsInfo bbb0Stats = pivot.getFieldStatsInfo().get(STAT_FIELD);
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.java
index 8ae9929b557..bb9959cf2f3 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallAdvancedTest.java
@@ -272,13 +272,14 @@ public class DistributedFacetPivotSmallAdvancedTest extends BaseDistributedSearc
.get("place_t,company_t")
.get(0)
.getValue();
- assertFalse(
+ assertNotEquals(
"both shards have same top constraint, test is invalid"
+ "(did someone change the test data?) ==> "
+ s0pivValue
+ "=="
+ s1pivValue,
- s0pivValue.equals(s1pivValue));
+ s0pivValue,
+ s1pivValue);
}
private void doTestDeepPivotStatsOnString() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.java
index ff77a3186b3..83a51980349 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedFacetPivotSmallTest.java
@@ -490,8 +490,8 @@ public class DistributedFacetPivotSmallTest extends BaseDistributedSearchTestCas
assertNull(krakowFujitsuStatsInfo.getSumOfSquares());
assertNull(krakowFujitsuStatsInfo.getStddev());
} else {
- assertEquals(null, krakowFujitsuStatsInfo.getMin());
- assertEquals(null, krakowFujitsuStatsInfo.getMax());
+ assertNull(krakowFujitsuStatsInfo.getMin());
+ assertNull(krakowFujitsuStatsInfo.getMax());
assertEquals(0, (long) krakowFujitsuStatsInfo.getCount());
assertEquals(1, (long) krakowFujitsuStatsInfo.getMissing());
assertEquals(0.0, krakowFujitsuStatsInfo.getSum());
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java
index 1982d5089b6..5f00e3f4264 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java
@@ -608,9 +608,10 @@ public class DistributedQueryComponentOptimizationTest extends SolrCloudTestCase
for (int i = 0; i < q.length; i += 2) {
if (ShardParams.DISTRIB_SINGLE_PASS.equals(q[i].toString())
&& Boolean.parseBoolean(q[i + 1].toString())) {
- assertTrue(
+ assertEquals(
"distrib.singlePass=true made more requests than number of shards",
- numRequests == sliceCount);
+ sliceCount,
+ numRequests);
distribSinglePass = true;
}
if (CommonParams.FL.equals(q[i].toString())) {
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
index b5d19730109..72fd63f1004 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
@@ -26,7 +26,6 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SpellingParams;
import org.apache.solr.common.util.NamedList;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -79,7 +78,7 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes
explicitNumSuggestExpected,
Integer.toString(sug.size()));
} else if (sug.size() == 0) {
- Assert.fail("Control data did not return any suggestions.");
+ fail("Control data did not return any suggestions.");
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.java
index 832f8a3e9e3..f916427d6ae 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedSuggestComponentTest.java
@@ -24,7 +24,6 @@ import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.spelling.suggest.SuggesterParams;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -57,7 +56,7 @@ public class DistributedSuggestComponentTest extends BaseDistributedSearchTestCa
(NamedList<SimpleOrderedMap<NamedList<Object>>>) nl.get("suggest");
String command = (String) nl.get("command");
if (sc.size() == 0 && command == null) {
- Assert.fail("Control data did not return any suggestions or execute any command");
+ fail("Control data did not return any suggestions or execute any command");
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java
index 10f57fb5515..ed3fd4a9880 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/PhrasesIdentificationComponentTest.java
@@ -239,7 +239,7 @@ public class PhrasesIdentificationComponentTest extends SolrTestCaseJ4 {
final int inputPositionLength,
final int maxIndexedPositionLength,
final int maxQueryPositionLength) {
- assert 0 < phrases.size() : "Don't use this method if phrases might be empty";
+ assertTrue("Don't use this method if phrases might be empty", 0 < phrases.size());
assertEmptyStream(
"no phrase should be longer then " + maxQueryPositionLength + " positions",
diff --git a/solr/core/src/test/org/apache/solr/handler/component/ShardsAllowListTest.java b/solr/core/src/test/org/apache/solr/handler/component/ShardsAllowListTest.java
index 39458e7dc19..f54536d314e 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/ShardsAllowListTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/ShardsAllowListTest.java
@@ -308,7 +308,7 @@ public class ShardsAllowListTest extends MultiSolrCloudTestCase {
q.set("shards", shardsParamValue);
}
if (otherParams != null) {
- assert otherParams.length % 2 == 0;
+ assertEquals(0, otherParams.length % 2);
for (int i = 0; i < otherParams.length; i += 2) {
q.set(otherParams[i], otherParams[i + 1]);
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
index 56911b30a05..4a0eda8e506 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
@@ -609,7 +609,7 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
// TODO: how do we make this into a 1-liner using "assertQ()" ???
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -627,8 +627,8 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
NamedList<?> values = rsp.getValues();
NamedList<?> spellCheck = (NamedList<?>) values.get("spellcheck");
NamedList<?> suggestions = (NamedList<?>) spellCheck.get("suggestions");
- assertTrue(suggestions.get("suggestion") == null);
- assertTrue((Boolean) spellCheck.get("correctlySpelled") == false);
+ assertNull(suggestions.get("suggestion"));
+ assertFalse((Boolean) spellCheck.get("correctlySpelled"));
params.remove(SpellingParams.SPELLCHECK_DICT);
params.add(SpellingParams.SPELLCHECK_DICT, "threshold_direct");
@@ -640,7 +640,7 @@ public class SpellCheckComponentTest extends SolrTestCaseJ4 {
values = rsp.getValues();
spellCheck = (NamedList<?>) values.get("spellcheck");
suggestions = (NamedList<?>) spellCheck.get("suggestions");
- assertTrue(suggestions.get("suggestion") == null);
- assertTrue((Boolean) spellCheck.get("correctlySpelled") == false);
+ assertNull(suggestions.get("suggestion"));
+ assertFalse((Boolean) spellCheck.get("correctlySpelled"));
}
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
index a0a9f733a50..8519dbaa0fe 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
@@ -1019,9 +1019,9 @@ public class StatsComponentTest extends SolrTestCaseJ4 {
assertTrue(
"schema no longer satisfies test requirements: foo_ss no longer multivalued",
foo_ss.multiValued());
- assertTrue(
+ assertFalse(
"schema no longer satisfies test requirements: foo_ss's fieldtype no longer single valued",
- !foo_ss.getType().isMultiValued());
+ foo_ss.getType().isMultiValued());
assertQEx(
"no failure trying to get stats facet on foo_ss",
@@ -1078,9 +1078,9 @@ public class StatsComponentTest extends SolrTestCaseJ4 {
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer multivalued",
catDocValues.multiValued());
- assertTrue(
+ assertFalse(
"schema no longer satisfies test requirements: cat_docValues fieldtype no longer single valued",
- !catDocValues.getType().isMultiValued());
+ catDocValues.getType().isMultiValued());
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer has docValues",
catDocValues.hasDocValues());
@@ -1128,9 +1128,9 @@ public class StatsComponentTest extends SolrTestCaseJ4 {
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer multivalued",
catDocValues.multiValued());
- assertTrue(
+ assertFalse(
"schema no longer satisfies test requirements: cat_docValues fieldtype no longer single valued",
- !catDocValues.getType().isMultiValued());
+ catDocValues.getType().isMultiValued());
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer has docValues",
catDocValues.hasDocValues());
@@ -1186,9 +1186,9 @@ public class StatsComponentTest extends SolrTestCaseJ4 {
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer multivalued",
catDocValues.multiValued());
- assertTrue(
+ assertFalse(
"schema no longer satisfies test requirements: cat_docValues fieldtype no longer single valued",
- !catDocValues.getType().isMultiValued());
+ catDocValues.getType().isMultiValued());
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer has docValues",
catDocValues.hasDocValues());
@@ -1311,9 +1311,9 @@ public class StatsComponentTest extends SolrTestCaseJ4 {
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer multivalued",
catDocValues.multiValued());
- assertTrue(
+ assertFalse(
"schema no longer satisfies test requirements: cat_docValues fieldtype no longer single valued",
- !catDocValues.getType().isMultiValued());
+ catDocValues.getType().isMultiValued());
assertTrue(
"schema no longer satisfies test requirements: cat_docValues no longer has docValues",
catDocValues.hasDocValues());
diff --git a/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
index ba041108157..764448dbb92 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/TermsComponentTest.java
@@ -725,7 +725,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
i += count;
// if (i < 10) System.out.println("COUNT=" + count + " OBJ="+v.toObject());
}
- assert (i == nvals);
+ assertEquals(i, nvals);
totBuff = random().nextInt(50) + 1;
minSegBuff = random().nextInt(10) + 1;
@@ -741,7 +741,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
i += count;
// if (i < 10) System.out.println("COUNT=" + count + " OBJ="+v.toObject());
}
- assert (i == nvals);
+ assertEquals(i, nvals);
totBuff = random().nextInt(50) + 1;
minSegBuff = random().nextInt(10) + 1;
@@ -757,7 +757,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
i += count;
// if (i < 10) System.out.println("COUNT=" + count + " OBJ="+v.toObject());
}
- assert (i == nvals);
+ assertEquals(i, nvals);
totBuff = random().nextInt(50) + 1;
minSegBuff = random().nextInt(10) + 1;
@@ -773,7 +773,7 @@ public class TermsComponentTest extends SolrTestCaseJ4 {
i += count;
// if (i < 10) System.out.println("COUNT=" + count + " OBJ="+v.toObject());
}
- assert (i == nvals);
+ assertEquals(i, nvals);
assertQ(
req(
diff --git a/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java b/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
index c9995fd2d7c..a860ac7c9ef 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/TestTrackingShardHandlerFactory.java
@@ -61,7 +61,7 @@ public class TestTrackingShardHandlerFactory extends AbstractFullDistribZkTestBa
for (JettySolrRunner runner : runners) {
CoreContainer container = runner.getCoreContainer();
ShardHandlerFactory factory = container.getShardHandlerFactory();
- assert factory instanceof TrackingShardHandlerFactory;
+ assertTrue(factory instanceof TrackingShardHandlerFactory);
@SuppressWarnings("resource")
TrackingShardHandlerFactory trackingShardHandlerFactory =
(TrackingShardHandlerFactory) factory;
@@ -130,7 +130,7 @@ public class TestTrackingShardHandlerFactory extends AbstractFullDistribZkTestBa
for (JettySolrRunner runner : runners) {
CoreContainer container = runner.getCoreContainer();
ShardHandlerFactory factory = container.getShardHandlerFactory();
- assert factory instanceof TrackingShardHandlerFactory;
+ assertTrue(factory instanceof TrackingShardHandlerFactory);
@SuppressWarnings("resource")
TrackingShardHandlerFactory trackingShardHandlerFactory =
(TrackingShardHandlerFactory) factory;
diff --git a/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java b/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java
index 567622cfe20..a53521bfec9 100644
--- a/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/designer/ManagedSchemaDiffTest.java
@@ -33,7 +33,6 @@ import org.apache.solr.schema.IntPointField;
import org.apache.solr.schema.ManagedIndexSchema;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.util.ExternalPaths;
-import org.junit.Assert;
import org.junit.BeforeClass;
public class ManagedSchemaDiffTest extends SolrCloudTestCase {
@@ -62,29 +61,29 @@ public class ManagedSchemaDiffTest extends SolrCloudTestCase {
Map<String, Object> diff =
ManagedSchemaDiff.diff(
mapFieldsToPropertyValues(schema1FieldMap), mapFieldsToPropertyValues(schema2FieldMap));
- Assert.assertTrue(diff.containsKey("updated"));
- Assert.assertTrue(diff.containsKey("added"));
- Assert.assertTrue(diff.containsKey("removed"));
+ assertTrue(diff.containsKey("updated"));
+ assertTrue(diff.containsKey("added"));
+ assertTrue(diff.containsKey("removed"));
Map<String, Object> changedFields = getInnerMap(diff, "updated");
- Assert.assertEquals(1, changedFields.size());
- Assert.assertTrue(changedFields.containsKey("strfield"));
- Assert.assertEquals(
+ assertEquals(1, changedFields.size());
+ assertTrue(changedFields.containsKey("strfield"));
+ assertEquals(
Arrays.asList(
Map.of("type", "string", "multiValued", false),
Map.of("type", "strings", "multiValued", true)),
changedFields.get("strfield"));
Map<String, Object> addedFields = getInnerMap(diff, "added");
- Assert.assertEquals(1, addedFields.size());
- Assert.assertTrue(addedFields.containsKey("intfield"));
- Assert.assertEquals(
+ assertEquals(1, addedFields.size());
+ assertTrue(addedFields.containsKey("intfield"));
+ assertEquals(
schema2FieldMap.get("intfield").getNamedPropertyValues(true), addedFields.get("intfield"));
Map<String, Object> removedFields = getInnerMap(diff, "removed");
- Assert.assertEquals(1, removedFields.size());
- Assert.assertTrue(removedFields.containsKey("boolfield"));
- Assert.assertEquals(
+ assertEquals(1, removedFields.size());
+ assertTrue(removedFields.containsKey("boolfield"));
+ assertEquals(
schema1FieldMap.get("boolfield").getNamedPropertyValues(true),
removedFields.get("boolfield"));
}
@@ -110,10 +109,10 @@ public class ManagedSchemaDiffTest extends SolrCloudTestCase {
List<SimpleOrderedMap<Object>> list2 = Arrays.asList(obj1, obj3, obj4);
Map<String, Object> diff = ManagedSchemaDiff.diff(list1, list2);
- Assert.assertTrue(diff.containsKey("old"));
- Assert.assertTrue(diff.containsKey("new"));
- Assert.assertEquals(Collections.singletonList(obj2), diff.get("old"));
- Assert.assertEquals(Arrays.asList(obj3, obj4), diff.get("new"));
+ assertTrue(diff.containsKey("old"));
+ assertTrue(diff.containsKey("new"));
+ assertEquals(Collections.singletonList(obj2), diff.get("old"));
+ assertEquals(Arrays.asList(obj3, obj4), diff.get("new"));
}
@SuppressWarnings("unchecked")
diff --git a/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java b/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java
index 3dd83702f10..7d0cf5e4e6a 100644
--- a/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java
+++ b/solr/core/src/test/org/apache/solr/handler/export/TestExportWriter.java
@@ -1048,11 +1048,11 @@ public class TestExportWriter extends SolrTestCaseJ4 {
String field = "number_" + type + mv + indexed;
SchemaField sf = h.getCore().getLatestSchema().getField(field + "_t");
assertTrue(sf.hasDocValues());
- assertTrue(sf.getType().getNumberType() != null);
+ assertNotNull(sf.getType().getNumberType());
sf = h.getCore().getLatestSchema().getField(field + "_p");
assertTrue(sf.hasDocValues());
- assertTrue(sf.getType().getNumberType() != null);
+ assertNotNull(sf.getType().getNumberType());
assertTrue(sf.getType().isPointField());
trieFields.add(field + "_t");
@@ -1354,7 +1354,7 @@ public class TestExportWriter extends SolrTestCaseJ4 {
Map rsp = (Map) Utils.fromJSONString(response);
List doclist = (List) (((Map) rsp.get("response")).get("docs"));
- assert docs.size() == numDocs;
+ assertEquals(docs.size(), numDocs);
for (int i = 0; i < docs.size() - 1; i++) { // docs..
assertEquals(
diff --git a/solr/core/src/test/org/apache/solr/handler/loader/JavabinLoaderTest.java b/solr/core/src/test/org/apache/solr/handler/loader/JavabinLoaderTest.java
index b4d4b22e66a..66ac7c724db 100644
--- a/solr/core/src/test/org/apache/solr/handler/loader/JavabinLoaderTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/loader/JavabinLoaderTest.java
@@ -87,7 +87,7 @@ public class JavabinLoaderTest extends SolrTestCaseJ4 {
mockUpdateProcessor);
req.close();
- assertTrue(mockUpdateProcessor.addCommands.size() == numDocsInBatch);
+ assertEquals(mockUpdateProcessor.addCommands.size(), numDocsInBatch);
for (int i = 0; i < numDocsInBatch - 1; i++)
assertFalse(mockUpdateProcessor.addCommands.get(i).isLastDocInBatch); // not last doc in batch
diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java b/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java
index f4b8368dfb5..2b366f11311 100644
--- a/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/tagger/RandomizedTaggerTest.java
@@ -113,7 +113,7 @@ public class RandomizedTaggerTest extends TaggerTestCase {
}
private void assertBruteForce(String input) throws Exception {
- assert input.matches(" .* ");
+ assertTrue(input.matches(" .* "));
baseParams.set("overlaps", "ALL");
// loop through NAMES and find all tag offsets
diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTest.java b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTest.java
index 106f96e87fa..d8ce050dc07 100644
--- a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTest.java
@@ -303,14 +303,14 @@ public class TaggerTest extends TaggerTestCase {
}
private TestTag tt(String doc, String substring, int substringIndex, N name) {
- assert substringIndex == 0;
+ assertEquals(0, substringIndex);
// little bit of copy-paste code from super.tt()
int startOffset = -1, endOffset;
int substringIndex1 = 0;
for (int i = 0; i <= substringIndex1; i++) {
startOffset = doc.indexOf(substring, ++startOffset);
- assert startOffset >= 0 : "The test itself is broken";
+ assertTrue("The test itself is broken", startOffset >= 0);
}
endOffset = startOffset + substring.length(); // 1 greater (exclusive)
return new TestTag(startOffset, endOffset, substring, lookupByName(name.getName()));
diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java
index f48e3f5a1ab..2f22e0de4c5 100644
--- a/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java
+++ b/solr/core/src/test/org/apache/solr/handler/tagger/TaggerTestCase.java
@@ -112,7 +112,7 @@ public abstract class TaggerTestCase extends SolrTestCaseJ4 {
int substringIndex = 0;
for (int i = 0; i <= substringIndex; i++) {
startOffset = doc.indexOf(substring, ++startOffset);
- assert startOffset >= 0 : "The test itself is broken";
+ assertTrue("The test itself is broken", startOffset >= 0);
}
endOffset = startOffset + substring.length(); // 1 greater (exclusive)
return new TestTag(startOffset, endOffset, substring, lookupByName(substring));
diff --git a/solr/core/src/test/org/apache/solr/internal/csv/CSVParserTest.java b/solr/core/src/test/org/apache/solr/internal/csv/CSVParserTest.java
index 801e282b118..ab558c50c9f 100644
--- a/solr/core/src/test/org/apache/solr/internal/csv/CSVParserTest.java
+++ b/solr/core/src/test/org/apache/solr/internal/csv/CSVParserTest.java
@@ -19,7 +19,6 @@ package org.apache.solr.internal.csv;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
-import java.util.Arrays;
import org.apache.solr.SolrTestCase;
/**
@@ -218,10 +217,10 @@ public class CSVParserTest extends SolrTestCase {
String[] tmp = null;
for (String[] re : res) {
tmp = parser.getLine();
- assertTrue(Arrays.equals(re, tmp));
+ assertArrayEquals(re, tmp);
}
tmp = parser.getLine();
- assertTrue(tmp == null);
+ assertNull(tmp);
}
public void testNextValue() throws IOException {
@@ -234,7 +233,7 @@ public class CSVParserTest extends SolrTestCase {
}
}
tmp = parser.nextValue();
- assertTrue(tmp == null);
+ assertNull(tmp);
}
public void testGetAllValues() throws IOException {
@@ -243,7 +242,7 @@ public class CSVParserTest extends SolrTestCase {
assertEquals(res.length, tmp.length);
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
@@ -263,7 +262,7 @@ public class CSVParserTest extends SolrTestCase {
assertEquals(res.length, tmp.length);
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
@@ -281,7 +280,7 @@ public class CSVParserTest extends SolrTestCase {
assertEquals(res.length, tmp.length);
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
@@ -307,7 +306,7 @@ public class CSVParserTest extends SolrTestCase {
assertEquals(res.length, tmp.length);
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
}
@@ -334,7 +333,7 @@ public class CSVParserTest extends SolrTestCase {
assertEquals(res.length, tmp.length);
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
}
@@ -354,7 +353,7 @@ public class CSVParserTest extends SolrTestCase {
assertEquals(res.length, tmp.length);
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
}
@@ -372,7 +371,7 @@ public class CSVParserTest extends SolrTestCase {
assertEquals(res.length, tmp.length);
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
}
@@ -416,7 +415,7 @@ public class CSVParserTest extends SolrTestCase {
String[][] tmp = parser.getAllValues();
assertTrue(tmp.length > 0);
for (int i = 0; i < res.length; i++) {
- assertTrue(Arrays.equals(res[i], tmp[i]));
+ assertArrayEquals(res[i], tmp[i]);
}
}
@@ -455,7 +454,7 @@ public class CSVParserTest extends SolrTestCase {
assertTrue(tmp.length > 0);
if (!CSVPrinterTest.equals(res, tmp)) {
- assertTrue(false);
+ fail();
}
}
@@ -481,7 +480,7 @@ public class CSVParserTest extends SolrTestCase {
assertTrue(tmp.length > 0);
if (!CSVPrinterTest.equals(res, tmp)) {
- assertTrue(false);
+ fail();
}
String[][] res_comments = {
@@ -495,7 +494,7 @@ public class CSVParserTest extends SolrTestCase {
tmp = parser.getAllValues();
if (!CSVPrinterTest.equals(res_comments, tmp)) {
- assertTrue(false);
+ fail();
}
}
@@ -542,7 +541,7 @@ public class CSVParserTest extends SolrTestCase {
parser = new CSVParser(new StringReader(code));
CSVParser parser1 = new CSVParser(new StringReader(code));
for (String[] datum : data) {
- assertTrue(Arrays.equals(parser1.getLine(), datum));
+ assertArrayEquals(parser1.getLine(), datum);
for (String d : datum) {
assertEquals(parser.nextValue(), d);
}
diff --git a/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java b/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java
index 72038c44779..ee7e7507ffb 100644
--- a/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java
+++ b/solr/core/src/test/org/apache/solr/internal/csv/CSVPrinterTest.java
@@ -131,7 +131,7 @@ public class CSVPrinterTest extends SolrTestCase {
if (!equals(lines, parseResult)) {
System.out.println("Printer output :" + printable(result));
- assertTrue(false);
+ fail();
}
}
diff --git a/solr/core/src/test/org/apache/solr/internal/csv/CSVStrategyTest.java b/solr/core/src/test/org/apache/solr/internal/csv/CSVStrategyTest.java
index 9163ac7a32e..e9fd504b551 100644
--- a/solr/core/src/test/org/apache/solr/internal/csv/CSVStrategyTest.java
+++ b/solr/core/src/test/org/apache/solr/internal/csv/CSVStrategyTest.java
@@ -52,16 +52,16 @@ public class CSVStrategyTest extends SolrTestCase {
assertEquals(strategy.getDelimiter(), ',');
assertEquals(strategy.getEncapsulator(), '"');
assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
- assertEquals(true, strategy.getIgnoreLeadingWhitespaces());
- assertEquals(false, strategy.getUnicodeEscapeInterpretation());
- assertEquals(true, strategy.getIgnoreEmptyLines());
+ assertTrue(strategy.getIgnoreLeadingWhitespaces());
+ assertFalse(strategy.getUnicodeEscapeInterpretation());
+ assertTrue(strategy.getIgnoreEmptyLines());
// explicit csv settings
assertEquals(strategy.getDelimiter(), ',');
assertEquals(strategy.getEncapsulator(), '"');
assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
- assertEquals(true, strategy.getIgnoreLeadingWhitespaces());
- assertEquals(false, strategy.getUnicodeEscapeInterpretation());
- assertEquals(true, strategy.getIgnoreEmptyLines());
+ assertTrue(strategy.getIgnoreLeadingWhitespaces());
+ assertFalse(strategy.getUnicodeEscapeInterpretation());
+ assertTrue(strategy.getIgnoreEmptyLines());
}
public void testSetExcelStrategy() {
@@ -69,8 +69,8 @@ public class CSVStrategyTest extends SolrTestCase {
assertEquals(strategy.getDelimiter(), ',');
assertEquals(strategy.getEncapsulator(), '"');
assertEquals(strategy.getCommentStart(), CSVStrategy.COMMENTS_DISABLED);
- assertEquals(false, strategy.getIgnoreLeadingWhitespaces());
- assertEquals(false, strategy.getUnicodeEscapeInterpretation());
- assertEquals(false, strategy.getIgnoreEmptyLines());
+ assertFalse(strategy.getIgnoreLeadingWhitespaces());
+ assertFalse(strategy.getUnicodeEscapeInterpretation());
+ assertFalse(strategy.getIgnoreEmptyLines());
}
}
diff --git a/solr/core/src/test/org/apache/solr/internal/csv/ExtendedBufferedReaderTest.java b/solr/core/src/test/org/apache/solr/internal/csv/ExtendedBufferedReaderTest.java
index 3fc74da5b44..bc5885f05f1 100644
--- a/solr/core/src/test/org/apache/solr/internal/csv/ExtendedBufferedReaderTest.java
+++ b/solr/core/src/test/org/apache/solr/internal/csv/ExtendedBufferedReaderTest.java
@@ -17,7 +17,6 @@
package org.apache.solr.internal.csv;
import java.io.StringReader;
-import java.util.Arrays;
import org.apache.solr.SolrTestCase;
/** ExtendedBufferedReaderTest */
@@ -89,20 +88,20 @@ public class ExtendedBufferedReaderTest extends SolrTestCase {
ExtendedBufferedReader br = getEBR("");
assertEquals(0, br.read(res, 0, 0));
- assertTrue(Arrays.equals(res, ref));
+ assertArrayEquals(res, ref);
br = getEBR("abcdefg");
ref[0] = 'a';
ref[1] = 'b';
ref[2] = 'c';
assertEquals(3, br.read(res, 0, 3));
- assertTrue(Arrays.equals(res, ref));
+ assertArrayEquals(res, ref);
assertEquals('c', br.readAgain());
assertEquals('d', br.lookAhead());
ref[4] = 'd';
assertEquals(1, br.read(res, 4, 1));
- assertTrue(Arrays.equals(res, ref));
+ assertArrayEquals(res, ref);
assertEquals('d', br.readAgain());
}
@@ -112,43 +111,43 @@ public class ExtendedBufferedReaderTest extends SolrTestCase {
public void testReadLine() throws Exception {
ExtendedBufferedReader br = getEBR("");
- assertTrue(br.readLine() == null);
+ assertNull(br.readLine());
br = getEBR("\n");
- assertTrue(br.readLine().equals(""));
- assertTrue(br.readLine() == null);
+ assertEquals("", br.readLine());
+ assertNull(br.readLine());
br = getEBR("foo\n\nhello");
assertEquals(0, br.getLineNumber());
- assertTrue(br.readLine().equals("foo"));
+ assertEquals("foo", br.readLine());
assertEquals(1, br.getLineNumber());
- assertTrue(br.readLine().equals(""));
+ assertEquals("", br.readLine());
assertEquals(2, br.getLineNumber());
- assertTrue(br.readLine().equals("hello"));
+ assertEquals("hello", br.readLine());
assertEquals(3, br.getLineNumber());
- assertTrue(br.readLine() == null);
+ assertNull(br.readLine());
assertEquals(3, br.getLineNumber());
br = getEBR("foo\n\nhello");
assertEquals('f', br.read());
assertEquals('o', br.lookAhead());
- assertTrue(br.readLine().equals("oo"));
+ assertEquals("oo", br.readLine());
assertEquals(1, br.getLineNumber());
assertEquals('\n', br.lookAhead());
- assertTrue(br.readLine().equals(""));
+ assertEquals("", br.readLine());
assertEquals(2, br.getLineNumber());
assertEquals('h', br.lookAhead());
- assertTrue(br.readLine().equals("hello"));
- assertTrue(br.readLine() == null);
+ assertEquals("hello", br.readLine());
+ assertNull(br.readLine());
assertEquals(3, br.getLineNumber());
br = getEBR("foo\rbaar\r\nfoo");
- assertTrue(br.readLine().equals("foo"));
+ assertEquals("foo", br.readLine());
assertEquals('b', br.lookAhead());
- assertTrue(br.readLine().equals("baar"));
+ assertEquals("baar", br.readLine());
assertEquals('f', br.lookAhead());
- assertTrue(br.readLine().equals("foo"));
- assertTrue(br.readLine() == null);
+ assertEquals("foo", br.readLine());
+ assertNull(br.readLine());
}
public void testSkip0() throws Exception {
@@ -171,11 +170,11 @@ public class ExtendedBufferedReaderTest extends SolrTestCase {
assertEquals(3, br.skip(3));
assertEquals('f', br.lookAhead());
assertEquals(2, br.skip(5));
- assertTrue(br.readLine() == null);
+ assertNull(br.readLine());
br = getEBR("12345");
assertEquals(5, br.skip(5));
- assertTrue(br.lookAhead() == ExtendedBufferedReader.END_OF_STREAM);
+ assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.lookAhead());
}
public void testSkipUntil() throws Exception {
@@ -194,16 +193,16 @@ public class ExtendedBufferedReaderTest extends SolrTestCase {
public void testReadUntil() throws Exception {
ExtendedBufferedReader br = getEBR("");
- assertTrue(br.readUntil(';').equals(""));
+ assertEquals("", br.readUntil(';'));
br = getEBR("ABCDEF;GHL;;MN");
- assertTrue(br.readUntil(';').equals("ABCDEF"));
- assertTrue(br.readUntil(';').length() == 0);
+ assertEquals("ABCDEF", br.readUntil(';'));
+ assertEquals(0, br.readUntil(';').length());
br.skip(1);
- assertTrue(br.readUntil(';').equals("GHL"));
+ assertEquals("GHL", br.readUntil(';'));
br.skip(1);
- assertTrue(br.readUntil(';').equals(""));
+ assertEquals("", br.readUntil(';'));
br.skip(1);
- assertTrue(br.readUntil(',').equals("MN"));
+ assertEquals("MN", br.readUntil(','));
}
private ExtendedBufferedReader getEBR(String s) {
diff --git a/solr/core/src/test/org/apache/solr/legacy/TestLegacyFieldReuse.java b/solr/core/src/test/org/apache/solr/legacy/TestLegacyFieldReuse.java
index 80c1faa6032..ac0dd9b16f3 100644
--- a/solr/core/src/test/org/apache/solr/legacy/TestLegacyFieldReuse.java
+++ b/solr/core/src/test/org/apache/solr/legacy/TestLegacyFieldReuse.java
@@ -53,7 +53,6 @@ public class TestLegacyFieldReuse extends BaseTokenStreamTestCase {
// pass another bogus stream (numeric, but different precision step!)
legacyIntField = new LegacyIntField("foo", 42, Field.Store.NO);
- assert 3 != LegacyNumericUtils.PRECISION_STEP_DEFAULT;
bogus = new LegacyNumericTokenStream(3);
ts = legacyIntField.tokenStream(null, bogus);
assertNotSame(bogus, ts);
diff --git a/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java b/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java
index 07fd9726e49..b05aaf248d4 100644
--- a/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java
+++ b/solr/core/src/test/org/apache/solr/legacy/TestLegacyNumericUtils.java
@@ -224,9 +224,10 @@ public class TestLegacyNumericUtils extends SolrTestCase {
// check forward and back conversion
for (int i = 0; i < vals.length; i++) {
longVals[i] = NumericUtils.doubleToSortableLong(vals[i]);
- assertTrue(
+ assertEquals(
"forward and back conversion should generate same double",
- Double.compare(vals[i], NumericUtils.sortableLongToDouble(longVals[i])) == 0);
+ 0,
+ Double.compare(vals[i], NumericUtils.sortableLongToDouble(longVals[i])));
}
// check sort order (prefixVals should be ascending)
@@ -283,9 +284,10 @@ public class TestLegacyNumericUtils extends SolrTestCase {
// check forward and back conversion
for (int i = 0; i < vals.length; i++) {
intVals[i] = NumericUtils.floatToSortableInt(vals[i]);
- assertTrue(
+ assertEquals(
"forward and back conversion should generate same double",
- Float.compare(vals[i], NumericUtils.sortableIntToFloat(intVals[i])) == 0);
+ 0,
+ Float.compare(vals[i], NumericUtils.sortableIntToFloat(intVals[i])));
}
// check sort order (prefixVals should be ascending)
diff --git a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.java b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.java
index 308a4c12488..73481b5f0b5 100644
--- a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.java
+++ b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.java
@@ -543,7 +543,7 @@ public class TestNumericRangeQuery32 extends SolrTestCase {
// only test equality:
Query q1 = LegacyNumericRangeQuery.newIntRange("test14", 4, 10, 20, true, true);
Query q2 = LegacyNumericRangeQuery.newLongRange("test14", 4, 10L, 20L, true, true);
- assertFalse(q1.equals(q2));
- assertFalse(q2.equals(q1));
+ assertNotEquals(q1, q2);
+ assertNotEquals(q2, q1);
}
}
diff --git a/solr/core/src/test/org/apache/solr/metrics/DelegateRegistryTimerTest.java b/solr/core/src/test/org/apache/solr/metrics/DelegateRegistryTimerTest.java
index 4a6f44453e6..71e816fa4f3 100644
--- a/solr/core/src/test/org/apache/solr/metrics/DelegateRegistryTimerTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/DelegateRegistryTimerTest.java
@@ -17,18 +17,16 @@
package org.apache.solr.metrics;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import com.codahale.metrics.Clock;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.solr.SolrTestCase;
import org.junit.Test;
-public class DelegateRegistryTimerTest {
+public class DelegateRegistryTimerTest extends SolrTestCase {
MetricRegistry.MetricSupplier<Timer> timerSupplier =
new MetricSuppliers.DefaultTimerSupplier(null);
diff --git a/solr/core/src/test/org/apache/solr/metrics/MetricsConfigTest.java b/solr/core/src/test/org/apache/solr/metrics/MetricsConfigTest.java
index 2b0d4b69525..45c1e3f7601 100644
--- a/solr/core/src/test/org/apache/solr/metrics/MetricsConfigTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/MetricsConfigTest.java
@@ -91,7 +91,7 @@ public class MetricsConfigTest extends SolrTestCaseJ4 {
MockMeterSupplier mockMeterSupplier = ((MockMeterSupplier) mgr.getMeterSupplier());
assertEquals("bar", mockMeterSupplier.foo);
MockTimerSupplier mockTimerSupplier = ((MockTimerSupplier) mgr.getTimerSupplier());
- assertEquals(true, mockTimerSupplier.boolParam);
+ assertTrue(mockTimerSupplier.boolParam);
assertEquals("strParam", mockTimerSupplier.strParam);
assertEquals(-100, mockTimerSupplier.intParam);
@@ -118,7 +118,7 @@ public class MetricsConfigTest extends SolrTestCaseJ4 {
NodeConfig cfg = loadNodeConfig("solr-metricsconfig1.xml");
SolrMetricManager mgr =
new SolrMetricManager(cfg.getSolrResourceLoader(), cfg.getMetricsConfig());
- assertEquals("nullNumber", null, mgr.nullNumber());
+ assertNull("nullNumber", mgr.nullNumber());
assertEquals("notANumber", -1, mgr.notANumber());
assertEquals("nullNumber", "", mgr.nullString());
assertTrue("nullObject", mgr.nullObject() instanceof Map);
diff --git a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
index b3fc5a49055..4be3a5a583c 100644
--- a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
@@ -272,7 +272,7 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
coreMetricManager.getTag());
String root2 = PREFIX + TestUtil.randomSimpleString(random(), 5, 10);
- assertFalse(root2.equals(root1));
+ assertNotEquals(root2, root1);
PluginInfo pluginInfo2 = createReporterPluginInfo(root2, false);
metricManager.loadReporter(
coreMetricManager.getRegistryName(),
diff --git a/solr/core/src/test/org/apache/solr/parser/SolrQueryParserBaseTest.java b/solr/core/src/test/org/apache/solr/parser/SolrQueryParserBaseTest.java
index 41315b95137..be64a28fe9e 100644
--- a/solr/core/src/test/org/apache/solr/parser/SolrQueryParserBaseTest.java
+++ b/solr/core/src/test/org/apache/solr/parser/SolrQueryParserBaseTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.solr.parser;
-import static org.apache.solr.SolrTestCaseJ4.assumeWorkingMockito;
-import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
@@ -26,6 +24,7 @@ import java.util.Arrays;
import java.util.List;
import org.apache.lucene.queryparser.charstream.CharStream;
import org.apache.lucene.search.Query;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
@@ -33,12 +32,9 @@ import org.apache.solr.search.QParser;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
-@RunWith(MockitoJUnitRunner.class)
-public class SolrQueryParserBaseTest {
+public class SolrQueryParserBaseTest extends SolrTestCaseJ4 {
@BeforeClass
public static void setUpClass() {
@@ -55,16 +51,17 @@ public class SolrQueryParserBaseTest {
}
}
- @Mock private QParser qParser;
- @Mock private QParser subQParser;
- @Mock private SolrQueryRequest solrQueryRequest;
- @Mock private Query query;
- @Mock private IndexSchema indexSchema;
+ private final QParser qParser = Mockito.mock(QParser.class);
+ private final QParser subQParser = Mockito.mock(QParser.class);
+ private final SolrQueryRequest solrQueryRequest = Mockito.mock(SolrQueryRequest.class);
+ private final Query query = Mockito.mock(Query.class);
+ private final IndexSchema indexSchema = Mockito.mock(IndexSchema.class);
private MockSolrQueryParser solrQueryParser;
@Before
- public void setUp() {
+ public void setUp() throws Exception {
+ super.setUp();
solrQueryParser = new MockSolrQueryParser();
}
diff --git a/solr/core/src/test/org/apache/solr/request/TestIntervalFaceting.java b/solr/core/src/test/org/apache/solr/request/TestIntervalFaceting.java
index 6221f424d93..d66e6c6fa45 100644
--- a/solr/core/src/test/org/apache/solr/request/TestIntervalFaceting.java
+++ b/solr/core/src/test/org/apache/solr/request/TestIntervalFaceting.java
@@ -559,7 +559,7 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
Number[] values = new Number[2];
FieldType ft = h.getCore().getLatestSchema().getField(fieldName).getType();
if (ft.getNumberType() == null) {
- assert ft instanceof StrField;
+ assertTrue(ft instanceof StrField);
values[0] = randomInt(max);
values[1] = randomInt(max);
Arrays.sort(values, (o1, o2) -> String.valueOf(o1).compareTo(String.valueOf(o2)));
@@ -1050,7 +1050,7 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
private void assertIntervalKey(
String fieldName, String intervalStr, String expectedKey, String... params)
throws SyntaxError {
- assert (params.length & 1) == 0 : "Params must have an even number of elements";
+ assertEquals("Params must have an even number of elements", 0, (params.length & 1));
SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
ModifiableSolrParams solrParams = new ModifiableSolrParams();
for (int i = 0; i < params.length - 1; ) {
@@ -1612,7 +1612,7 @@ public class TestIntervalFaceting extends SolrTestCaseJ4 {
private void assertIntervalQuery(
String field, String query, int resultCount, String... intervals) {
- assert (intervals.length & 1) == 0;
+ assertEquals(0, (intervals.length & 1));
int idx = 0;
String[] params = new String[intervals.length + 6];
params[idx++] = "q";
diff --git a/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java b/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java
index 680b85985b5..a02c400cce8 100644
--- a/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java
+++ b/solr/core/src/test/org/apache/solr/request/macro/TestMacroExpander.java
@@ -108,7 +108,7 @@ public class TestMacroExpander extends SolrTestCase {
"q=popularity:[ " + expandedLow + " TO " + expandedHigh + " ]",
meSkipOnMissingParams.expand(testQuery));
if (testParams.size() < 2) { // at least one of the two parameters missing
- assertEquals(null, meFailOnMissingParams.expand(testQuery));
+ assertNull(meFailOnMissingParams.expand(testQuery));
}
}
diff --git a/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java b/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java
index 79b4ce3765a..66c4f80edb6 100644
--- a/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java
+++ b/solr/core/src/test/org/apache/solr/response/TestRetrieveFieldsOptimizer.java
@@ -21,7 +21,6 @@ import static org.apache.lucene.tests.util.LuceneTestCase.random;
import static org.apache.solr.search.SolrReturnFields.FIELD_SOURCES.ALL_FROM_DV;
import static org.apache.solr.search.SolrReturnFields.FIELD_SOURCES.ALL_FROM_STORED;
import static org.apache.solr.search.SolrReturnFields.FIELD_SOURCES.MIXED_SOURCES;
-import static org.junit.Assert.fail;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import java.io.ByteArrayInputStream;
@@ -616,7 +615,7 @@ class RetrieveField {
break;
default:
- fail("Found no case for field " + name + " type " + type);
+ SolrTestCaseJ4.fail("Found no case for field " + name + " type " + type);
break;
}
// There are tricky cases with multiValued fields that are sometimes fetched from docValues that
@@ -677,7 +676,7 @@ class RetrieveField {
break;
default:
- fail("Found no case for field " + name + " type " + type);
+ SolrTestCaseJ4.fail("Found no case for field " + name + " type " + type);
break;
}
}
diff --git a/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java b/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java
index 060a6f9b320..3d6fbe46e57 100644
--- a/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java
+++ b/solr/core/src/test/org/apache/solr/response/TestSolrQueryResponse.java
@@ -79,7 +79,7 @@ public class TestSolrQueryResponse extends SolrTestCase {
@Test
public void testResponse() {
final SolrQueryResponse response = new SolrQueryResponse();
- assertEquals("response initial value", null, response.getResponse());
+ assertNull("response initial value", response.getResponse());
final Object newValue =
(random().nextBoolean() ? (random().nextBoolean() ? "answer" : Integer.valueOf(42)) : null);
response.addResponse(newValue);
@@ -278,20 +278,20 @@ public class TestSolrQueryResponse extends SolrTestCase {
@Test
public void testResponseHeader() {
final SolrQueryResponse response = new SolrQueryResponse();
- assertEquals("responseHeader initially present", null, response.getResponseHeader());
+ assertNull("responseHeader initially present", response.getResponseHeader());
final NamedList<Object> newValue = new SimpleOrderedMap<>();
newValue.add("key1", "value1");
response.add("key2", "value2");
response.addResponseHeader(newValue);
assertEquals("responseHeader new value", newValue, response.getResponseHeader());
response.removeResponseHeader();
- assertEquals("responseHeader removed value", null, response.getResponseHeader());
+ assertNull("responseHeader removed value", response.getResponseHeader());
}
@Test
public void testHttpCaching() {
final SolrQueryResponse response = new SolrQueryResponse();
- assertEquals("httpCaching initial value", true, response.isHttpCaching());
+ assertTrue("httpCaching initial value", response.isHttpCaching());
final boolean newValue = random().nextBoolean();
response.setHttpCaching(newValue);
assertEquals("httpCaching new value", newValue, response.isHttpCaching());
diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java
index 9fa02edf51f..40091a7bfba 100644
--- a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java
+++ b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformer.java
@@ -661,7 +661,7 @@ public class TestSubQueryTransformer extends SolrTestCaseJ4 {
for (int deptNum : new int[] {0, deptMultiplier - 1}) {
SolrDocument deptDoc = subDoc.get(deptNum);
Object expectedDept = (subResult.equals("depts") ? engText : engId);
- assertTrue("" + expectedDept + " equals to " + deptDoc, expectedDept.equals(deptDoc));
+ assertEquals("" + expectedDept + " equals to " + deptDoc, expectedDept, deptDoc);
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/schema/ChangedSchemaMergeTest.java b/solr/core/src/test/org/apache/solr/schema/ChangedSchemaMergeTest.java
index 7906b6399ed..6dbc2b2111e 100644
--- a/solr/core/src/test/org/apache/solr/schema/ChangedSchemaMergeTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/ChangedSchemaMergeTest.java
@@ -133,7 +133,7 @@ public class ChangedSchemaMergeTest extends SolrTestCaseJ4 {
assertSimilarity(changed, simfac2);
// sanity check our sanity check
- assertFalse("test is broken: both simfacs are the same", simfac1.equals(simfac2));
+ assertNotEquals("test is broken: both simfacs are the same", simfac1, simfac2);
addDoc(changed, "id", "1", "text", "some stuff without which");
addDoc(changed, "id", "5", "text", "some stuff without which");
diff --git a/solr/core/src/test/org/apache/solr/schema/CopyFieldTest.java b/solr/core/src/test/org/apache/solr/schema/CopyFieldTest.java
index 81767b3ec44..a09c5003d36 100644
--- a/solr/core/src/test/org/apache/solr/schema/CopyFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/CopyFieldTest.java
@@ -198,30 +198,32 @@ public class CopyFieldTest extends SolrTestCaseJ4 {
"schema should contain explicit field 'sku2'", schema.getFields().containsKey("sku2"));
assertNull("'sku*' should not be (or match) a dynamic field", schema.getDynamicPattern("sku*"));
- assertTrue(
- "schema should contain dynamic field '*_s'", schema.getDynamicPattern("*_s").equals("*_s"));
+ assertEquals(
+ "schema should contain dynamic field '*_s'", "*_s", schema.getDynamicPattern("*_s"));
final String subsetPattern = "*_dest_sub_s";
final String dynamicPattern1 = schema.getDynamicPattern(subsetPattern);
- assertTrue(
+ assertEquals(
"'"
+ subsetPattern
+ "' should match dynamic field '*_s', but instead matches '"
+ dynamicPattern1
+ "'",
- dynamicPattern1.equals("*_s"));
+ "*_s",
+ dynamicPattern1);
final String dest_sub_no_ast_s = "dest_sub_no_ast_s";
assertFalse(
schema.getFields().containsKey(dest_sub_no_ast_s)); // Should not be an explicit field
final String dynamicPattern2 = schema.getDynamicPattern(dest_sub_no_ast_s);
- assertTrue(
+ assertEquals(
"'"
+ dest_sub_no_ast_s
+ "' should match dynamic field '*_s', but instead matches '"
+ dynamicPattern2
+ "'",
- dynamicPattern2.equals("*_s"));
+ "*_s",
+ dynamicPattern2);
assertU(adoc("id", "5", "sku1", "10-1839ACX-93", "sku2", "AAM46"));
assertU(commit());
@@ -270,8 +272,8 @@ public class CopyFieldTest extends SolrTestCaseJ4 {
"'testing123_*' should not be (or match) a dynamic or explicit field",
schema.getFieldOrNull("testing123_*"));
- assertTrue(
- "schema should contain dynamic field '*_s'", schema.getDynamicPattern("*_s").equals("*_s"));
+ assertEquals(
+ "schema should contain dynamic field '*_s'", "*_s", schema.getDynamicPattern("*_s"));
assertU(adoc("id", "5", "sku1", "10-1839ACX-93", "testing123_s", "AAM46"));
assertU(commit());
diff --git a/solr/core/src/test/org/apache/solr/schema/DenseVectorFieldTest.java b/solr/core/src/test/org/apache/solr/schema/DenseVectorFieldTest.java
index eb84ee237d1..46f3541551f 100644
--- a/solr/core/src/test/org/apache/solr/schema/DenseVectorFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/DenseVectorFieldTest.java
@@ -24,7 +24,6 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.AbstractBadConfigTestBase;
import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
import org.junit.Test;
public class DenseVectorFieldTest extends AbstractBadConfigTestBase {
@@ -167,7 +166,7 @@ public class DenseVectorFieldTest extends AbstractBadConfigTestBase {
@Test
public void parseVector_NotAList_shouldThrowException() {
RuntimeException thrown =
- Assert.assertThrows(
+ assertThrows(
"Single string value should throw an exception",
SolrException.class,
() -> {
@@ -180,7 +179,7 @@ public class DenseVectorFieldTest extends AbstractBadConfigTestBase {
+ " The expected format is an array :'[f1,f2..f3]' where each element f is a float"));
thrown =
- Assert.assertThrows(
+ assertThrows(
"Single float value should throw an exception",
SolrException.class,
() -> {
@@ -198,7 +197,7 @@ public class DenseVectorFieldTest extends AbstractBadConfigTestBase {
toTest = new DenseVectorField(3);
RuntimeException thrown =
- Assert.assertThrows(
+ assertThrows(
"Incorrect elements should throw an exception",
SolrException.class,
() -> {
@@ -217,7 +216,7 @@ public class DenseVectorFieldTest extends AbstractBadConfigTestBase {
toTest = new DenseVectorField(3);
RuntimeException thrown =
- Assert.assertThrows(
+ assertThrows(
"Incorrect vector dimension should throw an exception",
SolrException.class,
() -> {
@@ -234,7 +233,7 @@ public class DenseVectorFieldTest extends AbstractBadConfigTestBase {
toTest = new DenseVectorField(3);
RuntimeException thrown =
- Assert.assertThrows(
+ assertThrows(
"Incorrect elements should throw an exception",
SolrException.class,
() -> {
diff --git a/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java b/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java
index 17a2a7b7ef1..d38e21aea09 100644
--- a/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/OpenExchangeRatesOrgProviderTest.java
@@ -107,6 +107,6 @@ public class OpenExchangeRatesOrgProviderTest extends SolrTestCaseJ4 {
@Test(expected = SolrException.class)
public void testNoInit() {
oerp.getExchangeRate("ABC", "DEF");
- assertTrue("Should have thrown exception if not initialized", false);
+ fail("Should have thrown exception if not initialized");
}
}
diff --git a/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java b/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java
index 14401db3646..1be999ab371 100644
--- a/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/PolyFieldTest.java
@@ -113,7 +113,7 @@ public class PolyFieldTest extends SolrTestCaseJ4 {
assertNotNull(home);
try {
fields = home.createFields("35.0,foo");
- assertTrue(false);
+ fail();
} catch (Exception e) {
//
}
diff --git a/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java b/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java
index b33b68ac0c1..69d7b19a51b 100644
--- a/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/PreAnalyzedFieldTest.java
@@ -221,7 +221,7 @@ public class PreAnalyzedFieldTest extends SolrTestCaseJ4 {
CharTermAttribute termAttr = stream.addAttribute(CharTermAttribute.class);
stream.reset();
while (stream.incrementToken()) {
- assertFalse("zero-length token", termAttr.length() == 0);
+ assertNotEquals("zero-length token", 0, termAttr.length());
}
stream.end();
stream.close();
diff --git a/solr/core/src/test/org/apache/solr/schema/SchemaVersionSpecificBehaviorTest.java b/solr/core/src/test/org/apache/solr/schema/SchemaVersionSpecificBehaviorTest.java
index 91cbfab85a5..d0e54314777 100644
--- a/solr/core/src/test/org/apache/solr/schema/SchemaVersionSpecificBehaviorTest.java
+++ b/solr/core/src/test/org/apache/solr/schema/SchemaVersionSpecificBehaviorTest.java
@@ -71,10 +71,8 @@ public class SchemaVersionSpecificBehaviorTest extends SolrTestCaseJ4 {
field.useDocValuesAsStored());
// uninvertable defaults to true (for now)
- assertEquals(
- f + " field's type has wrong uninvertable for ver=" + ver,
- true,
- field.isUninvertible());
+ assertTrue(
+ f + " field's type has wrong uninvertable for ver=" + ver, field.isUninvertible());
}
// regardless of version, explicit multiValued values on field or type
diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
index e930e00f8e9..64ffb41c072 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java
@@ -3147,9 +3147,10 @@ public class TestPointFields extends SolrTestCaseJ4 {
toStringArray(getRandomInstants(2, false).stream().sorted().collect(Collectors.toList()));
String[] min = new String[] {ints[0], longs[0], doubles[0], floats[0], dates[0]};
String[] max = new String[] {ints[1], longs[1], doubles[1], floats[1], dates[1]};
- assert fieldTypeNames.length == fieldTypes.length
- && fieldTypeNames.length == max.length
- && fieldTypeNames.length == min.length;
+ assertTrue(
+ fieldTypeNames.length == fieldTypes.length
+ && fieldTypeNames.length == max.length
+ && fieldTypeNames.length == min.length);
for (int i = 0; i < fieldTypeNames.length; i++) {
SchemaField fieldIndexed = h.getCore().getLatestSchema().getField("foo_" + fieldTypeNames[i]);
SchemaField fieldIndexedAndDv =
@@ -3264,7 +3265,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private List<Integer> getRandomInts(int length, boolean missingVals, int boundPosNeg) {
- assert boundPosNeg > 0L;
+ assertTrue(boundPosNeg > 0L);
return getRandomList(
length,
missingVals,
@@ -3276,7 +3277,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private List<Long> getRandomLongs(int length, boolean missingVals, long boundPosNeg) {
- assert boundPosNeg > 0L;
+ assertTrue(boundPosNeg > 0L);
return getRandomList(
length,
missingVals,
@@ -3300,7 +3301,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private String[] getSequentialStringArrayWithDates(int length) {
- assert length < 60;
+ assertTrue(length < 60);
String[] arr = new String[length];
for (int i = 0; i < length; i++) {
arr[i] = String.format(Locale.ROOT, "1995-12-11T19:59:%02dZ", i);
@@ -3317,7 +3318,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private void doTestFieldNotIndexed(String field, String[] values) throws IOException {
- assert values.length == 10;
+ assertTrue(values.length == 10);
// test preconditions
SchemaField sf = h.getCore().getLatestSchema().getField(field);
assertFalse("Field should be indexed=false", sf.indexed());
@@ -3411,8 +3412,9 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestPointFieldReturn(String field, String type, String[] values) {
SchemaField sf = h.getCore().getLatestSchema().getField(field);
- assert sf.stored() || (sf.hasDocValues() && sf.useDocValuesAsStored())
- : "Unexpected field definition for " + field;
+ assertTrue(
+ "Unexpected field definition for " + field,
+ sf.stored() || (sf.hasDocValues() && sf.useDocValuesAsStored()));
for (int i = 0; i < values.length; i++) {
assertU(adoc("id", String.valueOf(i), field, values[i]));
}
@@ -3627,7 +3629,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestPointFieldFacetField(
String nonDocValuesField, String docValuesField, String[] numbers) {
- assert numbers != null && numbers.length == 10;
+ assertTrue(numbers != null && numbers.length == 10);
assertFalse(h.getCore().getLatestSchema().getField(docValuesField).multiValued());
assertTrue(h.getCore().getLatestSchema().getField(docValuesField).hasDocValues());
@@ -4009,7 +4011,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
final String MATCH_ONE = "//*[@numFound='" + (searchable ? "1" : "0") + "']";
final String MATCH_TWO = "//*[@numFound='" + (searchable ? "2" : "0") + "']";
- assert numbers != null && numbers.length == 20;
+ assertTrue(numbers != null && numbers.length == 20);
assertTrue(h.getCore().getLatestSchema().getField(fieldName).multiValued());
assertTrue(h.getCore().getLatestSchema().getField(fieldName).getType() instanceof PointField);
for (int i = 0; i < 10; i++) {
@@ -4057,7 +4059,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
}
private void doTestPointFieldMultiValuedReturn(String fieldName, String type, String[] numbers) {
- assert numbers != null && numbers.length == 20;
+ assertTrue(numbers != null && numbers.length == 20);
assertTrue(h.getCore().getLatestSchema().getField(fieldName).multiValued());
assertTrue(h.getCore().getLatestSchema().getField(fieldName).getType() instanceof PointField);
for (int i = 9; i >= 0; i--) {
@@ -4116,7 +4118,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestPointFieldMultiValuedRangeQuery(
String fieldName, String type, String[] numbers) {
- assert numbers != null && numbers.length == 20;
+ assertTrue(numbers != null && numbers.length == 20);
SchemaField sf = h.getCore().getLatestSchema().getField(fieldName);
assertTrue(sf.multiValued());
assertTrue(sf.getType() instanceof PointField);
@@ -4279,7 +4281,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestPointFieldMultiValuedFacetField(
String nonDocValuesField, String dvFieldName, String[] numbers) {
- assert numbers != null && numbers.length == 20;
+ assertTrue(numbers != null && numbers.length == 20);
assertTrue(h.getCore().getLatestSchema().getField(dvFieldName).multiValued());
assertTrue(h.getCore().getLatestSchema().getField(dvFieldName).hasDocValues());
assertTrue(h.getCore().getLatestSchema().getField(dvFieldName).getType() instanceof PointField);
@@ -4590,7 +4592,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
private void doTestPointMultiValuedFunctionQuery(
String nonDocValuesField, String docValuesField, String[] numbers) {
- assert numbers != null && numbers.length == 20;
+ assertTrue(numbers != null && numbers.length == 20);
for (int i = 0; i < 10; i++) {
assertU(
adoc(
@@ -4804,7 +4806,7 @@ public class TestPointFields extends SolrTestCaseJ4 {
* @param values list of values in ascending order
*/
private <T extends Comparable<T>> void doTestPointFieldSort(String field, List<T> values) {
- assert values != null && 2 <= values.size();
+ assertTrue(values != null && 2 <= values.size());
final List<SolrInputDocument> docs = new ArrayList<>(values.size());
final String[] ascXpathChecks = new String[values.size() + 1];
@@ -5749,34 +5751,34 @@ public class TestPointFields extends SolrTestCaseJ4 {
PointValues.size(ir, field));
}
if (ignoredField) {
- assertTrue(
+ assertEquals(
"Field " + field + " should not have docValues",
- DocValues.getSortedNumeric(leafReaderForCheckingDVs, field).nextDoc()
- == DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(
+ DocIdSetIterator.NO_MORE_DOCS,
+ DocValues.getSortedNumeric(leafReaderForCheckingDVs, field).nextDoc());
+ assertEquals(
"Field " + field + " should not have docValues",
- DocValues.getNumeric(leafReaderForCheckingDVs, field).nextDoc()
- == DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(
+ DocIdSetIterator.NO_MORE_DOCS,
+ DocValues.getNumeric(leafReaderForCheckingDVs, field).nextDoc());
+ assertEquals(
"Field " + field + " should not have docValues",
- DocValues.getSorted(leafReaderForCheckingDVs, field).nextDoc()
- == DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(
+ DocIdSetIterator.NO_MORE_DOCS,
+ DocValues.getSorted(leafReaderForCheckingDVs, field).nextDoc());
+ assertEquals(
"Field " + field + " should not have docValues",
- DocValues.getBinary(leafReaderForCheckingDVs, field).nextDoc()
- == DocIdSetIterator.NO_MORE_DOCS);
+ DocIdSetIterator.NO_MORE_DOCS,
+ DocValues.getBinary(leafReaderForCheckingDVs, field).nextDoc());
} else {
if (sf.hasDocValues()) {
if (sf.multiValued()) {
- assertFalse(
+ assertNotEquals(
"Field " + field + " should have docValues",
- DocValues.getSortedNumeric(leafReaderForCheckingDVs, field).nextDoc()
- == DocIdSetIterator.NO_MORE_DOCS);
+ DocIdSetIterator.NO_MORE_DOCS,
+ DocValues.getSortedNumeric(leafReaderForCheckingDVs, field).nextDoc());
} else {
- assertFalse(
+ assertNotEquals(
"Field " + field + " should have docValues",
- DocValues.getNumeric(leafReaderForCheckingDVs, field).nextDoc()
- == DocIdSetIterator.NO_MORE_DOCS);
+ DocIdSetIterator.NO_MORE_DOCS,
+ DocValues.getNumeric(leafReaderForCheckingDVs, field).nextDoc());
}
} else {
expectThrows(
diff --git a/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java b/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java
index d2aa64899b9..6e35ea5b11e 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestSchemalessBufferedUpdates.java
@@ -116,7 +116,7 @@ public class TestSchemalessBufferedUpdates extends SolrTestCaseJ4 {
Future<UpdateLog.RecoveryInfo> rinfoFuture = ulog.applyBufferedUpdates();
- assertTrue(rinfoFuture != null);
+ assertNotNull(rinfoFuture);
assertEquals(UpdateLog.State.APPLYING_BUFFERED, ulog.getState());
diff --git a/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java b/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java
index 5b5e0d763c4..a326edbcf1c 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestSortableTextField.java
@@ -430,16 +430,14 @@ public class TestSortableTextField extends SolrTestCaseJ4 {
for (String n : Arrays.asList("keyword_stxt", "whitespace_max0_stxt", "whitespace_max6_stxt")) {
{
FieldType ft = h.getCore().getLatestSchema().getFieldTypeByName(n);
- assertEquals(
+ assertFalse(
"type " + ft.getTypeName() + " should not default to useDocValuesAsStored",
- false,
ft.useDocValuesAsStored());
}
{
SchemaField sf = h.getCore().getLatestSchema().getField(n);
- assertEquals(
+ assertFalse(
"field " + sf.getName() + " should not default to useDocValuesAsStored",
- false,
sf.useDocValuesAsStored());
}
}
@@ -451,9 +449,8 @@ public class TestSortableTextField extends SolrTestCaseJ4 {
if (entry.getKey().endsWith("_has_usedvs")) {
num_types_found++;
FieldType ft = entry.getValue();
- assertEquals(
+ assertTrue(
"type " + ft.getTypeName() + " has unexpected useDocValuesAsStored value",
- true,
ft.useDocValuesAsStored());
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.java b/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.java
index 1427f73b7e6..0cde4d58e28 100644
--- a/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.java
+++ b/solr/core/src/test/org/apache/solr/search/MergeStrategyTest.java
@@ -167,9 +167,9 @@ public class MergeStrategyTest extends BaseDistributedSearchTestCase {
MergeStrategy[] merges = {m1, m2, m3};
Arrays.sort(merges, MergeStrategy.MERGE_COMP);
- assert (merges[0].getCost() == 1);
- assert (merges[1].getCost() == 50);
- assert (merges[2].getCost() == 100);
+ assertEquals(1, merges[0].getCost());
+ assertEquals(50, merges[1].getCost());
+ assertEquals(100, merges[2].getCost());
}
private void assertOrder(QueryResponse rsp, String... docs) throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java b/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java
index fa0def076d5..1cbaee0a957 100644
--- a/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/RankQueryTestPlugin.java
@@ -47,6 +47,7 @@ import org.apache.lucene.search.TotalHits;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.InPlaceMergeSorter;
import org.apache.lucene.util.PriorityQueue;
+import org.apache.solr.SolrTestCase;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
@@ -664,8 +665,10 @@ public class RankQueryTestPlugin extends QParserPlugin {
final String sortFieldName = sortField.getField();
final String valueFieldName = sortFieldValues.getName(marshalledFieldNum);
- assert sortFieldName.equals(valueFieldName)
- : "sortFieldValues name key does not match expected SortField.getField";
+ SolrTestCase.assertEquals(
+ "sortFieldValues name key does not match expected SortField.getField",
+ sortFieldName,
+ valueFieldName);
List sortVals = (List) sortFieldValues.getVal(marshalledFieldNum);
diff --git a/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java b/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
index 568095d5421..0db966e01f3 100644
--- a/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
+++ b/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
@@ -572,12 +572,13 @@ public class ReturnFieldsTest extends SolrTestCaseJ4 {
int offset = TestUtil.nextInt(r, 0, WHITESPACE_CHARACTERS.length - 1);
char c = WHITESPACE_CHARACTERS[offset];
// sanity check
- assert Character.isWhitespace(c)
- : String.format(
+ assertTrue(
+ String.format(
Locale.ENGLISH,
"Not really whitespace? WHITESPACE_CHARACTERS[%d] is '\\u%04X'",
offset,
- (int) c);
+ (int) c),
+ Character.isWhitespace(c));
out.append(c);
}
return out.toString();
diff --git a/solr/core/src/test/org/apache/solr/search/SolrIndexSearcherTest.java b/solr/core/src/test/org/apache/solr/search/SolrIndexSearcherTest.java
index 2736ec78ba4..2a13531e345 100644
--- a/solr/core/src/test/org/apache/solr/search/SolrIndexSearcherTest.java
+++ b/solr/core/src/test/org/apache/solr/search/SolrIndexSearcherTest.java
@@ -451,7 +451,7 @@ public class SolrIndexSearcherTest extends SolrTestCaseJ4 {
public MockPostFilter(int maxDocsToCollect, int cost, ScoreMode scoreMode) {
super(new Term("foo", "bar")); // The term won't really be used. just the collector
- assert cost > 100;
+ assertTrue(cost > 100);
this.cost = cost;
this.maxDocsToCollect = maxDocsToCollect;
this.scoreMode = scoreMode;
diff --git a/solr/core/src/test/org/apache/solr/search/SortSpecParsingTest.java b/solr/core/src/test/org/apache/solr/search/SortSpecParsingTest.java
index 613f267356d..dfe4ff6b313 100644
--- a/solr/core/src/test/org/apache/solr/search/SortSpecParsingTest.java
+++ b/solr/core/src/test/org/apache/solr/search/SortSpecParsingTest.java
@@ -74,14 +74,14 @@ public class SortSpecParsingTest extends SolrTestCaseJ4 {
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
assertEquals(flds[0].getField(), "weight");
- assertEquals(flds[0].getReverse(), true);
+ assertTrue(flds[0].getReverse());
spec = doParseSortSpec("weight dEsC", req);
flds = spec.getSort().getSort();
assertEquals(1, flds.length);
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
assertEquals(flds[0].getField(), "weight");
- assertEquals(flds[0].getReverse(), true);
+ assertTrue(flds[0].getReverse());
assertEquals(1, spec.getSchemaFields().size());
assertNotNull(spec.getSchemaFields().get(0));
assertEquals("weight", spec.getSchemaFields().get(0).getName());
@@ -90,27 +90,27 @@ public class SortSpecParsingTest extends SolrTestCaseJ4 {
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
assertEquals(flds[0].getField(), "weight");
- assertEquals(flds[0].getReverse(), true);
+ assertTrue(flds[0].getReverse());
assertEquals(flds[1].getType(), SortField.Type.LONG);
assertEquals(flds[1].getField(), "bday");
- assertEquals(flds[1].getReverse(), false);
+ assertFalse(flds[1].getReverse());
// order aliases
sort = doParseSortSpec("weight top,bday asc", req).getSort();
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
assertEquals(flds[0].getField(), "weight");
- assertEquals(flds[0].getReverse(), true);
+ assertTrue(flds[0].getReverse());
assertEquals(flds[1].getType(), SortField.Type.LONG);
assertEquals(flds[1].getField(), "bday");
- assertEquals(flds[1].getReverse(), false);
+ assertFalse(flds[1].getReverse());
sort = doParseSortSpec("weight top,bday bottom", req).getSort();
flds = sort.getSort();
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
assertEquals(flds[0].getField(), "weight");
- assertEquals(flds[0].getReverse(), true);
+ assertTrue(flds[0].getReverse());
assertEquals(flds[1].getType(), SortField.Type.LONG);
assertEquals(flds[1].getField(), "bday");
- assertEquals(flds[1].getReverse(), false);
+ assertFalse(flds[1].getReverse());
// test weird spacing
sort = doParseSortSpec("weight DESC, bday asc", req).getSort();
@@ -237,40 +237,40 @@ public class SortSpecParsingTest extends SolrTestCaseJ4 {
// test some bad vals
try {
sort = doParseSortSpec("weight, desc", req).getSort();
- assertTrue(false);
+ fail();
} catch (SolrException e) {
// expected
}
try {
sort = doParseSortSpec("w", req).getSort();
- assertTrue(false);
+ fail();
} catch (SolrException e) {
// expected
}
try {
sort = doParseSortSpec("weight desc, bday", req).getSort();
- assertTrue(false);
+ fail();
} catch (SolrException e) {
}
try {
// bad number of commas
sort = SortSpecParsing.parseSortSpec("pow(weight,,2) desc, bday asc", req).getSort();
- assertTrue(false);
+ fail();
} catch (SolrException e) {
}
try {
// bad function
sort = SortSpecParsing.parseSortSpec("pow() desc, bday asc", req).getSort();
- assertTrue(false);
+ fail();
} catch (SolrException e) {
}
try {
// bad number of parens
sort = SortSpecParsing.parseSortSpec("pow((weight,2) desc, bday asc", req).getSort();
- assertTrue(false);
+ fail();
} catch (SolrException e) {
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java b/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java
index 30758369373..87ff29d5e6a 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java
@@ -65,13 +65,13 @@ public class TestCaffeineCache extends SolrTestCase {
}
assertEquals("15", lfuCache.get(15));
assertEquals("75", lfuCache.get(75));
- assertEquals(null, lfuCache.get(110));
+ assertNull(lfuCache.get(110));
Map<String, Object> nl = lfuCache.getMetricsMap().getValue();
assertEquals(3L, nl.get("lookups"));
assertEquals(2L, nl.get("hits"));
assertEquals(101L, nl.get("inserts"));
- assertEquals(null, lfuCache.get(1)); // first item put in should be the first out
+ assertNull(lfuCache.get(1)); // first item put in should be the first out
// Test autowarming
newLFUCache.init(params, initObj, regenerator);
@@ -81,7 +81,7 @@ public class TestCaffeineCache extends SolrTestCase {
newLFUCache.put(103, "103");
assertEquals("15", newLFUCache.get(15));
assertEquals("75", newLFUCache.get(75));
- assertEquals(null, newLFUCache.get(50));
+ assertNull(newLFUCache.get(50));
nl = newLFUCache.getMetricsMap().getValue();
assertEquals(3L, nl.get("lookups"));
assertEquals(2L, nl.get("hits"));
diff --git a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
index e0c8cfe22ac..d6e20ed93d6 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
@@ -1139,21 +1139,21 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
s = GroupHeadSelector.build(params("max", "foo_s"));
assertEquals(GroupHeadSelectorType.MAX, s.type);
assertEquals("foo_s", s.selectorText);
- assertFalse(s.equals(GroupHeadSelector.build(params("min", "foo_s", "other", "stuff"))));
+ assertNotEquals(s, GroupHeadSelector.build(params("min", "foo_s", "other", "stuff")));
s = GroupHeadSelector.build(params());
assertEquals(GroupHeadSelectorType.SCORE, s.type);
assertNotNull(s.selectorText);
assertEquals(GroupHeadSelector.build(params()), s);
- assertFalse(s.equals(GroupHeadSelector.build(params("min", "BAR_s"))));
+ assertNotEquals(s, GroupHeadSelector.build(params("min", "BAR_s")));
s = GroupHeadSelector.build(params("sort", "foo_s asc"));
assertEquals(GroupHeadSelectorType.SORT, s.type);
assertEquals("foo_s asc", s.selectorText);
assertEquals(GroupHeadSelector.build(params("sort", "foo_s asc")), s);
- assertFalse(s.equals(GroupHeadSelector.build(params("sort", "BAR_s asc"))));
- assertFalse(s.equals(GroupHeadSelector.build(params("min", "BAR_s"))));
- assertFalse(s.equals(GroupHeadSelector.build(params())));
+ assertNotEquals(s, GroupHeadSelector.build(params("sort", "BAR_s asc")));
+ assertNotEquals(s, GroupHeadSelector.build(params("min", "BAR_s")));
+ assertNotEquals(s, GroupHeadSelector.build(params()));
assertEquals(
GroupHeadSelector.build(params("sort", "foo_s asc")).hashCode(),
diff --git a/solr/core/src/test/org/apache/solr/search/TestDocSet.java b/solr/core/src/test/org/apache/solr/search/TestDocSet.java
index 1ea09b2d8bf..3583ca385a6 100644
--- a/solr/core/src/test/org/apache/solr/search/TestDocSet.java
+++ b/solr/core/src/test/org/apache/solr/search/TestDocSet.java
@@ -157,7 +157,7 @@ public class TestDocSet extends SolrTestCase {
DocIterator i1 = d1.iterator();
DocIterator i2 = d2.iterator();
- assert (i1.hasNext() == i2.hasNext());
+ assertEquals(i1.hasNext(), i2.hasNext());
for (; ; ) {
boolean b1 = i1.hasNext();
diff --git a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
index b86ca6aa636..98b94d04f2d 100644
--- a/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
+++ b/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
@@ -52,7 +52,6 @@ import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.BaseTestHarness;
import org.apache.solr.util.SolrPluginUtils;
import org.hamcrest.MatcherAssert;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -1518,7 +1517,7 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {
ExtendedDismaxQParser parser =
new ExtendedDismaxQParser(query, null, request.getParams(), request);
List<ExtendedDismaxQParser.Clause> clauses = parser.splitIntoClauses(query, false);
- Assert.assertEquals(3, clauses.size());
+ assertEquals(3, clauses.size());
assertClause(clauses.get(0), "\\(", false, true);
assertClause(clauses.get(1), "foo\nfoo", true, false);
assertClause(clauses.get(2), "\\)", false, true);
@@ -1527,7 +1526,7 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {
request = req("q", query, "qf", "cat_s", "defType", "edismax");
parser = new ExtendedDismaxQParser(query, null, request.getParams(), request);
clauses = parser.splitIntoClauses(query, false);
- Assert.assertEquals(5, clauses.size());
+ assertEquals(5, clauses.size());
assertClause(clauses.get(0), "\\[", false, true, "cat_s");
assertClause(clauses.get(1), "foo\nfoo", true, false);
assertClause(clauses.get(2), "TO", true, false);
@@ -1538,7 +1537,7 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {
request = req("q", query, "qf", "cat_s", "defType", "edismax");
parser = new ExtendedDismaxQParser(query, null, request.getParams(), request);
clauses = parser.splitIntoClauses(query, false);
- Assert.assertEquals(5, clauses.size());
+ assertEquals(5, clauses.size());
assertClause(clauses.get(0), "\\[", true, true, "cat_s");
assertClause(clauses.get(1), "foo\nfoo", true, false);
assertClause(clauses.get(2), "TO", true, false);
@@ -1554,7 +1553,7 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {
parser = new ExtendedDismaxQParser(query, null, request.getParams(), request);
clauses = parser.splitIntoClauses(query, false);
- Assert.assertEquals(1, clauses.size());
+ assertEquals(1, clauses.size());
assertClause(
clauses.get(0), "\\!\\(\\)\\:\\^\\[\\]\\{\\}\\~\\*\\?\\\"\\+\\-\\\\\\|\\&\\/", false, true);
@@ -1563,7 +1562,7 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {
parser = new ExtendedDismaxQParser(query, null, request.getParams(), request);
clauses = parser.splitIntoClauses(query, false);
- Assert.assertEquals(1, clauses.size());
+ assertEquals(1, clauses.size());
assertClause(clauses.get(0), "foo\\/", false, true);
}
@@ -1573,10 +1572,10 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {
boolean hasWhitespace,
boolean hasSpecialSyntax,
String field) {
- Assert.assertEquals(value, clause.val);
- Assert.assertEquals(hasWhitespace, clause.hasWhitespace);
- Assert.assertEquals(hasSpecialSyntax, clause.hasSpecialSyntax);
- Assert.assertEquals(field, clause.field);
+ assertEquals(value, clause.val);
+ assertEquals(hasWhitespace, clause.hasWhitespace);
+ assertEquals(hasSpecialSyntax, clause.hasSpecialSyntax);
+ assertEquals(field, clause.field);
}
private static void assertClause(
diff --git a/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.java b/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.java
index c29b28b96c2..153db65f0f7 100644
--- a/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.java
+++ b/solr/core/src/test/org/apache/solr/search/TestFilteredDocIdSet.java
@@ -38,7 +38,6 @@ import org.apache.lucene.search.Weight;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.index.RandomIndexWriter;
import org.apache.solr.SolrTestCase;
-import org.junit.Assert;
public class TestFilteredDocIdSet extends SolrTestCase {
public void testFilteredDocIdSet() throws Exception {
@@ -126,7 +125,7 @@ public class TestFilteredDocIdSet extends SolrTestCase {
// First verify the document is searchable.
IndexSearcher searcher = newSearcher(reader);
- Assert.assertEquals(1, searcher.search(new MatchAllDocsQuery(), 10).totalHits.value);
+ assertEquals(1, searcher.search(new MatchAllDocsQuery(), 10).totalHits.value);
// Now search w/ a Query which returns a null Scorer
DocSetQuery f = new DocSetQuery(DocSet.empty());
@@ -136,7 +135,7 @@ public class TestFilteredDocIdSet extends SolrTestCase {
.add(new MatchAllDocsQuery(), Occur.MUST)
.add(f, Occur.FILTER)
.build();
- Assert.assertEquals(0, searcher.search(filtered, 10).totalHits.value);
+ assertEquals(0, searcher.search(filtered, 10).totalHits.value);
reader.close();
dir.close();
}
@@ -152,7 +151,7 @@ public class TestFilteredDocIdSet extends SolrTestCase {
// First verify the document is searchable.
IndexSearcher searcher = newSearcher(reader);
- Assert.assertEquals(1, searcher.search(new MatchAllDocsQuery(), 10).totalHits.value);
+ assertEquals(1, searcher.search(new MatchAllDocsQuery(), 10).totalHits.value);
// Now search w/ a Query which returns a null Scorer
Query f =
@@ -202,7 +201,7 @@ public class TestFilteredDocIdSet extends SolrTestCase {
.add(new MatchAllDocsQuery(), Occur.MUST)
.add(f, Occur.FILTER)
.build();
- Assert.assertEquals(0, searcher.search(filtered, 10).totalHits.value);
+ assertEquals(0, searcher.search(filtered, 10).totalHits.value);
reader.close();
dir.close();
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestFiltering.java b/solr/core/src/test/org/apache/solr/search/TestFiltering.java
index d00097a27ee..7d559d4d296 100644
--- a/solr/core/src/test/org/apache/solr/search/TestFiltering.java
+++ b/solr/core/src/test/org/apache/solr/search/TestFiltering.java
@@ -84,7 +84,7 @@ public class TestFiltering extends SolrTestCaseJ4 {
if (live == null) {
live = searcher.getLiveDocSet();
}
- assertTrue(set == live);
+ assertSame(set, live);
QueryCommand cmd = new QueryCommand();
cmd.setQuery(QParser.getParser(qstr, null, req).getQuery());
@@ -93,14 +93,14 @@ public class TestFiltering extends SolrTestCaseJ4 {
QueryResult res = new QueryResult();
searcher.search(res, cmd);
set = res.getDocSet();
- assertTrue(set == live);
+ assertSame(set, live);
cmd.setQuery(QParser.getParser(qstr + " OR id:0", null, req).getQuery());
cmd.setFilterList(QParser.getParser(qstr + " OR id:1", null, req).getQuery());
res = new QueryResult();
searcher.search(res, cmd);
set = res.getDocSet();
- assertTrue(set == live);
+ assertSame(set, live);
}
} finally {
diff --git a/solr/core/src/test/org/apache/solr/search/TestHashQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestHashQParserPlugin.java
index 4170bfd3ca1..d8e7ce65808 100644
--- a/solr/core/src/test/org/apache/solr/search/TestHashQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestHashQParserPlugin.java
@@ -194,10 +194,10 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
}
}
- assert (set1.size() > 0);
- assert (set2.size() > 0);
- assert (set3.size() > 0);
- assert (set1.size() + set2.size() + set3.size() == set.size());
+ assertTrue(set1.size() > 0);
+ assertTrue(set2.size() > 0);
+ assertTrue(set3.size() > 0);
+ assertTrue(set1.size() + set2.size() + set3.size() == set.size());
assertNoOverLap(set1, set2);
assertNoOverLap(set1, set3);
assertNoOverLap(set2, set3);
@@ -244,9 +244,9 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
}
}
- assert (set1.size() > 0);
- assert (set2.size() > 0);
- assert (set1.size() + set2.size() == set.size());
+ assertTrue(set1.size() > 0);
+ assertTrue(set2.size() > 0);
+ assertTrue(set1.size() + set2.size() == set.size());
assertNoOverLap(set1, set2);
// Test with 2 workers and compound partition Key
@@ -291,9 +291,9 @@ public class TestHashQParserPlugin extends SolrTestCaseJ4 {
}
}
- assert (set1.size() > 0);
- assert (set2.size() > 0);
- assert (set1.size() + set2.size() == set.size());
+ assertTrue(set1.size() > 0);
+ assertTrue(set2.size() > 0);
+ assertEquals(set1.size() + set2.size(), set.size());
assertNoOverLap(set1, set2);
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java b/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
index d44daee769f..6c0b6a4d908 100644
--- a/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
+++ b/solr/core/src/test/org/apache/solr/search/TestIndexSearcher.java
@@ -174,12 +174,8 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
IndexReaderContext rCtx6 = sr6.getSearcher().getTopReaderContext();
assertEquals(
1, rCtx6.leaves().get(0).reader().numDocs()); // only a single doc left in the first segment
- assertTrue(
- !rCtx5
- .leaves()
- .get(0)
- .reader()
- .equals(rCtx6.leaves().get(0).reader())); // readers now different
+ assertNotEquals(
+ rCtx5.leaves().get(0).reader(), rCtx6.leaves().get(0).reader()); // readers now different
sr5.close();
sr6.close();
@@ -495,8 +491,8 @@ public class TestIndexSearcher extends SolrTestCaseJ4 {
@Override
public void newSearcher(SolrIndexSearcher newSearcher, SolrIndexSearcher currentSearcher) {
try {
- assert currentSearcher == null
- : "SlowSearcherListener should only be used as FirstSearcherListener";
+ assertNull(
+ "SlowSearcherListener should only be used as FirstSearcherListener", currentSearcher);
// simulate a slow searcher listener
latch.await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
diff --git a/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java b/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java
index 2a9a52a5022..2b8d3ec62fc 100644
--- a/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java
+++ b/solr/core/src/test/org/apache/solr/search/TestQueryUtils.java
@@ -45,26 +45,26 @@ public class TestQueryUtils extends SolrTestCaseJ4 {
public void positive(Query q) {
assertFalse(QueryUtils.isNegative(q));
- assertTrue(QueryUtils.getAbs(q) == q);
+ assertSame(QueryUtils.getAbs(q), q);
Collection<BooleanClause> clauses =
(q instanceof BooleanQuery) ? ((BooleanQuery) q).clauses() : null;
if (clauses != null) {
if (clauses.size() != 0) {
- assertTrue(QueryUtils.makeQueryable(q) == q);
+ assertSame(QueryUtils.makeQueryable(q), q);
}
} else {
- assertTrue(QueryUtils.makeQueryable(q) == q);
+ assertSame(QueryUtils.makeQueryable(q), q);
}
}
public void negative(Query q) {
assertTrue(QueryUtils.isNegative(q));
Query abs = QueryUtils.getAbs(q);
- assertTrue(q != abs);
+ assertNotSame(q, abs);
Query neg2 = QueryUtils.fixNegativeQuery(q);
- assertFalse(abs.equals(q));
- assertFalse(neg2.equals(q));
+ assertNotEquals(abs, q);
+ assertNotEquals(neg2, q);
}
public void testNegativeQueries() {
diff --git a/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java
index 3c71eba2fe4..7701f05d4fc 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRandomCollapseQParserPlugin.java
@@ -190,14 +190,15 @@ public class TestRandomCollapseQParserPlugin extends SolrTestCaseJ4 {
continue;
}
- assertFalse(
+ assertNotEquals(
groupHeadId
+ " has null collapseVal but nullPolicy==ignore; "
+ "mainP: "
+ mainP
+ ", collapseP: "
+ collapseP,
- nullPolicy.equals(CollapsingQParserPlugin.NullPolicy.IGNORE.getName()));
+ nullPolicy,
+ CollapsingQParserPlugin.NullPolicy.IGNORE.getName());
}
// workaround for SOLR-8082...
@@ -220,9 +221,9 @@ public class TestRandomCollapseQParserPlugin extends SolrTestCaseJ4 {
final QueryResponse checkRsp = SOLR.query(SolrParams.wrapDefaults(checkP, mainP));
- assertTrue(
+ assertFalse(
"not even 1 match for sanity check query? expected: " + doc,
- !checkRsp.getResults().isEmpty());
+ checkRsp.getResults().isEmpty());
final SolrDocument firstMatch = checkRsp.getResults().get(0);
final Object firstMatchId = firstMatch.getFieldValue("id");
assertEquals(
diff --git a/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java b/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
index 705ac0bb211..b8e0380988f 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRangeQuery.java
@@ -771,7 +771,7 @@ public class TestRangeQuery extends SolrTestCaseJ4 {
Number[] values = new Number[2];
FieldType ft = h.getCore().getLatestSchema().getField("field_" + fieldName).getType();
if (ft.getNumberType() == null) {
- assert ft instanceof StrField;
+ assertTrue(ft instanceof StrField);
values[0] = randomInt(max);
values[1] = randomInt(max);
Arrays.sort(values, (o1, o2) -> String.valueOf(o1).compareTo(String.valueOf(o2)));
@@ -958,7 +958,7 @@ public class TestRangeQuery extends SolrTestCaseJ4 {
}
private static <X extends Comparable<? super X>, Y> X randomKey(Map<X, Y> map) {
- assert !map.isEmpty();
+ assertFalse(map.isEmpty());
List<X> sortedKeys = new ArrayList<>(map.keySet());
Collections.sort(sortedKeys);
return sortedKeys.get(random().nextInt(sortedKeys.size()));
diff --git a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
index 06b41d7e2ac..8b978ff96e5 100644
--- a/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java
@@ -623,7 +623,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
stats = metrics.getValue();
long inserts2 = (Long) stats.get("inserts");
// Last query was NOT added to the cache
- assertTrue(inserts1 == inserts2);
+ assertEquals(inserts1, inserts2);
// Test range query embedded in larger query
params = new ModifiableSolrParams();
@@ -894,7 +894,7 @@ public class TestReRankQParserPlugin extends SolrTestCaseJ4 {
+ ReRankQParserPlugin.RERANK_QUERY
+ " parameter is not specified",
() -> h.query(req(params)));
- assertTrue(se.code() == SolrException.ErrorCode.BAD_REQUEST.code);
+ assertEquals(se.code(), SolrException.ErrorCode.BAD_REQUEST.code);
unIgnoreException("reRankQuery parameter is mandatory");
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java b/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java
index 1f842ea7025..44749171af4 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java
@@ -914,7 +914,7 @@ public class TestRealTimeGet extends TestRTGBase {
|| (foundVer == info.version
&& foundVal != info.val)) { // if the version matches, the val must
verbose("ERROR, id=", id, "found=", response, "model", info);
- assertTrue(false);
+ fail();
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestRecovery.java b/solr/core/src/test/org/apache/solr/search/TestRecovery.java
index 12af30af76b..e87a84fb856 100644
--- a/solr/core/src/test/org/apache/solr/search/TestRecovery.java
+++ b/solr/core/src/test/org/apache/solr/search/TestRecovery.java
@@ -653,7 +653,7 @@ public class TestRecovery extends SolrTestCaseJ4 {
assertEquals(UpdateLog.State.BUFFERING, ulog.getState());
Future<UpdateLog.RecoveryInfo> rinfoFuture = ulog.applyBufferedUpdates();
- assertTrue(rinfoFuture == null);
+ assertNull(rinfoFuture);
assertEquals(UpdateLog.State.ACTIVE, ulog.getState());
ulog.bufferUpdates();
@@ -725,7 +725,7 @@ public class TestRecovery extends SolrTestCaseJ4 {
assertEquals(6, bufferedOps.getValue() - initialOps);
rinfoFuture = ulog.applyBufferedUpdates();
- assertTrue(rinfoFuture != null);
+ assertNotNull(rinfoFuture);
assertEquals(UpdateLog.State.APPLYING_BUFFERED, ulog.getState());
@@ -785,7 +785,7 @@ public class TestRecovery extends SolrTestCaseJ4 {
logReplay.drainPermits();
rinfoFuture = ulog.applyBufferedUpdates();
- assertTrue(rinfoFuture != null);
+ assertNotNull(rinfoFuture);
assertEquals(UpdateLog.State.APPLYING_BUFFERED, ulog.getState());
// apply a single update
@@ -880,7 +880,7 @@ public class TestRecovery extends SolrTestCaseJ4 {
ulog.bufferUpdates();
assertEquals(UpdateLog.State.BUFFERING, ulog.getState());
Future<UpdateLog.RecoveryInfo> rinfoFuture = ulog.applyBufferedUpdates();
- assertTrue(rinfoFuture == null);
+ assertNull(rinfoFuture);
assertEquals(UpdateLog.State.ACTIVE, ulog.getState());
ulog.bufferUpdates();
@@ -1295,7 +1295,7 @@ public class TestRecovery extends SolrTestCaseJ4 {
assertU(commit());
long D1Version2 = getVer(req("q", "id:D1"));
- assert (D1Version2 > D1Version1);
+ assertTrue(D1Version2 > D1Version1);
assertJQ(
req("qt", "/get", "getVersions", "2"),
diff --git a/solr/core/src/test/org/apache/solr/search/TestStressLucene.java b/solr/core/src/test/org/apache/solr/search/TestStressLucene.java
index 9db05f76598..a02b55cb92f 100644
--- a/solr/core/src/test/org/apache/solr/search/TestStressLucene.java
+++ b/solr/core/src/test/org/apache/solr/search/TestStressLucene.java
@@ -173,8 +173,8 @@ public class TestStressLucene extends TestRTGBase {
verbose("reopen result", newReader);
synchronized (globalLock) {
- assert newReader.getRefCount() > 0;
- assert reader.getRefCount() > 0;
+ assertTrue(newReader.getRefCount() > 0);
+ assertTrue(reader.getRefCount() > 0);
// install the new reader if it's newest (and check the current version
// since another reader may have already been installed)
diff --git a/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java b/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java
index 1068f494893..299a8b82cf0 100644
--- a/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java
+++ b/solr/core/src/test/org/apache/solr/search/TestStressRecovery.java
@@ -346,7 +346,7 @@ public class TestStressRecovery extends TestRTGBase {
|| (foundVer == info.version
&& foundVal != info.val)) { // if the version matches, the val must
verbose("ERROR, id=", id, "found=", response, "model", info);
- assertTrue(false);
+ fail();
}
}
}
@@ -373,7 +373,7 @@ public class TestStressRecovery extends TestRTGBase {
int bufferedAddsApplied = 0;
do {
- assertTrue(uLog.getState() == UpdateLog.State.ACTIVE);
+ assertSame(uLog.getState(), UpdateLog.State.ACTIVE);
// before we start buffering updates, we want to point
// visibleModel away from the live model.
@@ -384,7 +384,7 @@ public class TestStressRecovery extends TestRTGBase {
uLog.bufferUpdates();
}
- assertTrue(uLog.getState() == UpdateLog.State.BUFFERING);
+ assertSame(uLog.getState(), UpdateLog.State.BUFFERING);
// sometimes wait for a second to allow time for writers to write something
if (random().nextBoolean()) Thread.sleep(random().nextInt(10) + 1);
diff --git a/solr/core/src/test/org/apache/solr/search/TestStressReorder.java b/solr/core/src/test/org/apache/solr/search/TestStressReorder.java
index 8c5dedb7f10..54917fa7399 100644
--- a/solr/core/src/test/org/apache/solr/search/TestStressReorder.java
+++ b/solr/core/src/test/org/apache/solr/search/TestStressReorder.java
@@ -347,7 +347,7 @@ public class TestStressReorder extends TestRTGBase {
|| (foundVer == info.version
&& foundVal != info.val)) { // if the version matches, the val must
log.error("ERROR, id={} found={} model {}", id, response, info);
- assertTrue(false);
+ fail();
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java b/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java
index 430fce5606b..3314b913f6d 100644
--- a/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java
+++ b/solr/core/src/test/org/apache/solr/search/TestStressUserVersions.java
@@ -314,7 +314,7 @@ public class TestStressUserVersions extends TestRTGBase {
|| (foundVer == info.version
&& foundVal != info.val)) { // if the version matches, the val must
log.error("ERROR, id={} found={} model {}", id, response, info);
- assertTrue(false);
+ fail();
}
} else {
// if the doc is deleted (via tombstone), it shouldn't have a value on it.
@@ -322,7 +322,7 @@ public class TestStressUserVersions extends TestRTGBase {
if (foundVer < Math.abs(info.version)) {
log.error("ERROR, id={} found={} model {}", id, response, info);
- assertTrue(false);
+ fail();
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestStressVersions.java b/solr/core/src/test/org/apache/solr/search/TestStressVersions.java
index a01fbce0b64..03adc37a47a 100644
--- a/solr/core/src/test/org/apache/solr/search/TestStressVersions.java
+++ b/solr/core/src/test/org/apache/solr/search/TestStressVersions.java
@@ -254,7 +254,7 @@ public class TestStressVersions extends TestRTGBase {
|| (foundVer == info.version
&& foundVal != info.val)) { // if the version matches, the val must
verbose("ERROR, id=", id, "found=", response, "model", info);
- assertTrue(false);
+ fail();
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/facet/DistributedFacetSimpleRefinementLongTailTest.java b/solr/core/src/test/org/apache/solr/search/facet/DistributedFacetSimpleRefinementLongTailTest.java
index d12ec011172..40cfb8a5019 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/DistributedFacetSimpleRefinementLongTailTest.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/DistributedFacetSimpleRefinementLongTailTest.java
@@ -240,7 +240,7 @@ public class DistributedFacetSimpleRefinementLongTailTest extends BaseDistribute
// this will be short the "+1" fo the doc added to shard2...
NamedList bucket = foo_buckets.get(5);
- assertTrue(bucket.toString(), bucket.get("val").equals("bbb0")); // 'tail' is missed
+ assertEquals(bucket.toString(), "bbb0", bucket.get("val")); // 'tail' is missed
assertEquals(
bucket.toString(),
100L,
@@ -281,7 +281,7 @@ public class DistributedFacetSimpleRefinementLongTailTest extends BaseDistribute
}
// ...but it should have correctly asked shard2 to refine bbb0
NamedList bucket = foo_buckets.get(5);
- assertTrue(bucket.toString(), bucket.get("val").equals("bbb0"));
+ assertEquals(bucket.toString(), "bbb0", bucket.get("val"));
assertEquals(bucket.toString(), 101L, bucket.get("count"));
// ...and the status under bbb0 should be correct to include the refinement
assertEquals(ALL_STATS.size() + 3, bucket.size()); // val,count,facet
diff --git a/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java b/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java
index 7a48d045ebb..4de05a620c7 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/RangeFacetCloudTest.java
@@ -1114,9 +1114,9 @@ public class RangeFacetCloudTest extends SolrCloudTestCase {
/** Don't use, use the convenience methods */
public ModelRange(int lower, int upper) {
if (lower < 0 || upper < 0) {
- assert (lower < 0 && upper < lower);
+ assertTrue(lower < 0 && upper < lower);
} else {
- assert (lower <= upper);
+ assertTrue(lower <= upper);
}
this.lower = lower;
this.upper = upper;
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
index 0c7f0fab9e0..a71d90ed4d5 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
@@ -161,7 +161,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
* @see #randFieldValue
*/
private static String field(final String[] suffixes, final int fieldNum) {
- assert fieldNum < MAX_FIELD_NUM;
+ assertTrue(fieldNum < MAX_FIELD_NUM);
final String suffix = suffixes[fieldNum % suffixes.length];
return "field_" + fieldNum + suffix;
@@ -735,7 +735,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
public TermFacet(
String field, JoinDomain domain, Integer limit, Integer overrequest, Boolean refine) {
- assert null != field;
+ assertNotNull(field);
this.field = field;
this.domain = domain;
this.limit = limit;
@@ -799,8 +799,8 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
* value to use for testing them against in a solr request.
*/
public static CharSequence toJSONFacetParamValue(Map<String, TermFacet> facets) {
- assert null != facets;
- assert 0 < facets.size();
+ assertNotNull(facets);
+ assertTrue(0 < facets.size());
StringBuilder sb = new StringBuilder("{");
for (String key : facets.keySet()) {
sb.append(key).append(" : ").append(facets.get(key).toJSONFacetParamValue());
@@ -931,7 +931,6 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
Map<String, TermFacet> results = new LinkedHashMap<>();
for (int i = 0; i < numFacets; i++) {
final JoinDomain domain = JoinDomain.buildRandomDomain();
- assert null != domain;
final Integer limit = randomLimitParam(random());
final Integer overrequest = randomOverrequestParam(random());
final TermFacet facet =
@@ -967,7 +966,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
* @param filter filter to apply to domain, null if domain involves no filtering
*/
public JoinDomain(String from, String to, String filter) {
- assert !((null == from) ^ (null == to)) : "if from is null, to must be null";
+ assertEquals("if from is null, to must be null", (null == from), (null == to));
this.from = from;
this.to = to;
this.filter = filter;
@@ -983,7 +982,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
}
StringBuilder sb = new StringBuilder("domain:{");
if (null != from) {
- assert null != to;
+ assertNotNull(to);
sb.append("join:{from:").append(from).append(",to:").append(to).append("}");
if (null != filter) {
sb.append(",");
@@ -1002,8 +1001,8 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
* facet
*/
public SolrParams applyDomainToQuery(String safeKey, SolrParams in) {
- assert null
- == in.get(safeKey); // shouldn't be possible if every facet uses a unique key string
+ // shouldn't be possible if every facet uses a unique key string
+ assertNull(in.get(safeKey));
String q = in.get("q");
final ModifiableSolrParams out = new ModifiableSolrParams(in);
@@ -1065,7 +1064,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
}
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
index 69fafaf05ca..1ca9080ebd6 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
@@ -204,7 +204,7 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
* @see #randFieldValue
*/
private static String field(final String[] suffixes, final int fieldNum) {
- assert fieldNum < MAX_FIELD_NUM;
+ assertTrue(fieldNum < MAX_FIELD_NUM);
final String suffix = suffixes[fieldNum % suffixes.length];
return "field_" + fieldNum + suffix;
@@ -354,7 +354,7 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
}
private static String buildORQuery(String... clauses) {
- assert 0 < clauses.length;
+ assertTrue(0 < clauses.length);
return "(" + String.join(" OR ", clauses) + ")";
}
@@ -581,7 +581,7 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
* @param options can set any of options used in a term facet other than field or (sub) facets
*/
public TermFacet(final String field, final Map<String, Object> options) {
- assert null != field;
+ assertNotNull(field);
this.field = field;
jsonData.putAll(options);
@@ -623,8 +623,8 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
* value to use for testing them against in a solr request.
*/
public static String toJSONFacetParamValue(final Map<String, TermFacet> facets) {
- assert null != facets;
- assert !facets.isEmpty();
+ assertNotNull(facets);
+ assertFalse(facets.isEmpty());
// see class javadocs for why we always want processEmpty
final Map<String, Object> jsonData = map("processEmpty", true);
@@ -700,8 +700,9 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
// never used a prefix on a numeric field
return null;
}
- assert (facetField.contains("multi_s") || facetField.contains("solo_s"))
- : "possible facet fields have changed, breaking test";
+ assertTrue(
+ "possible facet fields have changed, breaking test",
+ facetField.contains("multi_s") || facetField.contains("solo_s"));
switch (r.nextInt(5)) {
case 0:
@@ -899,7 +900,7 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
}
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
index 235578d82d0..4bb741e772c 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
@@ -194,7 +194,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
* @see #randFieldValue
*/
private static String field(final String[] suffixes, final int fieldNum) {
- assert fieldNum < MAX_FIELD_NUM;
+ assertTrue(fieldNum < MAX_FIELD_NUM);
final String suffix = suffixes[fieldNum % suffixes.length];
return "field_" + fieldNum + suffix;
@@ -759,7 +759,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
}
private static String buildORQuery(String... clauses) {
- assert 0 < clauses.length;
+ assertTrue(0 < clauses.length);
return "(" + String.join(" OR ", clauses) + ")";
}
@@ -865,8 +865,8 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
* value to use for testing them against in a solr request.
*/
public static String toJSONFacetParamValue(final Map<String, ? extends Facet> facets) {
- assert null != facets;
- assert !facets.isEmpty();
+ assertNotNull(facets);
+ assertFalse(facets.isEmpty());
return JSONUtil.toJSON(facets, -1); // no newlines
}
@@ -925,7 +925,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
public RelatednessFacet(
final String foreQ, final String backQ, final Map<String, Object> options) {
- assert null != options;
+ assertNotNull(options);
final String f = null == foreQ ? "$fore" : "{!v='" + foreQ + "'}";
final String b = null == backQ ? "$back" : "{!v='" + backQ + "'}";
@@ -980,7 +980,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
* @param options can set any of options used in a term facet other than field or (sub) facets
*/
public TermFacet(final String field, final Map<String, Object> options) {
- assert null != field;
+ assertNotNull(field);
jsonData.put("method", "${method_val:smart}");
@@ -1135,8 +1135,9 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
// never used a prefix on a numeric field
return null;
}
- assert (facetField.contains("multi_s") || facetField.contains("solo_s"))
- : "possible facet fields have changed, breaking test";
+ assertTrue(
+ "possible facet fields have changed, breaking test",
+ facetField.contains("multi_s") || facetField.contains("solo_s"));
switch (r.nextInt(5)) {
case 0:
@@ -1306,7 +1307,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
- assert null != client.getDefaultCollection();
+ assertNotNull(client.getDefaultCollection());
AbstractDistribZkTestBase.waitForRecoveriesToFinish(
client.getDefaultCollection(), ZkStateReader.from(client), true, true, 330);
}
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
index b82414893f9..e2a451e7dcf 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
@@ -3575,7 +3575,7 @@ public class TestJsonFacets extends SolrTestCaseHS {
"facets=={ 'count':6, " + "f1:{ buckets:[{ val:batman, count:1, x:1}]}" + " } ");
assertEquals(1, DebugAgg.Acc.creates.get() - creates);
- assertTrue(DebugAgg.Acc.resets.get() - resets == 0);
+ assertEquals(0, DebugAgg.Acc.resets.get() - resets);
// all slots should be done in a single shot. there may be more than 5 due to special slots or
// hashing.
assertTrue(DebugAgg.Acc.last.numSlots >= 5);
@@ -3593,7 +3593,7 @@ public class TestJsonFacets extends SolrTestCaseHS {
"facets==");
assertEquals(1, DebugAgg.Acc.creates.get() - creates);
- assertTrue(DebugAgg.Acc.resets.get() - resets == 0);
+ assertEquals(0, DebugAgg.Acc.resets.get() - resets);
// all slots should be done in a single shot. there may be more than 5 due to special slots or
// hashing.
assertTrue(DebugAgg.Acc.last.numSlots >= 5);
@@ -3612,7 +3612,7 @@ public class TestJsonFacets extends SolrTestCaseHS {
"facets==");
assertEquals(1, DebugAgg.Acc.creates.get() - creates);
- assertTrue(DebugAgg.Acc.resets.get() - resets == 0);
+ assertEquals(0, DebugAgg.Acc.resets.get() - resets);
// all slots should be done in a single shot. there may be more than 5 due to special slots or
// hashing.
assertTrue(DebugAgg.Acc.last.numSlots >= 5);
diff --git a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
index a059675089a..56d94a5f2ab 100644
--- a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
+++ b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
@@ -117,7 +117,7 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
for (int i = 0; i < results.length; i += 2) {
final int id = (int) results[i];
- assert ((float) id) == results[i];
+ assertEquals(((float) id), results[i], 0.0);
String xpath =
"//doc[./str[@name='id']='"
@@ -225,14 +225,14 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
Object orig = FileFloatSource.onlyForTesting;
singleTest(field, "log(\0)");
// make sure the values were cached
- assertTrue(orig == FileFloatSource.onlyForTesting);
+ assertSame(orig, FileFloatSource.onlyForTesting);
singleTest(field, "sqrt(\0)");
- assertTrue(orig == FileFloatSource.onlyForTesting);
+ assertSame(orig, FileFloatSource.onlyForTesting);
makeExternalFile(field, "0=1");
assertU(h.query("/reloadCache", lrf.makeRequest("", "")));
singleTest(field, "sqrt(\0)");
- assertTrue(orig != FileFloatSource.onlyForTesting);
+ assertNotSame(orig, FileFloatSource.onlyForTesting);
Random r = random();
for (int i = 0; i < 10; i++) { // do more iterations for a thorough test
@@ -1042,15 +1042,15 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
Object orig = FileFloatSource.onlyForTesting;
singleTest(fieldAsFunc, "log(\0)");
// make sure the values were cached
- assertTrue(orig == FileFloatSource.onlyForTesting);
+ assertSame(orig, FileFloatSource.onlyForTesting);
singleTest(fieldAsFunc, "sqrt(\0)");
- assertTrue(orig == FileFloatSource.onlyForTesting);
+ assertSame(orig, FileFloatSource.onlyForTesting);
makeExternalFile(field, "0=1");
assertU(adoc("id", "10000")); // will get same reader if no index change
assertU(commit());
singleTest(fieldAsFunc, "sqrt(\0)");
- assertTrue(orig != FileFloatSource.onlyForTesting);
+ assertNotSame(orig, FileFloatSource.onlyForTesting);
}
/**
diff --git a/solr/core/src/test/org/apache/solr/search/function/TestMinMaxOnMultiValuedField.java b/solr/core/src/test/org/apache/solr/search/function/TestMinMaxOnMultiValuedField.java
index 374b2e510a6..19e3ecf63ca 100644
--- a/solr/core/src/test/org/apache/solr/search/function/TestMinMaxOnMultiValuedField.java
+++ b/solr/core/src/test/org/apache/solr/search/function/TestMinMaxOnMultiValuedField.java
@@ -634,7 +634,7 @@ public class TestMinMaxOnMultiValuedField extends SolrTestCaseJ4 {
@SuppressWarnings({"rawtypes"}) final Comparable... vals) {
clearIndex();
- assert 0 < vals.length;
+ assertTrue(0 < vals.length);
@SuppressWarnings({"rawtypes"})
Comparable min = vals[0];
@SuppressWarnings({"rawtypes"})
diff --git a/solr/core/src/test/org/apache/solr/search/function/TestOrdValues.java b/solr/core/src/test/org/apache/solr/search/function/TestOrdValues.java
index af2f00d4634..5c37805b9e4 100644
--- a/solr/core/src/test/org/apache/solr/search/function/TestOrdValues.java
+++ b/solr/core/src/test/org/apache/solr/search/function/TestOrdValues.java
@@ -152,8 +152,8 @@ public class TestOrdValues extends SolrTestCase {
inOrder
? id2String(N_DOCS - i) // in-order ==> larger values first
: id2String(i + 1); // reverse ==> smaller values first
- assertTrue(
- "id of result " + i + " should be " + expectedId + " != " + score, expectedId.equals(id));
+ assertEquals(
+ "id of result " + i + " should be " + expectedId + " != " + score, expectedId, id);
}
r.close();
}
@@ -161,10 +161,10 @@ public class TestOrdValues extends SolrTestCase {
// LUCENE-1250
public void testEqualsNull() {
OrdFieldSource ofs = new OrdFieldSource("f");
- assertFalse(ofs.equals(null));
+ assertNotEquals(null, ofs);
ReverseOrdFieldSource rofs = new ReverseOrdFieldSource("f");
- assertFalse(rofs.equals(null));
+ assertNotEquals(null, rofs);
}
/**
diff --git a/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java b/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
index 5fd3ebcd0d0..1a6c85e5894 100644
--- a/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
+++ b/solr/core/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
@@ -294,7 +294,7 @@ public class DistanceFunctionTest extends SolrTestCaseJ4 {
"fq",
"id:1"),
"//float[@name='score']='0.0'");
- assertTrue("should throw an exception", false);
+ fail("should throw an exception");
} catch (Exception e) {
Throwable cause = e.getCause();
assertNotNull(cause);
diff --git a/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java b/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
index e110c015019..2282f33e1b0 100644
--- a/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
+++ b/solr/core/src/test/org/apache/solr/search/join/BJQParserTest.java
@@ -117,8 +117,9 @@ public class BJQParserTest extends SolrTestCaseJ4 {
// add grandchildren after children
for (ListIterator<String[]> iter = block.listIterator(); iter.hasNext(); ) {
String[] child = iter.next();
- assert Objects.equals(child[0], "child_s") && Objects.equals(child[2], "parentchild_s")
- : Arrays.toString(child);
+ assertTrue(
+ Arrays.toString(child),
+ Objects.equals(child[0], "child_s") && Objects.equals(child[2], "parentchild_s"));
String child_s = child[1];
String parentchild_s = child[3];
int grandChildPos = 0;
@@ -178,7 +179,6 @@ public class BJQParserTest extends SolrTestCaseJ4 {
"//doc/arr[@name='child_s']/str='" + klm[0] + "'",
"//doc/arr[@name='child_s']/str='" + klm[1] + "'",
"//doc/arr[@name='child_s']/str='" + klm[2] + "'");
- assert klm.length == 3 : "change asserts pls " + Arrays.toString(klm);
}
private static final String beParents[] =
diff --git a/solr/core/src/test/org/apache/solr/search/join/TestNestedDocsSort.java b/solr/core/src/test/org/apache/solr/search/join/TestNestedDocsSort.java
index 0ba318c8449..904af50fe7d 100644
--- a/solr/core/src/test/org/apache/solr/search/join/TestNestedDocsSort.java
+++ b/solr/core/src/test/org/apache/solr/search/join/TestNestedDocsSort.java
@@ -100,7 +100,7 @@ public class TestNestedDocsSort extends SolrTestCaseJ4 {
}
private void parseAssertNe(String sortField, String sortField2) {
- assertFalse(parse(sortField).equals(parse(sortField2)));
+ assertNotEquals(parse(sortField), parse(sortField2));
}
private SortField parse(String a) {
diff --git a/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPNoScore.java b/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPNoScore.java
index 61201956565..a3702453162 100644
--- a/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPNoScore.java
+++ b/solr/core/src/test/org/apache/solr/search/join/TestScoreJoinQPNoScore.java
@@ -206,7 +206,7 @@ public class TestScoreJoinQPNoScore extends SolrTestCaseJ4 {
Query y =
QParser.getParser("{!join from=dept_ss to=dept_ss score=none}text_t:develop", req)
.getQuery();
- assertFalse("diff from fields produce equal queries", x.equals(y));
+ assertNotEquals("diff from fields produce equal queries", x, y);
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/join/another/BJQFilterAccessibleTest.java b/solr/core/src/test/org/apache/solr/search/join/another/BJQFilterAccessibleTest.java
index e1f029daff6..680e8be971a 100644
--- a/solr/core/src/test/org/apache/solr/search/join/another/BJQFilterAccessibleTest.java
+++ b/solr/core/src/test/org/apache/solr/search/join/another/BJQFilterAccessibleTest.java
@@ -29,7 +29,6 @@ import org.apache.lucene.search.join.ToParentBlockJoinQuery;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.join.BlockJoinParentQParser;
-import org.junit.Assert;
import org.junit.BeforeClass;
public class BJQFilterAccessibleTest extends SolrTestCaseJ4 {
@@ -49,7 +48,7 @@ public class BJQFilterAccessibleTest extends SolrTestCaseJ4 {
childQuery,
BlockJoinParentQParser.getCachedBitSetProducer(req, parentQuery),
ScoreMode.Max);
- Assert.assertEquals(6, req.getSearcher().search(tpbjq, 10).totalHits.value);
+ assertEquals(6, req.getSearcher().search(tpbjq, 10).totalHits.value);
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/search/similarities/TestClassicSimilarityFactory.java b/solr/core/src/test/org/apache/solr/search/similarities/TestClassicSimilarityFactory.java
index f481b03b74c..894054f9921 100644
--- a/solr/core/src/test/org/apache/solr/search/similarities/TestClassicSimilarityFactory.java
+++ b/solr/core/src/test/org/apache/solr/search/similarities/TestClassicSimilarityFactory.java
@@ -34,11 +34,11 @@ public class TestClassicSimilarityFactory extends BaseSimilarityTestCase {
/** Classic w/ default parameters */
public void testDefaults() {
ClassicSimilarity sim = getSimilarity("text", ClassicSimilarity.class);
- assertEquals(true, sim.getDiscountOverlaps());
+ assertTrue(sim.getDiscountOverlaps());
}
/** Classic w/ explicit params */
public void testParams() {
ClassicSimilarity sim = getSimilarity("text_overlap", ClassicSimilarity.class);
- assertEquals(false, sim.getDiscountOverlaps());
+ assertFalse(sim.getDiscountOverlaps());
}
}
diff --git a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
index 30050214d43..77e45711e08 100644
--- a/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
+++ b/solr/core/src/test/org/apache/solr/servlet/CacheHeaderTest.java
@@ -70,7 +70,7 @@ public class CacheHeaderTest extends CacheHeaderTestBase {
HttpRequestBase m = getSelectMethod("GET", "q", "xyz_ignore_exception:solr", "qt", "standard");
// We force an exception from Solr. This should emit "no-cache" HTTP headers
HttpResponse response = getClient().execute(m);
- assertFalse(response.getStatusLine().getStatusCode() == 200);
+ assertNotEquals(200, response.getStatusLine().getStatusCode());
checkVetoHeaders(response, false);
}
diff --git a/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java b/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java
index d19cf56c7bc..b3740e8849c 100644
--- a/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java
+++ b/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java
@@ -185,7 +185,7 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
for (Future<?> future : futures) {
try {
- assertTrue(future.get() != null);
+ assertNotNull(future.get());
} catch (Exception e) {
MatcherAssert.assertThat(
e.getMessage(), containsString("non ok status: 429, message:Too Many Requests"));
diff --git a/solr/core/src/test/org/apache/solr/spelling/ConjunctionSolrSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/ConjunctionSolrSpellCheckerTest.java
index ecee18313a5..e58c1e8bf6b 100644
--- a/solr/core/src/test/org/apache/solr/spelling/ConjunctionSolrSpellCheckerTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/ConjunctionSolrSpellCheckerTest.java
@@ -24,7 +24,6 @@ import org.apache.lucene.search.spell.StringDistance;
import org.apache.solr.SolrTestCase;
import org.apache.solr.core.SolrCore;
import org.apache.solr.search.SolrIndexSearcher;
-import org.junit.Assert;
import org.junit.Test;
public class ConjunctionSolrSpellCheckerTest extends SolrTestCase {
@@ -55,7 +54,7 @@ public class ConjunctionSolrSpellCheckerTest extends SolrTestCase {
"Cannot set up test. 2 NGramDistances with different gram sizes should not be equal.");
}
}
- Assert.assertEquals(
+ assertEquals(
"The distance " + sameDistance + " does not properly implement equals.",
sameDistance1,
sameDistance2);
diff --git a/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java
index 36d065f062d..e6fc2bd328e 100644
--- a/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java
@@ -75,9 +75,10 @@ public class DirectSolrSpellCheckerTest extends SolrTestCaseJ4 {
assertFalse("suggestions shouldn't be empty", suggestions.isEmpty());
Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
assertEquals("foo", entry.getKey());
- assertFalse(
+ assertNotEquals(
entry.getValue() + " equals: " + SpellingResult.NO_FREQUENCY_INFO,
- entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
+ SpellingResult.NO_FREQUENCY_INFO,
+ (int) entry.getValue());
// check that 'super' is *not* corrected
spellOpts.tokens = queryConverter.convert("super");
diff --git a/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
index 4a68253b6d9..3f6c5381150 100644
--- a/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
@@ -72,7 +72,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, indexDir.getAbsolutePath());
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
- assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
+ assertEquals(dictName + " is not equal to " + "external", "external", dictName);
checker.build(core, null);
h.getCore()
@@ -84,12 +84,11 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
assertNotNull("result shouldn't be null", result);
Map<String, Integer> suggestions = result.get(spellOpts.tokens.iterator().next());
Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
- assertTrue(
- entry.getKey() + " is not equal to " + "foo",
- entry.getKey().equals("foo") == true);
- assertTrue(
+ assertEquals(entry.getKey() + " is not equal to " + "foo", "foo", entry.getKey());
+ assertEquals(
entry.getValue() + " does not equal: " + SpellingResult.NO_FREQUENCY_INFO,
- entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
+ SpellingResult.NO_FREQUENCY_INFO,
+ (int) entry.getValue());
spellOpts.tokens = queryConverter.convert("super");
result = checker.getSuggestions(spellOpts);
@@ -124,7 +123,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
spellchecker.add(SolrSpellChecker.FIELD_TYPE, "teststop");
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
- assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
+ assertEquals(dictName + " is not equal to " + "external", "external", dictName);
checker.build(core, null);
Collection<Token> tokens = queryConverter.convert("Solar");
@@ -133,19 +132,19 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
searcher -> {
SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.getIndexReader());
SpellingResult result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
// should be lowercased, b/c we are using a lowercasing analyzer
Map<String, Integer> suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue(
+ assertEquals(
"suggestions Size: " + suggestions.size() + " is not: " + 1,
- suggestions.size() == 1);
+ 1,
+ suggestions.size());
Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
- assertTrue(
- entry.getKey() + " is not equal to " + "solr",
- entry.getKey().equals("solr") == true);
- assertTrue(
+ assertEquals(entry.getKey() + " is not equal to " + "solr", "solr", entry.getKey());
+ assertEquals(
entry.getValue() + " does not equal: " + SpellingResult.NO_FREQUENCY_INFO,
- entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
+ SpellingResult.NO_FREQUENCY_INFO,
+ (int) entry.getValue());
// test something not in the spell checker
spellOpts.tokens = queryConverter.convert("super");
@@ -174,7 +173,7 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
- assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
+ assertEquals(dictName + " is not equal to " + "external", "external", dictName);
checker.build(core, null);
h.getCore()
@@ -186,16 +185,16 @@ public class FileBasedSpellCheckerTest extends SolrTestCaseJ4 {
assertNotNull("result shouldn't be null", result);
// should be lowercased, b/c we are using a lowercasing analyzer
Map<String, Integer> suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue(
+ assertEquals(
"suggestions Size: " + suggestions.size() + " is not: " + 1,
- suggestions.size() == 1);
+ 1,
+ suggestions.size());
Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
- assertTrue(
- entry.getKey() + " is not equal to " + "solr",
- entry.getKey().equals("solr") == true);
- assertTrue(
+ assertEquals(entry.getKey() + " is not equal to " + "solr", "solr", entry.getKey());
+ assertEquals(
entry.getValue() + " does not equal: " + SpellingResult.NO_FREQUENCY_INFO,
- entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
+ SpellingResult.NO_FREQUENCY_INFO,
+ (int) entry.getValue());
spellOpts.tokens = queryConverter.convert("super");
result = checker.getSuggestions(spellOpts);
diff --git a/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
index 9f592ea5450..0db7a5d8462 100644
--- a/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
@@ -115,9 +115,10 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
- assertTrue(
+ assertEquals(
dictName + " is not equal to " + SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
- dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+ SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+ dictName);
h.getCore()
.withSearcher(
searcher -> {
@@ -127,34 +128,33 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
Collection<Token> tokens = queryConverter.convert("documemt");
SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
SpellingResult result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
// should be lowercased, b/c we are using a lowercasing analyzer
Map<String, Integer> suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("documemt is null and it shouldn't be", suggestions != null);
- assertTrue(
- "documemt Size: " + suggestions.size() + " is not: " + 1,
- suggestions.size() == 1);
+ assertNotNull("documemt is null and it shouldn't be", suggestions);
+ assertEquals(
+ "documemt Size: " + suggestions.size() + " is not: " + 1, 1, suggestions.size());
Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
- assertTrue(
- entry.getKey() + " is not equal to " + "document",
- entry.getKey().equals("document") == true);
- assertTrue(
+ assertEquals(
+ entry.getKey() + " is not equal to " + "document", "document", entry.getKey());
+ assertEquals(
entry.getValue() + " does not equal: " + SpellingResult.NO_FREQUENCY_INFO,
- entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
+ SpellingResult.NO_FREQUENCY_INFO,
+ (int) entry.getValue());
// test something not in the spell checker
spellOpts.tokens = queryConverter.convert("super");
result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("suggestions size should be 0", suggestions.size() == 0);
+ assertEquals("suggestions size should be 0", 0, suggestions.size());
// test something that is spelled correctly
spellOpts.tokens = queryConverter.convert("document");
result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("suggestions is null and it shouldn't be", suggestions == null);
+ assertNull("suggestions is null and it shouldn't be", suggestions);
// Has multiple possibilities, but the exact exists, so that should be returned
spellOpts.tokens = queryConverter.convert("red");
@@ -162,7 +162,7 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
result = checker.getSuggestions(spellOpts);
assertNotNull(result);
suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("suggestions is not null and it should be", suggestions == null);
+ assertNull("suggestions is not null and it should be", suggestions);
// Try out something which should have multiple suggestions
spellOpts.tokens = queryConverter.convert("bug");
@@ -170,25 +170,30 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
assertNotNull(result);
suggestions = result.get(spellOpts.tokens.iterator().next());
assertNotNull(suggestions);
- assertTrue(
+ assertEquals(
"suggestions Size: " + suggestions.size() + " is not: " + 2,
- suggestions.size() == 2);
+ 2,
+ suggestions.size());
entry = suggestions.entrySet().iterator().next();
- assertTrue(
+ assertNotEquals(
entry.getKey() + " is equal to " + "bug and it shouldn't be",
- entry.getKey().equals("bug") == false);
- assertTrue(
+ "bug",
+ entry.getKey());
+ assertEquals(
entry.getValue() + " does not equal: " + SpellingResult.NO_FREQUENCY_INFO,
- entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
+ SpellingResult.NO_FREQUENCY_INFO,
+ (int) entry.getValue());
entry = suggestions.entrySet().iterator().next();
- assertTrue(
+ assertNotEquals(
entry.getKey() + " is equal to " + "bug and it shouldn't be",
- entry.getKey().equals("bug") == false);
- assertTrue(
+ "bug",
+ entry.getKey());
+ assertEquals(
entry.getValue() + " does not equal: " + SpellingResult.NO_FREQUENCY_INFO,
- entry.getValue() == SpellingResult.NO_FREQUENCY_INFO);
+ SpellingResult.NO_FREQUENCY_INFO,
+ (int) entry.getValue());
// Check empty token due to spellcheck.q = ""
spellOpts.tokens = Collections.singletonList(new Token("", 0, 0));
@@ -214,9 +219,10 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
- assertTrue(
+ assertEquals(
dictName + " is not equal to " + SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
- dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+ SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+ dictName);
h.getCore()
.withSearcher(
searcher -> {
@@ -228,31 +234,29 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
new SpellingOptions(
tokens, reader, 1, SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX, true, 0.5f, null);
SpellingResult result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
// should be lowercased, b/c we are using a lowercasing analyzer
Map<String, Integer> suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("documemt is null and it shouldn't be", suggestions != null);
- assertTrue(
- "documemt Size: " + suggestions.size() + " is not: " + 1,
- suggestions.size() == 1);
+ assertNotNull("documemt is null and it shouldn't be", suggestions);
+ assertEquals(
+ "documemt Size: " + suggestions.size() + " is not: " + 1, 1, suggestions.size());
Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
- assertTrue(
- entry.getKey() + " is not equal to " + "document",
- entry.getKey().equals("document") == true);
- assertTrue(entry.getValue() + " does not equal: " + 2, entry.getValue() == 2);
+ assertEquals(
+ entry.getKey() + " is not equal to " + "document", "document", entry.getKey());
+ assertEquals(entry.getValue() + " does not equal: " + 2, 2, (int) entry.getValue());
// test something not in the spell checker
spellOpts.tokens = queryConverter.convert("super");
result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("suggestions size should be 0", suggestions.size() == 0);
+ assertEquals("suggestions size should be 0", 0, suggestions.size());
spellOpts.tokens = queryConverter.convert("document");
result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("suggestions is not null and it should be", suggestions == null);
+ assertNull("suggestions is not null and it should be", suggestions);
return null;
});
}
@@ -278,17 +282,18 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
AbstractLuceneSpellChecker.STRING_DISTANCE, JaroWinklerDistance.class.getName());
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
- assertTrue(
+ assertEquals(
dictName + " is not equal to " + SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
- dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+ SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+ dictName);
h.getCore()
.withSearcher(
searcher -> {
checker.build(core, searcher);
SpellChecker sc = checker.getSpellChecker();
- assertTrue("sc is null and it shouldn't be", sc != null);
+ assertNotNull("sc is null and it shouldn't be", sc);
StringDistance sd = sc.getStringDistance();
- assertTrue("sd is null and it shouldn't be", sd != null);
+ assertNotNull("sd is null and it shouldn't be", sd);
assertTrue(
"sd is not an instance of " + JaroWinklerDistance.class.getName(),
sd instanceof JaroWinklerDistance);
@@ -334,9 +339,10 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, spellchecker);
SolrCore core = h.getCore();
String dictName = checker.init(spellchecker, core);
- assertTrue(
+ assertEquals(
dictName + " is not equal to " + SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
- dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+ SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+ dictName);
h.getCore()
.withSearcher(
searcher -> {
@@ -348,30 +354,28 @@ public class IndexBasedSpellCheckerTest extends SolrTestCaseJ4 {
new SpellingOptions(
tokens, reader, 1, SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX, true, 0.5f, null);
SpellingResult result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
// should be lowercased, b/c we are using a lowercasing analyzer
Map<String, Integer> suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("flesh is null and it shouldn't be", suggestions != null);
- assertTrue(
- "flesh Size: " + suggestions.size() + " is not: " + 1, suggestions.size() == 1);
+ assertNotNull("flesh is null and it shouldn't be", suggestions);
+ assertEquals(
+ "flesh Size: " + suggestions.size() + " is not: " + 1, 1, suggestions.size());
Map.Entry<String, Integer> entry = suggestions.entrySet().iterator().next();
- assertTrue(
- entry.getKey() + " is not equal to " + "flash",
- entry.getKey().equals("flash") == true);
- assertTrue(entry.getValue() + " does not equal: " + 1, entry.getValue() == 1);
+ assertEquals(entry.getKey() + " is not equal to " + "flash", "flash", entry.getKey());
+ assertEquals(entry.getValue() + " does not equal: " + 1, 1, (int) entry.getValue());
// test something not in the spell checker
spellOpts.tokens = queryConverter.convert("super");
result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("suggestions size should be 0", suggestions.size() == 0);
+ assertEquals("suggestions size should be 0", 0, suggestions.size());
spellOpts.tokens = queryConverter.convert("Caroline");
result = checker.getSuggestions(spellOpts);
- assertTrue("result is null and it shouldn't be", result != null);
+ assertNotNull("result is null and it shouldn't be", result);
suggestions = result.get(spellOpts.tokens.iterator().next());
- assertTrue("suggestions is not null and it should be", suggestions == null);
+ assertNull("suggestions is not null and it should be", suggestions);
return null;
});
}
diff --git a/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java b/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java
index d2843a7ffe8..f7687441d02 100644
--- a/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java
@@ -138,7 +138,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testCollationWithRangeQuery() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -158,11 +158,11 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationHolder = (NamedList) spellCheck.get("collations");
List<String> collations = collationHolder.getAll("collation");
- assertTrue(collations.size() == 1);
+ assertEquals(1, collations.size());
String collation = collations.iterator().next();
System.out.println(collation);
- assertTrue(
- "Incorrect collation: " + collation, "id:[1 TO 10] AND lowerfilt:love".equals(collation));
+ assertEquals(
+ "Incorrect collation: " + collation, "id:[1 TO 10] AND lowerfilt:love", collation);
}
}
@@ -171,7 +171,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testCollationWithHypens() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -191,10 +191,9 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationHolder = (NamedList) spellCheck.get("collations");
List<String> collations = collationHolder.getAll("collation");
- assertTrue(collations.size() == 1);
+ assertEquals(1, collations.size());
String collation = collations.iterator().next();
- assertTrue(
- "Incorrect collation: " + collation, "lowerfilt:(hyphenated-word)".equals(collation));
+ assertEquals("Incorrect collation: " + collation, "lowerfilt:(hyphenated-word)", collation);
}
params.remove(CommonParams.Q);
@@ -212,9 +211,9 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationHolder = (NamedList) spellCheck.get("collations");
List<String> collations = collationHolder.getAll("collation");
- assertTrue(collations.size() == 1);
+ assertEquals(1, collations.size());
String collation = collations.iterator().next();
- assertTrue("Incorrect collation: " + collation, "hyphenated-word".equals(collation));
+ assertEquals("Incorrect collation: " + collation, "hyphenated-word", collation);
}
}
@@ -278,7 +277,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testCollateWithFilter() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -305,7 +304,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
List<String> collations = collationHolder.getAll("collation");
assertTrue(collations.size() > 0);
for (String collation : collations) {
- assertTrue(!collation.equals("lowerfilt:(+faith +hope +loaves)"));
+ assertNotEquals("lowerfilt:(+faith +hope +loaves)", collation);
}
}
@@ -314,7 +313,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testCollateWithMultipleRequestHandlers() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -361,7 +360,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testExtendedCollate() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(CommonParams.QT, "spellCheckCompRH");
@@ -421,7 +420,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
spellCheck = (NamedList) values.get("spellcheck");
collationHolder = (NamedList) spellCheck.get("collations");
List<String> collations = collationHolder.getAll("collation");
- assertTrue(collations.size() == 2);
+ assertEquals(2, collations.size());
for (String multipleCollation : collations) {
assertTrue(
multipleCollation.equals("lowerfilt:(+faith +hope +love)")
@@ -442,26 +441,26 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
collationHolder = (NamedList) spellCheck.get("collations");
List<NamedList> expandedCollationList = collationHolder.getAll("collation");
Set<String> usedcollations = new HashSet<>();
- assertTrue(expandedCollationList.size() == 2);
+ assertEquals(2, expandedCollationList.size());
for (NamedList expandedCollation : expandedCollationList) {
String multipleCollation = (String) expandedCollation.get("collationQuery");
assertTrue(
multipleCollation.equals("lowerfilt:(+faith +hope +love)")
|| multipleCollation.equals("lowerfilt:(+faith +hope +loaves)"));
- assertTrue(!usedcollations.contains(multipleCollation));
+ assertFalse(usedcollations.contains(multipleCollation));
usedcollations.add(multipleCollation);
assertEquals(1L, expandedCollation.get("hits"));
NamedList misspellingsAndCorrections =
(NamedList) expandedCollation.get("misspellingsAndCorrections");
- assertTrue(misspellingsAndCorrections.size() == 3);
+ assertEquals(3, misspellingsAndCorrections.size());
String correctionForFauth = (String) misspellingsAndCorrections.get("fauth");
String correctionForHome = (String) misspellingsAndCorrections.get("home");
String correctionForLoane = (String) misspellingsAndCorrections.get("loane");
- assertTrue(correctionForFauth.equals("faith"));
- assertTrue(correctionForHome.equals("hope"));
+ assertEquals("faith", correctionForFauth);
+ assertEquals("hope", correctionForHome);
assertTrue(correctionForLoane.equals("love") || correctionForLoane.equals("loaves"));
}
}
@@ -471,7 +470,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testCollateWithGrouping() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -497,7 +496,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationHolder = (NamedList) spellCheck.get("collations");
List<String> collations = collationHolder.getAll("collation");
- assertTrue(collations.size() == 1);
+ assertEquals(1, collations.size());
}
@Test
@@ -705,7 +704,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testZeroTries() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -725,7 +724,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationList = (NamedList) spellCheck.get("collations");
List<?> collations = (List<?>) collationList.getAll("collation");
- assertTrue(collations.size() == 2);
+ assertEquals(2, collations.size());
}
@Test
@@ -733,7 +732,7 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
public void testWithCursorMark() {
SolrCore core = h.getCore();
SearchComponent speller = core.getSearchComponent("spellcheck");
- assertTrue("speller is null and it shouldn't be", speller != null);
+ assertNotNull("speller is null and it shouldn't be", speller);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(SpellCheckComponent.COMPONENT_NAME, "true");
@@ -755,6 +754,6 @@ public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
NamedList spellCheck = (NamedList) values.get("spellcheck");
NamedList collationList = (NamedList) spellCheck.get("collations");
List<?> collations = (List<?>) collationList.getAll("collation");
- assertTrue(collations.size() == 1);
+ assertEquals(1, collations.size());
}
}
diff --git a/solr/core/src/test/org/apache/solr/spelling/SpellPossibilityIteratorTest.java b/solr/core/src/test/org/apache/solr/spelling/SpellPossibilityIteratorTest.java
index 5e31b0f8ffe..d402044b4ce 100644
--- a/solr/core/src/test/org/apache/solr/spelling/SpellPossibilityIteratorTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/SpellPossibilityIteratorTest.java
@@ -114,7 +114,7 @@ public class SpellPossibilityIteratorTest extends SolrTestCaseJ4 {
PossibilityIterator.RankedSpellPossibility rsp = iter.next();
count++;
}
- assertTrue(count == 1000);
+ assertEquals(1000, count);
lotsaSuggestions.put(new Token("AYE_BEE1", 0, 7), AYE_BEE);
lotsaSuggestions.put(new Token("AYE_BEE2", 0, 7), AYE_BEE);
@@ -142,15 +142,16 @@ public class SpellPossibilityIteratorTest extends SolrTestCaseJ4 {
PossibilityIterator.RankedSpellPossibility rsp = iter.next();
if (count == 0) {
- assertTrue("I".equals(rsp.corrections.get(0).getCorrection()));
- assertTrue("alpha".equals(rsp.corrections.get(1).getCorrection()));
- assertTrue("one".equals(rsp.corrections.get(2).getCorrection()));
+ assertEquals("I", rsp.corrections.get(0).getCorrection());
+ assertEquals("alpha", rsp.corrections.get(1).getCorrection());
+ assertEquals("one", rsp.corrections.get(2).getCorrection());
}
count++;
}
- assertTrue(
+ assertEquals(
("Three maps (8*9*10) should return 720 iterations but instead returned " + count),
- count == 720);
+ 720,
+ count);
suggestions.remove(TOKEN_CEE);
iter = new PossibilityIterator(suggestions, 100, 10000, false);
@@ -159,8 +160,8 @@ public class SpellPossibilityIteratorTest extends SolrTestCaseJ4 {
iter.next();
count++;
}
- assertTrue(
- ("Two maps (8*9) should return 72 iterations but instead returned " + count), count == 72);
+ assertEquals(
+ ("Two maps (8*9) should return 72 iterations but instead returned " + count), 72, count);
suggestions.remove(TOKEN_BEE);
iter = new PossibilityIterator(suggestions, 5, 10000, false);
@@ -169,7 +170,7 @@ public class SpellPossibilityIteratorTest extends SolrTestCaseJ4 {
iter.next();
count++;
}
- assertTrue(("We requested 5 suggestions but got " + count), count == 5);
+ assertEquals(("We requested 5 suggestions but got " + count), 5, count);
suggestions.remove(TOKEN_AYE);
iter = new PossibilityIterator(suggestions, Integer.MAX_VALUE, 10000, false);
@@ -178,7 +179,7 @@ public class SpellPossibilityIteratorTest extends SolrTestCaseJ4 {
iter.next();
count++;
}
- assertTrue(("No maps should return 0 iterations but instead returned " + count), count == 0);
+ assertEquals(("No maps should return 0 iterations but instead returned " + count), 0, count);
}
@Test
@@ -216,12 +217,12 @@ public class SpellPossibilityIteratorTest extends SolrTestCaseJ4 {
aCount++;
}
}
- assertTrue(c != null);
+ assertNotNull(c);
assertTrue(ab != null || (a != null && b != null));
assertTrue(ab == null || (a == null && b == null));
assertTrue(dupChecker.add(rsp));
}
- assertTrue(aCount == 2160);
- assertTrue(abCount == 180);
+ assertEquals(2160, aCount);
+ assertEquals(180, abCount);
}
}
diff --git a/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java b/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
index e5dbaba66d3..42172c89e45 100644
--- a/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
@@ -37,8 +37,8 @@ public class SpellingQueryConverterTest extends SolrTestCase {
converter.init(new NamedList<>());
converter.setAnalyzer(new WhitespaceAnalyzer());
Collection<Token> tokens = converter.convert("field:foo");
- assertTrue("tokens is null and it shouldn't be", tokens != null);
- assertTrue("tokens Size: " + tokens.size() + " is not: " + 1, tokens.size() == 1);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
+ assertEquals("tokens Size: " + tokens.size() + " is not: " + 1, 1, tokens.size());
}
@Test
@@ -59,9 +59,10 @@ public class SpellingQueryConverterTest extends SolrTestCase {
int[] tokensToExpect = {1, 1, 2, 2, 2, 2, 2, 2};
for (int i = 0; i < queries.length; i++) {
Collection<Token> tokens = converter.convert(queries[i]);
- assertTrue(
+ assertEquals(
"tokens Size: " + tokens.size() + " is not: " + tokensToExpect[i],
- tokens.size() == tokensToExpect[i]);
+ tokens.size(),
+ tokensToExpect[i]);
}
}
@@ -72,19 +73,19 @@ public class SpellingQueryConverterTest extends SolrTestCase {
converter.setAnalyzer(new WhitespaceAnalyzer());
String original = "field_with_underscore:value_with_underscore";
Collection<Token> tokens = converter.convert(original);
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
original = "field_with_digits123:value_with_digits123";
tokens = converter.convert(original);
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
original = "field-with-hyphens:value-with-hyphens";
tokens = converter.convert(original);
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
@@ -97,7 +98,7 @@ public class SpellingQueryConverterTest extends SolrTestCase {
original = "foo:bar^5.0";
tokens = converter.convert(original);
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
@@ -105,15 +106,17 @@ public class SpellingQueryConverterTest extends SolrTestCase {
String secondKeyword = "value2";
original = "field-with-parenthesis:(" + firstKeyword + " " + secondKeyword + ")";
tokens = converter.convert(original);
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 2", 2, tokens.size());
assertTrue("Token offsets do not match", isOffsetCorrect(original, tokens));
- assertTrue(
+ assertEquals(
"first Token is not " + firstKeyword,
- new ArrayList<>(tokens).get(0).toString().equals(firstKeyword));
- assertTrue(
+ new ArrayList<>(tokens).get(0).toString(),
+ firstKeyword);
+ assertEquals(
"second Token is not " + secondKeyword,
- new ArrayList<>(tokens).get(1).toString().equals(secondKeyword));
+ new ArrayList<>(tokens).get(1).toString(),
+ secondKeyword);
}
private boolean isOffsetCorrect(String s, Collection<Token> tokens) {
@@ -133,15 +136,15 @@ public class SpellingQueryConverterTest extends SolrTestCase {
// chinese text value
Collection<Token> tokens = converter.convert("text_field:我购买了道具和服装。");
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
tokens = converter.convert("text_购field:我购买了道具和服装。");
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
tokens = converter.convert("text_field:我购xyz买了道具和服装。");
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 1", 1, tokens.size());
}
@@ -153,12 +156,12 @@ public class SpellingQueryConverterTest extends SolrTestCase {
// two field:value pairs should give two tokens
Collection<Token> tokens = converter.convert("买text_field:我购买了道具和服装。 field2:bar");
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 2", 2, tokens.size());
// a field:value pair and a search term should give two tokens
tokens = converter.convert("text_field:我购买了道具和服装。 bar");
- assertTrue("tokens is null and it shouldn't be", tokens != null);
+ assertNotNull("tokens is null and it shouldn't be", tokens);
assertEquals("tokens Size: " + tokens.size() + " is not 2", 2, tokens.size());
}
diff --git a/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java b/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java
index 06eeebb05c4..59d906dc257 100644
--- a/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/WordBreakSolrSpellCheckerTest.java
@@ -78,7 +78,7 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
SpellingResult result = checker.getSuggestions(spellOpts);
searcher.decref();
assertTrue(result != null && result.getSuggestions() != null);
- assertTrue(result.getSuggestions().size() == 5);
+ assertEquals(5, result.getSuggestions().size());
}
Collection<Token> tokens = qc.convert("paintable pine apple good ness");
@@ -87,70 +87,70 @@ public class WordBreakSolrSpellCheckerTest extends SolrTestCaseJ4 {
searcher.decref();
assertTrue(result != null && result.getSuggestions() != null);
- assertTrue(result.getSuggestions().size() == 9);
+ assertEquals(9, result.getSuggestions().size());
for (Map.Entry<Token, LinkedHashMap<String, Integer>> s : result.getSuggestions().entrySet()) {
Token orig = s.getKey();
String[] corr = s.getValue().keySet().toArray(new String[0]);
if (orig.toString().equals("paintable")) {
- assertTrue(orig.startOffset() == 0);
- assertTrue(orig.endOffset() == 9);
- assertTrue(orig.length() == 9);
- assertTrue(corr.length == 3);
- assertTrue(corr[0].equals("paint able")); // 1 op ; max doc freq=5
- assertTrue(corr[1].equals("pain table")); // 1 op ; max doc freq=2
- assertTrue(corr[2].equals("pa in table")); // 2 ops
+ assertEquals(0, orig.startOffset());
+ assertEquals(9, orig.endOffset());
+ assertEquals(9, orig.length());
+ assertEquals(3, corr.length);
+ assertEquals("paint able", corr[0]); // 1 op ; max doc freq=5
+ assertEquals("pain table", corr[1]); // 1 op ; max doc freq=2
+ assertEquals("pa in table", corr[2]); // 2 ops
} else if (orig.toString().equals("pine apple")) {
- assertTrue(orig.startOffset() == 10);
- assertTrue(orig.endOffset() == 20);
- assertTrue(orig.length() == 10);
- assertTrue(corr.length == 1);
- assertTrue(corr[0].equals("pineapple"));
+ assertEquals(10, orig.startOffset());
+ assertEquals(20, orig.endOffset());
+ assertEquals(10, orig.length());
+ assertEquals(1, corr.length);
+ assertEquals("pineapple", corr[0]);
} else if (orig.toString().equals("paintable pine")) {
- assertTrue(orig.startOffset() == 0);
- assertTrue(orig.endOffset() == 14);
- assertTrue(orig.length() == 14);
- assertTrue(corr.length == 1);
- assertTrue(corr[0].equals("paintablepine"));
+ assertEquals(0, orig.startOffset());
+ assertEquals(14, orig.endOffset());
+ assertEquals(14, orig.length());
+ assertEquals(1, corr.length);
+ assertEquals("paintablepine", corr[0]);
} else if (orig.toString().equals("good ness")) {
- assertTrue(orig.startOffset() == 21);
- assertTrue(orig.endOffset() == 30);
- assertTrue(orig.length() == 9);
- assertTrue(corr.length == 1);
- assertTrue(corr[0].equals("goodness"));
+ assertEquals(21, orig.startOffset());
+ assertEquals(30, orig.endOffset());
+ assertEquals(9, orig.length());
+ assertEquals(1, corr.length);
+ assertEquals("goodness", corr[0]);
} else if (orig.toString().equals("pine apple good ness")) {
- assertTrue(orig.startOffset() == 10);
- assertTrue(orig.endOffset() == 30);
- assertTrue(orig.length() == 20);
- assertTrue(corr.length == 1);
- assertTrue(corr[0].equals("pineapplegoodness"));
+ assertEquals(10, orig.startOffset());
+ assertEquals(30, orig.endOffset());
+ assertEquals(20, orig.length());
+ assertEquals(1, corr.length);
+ assertEquals("pineapplegoodness", corr[0]);
} else if (orig.toString().equals("pine")) {
- assertTrue(orig.startOffset() == 10);
- assertTrue(orig.endOffset() == 14);
- assertTrue(orig.length() == 4);
- assertTrue(corr.length == 1);
- assertTrue(corr[0].equals("pi ne"));
+ assertEquals(10, orig.startOffset());
+ assertEquals(14, orig.endOffset());
+ assertEquals(4, orig.length());
+ assertEquals(1, corr.length);
+ assertEquals("pi ne", corr[0]);
} else if (orig.toString().equals("pine")) {
- assertTrue(orig.startOffset() == 10);
- assertTrue(orig.endOffset() == 14);
- assertTrue(orig.length() == 4);
- assertTrue(corr.length == 1);
- assertTrue(corr[0].equals("pi ne"));
+ assertEquals(10, orig.startOffset());
+ assertEquals(14, orig.endOffset());
+ assertEquals(4, orig.length());
+ assertEquals(1, corr.length);
+ assertEquals("pi ne", corr[0]);
} else if (orig.toString().equals("apple")) {
- assertTrue(orig.startOffset() == 15);
- assertTrue(orig.endOffset() == 20);
- assertTrue(orig.length() == 5);
- assertTrue(corr.length == 0);
+ assertEquals(15, orig.startOffset());
+ assertEquals(20, orig.endOffset());
+ assertEquals(5, orig.length());
+ assertEquals(0, corr.length);
} else if (orig.toString().equals("good")) {
- assertTrue(orig.startOffset() == 21);
- assertTrue(orig.endOffset() == 25);
- assertTrue(orig.length() == 4);
- assertTrue(corr.length == 0);
+ assertEquals(21, orig.startOffset());
+ assertEquals(25, orig.endOffset());
+ assertEquals(4, orig.length());
+ assertEquals(0, corr.length);
} else if (orig.toString().equals("ness")) {
- assertTrue(orig.startOffset() == 26);
- assertTrue(orig.endOffset() == 30);
- assertTrue(orig.length() == 4);
- assertTrue(corr.length == 0);
+ assertEquals(26, orig.startOffset());
+ assertEquals(30, orig.endOffset());
+ assertEquals(4, orig.length());
+ assertEquals(0, corr.length);
} else {
fail("Unexpected original result: " + orig);
}
diff --git a/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java b/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
index a11bcb8f758..5646d10af63 100644
--- a/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
+++ b/solr/core/src/test/org/apache/solr/spelling/suggest/SuggesterTest.java
@@ -140,6 +140,6 @@ public class SuggesterTest extends SolrTestCaseJ4 {
params.add("field", "test_field");
params.add("lookupImpl", "org.apache.solr.spelling.suggest.tst.TSTLookupFactory");
suggester.init(params, h.getCore());
- assertTrue(suggester.getQueryAnalyzer() != null);
+ assertNotNull(suggester.getQueryAnalyzer());
}
}
diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java
index 78b25cd41d3..efbfa28b268 100644
--- a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java
+++ b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCache.java
@@ -176,9 +176,10 @@ public class TestFieldCache extends SolrTestCase {
assertTrue(
"docsWithField(theLong) must be class Bits.MatchAllBits",
docsWithField instanceof Bits.MatchAllBits);
- assertTrue(
+ assertEquals(
"docsWithField(theLong) Size: " + docsWithField.length() + " is not: " + NUM_DOCS,
- docsWithField.length() == NUM_DOCS);
+ docsWithField.length(),
+ NUM_DOCS);
for (int i = 0; i < docsWithField.length(); i++) {
assertTrue(docsWithField.get(i));
}
@@ -191,9 +192,10 @@ public class TestFieldCache extends SolrTestCase {
assertFalse(
"docsWithField(sparse) must not be class Bits.MatchAllBits",
docsWithField instanceof Bits.MatchAllBits);
- assertTrue(
+ assertEquals(
"docsWithField(sparse) Size: " + docsWithField.length() + " is not: " + NUM_DOCS,
- docsWithField.length() == NUM_DOCS);
+ docsWithField.length(),
+ NUM_DOCS);
for (int i = 0; i < docsWithField.length(); i++) {
assertEquals(i % 2 == 0, docsWithField.get(i));
}
@@ -279,7 +281,7 @@ public class TestFieldCache extends SolrTestCase {
assertEquals(i, termOrds.nextDoc());
}
long ord = termOrds.nextOrd();
- assert ord != SortedSetDocValues.NO_MORE_ORDS;
+ assertNotEquals(ord, SortedSetDocValues.NO_MORE_ORDS);
BytesRef scratch = termOrds.lookupOrd(ord);
assertEquals(v, scratch);
}
@@ -290,7 +292,7 @@ public class TestFieldCache extends SolrTestCase {
// test bad field
termOrds = cache.getDocTermOrds(reader, "bogusfield", null);
- assertTrue(termOrds.getValueCount() == 0);
+ assertEquals(0, termOrds.getValueCount());
FieldCache.DEFAULT.purgeByCacheKey(reader.getCoreCacheHelper().getKey());
}
diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSortRandom.java b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSortRandom.java
index 4a27ebb5b46..410e3a4ee55 100644
--- a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSortRandom.java
+++ b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSortRandom.java
@@ -114,7 +114,7 @@ public class TestFieldCacheSortRandom extends SolrTestCase {
if (type == SortField.Type.STRING) {
doc.add(new StringField("stringdv", s, Field.Store.NO));
} else {
- assert type == SortField.Type.STRING_VAL;
+ assertSame(type, SortField.Type.STRING_VAL);
doc.add(new BinaryDocValuesField("stringdv", new BytesRef(s)));
}
docValues.add(new BytesRef(s));
diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheVsDocValues.java b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheVsDocValues.java
index e8aa4f34537..89ae4181f85 100644
--- a/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheVsDocValues.java
+++ b/solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheVsDocValues.java
@@ -320,7 +320,7 @@ public class TestFieldCacheVsDocValues extends SolrTestCase {
int numDocs = atLeast(300);
// numDocs should be always > 256 so that in case of a codec that optimizes
// for numbers of values <= 256, all storage layouts are tested
- assert numDocs > 256;
+ assertTrue(numDocs > 256);
for (int i = 0; i < numDocs; i++) {
idField.setStringValue(Integer.toString(i));
long value = longs.next();
diff --git a/solr/core/src/test/org/apache/solr/uninverting/TestLegacyFieldCache.java b/solr/core/src/test/org/apache/solr/uninverting/TestLegacyFieldCache.java
index 6ed4d6c5a21..b1750a59921 100644
--- a/solr/core/src/test/org/apache/solr/uninverting/TestLegacyFieldCache.java
+++ b/solr/core/src/test/org/apache/solr/uninverting/TestLegacyFieldCache.java
@@ -143,9 +143,10 @@ public class TestLegacyFieldCache extends SolrTestCase {
assertTrue(
"docsWithField(theLong) must be class Bits.MatchAllBits",
docsWithField instanceof Bits.MatchAllBits);
- assertTrue(
+ assertEquals(
"docsWithField(theLong) Size: " + docsWithField.length() + " is not: " + NUM_DOCS,
- docsWithField.length() == NUM_DOCS);
+ docsWithField.length(),
+ NUM_DOCS);
for (int i = 0; i < docsWithField.length(); i++) {
assertTrue(docsWithField.get(i));
}
@@ -158,9 +159,10 @@ public class TestLegacyFieldCache extends SolrTestCase {
assertFalse(
"docsWithField(sparse) must not be class Bits.MatchAllBits",
docsWithField instanceof Bits.MatchAllBits);
- assertTrue(
+ assertEquals(
"docsWithField(sparse) Size: " + docsWithField.length() + " is not: " + NUM_DOCS,
- docsWithField.length() == NUM_DOCS);
+ docsWithField.length(),
+ NUM_DOCS);
for (int i = 0; i < docsWithField.length(); i++) {
assertEquals(i % 2 == 0, docsWithField.get(i));
}
diff --git a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
index 65a424cfb0b..0d30bb0f198 100644
--- a/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
@@ -443,7 +443,7 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
@Test
public void testPostSoftCommitEvents() {
SolrCore core = h.getCore();
- assert core != null;
+ assertNotNull(core);
DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
MySolrEventListener listener = new MySolrEventListener();
core.registerNewSearcherListener(listener);
@@ -451,7 +451,8 @@ public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
assertU(adoc("id", "999"));
assertU(commit("softCommit", "true"));
assertEquals("newSearcher was called more than once", 1, listener.newSearcherCount.get());
- assertFalse("postSoftCommit was not called", listener.postSoftCommitAt.get() == Long.MAX_VALUE);
+ assertNotEquals(
+ "postSoftCommit was not called", Long.MAX_VALUE, listener.postSoftCommitAt.get());
assertTrue(
"newSearcher was called after postSoftCommitCallback",
listener.postSoftCommitAt.get() >= listener.newSearcherOpenedAt.get());
diff --git a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
index 96b39d0d035..735fe27c402 100644
--- a/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
+++ b/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java
@@ -40,7 +40,6 @@ import org.apache.solr.schema.FieldType;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -385,7 +384,7 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
doc.addField("vector3", Arrays.asList(1.1f, 2.1f, 3.1f, 4.1f));
RuntimeException thrown =
- Assert.assertThrows(
+ assertThrows(
"Incorrect destination field type should raise exception",
SolrException.class,
() -> {
@@ -406,7 +405,7 @@ public class DocumentBuilderTest extends SolrTestCaseJ4 {
doc.addField("vector4", Arrays.asList(1.1f, 2.1f, 3.1f, 4.1f));
RuntimeException thrown =
- Assert.assertThrows(
+ assertThrows(
"Incorrect destination dimension should raise exception",
SolrException.class,
() -> {
diff --git a/solr/core/src/test/org/apache/solr/update/MaxSizeAutoCommitTest.java b/solr/core/src/test/org/apache/solr/update/MaxSizeAutoCommitTest.java
index 1b1b12628cb..08380cf251a 100644
--- a/solr/core/src/test/org/apache/solr/update/MaxSizeAutoCommitTest.java
+++ b/solr/core/src/test/org/apache/solr/update/MaxSizeAutoCommitTest.java
@@ -36,7 +36,6 @@ import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.SolrIndexSearcher;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@@ -104,15 +103,13 @@ public class MaxSizeAutoCommitTest extends SolrTestCaseJ4 {
@Test
public void testAdds() throws Exception {
-
- Assert.assertEquals(
+ assertEquals(
"There have been no updates yet, so there shouldn't have been any commits",
0,
hardCommitTracker.getCommitCount());
long tlogSizePreUpdates = updateHandler.getUpdateLog().getCurrentLogSizeFromStream();
- Assert.assertEquals(
- "There have been no updates yet, so tlog should be empty", 0, tlogSizePreUpdates);
+ assertEquals("There have been no updates yet, so tlog should be empty", 0, tlogSizePreUpdates);
// Add a large number of docs - should trigger a commit
int numDocsToAdd = 500;
@@ -128,15 +125,13 @@ public class MaxSizeAutoCommitTest extends SolrTestCaseJ4 {
@Test
public void testRedundantDeletes() throws Exception {
-
- Assert.assertEquals(
+ assertEquals(
"There have been no updates yet, so there shouldn't have been any commits",
0,
hardCommitTracker.getCommitCount());
long tlogSizePreUpdates = updateHandler.getUpdateLog().getCurrentLogSizeFromStream();
- Assert.assertEquals(
- "There have been no updates yet, so tlog should be empty", 0, tlogSizePreUpdates);
+ assertEquals("There have been no updates yet, so tlog should be empty", 0, tlogSizePreUpdates);
// Add docs
int numDocsToAdd = 150;
@@ -171,15 +166,13 @@ public class MaxSizeAutoCommitTest extends SolrTestCaseJ4 {
@Test
public void testDeletes() throws Exception {
-
- Assert.assertEquals(
+ assertEquals(
"There have been no updates yet, so there shouldn't have been any commits",
0,
hardCommitTracker.getCommitCount());
long tlogSizePreUpdates = updateHandler.getUpdateLog().getCurrentLogSizeFromStream();
- Assert.assertEquals(
- "There have been no updates yet, so tlog should be empty", 0, tlogSizePreUpdates);
+ assertEquals("There have been no updates yet, so tlog should be empty", 0, tlogSizePreUpdates);
// Add docs
int numDocsToAdd = 500;
diff --git a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
index 7a603bd74cc..fb010f9d3a1 100644
--- a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
+++ b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
@@ -463,7 +463,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
otherVersions, completeList, ourUpdates, ourLowThreshold);
// no updates requested since other has nothing
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
}
}
@@ -478,7 +478,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
otherVersions, completeList, ourUpdates, ourLowThreshold);
// no updates requested since us and other have the same versions
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
}
}
@@ -512,7 +512,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
*/
assertTrue(missing < ourLowThreshold);
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
}
}
}
@@ -548,7 +548,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
*/
assertTrue(missing < ourLowThreshold);
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
}
}
}
@@ -583,7 +583,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
} else {
// request no updates because ???
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
}
}
{
@@ -598,7 +598,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
} else {
// request no updates because ???
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
}
}
{
@@ -613,7 +613,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
} else {
// request no updates since we don't need a complete list ...
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
// ... and all the missing versions are older/lower than our 'low' threshold
for (Long version : otherVersions) {
if (!ourUpdates.contains(version)) {
@@ -656,7 +656,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
} else {
// request no updates because ???
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
}
}
{
@@ -671,7 +671,7 @@ public class PeerSyncTest extends BaseDistributedSearchTestCase {
} else {
// request no updates since we don't need a complete list ...
assertEquals(0L, mur.totalRequestedUpdates);
- assertEquals(null, mur.versionsAndRanges);
+ assertNull(mur.versionsAndRanges);
// ... and all the missing versions are older/lower than our 'low' threshold
for (Long version : otherVersions) {
if (!ourUpdates.contains(version)) {
diff --git a/solr/core/src/test/org/apache/solr/update/PeerSyncWithIndexFingerprintCachingTest.java b/solr/core/src/test/org/apache/solr/update/PeerSyncWithIndexFingerprintCachingTest.java
index 07fd1ec8c4c..02e62252efa 100644
--- a/solr/core/src/test/org/apache/solr/update/PeerSyncWithIndexFingerprintCachingTest.java
+++ b/solr/core/src/test/org/apache/solr/update/PeerSyncWithIndexFingerprintCachingTest.java
@@ -29,7 +29,6 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
-import org.junit.Assert;
import org.junit.Test;
/**
@@ -80,7 +79,7 @@ public class PeerSyncWithIndexFingerprintCachingTest extends BaseDistributedSear
IndexFingerprint after = getFingerprint(client0, Long.MAX_VALUE);
// make sure fingerprint before and after deleting are not the same
- Assert.assertTrue(IndexFingerprint.compare(before, after) != 0);
+ assertTrue(IndexFingerprint.compare(before, after) != 0);
// replica which missed the delete operation should be able to sync
assertSync(client1, numVersions, shardsArr[0]);
diff --git a/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java b/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java
index 141c45651b8..7a329d5c109 100644
--- a/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java
+++ b/solr/core/src/test/org/apache/solr/update/SoftAutoCommitTest.java
@@ -18,7 +18,6 @@ package org.apache.solr.update;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
-import static org.junit.Assert.assertEquals;
import java.lang.invoke.MethodHandles;
import java.util.concurrent.BlockingQueue;
@@ -94,7 +93,7 @@ public class SoftAutoCommitTest extends SolrTestCaseJ4 {
final int hardCommitMaxDocs = 7;
// remainder of test designed with these assumptions
- assert softCommitMaxDocs < hardCommitMaxDocs;
+ assertTrue(softCommitMaxDocs < hardCommitMaxDocs);
CommitTracker hardTracker = updater.commitTracker;
CommitTracker softTracker = updater.softCommitTracker;
@@ -524,7 +523,7 @@ public class SoftAutoCommitTest extends SolrTestCaseJ4 {
final BlockingQueue<Long> queue)
throws InterruptedException {
- assert 0 < maxNumCommits;
+ assertTrue(0 < maxNumCommits);
// these will be modified in each iteration of our assertion loop
long prevTimestampNanos = startTimestampNanos;
@@ -637,6 +636,6 @@ class MockEventListener implements SolrEventListener {
}
public void assertSaneOffers() {
- assertEquals("Failure of MockEventListener" + fail.toString(), 0, fail.length());
+ SolrTestCaseJ4.assertEquals("Failure of MockEventListener" + fail.toString(), 0, fail.length());
}
}
diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java
index 0f8caaa755d..f4b32d93522 100644
--- a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java
+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java
@@ -114,7 +114,7 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {
ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) iwc.getMergeScheduler();
assertEquals("ms.maxMergeCount", 987, ms.getMaxMergeCount());
assertEquals("ms.maxThreadCount", 42, ms.getMaxThreadCount());
- assertEquals("ms.isAutoIOThrottle", true, ms.getAutoIOThrottle());
+ assertTrue("ms.isAutoIOThrottle", ms.getAutoIOThrottle());
}
@Test
@@ -135,7 +135,7 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {
ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) iwc.getMergeScheduler();
assertEquals("ms.maxMergeCount", 987, ms.getMaxMergeCount());
assertEquals("ms.maxThreadCount", 42, ms.getMaxThreadCount());
- assertEquals("ms.isAutoIOThrottle", false, ms.getAutoIOThrottle());
+ assertFalse("ms.isAutoIOThrottle", ms.getAutoIOThrottle());
}
public void testSortingMPSolrIndexConfigCreation() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
index bfc47dd83cf..64078919cf0 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
@@ -490,7 +490,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
// already had an init value of 0 -- which is an interesting edge case, so we don't exclude it
final float multiplier = r.nextBoolean() ? -5.0F : 5.0F;
final float value = r.nextFloat() * multiplier;
- assert -5.0F <= value && value <= 5.0F;
+ assertTrue(-5.0F <= value && value <= 5.0F);
valuesList.set(id, value);
}
log.info("inplace_updatable_float: {}", valuesList);
@@ -523,9 +523,9 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
// thus ensuring that after all increments are done, there should be
// 0 test docs matching the query inplace_updatable_float:[-10 TO 10]
final float inc = (r.nextBoolean() ? -1.0F : 1.0F) * (r.nextFloat() + (float) atLeast(20));
- assert 20 < Math.abs(inc);
+ assertTrue(20 < Math.abs(inc));
final float value = (float) valuesList.get(id) + inc;
- assert value < -10 || 10 < value;
+ assertTrue(value < -10 || 10 < value);
valuesList.set(id, value);
index("id", id, "inplace_updatable_float", map("inc", inc));
@@ -651,7 +651,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
final String fieldName,
final List<Number> valuesList)
throws Exception {
- assert luceneDocids.size() == valuesList.size();
+ assertEquals(luceneDocids.size(), valuesList.size());
final long numFoundExpected = luceneDocids.size();
for (SolrClient client : clients) {
@@ -708,7 +708,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
final String fieldName,
final List<Number> valuesList) {
- assert luceneDocids.size() == valuesList.size();
+ assertEquals(luceneDocids.size(), valuesList.size());
assertEquals(
msgPre
+ ": rows param wasn't big enough, we need to compare all results matching the query",
@@ -758,9 +758,10 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
assertTrue(currentVersion > version);
version = currentVersion;
LEADER.commit();
- assertTrue(
+ assertEquals(
"Earlier: " + docids + ", now: " + getInternalDocIds("100"),
- docids.equals(getInternalDocIds("100")));
+ docids,
+ getInternalDocIds("100"));
SolrDocument sdoc = LEADER.getById("100"); // RTG straight from the index
assertEquals(sdoc.toString(), inplace_updatable_float, sdoc.get("inplace_updatable_float"));
@@ -795,9 +796,10 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
assertTrue(currentVersion > version);
version = currentVersion;
LEADER.commit();
- assertTrue(
+ assertEquals(
"Earlier: " + docids + ", now: " + getInternalDocIds("100"),
- docids.equals(getInternalDocIds("100")));
+ docids,
+ getInternalDocIds("100"));
currentVersion = addDocAndGetVersion("id", 100, "inplace_updatable_int", map("set", "100"));
assertTrue(currentVersion > version);
@@ -844,9 +846,10 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
// assert that the internal docid for id=100 document remains same, in each replica, as before
LEADER.commit(); // can't get (real) [docid] from the tlogs, need to force a commit
- assertTrue(
+ assertEquals(
"Earlier: " + docids + ", now: " + getInternalDocIds("100"),
- docids.equals(getInternalDocIds("100")));
+ docids,
+ getInternalDocIds("100"));
log.info("ensureRtgWorksWithPartialUpdatesTest: This test passed fine...");
}
@@ -864,7 +867,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
assertEquals(Integer.class, docid.getClass());
ret.add((Integer) docid);
}
- assert clients.size() == ret.size();
+ assertEquals(clients.size(), ret.size());
return ret;
}
@@ -1585,7 +1588,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
}
LEADER.commit();
- assert specialIds.size() == versions.size();
+ assertEquals(specialIds.size(), versions.size());
return versions;
}
diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
index dd819b690c3..cd0fab5c1c5 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
@@ -750,7 +750,7 @@ public class TestInPlaceUpdatesStandalone extends SolrTestCaseJ4 {
public static long addAndAssertVersion(long expectedCurrentVersion, Object... fields)
throws Exception {
- assert 0 < expectedCurrentVersion;
+ assertTrue(0 < expectedCurrentVersion);
long currentVersion = addAndGetVersion(sdoc(fields), null);
assertTrue(currentVersion > expectedCurrentVersion);
return currentVersion;
diff --git a/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java b/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java
index 1355f5b783f..f8eaf7b47ca 100644
--- a/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java
+++ b/solr/core/src/test/org/apache/solr/update/TestNestedUpdateProcessor.java
@@ -403,7 +403,7 @@ public class TestNestedUpdateProcessor extends SolrTestCaseJ4 {
// doc_id -> descendentId must have at least one ancestor (since it's not a root level
// document)
final String descendentId = doc_id;
- assert allDocs.get(descendentId).containsKey("ancestor_ids_ss");
+ assertTrue(allDocs.get(descendentId).containsKey("ancestor_ids_ss"));
final List<Object> allAncestorIds =
new ArrayList<>(allDocs.get(descendentId).getFieldValues("ancestor_ids_ss"));
@@ -670,8 +670,8 @@ public class TestNestedUpdateProcessor extends SolrTestCaseJ4 {
}
private void assertValidPathSyntax(String path) {
- assert path.startsWith("/");
- assert (1 == path.length()) ^ !path.endsWith("/");
+ assertTrue(path.startsWith("/"));
+ assertTrue((1 == path.length()) ^ !path.endsWith("/"));
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java b/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java
index 4c87d0ad313..6d7e743c1ee 100644
--- a/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java
+++ b/solr/core/src/test/org/apache/solr/update/UpdateParamsTest.java
@@ -52,9 +52,10 @@ public class UpdateParamsTest extends SolrTestCaseJ4 {
handler.handleRequestBody(req, rsp);
assertTrue("Old param update.processor should not have any effect anymore", true);
} catch (Exception e) {
- assertFalse(
+ assertNotEquals(
"Got wrong exception while testing update.chain",
- e.getMessage().equals("unknown UpdateRequestProcessorChain: nonexistent"));
+ "unknown UpdateRequestProcessorChain: nonexistent",
+ e.getMessage());
}
// Then check that the new param behaves correctly
@@ -63,8 +64,7 @@ public class UpdateParamsTest extends SolrTestCaseJ4 {
req.setParams(params);
try {
handler.handleRequestBody(req, rsp);
- assertFalse(
- "Faulty update.chain parameter not causing an error - i.e. it is not detected", true);
+ fail("Faulty update.chain parameter not causing an error - i.e. it is not detected");
} catch (Exception e) {
assertEquals(
"Got wrong exception while testing update.chain",
diff --git a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateJavabinTest.java b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateJavabinTest.java
index 4e51a2817cc..38b1957ea70 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateJavabinTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateJavabinTest.java
@@ -423,7 +423,7 @@ public class AtomicUpdateJavabinTest extends SolrCloudTestCase {
final QueryResponse response = request.process(cluster.getSolrClient(), COLLECTION);
final NamedList<Object> rawResponse = response.getResponse();
- assertTrue(rawResponse.get("doc") != null);
+ assertNotNull(rawResponse.get("doc"));
assertTrue(rawResponse.get("doc") instanceof SolrDocument);
final SolrDocument doc = (SolrDocument) rawResponse.get("doc");
final Collection<Object> valuesAfterUpdate = doc.getFieldValues(fieldName);
diff --git a/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java
index ebf912b27b0..9c3943634e5 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/CategoryRoutedAliasUpdateProcessorTest.java
@@ -466,7 +466,7 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro
.get(getAlias());
observedCols = new ArrayList<>(observedCols);
observedCols.sort(String::compareTo); // don't really care about the order here.
- assert !observedCols.isEmpty();
+ assertFalse(observedCols.isEmpty());
int numFoundViaCollections = 0;
for (String col : observedCols) {
diff --git a/solr/core/src/test/org/apache/solr/update/processor/DimensionalRoutedAliasUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/DimensionalRoutedAliasUpdateProcessorTest.java
index 7d8ae26aa48..28e5e665813 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/DimensionalRoutedAliasUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/DimensionalRoutedAliasUpdateProcessorTest.java
@@ -562,7 +562,7 @@ public class DimensionalRoutedAliasUpdateProcessorTest extends RoutedAliasUpdate
.process(solrClient)
.getAliasesAsLists()
.get(getSaferTestName());
- assert !cols.isEmpty();
+ assertFalse(cols.isEmpty());
for (String category : categories) {
List<String> cats =
diff --git a/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java b/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java
index 007eba8d4d3..c8d11232809 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java
@@ -247,10 +247,9 @@ public class NestedAtomicUpdateTest extends SolrTestCaseJ4 {
() -> {
docMerger.merge(updateDoc, existingDoc);
});
- assertTrue(
- expected
- .getMessage()
- .equals("A nested atomic update can only update an existing nested document"));
+ assertEquals(
+ "A nested atomic update can only update an existing nested document",
+ expected.getMessage());
}
@Test
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 550edc12328..f48fce7c9bf 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
@@ -16,8 +16,6 @@
*/
package org.apache.solr.update.processor;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -38,7 +36,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-public class SkipExistingDocumentsProcessorFactoryTest {
+public class SkipExistingDocumentsProcessorFactoryTest extends SolrTestCaseJ4 {
private BytesRef docId = new BytesRef();
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TestCloudDeduplication.java b/solr/core/src/test/org/apache/solr/update/processor/TestCloudDeduplication.java
index b1b8f5984f0..85f7952c4f6 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TestCloudDeduplication.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TestCloudDeduplication.java
@@ -110,7 +110,7 @@ public class TestCloudDeduplication extends SolrCloudTestCase {
}
assertEquals("commit failed", 0, getRandClient().commit(COLLECTION).getStatus());
- assert docCounter > uniqueMod;
+ assertTrue(docCounter > uniqueMod);
// query our collection and confirm no duplicates on the signature field (using faceting)
// Check every (node) for consistency...
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java b/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java
index 7ff2c37a4cf..0e2e0c2476a 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TestDocBasedVersionConstraints.java
@@ -789,7 +789,7 @@ public class TestDocBasedVersionConstraints extends SolrTestCaseJ4 {
}
private void updateWithChain(String chain, String... fields) throws Exception {
- assert fields.length % 2 == 0;
+ assertEquals(0, fields.length % 2);
SolrInputDocument doc = new SolrInputDocument(fields);
updateJ(jsonAdd(doc), params("update.chain", chain));
}
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java b/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java
index 2725d3d1e11..ecb05fad51f 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessorTest.java
@@ -720,9 +720,9 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcess
colsT1 =
new CollectionAdminRequest.ListAliases().process(solrClient).getAliasesAsLists().get(alias);
assertEquals(3, colsT1.size());
- assertTrue(
+ assertFalse(
"Preemptive creation appears to not be asynchronous anymore",
- !colsT1.contains("myalias" + TRA + "2017-10-26"));
+ colsT1.contains("myalias" + TRA + "2017-10-26"));
assertNumDocs("2017-10-23", 1, alias);
assertNumDocs("2017-10-24", 1, alias);
assertNumDocs("2017-10-25", 3, alias);
@@ -748,10 +748,10 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcess
List<String> cols;
cols =
new CollectionAdminRequest.ListAliases().process(solrClient).getAliasesAsLists().get(alias);
- assertTrue(
+ assertFalse(
"Preemptive creation happened twice and created a collection "
+ "further in the future than the configured time slice!",
- !cols.contains("myalias" + TRA + "2017-10-27"));
+ cols.contains("myalias" + TRA + "2017-10-27"));
validateCollectionCountAndAvailability(
alias, 4, "Only 4 cols expected (preemptive create happened" + "twice among threads");
@@ -857,7 +857,7 @@ public class TimeRoutedAliasUpdateProcessorTest extends RoutedAliasUpdateProcess
final List<String> cols =
new CollectionAdminRequest.ListAliases().process(solrClient).getAliasesAsLists().get(alias);
- assert !cols.isEmpty();
+ assertFalse(cols.isEmpty());
assertArrayEquals(
"expected reverse sorted",
diff --git a/solr/core/src/test/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.java b/solr/core/src/test/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.java
index 38eb42390f4..89efbdbe699 100644
--- a/solr/core/src/test/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.java
+++ b/solr/core/src/test/org/apache/solr/update/processor/TrackingUpdateProcessorFactory.java
@@ -69,11 +69,11 @@ public final class TrackingUpdateProcessorFactory extends UpdateRequestProcessor
public static void startRecording(String group) {
final List<UpdateCommand> updateCommands = groupToCommands.get(group);
- assert updateCommands == null || updateCommands.isEmpty();
+ SolrCloudTestCase.assertTrue(updateCommands == null || updateCommands.isEmpty());
List<UpdateCommand> existing =
groupToCommands.put(group, Collections.synchronizedList(new ArrayList<>()));
- assert existing == null : "Test cross-talk?";
+ SolrCloudTestCase.assertNull("Test cross-talk?", existing);
}
/**
diff --git a/solr/core/src/test/org/apache/solr/util/OrderedExecutorTest.java b/solr/core/src/test/org/apache/solr/util/OrderedExecutorTest.java
index 68b5b325d8c..f3731645856 100644
--- a/solr/core/src/test/org/apache/solr/util/OrderedExecutorTest.java
+++ b/solr/core/src/test/org/apache/solr/util/OrderedExecutorTest.java
@@ -224,7 +224,7 @@ public class OrderedExecutorTest extends SolrTestCase {
orderedExecutor.execute(key, () -> run.put(key, run.get(key) + 1));
}
orderedExecutor.shutdownAndAwaitTermination();
- assertTrue(base.equals(run));
+ assertEquals(base, run);
}
private static class IntBox {
diff --git a/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java b/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java
index 6d108c0bd4c..e844582eeb1 100644
--- a/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java
+++ b/solr/core/src/test/org/apache/solr/util/SimplePostToolTest.java
@@ -79,13 +79,13 @@ public class SimplePostToolTest extends SolrTestCaseJ4 {
@Test
public void testParseArgsAndInit() {
- assertEquals(false, t_file.auto);
- assertEquals(true, t_file_auto.auto);
+ assertFalse(t_file.auto);
+ assertTrue(t_file_auto.auto);
assertEquals(0, t_file_auto.recursive);
assertEquals(999, t_file_rec.recursive);
- assertEquals(true, t_file.commit);
- assertEquals(false, t_file.optimize);
- assertEquals(null, t_file.out);
+ assertTrue(t_file.commit);
+ assertFalse(t_file.optimize);
+ assertNull(t_file.out);
assertEquals(1, t_web.recursive);
assertEquals(10, t_web.delay);
@@ -119,10 +119,9 @@ public class SimplePostToolTest extends SolrTestCaseJ4 {
// TODO: How to know what is the base if URL path ends with "foo"??
// assertEquals("http://[ff01::114]/fil.html", t_web.computeFullUrl(new
// URL("http://[ff01::114]/foo?baz#hello"), "fil.html"));
- assertEquals(null, t_web.computeFullUrl(new URL("http://[ff01::114]/"), "fil.jpg"));
- assertEquals(
- null, t_web.computeFullUrl(new URL("http://[ff01::114]/"), "mailto:hello@foo.bar"));
- assertEquals(null, t_web.computeFullUrl(new URL("http://[ff01::114]/"), "ftp://server/file"));
+ assertNull(t_web.computeFullUrl(new URL("http://[ff01::114]/"), "fil.jpg"));
+ assertNull(t_web.computeFullUrl(new URL("http://[ff01::114]/"), "mailto:hello@foo.bar"));
+ assertNull(t_web.computeFullUrl(new URL("http://[ff01::114]/"), "ftp://server/file"));
}
@Test
@@ -201,9 +200,10 @@ public class SimplePostToolTest extends SolrTestCaseJ4 {
public void testRobotsExclusion() throws MalformedURLException {
assertFalse(t_web.pageFetcher.isDisallowedByRobots(new URL("http://[ff01::114]/")));
assertTrue(t_web.pageFetcher.isDisallowedByRobots(new URL("http://[ff01::114]/disallowed")));
- assertTrue(
+ assertEquals(
"There should be two entries parsed from robots.txt",
- t_web.pageFetcher.robotsCache.get("[ff01::114]").size() == 2);
+ 2,
+ t_web.pageFetcher.robotsCache.get("[ff01::114]").size());
}
static class MockPageFetcher extends PageFetcher {
diff --git a/solr/core/src/test/org/apache/solr/util/SolrCliUptimeTest.java b/solr/core/src/test/org/apache/solr/util/SolrCliUptimeTest.java
index cb5312cf22f..ff8def5eab6 100644
--- a/solr/core/src/test/org/apache/solr/util/SolrCliUptimeTest.java
+++ b/solr/core/src/test/org/apache/solr/util/SolrCliUptimeTest.java
@@ -16,11 +16,10 @@
*/
package org.apache.solr.util;
-import static org.junit.Assert.assertEquals;
-
+import org.apache.solr.SolrTestCase;
import org.junit.Test;
-public class SolrCliUptimeTest {
+public class SolrCliUptimeTest extends SolrTestCase {
@Test
public void testUptime() {
assertEquals("?", SolrCLI.uptime(0));
diff --git a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
index 7b1c0aff652..3503706c2eb 100644
--- a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
+++ b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
@@ -415,14 +415,15 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
}
numFound = solrClient.query(query).getResults().getNumFound();
}
- assertTrue(
+ assertEquals(
"expected 32 docs in the "
+ exampleName
+ " example but found "
+ numFound
+ ", output: "
+ toolOutput,
- numFound == 32);
+ 32,
+ numFound);
} finally {
solrClient.close();
}
@@ -605,6 +606,6 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
tool.runTool(
SolrCLI.processCommandLineArgs(
SolrCLI.joinCommonAndToolOptions(tool.getOptions()), toolArgs));
- assertTrue("Execution should have failed with return code 1", code == 1);
+ assertEquals("Execution should have failed with return code 1", 1, code);
}
}
diff --git a/solr/core/src/test/org/apache/solr/util/TestUtils.java b/solr/core/src/test/org/apache/solr/util/TestUtils.java
index 3d17bf046f2..698e6843281 100644
--- a/solr/core/src/test/org/apache/solr/util/TestUtils.java
+++ b/solr/core/src/test/org/apache/solr/util/TestUtils.java
@@ -136,7 +136,7 @@ public class TestUtils extends SolrTestCaseJ4 {
assertEquals("ONE", map.getName(0));
assertEquals(Integer.valueOf(100), map.get("one", 1));
assertEquals(4, map.indexOf(null, 1));
- assertEquals(null, map.get(null, 1));
+ assertNull(map.get(null, 1));
map = new SimpleOrderedMap<>();
map.add("one", 1);
diff --git a/solr/core/src/test/org/apache/solr/util/hll/BigEndianAscendingWordSerializerTest.java b/solr/core/src/test/org/apache/solr/util/hll/BigEndianAscendingWordSerializerTest.java
index e6b9a790aaf..b13ec118740 100644
--- a/solr/core/src/test/org/apache/solr/util/hll/BigEndianAscendingWordSerializerTest.java
+++ b/solr/core/src/test/org/apache/solr/util/hll/BigEndianAscendingWordSerializerTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.util.hll;
-import java.util.Arrays;
import org.apache.solr.SolrTestCase;
import org.junit.Test;
@@ -100,7 +99,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
new BigEndianAscendingWordSerializer(
shortWordLength, 0 /*wordCount*/, 0 /*bytePadding, none*/);
- assert (Arrays.equals(serializer.getBytes(), new byte[0]));
+ assertArrayEquals(serializer.getBytes(), new byte[0]);
}
{ // Should work on a byte-divisible sequence, with no padding.
final BigEndianAscendingWordSerializer serializer =
@@ -123,7 +122,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
-70, -86, -86, -86, -86, -86, -86, -84,
-113, -1, -1, -1, -1, -1, -1, -15
};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
{ // Should pad the array correctly.
final BigEndianAscendingWordSerializer serializer =
@@ -135,7 +134,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
// 0x00 | 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01
final byte[] bytes = serializer.getBytes();
final byte[] expectedBytes = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 1};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
}
@@ -148,8 +147,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
final BigEndianAscendingWordSerializer serializer =
new BigEndianAscendingWordSerializer(
shortWordLength, 0 /*wordCount*/, 0 /*bytePadding, none*/);
-
- assert (Arrays.equals(serializer.getBytes(), new byte[0]));
+ assertArrayEquals(serializer.getBytes(), new byte[0]);
}
{ // Should work on a non-byte-divisible sequence, with no padding.
final BigEndianAscendingWordSerializer serializer =
@@ -175,7 +173,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
final byte[] bytes = serializer.getBytes();
final byte[] expectedBytes = new byte[] {79, -62};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
{ // Should work on a byte-divisible sequence, with no padding.
final BigEndianAscendingWordSerializer serializer =
@@ -208,7 +206,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
final byte[] bytes = serializer.getBytes();
final byte[] expectedBytes = new byte[] {8, -122, 66, -104, -24};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
{ // Should pad the array correctly.
final BigEndianAscendingWordSerializer serializer =
@@ -219,7 +217,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
// 0000 0000 | 0000 1|000
final byte[] bytes = serializer.getBytes();
final byte[] expectedBytes = new byte[] {0, 8};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
}
@@ -232,8 +230,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
final BigEndianAscendingWordSerializer serializer =
new BigEndianAscendingWordSerializer(
shortWordLength, 0 /*wordCount*/, 0 /*bytePadding, none*/);
-
- assert (Arrays.equals(serializer.getBytes(), new byte[0]));
+ assertArrayEquals(serializer.getBytes(), new byte[0]);
}
{ // Should work on a non-byte-divisible sequence, with no padding.
final BigEndianAscendingWordSerializer serializer =
@@ -264,7 +261,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
final byte[] bytes = serializer.getBytes();
final byte[] expectedBytes = new byte[] {0, 4, -128, 10, -128, 9, 96};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
{ // Should work on a byte-divisible sequence, with no padding.
final BigEndianAscendingWordSerializer serializer =
@@ -311,7 +308,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
final byte[] bytes = serializer.getBytes();
final byte[] expectedBytes =
new byte[] {0, 0, -128, 0, -128, 0, 96, 0, 64, 0, 40, 0, 24, 0, 14, 0, 8};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
{ // Should pad the array correctly.
final BigEndianAscendingWordSerializer serializer =
@@ -323,7 +320,7 @@ public class BigEndianAscendingWordSerializerTest extends SolrTestCase {
// 0x00 0x00 0x00 0x80
final byte[] bytes = serializer.getBytes();
final byte[] expectedBytes = new byte[] {0, 0, 0, -128};
- assertTrue(Arrays.equals(bytes, expectedBytes));
+ assertArrayEquals(bytes, expectedBytes);
}
}
}
diff --git a/solr/core/src/test/org/apache/solr/util/hll/BitVectorTest.java b/solr/core/src/test/org/apache/solr/util/hll/BitVectorTest.java
index 832f1bc29cd..158027174bd 100644
--- a/solr/core/src/test/org/apache/solr/util/hll/BitVectorTest.java
+++ b/solr/core/src/test/org/apache/solr/util/hll/BitVectorTest.java
@@ -72,20 +72,20 @@ public class BitVectorTest extends SolrTestCase {
final LongIterator registerIterator3 = vector3.registerIterator();
final LongIterator registerIterator4 = vector4.registerIterator();
for (int i = 0; i < 128 /*2^7*/; i++) {
- assertEquals(registerIterator1.hasNext(), true);
- assertEquals(registerIterator2.hasNext(), true);
- assertEquals(registerIterator3.hasNext(), true);
- assertEquals(registerIterator4.hasNext(), true);
+ assertTrue(registerIterator1.hasNext());
+ assertTrue(registerIterator2.hasNext());
+ assertTrue(registerIterator3.hasNext());
+ assertTrue(registerIterator4.hasNext());
assertEquals(registerIterator1.next(), 0x1F);
assertEquals(registerIterator2.next(), (i & 0x1F));
assertEquals(registerIterator3.next(), ((127 - i) & 0x1F));
assertEquals(registerIterator4.next(), 0x15);
}
- assertEquals(registerIterator1.hasNext(), false /*no more*/);
- assertEquals(registerIterator2.hasNext(), false /*no more*/);
- assertEquals(registerIterator3.hasNext(), false /*no more*/);
- assertEquals(registerIterator4.hasNext(), false /*no more*/);
+ assertFalse(registerIterator1.hasNext());
+ assertFalse(registerIterator2.hasNext());
+ assertFalse(registerIterator3.hasNext());
+ assertFalse(registerIterator4.hasNext());
}
{ // scoped locally for sanity
diff --git a/solr/core/src/test/org/apache/solr/util/hll/ExplicitHLLTest.java b/solr/core/src/test/org/apache/solr/util/hll/ExplicitHLLTest.java
index c4696721433..aec3fc6d912 100644
--- a/solr/core/src/test/org/apache/solr/util/hll/ExplicitHLLTest.java
+++ b/solr/core/src/test/org/apache/solr/util/hll/ExplicitHLLTest.java
@@ -211,7 +211,7 @@ public class ExplicitHLLTest extends SolrTestCase {
final LongHashSet internalSetA = hllA.explicitStorage;
final LongHashSet internalSetB = hllB.explicitStorage;
- assertTrue(internalSetA.equals(internalSetB));
+ assertEquals(internalSetA, internalSetB);
}
/**
diff --git a/solr/core/src/test/org/apache/solr/util/hll/HLLSerializationTest.java b/solr/core/src/test/org/apache/solr/util/hll/HLLSerializationTest.java
index 89f30a9083d..d44822fc425 100644
--- a/solr/core/src/test/org/apache/solr/util/hll/HLLSerializationTest.java
+++ b/solr/core/src/test/org/apache/solr/util/hll/HLLSerializationTest.java
@@ -111,7 +111,7 @@ public class HLLSerializationTest extends SolrTestCase {
final long NUM_VALS = TestUtil.nextLong(random(), 150000, 1000000);
final long MIN_VAL = TestUtil.nextLong(random(), Long.MIN_VALUE, Long.MAX_VALUE - NUM_VALS);
final long MAX_VAL = MIN_VAL + NUM_VALS;
- assert MIN_VAL < MAX_VAL;
+ assertTrue(MIN_VAL < MAX_VAL);
for (long val = MIN_VAL; val < MAX_VAL; val++) {
hll.addRaw(val);
@@ -152,7 +152,7 @@ public class HLLSerializationTest extends SolrTestCase {
final long NUM_VALS = TestUtil.nextLong(random(), 150000, 1000000);
final long MIN_VAL = TestUtil.nextLong(random(), Long.MIN_VALUE, Long.MAX_VALUE - NUM_VALS);
final long MAX_VAL = MIN_VAL + NUM_VALS;
- assert MIN_VAL < MAX_VAL;
+ assertTrue(MIN_VAL < MAX_VAL);
for (long val = MIN_VAL; val < MAX_VAL; val++) {
hll.addRaw(val);
@@ -209,13 +209,13 @@ public class HLLSerializationTest extends SolrTestCase {
HLL copy = HLL.fromBytes(hllBytes);
assertEquals(copy.cardinality(), hllCardinality);
assertEquals(copy.getType(), hllType);
- assertTrue(Arrays.equals(copy.toBytes(), hllBytes));
+ assertArrayEquals(copy.toBytes(), hllBytes);
HLL clone = copy.clone();
copy = null; // allow some GC
assertEquals(clone.cardinality(), hllCardinality);
assertEquals(clone.getType(), hllType);
- assertTrue(Arrays.equals(clone.toBytes(), hllBytes));
+ assertArrayEquals(clone.toBytes(), hllBytes);
}
}
diff --git a/solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java b/solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java
index 3a0c4ae2c5b..e6ca7b99b43 100644
--- a/solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java
+++ b/solr/core/src/test/org/apache/solr/util/hll/NumberUtilTest.java
@@ -16,13 +16,11 @@
*/
package org.apache.solr.util.hll;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
+import org.apache.solr.SolrTestCase;
import org.junit.Test;
/** Tests {@link NumberUtil} */
-public class NumberUtilTest {
+public class NumberUtilTest extends SolrTestCase {
static final byte[] ALL_PRINTABLE_ASCII_CHARS =
new byte[] {
@@ -70,65 +68,62 @@ public class NumberUtilTest {
@Test
public void testLog2() {
final double log2Result = NumberUtil.log2(2d);
- assertTrue(log2Result == 1);
+ assertEquals(1, log2Result, 0.0);
}
/** Test {@link NumberUtil#toHex(byte[], int, int)} */
@Test
public void TestToHex() {
- assertTrue(
- ALL_PRINTABLE_ASCII_CHARS_IN_HEX.equals(
- NumberUtil.toHex(ALL_PRINTABLE_ASCII_CHARS, 0, ALL_PRINTABLE_ASCII_CHARS.length)));
+ assertEquals(
+ ALL_PRINTABLE_ASCII_CHARS_IN_HEX,
+ NumberUtil.toHex(ALL_PRINTABLE_ASCII_CHARS, 0, ALL_PRINTABLE_ASCII_CHARS.length));
}
/** Test {@link NumberUtil#toHex(byte[], int, int)} */
@Test
public void TestToHexWithOffset() {
- assertTrue(
- ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX.equals(
- NumberUtil.toHex(ALL_WORD_CHARAC_ASCII_CHARS, 10, ALL_PRINTABLE_ASCII_CHARS.length)));
+ assertEquals(
+ ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX,
+ NumberUtil.toHex(ALL_WORD_CHARAC_ASCII_CHARS, 10, ALL_PRINTABLE_ASCII_CHARS.length));
}
/** Test {@link NumberUtil#toHex(byte[], int, int)} */
@Test
public void TestToHexWithCountt() {
- assertTrue(
- ALL_NUMBER_ASCII_CHARS_IN_HEX.equals(NumberUtil.toHex(ALL_WORD_CHARAC_ASCII_CHARS, 0, 10)));
+ assertEquals(
+ ALL_NUMBER_ASCII_CHARS_IN_HEX, NumberUtil.toHex(ALL_WORD_CHARAC_ASCII_CHARS, 0, 10));
}
/** Test {@link NumberUtil#fromHex(String, int, int)} */
@Test
public void TestFromHex() {
- assertTrue(
- Arrays.equals(
- NumberUtil.fromHex(
- ALL_NUMBER_ASCII_CHARS_IN_HEX
- + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX
- + ALL_LOW_LETTERS_ASCII_CHARS_IN_HEX,
- 0,
- ALL_WORD_CHARAC_ASCII_CHARS.length * 2),
- ALL_WORD_CHARAC_ASCII_CHARS));
+ assertArrayEquals(
+ NumberUtil.fromHex(
+ ALL_NUMBER_ASCII_CHARS_IN_HEX
+ + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX
+ + ALL_LOW_LETTERS_ASCII_CHARS_IN_HEX,
+ 0,
+ ALL_WORD_CHARAC_ASCII_CHARS.length * 2),
+ ALL_WORD_CHARAC_ASCII_CHARS);
}
/** Test {@link NumberUtil#fromHex(String, int, int)} */
@Test
public void TestFromHexWithOffset() {
- assertTrue(
- Arrays.equals(
- NumberUtil.fromHex(
- ALL_NUMBER_ASCII_CHARS_IN_HEX + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX,
- 20,
- ALL_LETTER_ASCII_CHARS.length * 2),
- ALL_LETTER_ASCII_CHARS));
+ assertArrayEquals(
+ NumberUtil.fromHex(
+ ALL_NUMBER_ASCII_CHARS_IN_HEX + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX,
+ 20,
+ ALL_LETTER_ASCII_CHARS.length * 2),
+ ALL_LETTER_ASCII_CHARS);
}
/** Test {@link NumberUtil#fromHex(String, int, int)} */
@Test
public void TestFromHexWithCount() {
- assertTrue(
- Arrays.equals(
- NumberUtil.fromHex(
- ALL_NUMBER_ASCII_CHARS_IN_HEX + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX, 0, 20),
- ALL_NUMBER_CHARAC_ASCII_CHARS));
+ assertArrayEquals(
+ NumberUtil.fromHex(
+ ALL_NUMBER_ASCII_CHARS_IN_HEX + ALL_MAJ_LETTERS_ASCII_CHARS_IN_HEX, 0, 20),
+ ALL_NUMBER_CHARAC_ASCII_CHARS);
}
}
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/ExpressionFactoryTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/ExpressionFactoryTest.java
index bf11cdd3515..2bedb3fe32a 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/ExpressionFactoryTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/ExpressionFactoryTest.java
@@ -139,56 +139,54 @@ public class ExpressionFactoryTest extends SolrTestCaseJ4 {
// Two ungrouped exactly the same expression
fact.startRequest();
- assertTrue(
+ assertSame(
"The objects of the two mapping expressions are not the same.",
- fact.createExpression("pow(int_i,double_d)")
- == fact.createExpression("pow(int_i,double_d)"));
- assertTrue(
+ fact.createExpression("pow(int_i,double_d)"),
+ fact.createExpression("pow(int_i,double_d)"));
+ assertSame(
"The objects of the two reduced expressions are not the same.",
- fact.createExpression("unique(add(int_i,double_d))")
- == fact.createExpression("unique(add(int_i,double_d))"));
+ fact.createExpression("unique(add(int_i,double_d))"),
+ fact.createExpression("unique(add(int_i,double_d))"));
// Two ungrouped different expressions
fact.startRequest();
- assertFalse(
+ assertNotSame(
"The objects of the two mapping expressions are not the same.",
- fact.createExpression("pow(int_i,double_d)")
- == fact.createExpression("pow(int_i,float_f)"));
- assertFalse(
+ fact.createExpression("pow(int_i,double_d)"),
+ fact.createExpression("pow(int_i,float_f)"));
+ assertNotSame(
"The objects of the two reduced expressions are not the same.",
- fact.createExpression("unique(add(int_i,double_d))")
- == fact.createExpression("unique(add(int_i,float_f))"));
+ fact.createExpression("unique(add(int_i,double_d))"),
+ fact.createExpression("unique(add(int_i,float_f))"));
// Grouped and ungrouped mapping expression
fact.startRequest();
Object ungrouped = fact.createExpression("pow(int_i,double_d)");
fact.startGrouping();
Object grouped = fact.createExpression("pow(int_i,double_d)");
- assertTrue(
- "The objects of the two mapping expressions are not the same.", ungrouped == grouped);
+ assertSame("The objects of the two mapping expressions are not the same.", ungrouped, grouped);
// Grouped and ungrouped diferent mapping expressions
fact.startRequest();
ungrouped = fact.createExpression("pow(int_i,double_d)");
fact.startGrouping();
grouped = fact.createExpression("pow(int_i,float_f)");
- assertFalse(
- "The objects of the two mapping expressions are not the same.", ungrouped == grouped);
+ assertNotSame(
+ "The objects of the two mapping expressions are not the same.", ungrouped, grouped);
// Grouped and ungrouped reduced expression.
fact.startRequest();
ungrouped = fact.createExpression("unique(add(int_i,double_d))");
fact.startGrouping();
grouped = fact.createExpression("unique(add(int_i,double_d))");
- assertTrue(
- "The objects of the two mapping expressions are not the same.", ungrouped == grouped);
+ assertSame("The objects of the two mapping expressions are not the same.", ungrouped, grouped);
// Grouped and ungrouped different reduced expressions.
fact.startRequest();
ungrouped = fact.createExpression("unique(add(int_i,double_d))");
fact.startGrouping();
grouped = fact.createExpression("unique(add(int_i,float_f))");
- assertFalse("The objects of the two mapping expressions are the same.", ungrouped == grouped);
+ assertNotSame("The objects of the two mapping expressions are the same.", ungrouped, grouped);
}
@Test
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java
index 2aa3634fd9e..310bf191262 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AbsoluteValueFunctionTest.java
@@ -149,7 +149,7 @@ public class AbsoluteValueFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -186,7 +186,7 @@ public class AbsoluteValueFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -223,7 +223,7 @@ public class AbsoluteValueFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -260,7 +260,7 @@ public class AbsoluteValueFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java
index bb26a074cae..35efe555112 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AddFunctionTest.java
@@ -100,7 +100,7 @@ public class AddFunctionTest extends SolrTestCaseJ4 {
val2.setValue(21.56F).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -108,7 +108,7 @@ public class AddFunctionTest extends SolrTestCaseJ4 {
val2.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java
index 34005cb7487..341b9419e00 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/AndFunctionTest.java
@@ -53,22 +53,22 @@ public class AndFunctionTest extends SolrTestCaseJ4 {
// Both exist
val1.setValue(false).setExists(true);
val2.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val1.setValue(true).setExists(true);
val2.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val1.setValue(false).setExists(true);
val2.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val1.setValue(true).setExists(true);
val2.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -88,20 +88,20 @@ public class AndFunctionTest extends SolrTestCaseJ4 {
// One value
val.setValues(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValues(false);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
// Multiple values
val.setValues(true, true, false, true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val.setValues(true, true, true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -120,7 +120,7 @@ public class AndFunctionTest extends SolrTestCaseJ4 {
val2.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -128,7 +128,7 @@ public class AndFunctionTest extends SolrTestCaseJ4 {
val2.setValues(true, false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
@@ -186,14 +186,14 @@ public class AndFunctionTest extends SolrTestCaseJ4 {
val2.setValue(false).setExists(true);
val3.setValue(true).setExists(true);
val4.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val1.setValue(true).setExists(true);
val2.setValue(true).setExists(true);
val3.setValue(true).setExists(true);
val4.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
}
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java
index 18d7d55c264..31355fa9e1f 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/CeilingFunctionTest.java
@@ -98,7 +98,7 @@ public class CeilingFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -135,7 +135,7 @@ public class CeilingFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java
index 92f0c72459c..fe4e4356786 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ConcatFunctionTest.java
@@ -96,7 +96,7 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setValues();
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One exists
@@ -104,14 +104,14 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setValues("def");
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValue("abc").setExists(true);
val2.setValues();
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Both exist
@@ -142,7 +142,7 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setValues();
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One exists
@@ -150,14 +150,14 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setValues("def");
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValue("abc").setExists(true);
val2.setValues();
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Both exist
@@ -187,7 +187,7 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setExists(false);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One exists
@@ -195,14 +195,14 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setExists(false);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues();
val2.setValue("abc").setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Both exist
@@ -233,7 +233,7 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setExists(false);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One exists
@@ -241,14 +241,14 @@ public class ConcatFunctionTest extends SolrTestCaseJ4 {
val2.setExists(false);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues();
val2.setValue("abc").setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Both exist
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java
index 51202ced7b5..c069e97abd0 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/DivideFunctionTest.java
@@ -73,7 +73,7 @@ public class DivideFunctionTest extends SolrTestCaseJ4 {
divisor.setValue(21.56F).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -81,7 +81,7 @@ public class DivideFunctionTest extends SolrTestCaseJ4 {
divisor.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
@@ -111,7 +111,7 @@ public class DivideFunctionTest extends SolrTestCaseJ4 {
divisor.setValues();
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -119,7 +119,7 @@ public class DivideFunctionTest extends SolrTestCaseJ4 {
divisor.setValues(4L, 10023L);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/EqualFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/EqualFunctionTest.java
index 39aa068aef2..569471ce46b 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/EqualFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/EqualFunctionTest.java
@@ -63,12 +63,12 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
// Value exists
val1.setValue(false).setExists(true);
val2.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val1.setValue(false).setExists(true);
val2.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -101,12 +101,12 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
// Value exists
val1.setValue(21.56).setExists(true);
val2.setValue(21.56).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val1.setValue(21.56).setExists(true);
val2.setValue(21.57).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -139,12 +139,12 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
// Value exists
val1.setValue("1800-01-02T10:20:30Z").setExists(true);
val2.setValue("1800-01-02T10:20:30Z").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val1.setValue("1800-01-02T10:20:30Z").setExists(true);
val2.setValue("1800-01-02T10:20:31Z").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -177,12 +177,12 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
// Value exists
val1.setValue("abcdefghi").setExists(true);
val2.setValue("abcdefghi").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val1.setValue("abcdefghi1").setExists(true);
val2.setValue("abcdefghi2").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -201,14 +201,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue(false).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues(true);
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -249,14 +249,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue(false).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues(true);
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -297,14 +297,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue(-4.2).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues(-4.2);
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -345,14 +345,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue(-4.2).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues(-4.2);
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -393,14 +393,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue("1800-01-02T10:20:30Z").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues("1800-01-02T10:20:30Z");
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -445,14 +445,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue("1800-01-02T10:20:30Z").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues("1800-01-02T10:20:30Z");
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -497,14 +497,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue("abcdefghi").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues("abcdefghi");
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -545,14 +545,14 @@ public class EqualFunctionTest extends SolrTestCaseJ4 {
val2.setValue("abcdefghi").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val1.setValues("abcdefghi");
val2.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FillMissingFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FillMissingFunctionTest.java
index 7c079945ac0..eb0b560b54e 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FillMissingFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FillMissingFunctionTest.java
@@ -120,32 +120,32 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
// Value exists
val.setValue(true).setExists(true);
filler.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValue(false).setExists(true);
filler.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val.setValue(true).setExists(true);
filler.setExists(false);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValue(false).setExists(true);
filler.setExists(false);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val.setExists(false);
filler.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val.setExists(false);
filler.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -399,7 +399,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -449,7 +449,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -499,7 +499,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -549,7 +549,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -599,7 +599,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -653,7 +653,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -703,7 +703,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -752,7 +752,7 @@ public class FillMissingFunctionTest extends SolrTestCaseJ4 {
filler.setValues();
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FilterFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FilterFunctionTest.java
index 730a60135a5..cf272e996cb 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FilterFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FilterFunctionTest.java
@@ -87,7 +87,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
// Value exists
val.setValue(true).setExists(true);
filter.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValue(true).setExists(true);
@@ -97,7 +97,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
val.setValue(false).setExists(true);
filter.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val.setValue(false).setExists(true);
@@ -460,21 +460,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues(false, true, false);
filter.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -492,7 +492,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -510,7 +510,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -525,7 +525,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -544,21 +544,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues(1, 3, 5);
filter.setExists(false);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -576,7 +576,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -594,7 +594,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -609,7 +609,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -628,21 +628,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues(1L, 3L, 5L);
filter.setExists(false);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -660,7 +660,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -678,7 +678,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -693,7 +693,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -712,21 +712,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues(50.343F, -74.9874F, 2342332342.32F);
filter.setExists(false);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -744,7 +744,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -762,7 +762,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -777,7 +777,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -796,21 +796,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues(50.343, -74.9874, 2342332342.32);
filter.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -828,7 +828,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -846,7 +846,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -861,7 +861,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -884,21 +884,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues("1810-12-02T10:30:15Z", "1850-12-02T20:30:15Z");
filter.setExists(false);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -916,7 +916,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -934,7 +934,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -950,7 +950,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -969,21 +969,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues("abc", "123", "def", "456");
filter.setExists(false);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -1001,7 +1001,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -1019,7 +1019,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -1034,7 +1034,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -1051,21 +1051,21 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setExists(false);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues(3, "3", new Date(3));
filter.setExists(false);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
filter.setValue(true).setExists(true);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -1084,7 +1084,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -1102,7 +1102,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
filter.setValue(true).setExists(true);
@@ -1117,7 +1117,7 @@ public class FilterFunctionTest extends SolrTestCaseJ4 {
filter.setValue(false).setExists(true);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
}
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FloorFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FloorFunctionTest.java
index cd51d890157..22145ef5f30 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FloorFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/FloorFunctionTest.java
@@ -98,7 +98,7 @@ public class FloorFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -135,7 +135,7 @@ public class FloorFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTEFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTEFunctionTest.java
index 086265b671e..93fae174c5b 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTEFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTEFunctionTest.java
@@ -60,17 +60,17 @@ public class GTEFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue(21.56).setExists(true);
comp.setValue(21.56).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(21.57).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(-21.57).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -103,17 +103,17 @@ public class GTEFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:31Z").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1000-01-02T10:20:31Z").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -132,14 +132,14 @@ public class GTEFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues(-4.2);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -180,14 +180,14 @@ public class GTEFunctionTest extends SolrTestCaseJ4 {
comp.setValue(-4.2).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues(-4.2);
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -228,14 +228,14 @@ public class GTEFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues("1800-01-02T10:20:30Z");
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -281,14 +281,14 @@ public class GTEFunctionTest extends SolrTestCaseJ4 {
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues("1800-01-02T10:20:30Z");
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTFunctionTest.java
index 6beabb2725f..6ac044ab930 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/GTFunctionTest.java
@@ -60,17 +60,17 @@ public class GTFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue(21.56).setExists(true);
comp.setValue(21.56).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(21.57).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(-21.57).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -103,17 +103,17 @@ public class GTFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:31Z").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1000-01-02T10:20:31Z").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -132,14 +132,14 @@ public class GTFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues(-4.2);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -180,14 +180,14 @@ public class GTFunctionTest extends SolrTestCaseJ4 {
comp.setValue(-4.2).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues(-4.2);
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -228,14 +228,14 @@ public class GTFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues("1800-01-02T10:20:30Z");
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -281,14 +281,14 @@ public class GTFunctionTest extends SolrTestCaseJ4 {
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues("1800-01-02T10:20:30Z");
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/IfFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/IfFunctionTest.java
index 92a3c08e10d..50e970fe74b 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/IfFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/IfFunctionTest.java
@@ -158,25 +158,25 @@ public class IfFunctionTest extends SolrTestCaseJ4 {
cond.setValue(true).setExists(true);
then.setValue(false).setExists(true);
els.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
cond.setValue(true).setExists(true);
then.setValue(true).setExists(true);
els.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
cond.setValue(false).setExists(true);
then.setValue(false).setExists(true);
els.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
cond.setValue(false).setExists(true);
then.setValue(true).setExists(true);
els.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTEFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTEFunctionTest.java
index 964f2424a87..0a3b7f9d202 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTEFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTEFunctionTest.java
@@ -60,17 +60,17 @@ public class LTEFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue(21.56).setExists(true);
comp.setValue(21.56).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(21.57).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(-21.57).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -103,17 +103,17 @@ public class LTEFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:31Z").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1000-01-02T10:20:31Z").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -132,14 +132,14 @@ public class LTEFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues(-4.2);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -180,14 +180,14 @@ public class LTEFunctionTest extends SolrTestCaseJ4 {
comp.setValue(-4.2).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues(-4.2);
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -228,14 +228,14 @@ public class LTEFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues("1800-01-02T10:20:30Z");
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -281,14 +281,14 @@ public class LTEFunctionTest extends SolrTestCaseJ4 {
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues("1800-01-02T10:20:30Z");
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTFunctionTest.java
index c44a093fc96..1c83670b996 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LTFunctionTest.java
@@ -60,17 +60,17 @@ public class LTFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue(21.56).setExists(true);
comp.setValue(21.56).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(21.57).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue(21.56).setExists(true);
comp.setValue(-21.57).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -103,17 +103,17 @@ public class LTFunctionTest extends SolrTestCaseJ4 {
// Value exists
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1800-01-02T10:20:31Z").setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
base.setValue("1800-01-02T10:20:30Z").setExists(true);
comp.setValue("1000-01-02T10:20:31Z").setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -132,14 +132,14 @@ public class LTFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues(-4.2);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -180,14 +180,14 @@ public class LTFunctionTest extends SolrTestCaseJ4 {
comp.setValue(-4.2).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues(-4.2);
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -228,14 +228,14 @@ public class LTFunctionTest extends SolrTestCaseJ4 {
comp.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setExists(false);
comp.setValues("1800-01-02T10:20:30Z");
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -281,14 +281,14 @@ public class LTFunctionTest extends SolrTestCaseJ4 {
comp.setValue("1800-01-02T10:20:30Z").setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
base.setValues("1800-01-02T10:20:30Z");
comp.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java
index 77a38c1342b..2c000768438 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java
@@ -68,7 +68,7 @@ public class LogFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -137,7 +137,7 @@ public class LogFunctionTest extends SolrTestCaseJ4 {
val.setValue(21.56F).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -145,7 +145,7 @@ public class LogFunctionTest extends SolrTestCaseJ4 {
val.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
@@ -180,7 +180,7 @@ public class LogFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -188,7 +188,7 @@ public class LogFunctionTest extends SolrTestCaseJ4 {
val.setValues(4L, 10023L);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/MultFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/MultFunctionTest.java
index 2d558f4913a..54965049aff 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/MultFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/MultFunctionTest.java
@@ -99,7 +99,7 @@ public class MultFunctionTest extends SolrTestCaseJ4 {
val2.setValue(21.56F).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -107,7 +107,7 @@ public class MultFunctionTest extends SolrTestCaseJ4 {
val2.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/NegateFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/NegateFunctionTest.java
index f0ca115aa72..ff710d8990c 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/NegateFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/NegateFunctionTest.java
@@ -60,11 +60,11 @@ public class NegateFunctionTest extends SolrTestCaseJ4 {
// Value exists
val.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -177,7 +177,7 @@ public class NegateFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -214,7 +214,7 @@ public class NegateFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -251,7 +251,7 @@ public class NegateFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -288,7 +288,7 @@ public class NegateFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
@@ -325,7 +325,7 @@ public class NegateFunctionTest extends SolrTestCaseJ4 {
val.setValues();
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// One value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/OrFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/OrFunctionTest.java
index 05a3d2ddf16..3aa96e2aa3f 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/OrFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/OrFunctionTest.java
@@ -53,22 +53,22 @@ public class OrFunctionTest extends SolrTestCaseJ4 {
// Both exist
val1.setValue(false).setExists(true);
val2.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val1.setValue(true).setExists(true);
val2.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val1.setValue(false).setExists(true);
val2.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val1.setValue(true).setExists(true);
val2.setValue(true).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
}
@@ -88,20 +88,20 @@ public class OrFunctionTest extends SolrTestCaseJ4 {
// One value
val.setValues(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValues(false);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
// Multiple values
val.setValues(false, false, true, false);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValues(false, false, false);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -120,7 +120,7 @@ public class OrFunctionTest extends SolrTestCaseJ4 {
val2.setValues();
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -128,7 +128,7 @@ public class OrFunctionTest extends SolrTestCaseJ4 {
val2.setValues(true, false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
@@ -186,14 +186,14 @@ public class OrFunctionTest extends SolrTestCaseJ4 {
val2.setValue(true).setExists(true);
val3.setValue(false).setExists(true);
val4.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val1.setValue(false).setExists(true);
val2.setValue(false).setExists(true);
val3.setValue(false).setExists(true);
val4.setValue(false).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
}
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/PowerFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/PowerFunctionTest.java
index 7b11abbadfa..74fb9364505 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/PowerFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/PowerFunctionTest.java
@@ -73,7 +73,7 @@ public class PowerFunctionTest extends SolrTestCaseJ4 {
pow.setValue(21.56F).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -81,7 +81,7 @@ public class PowerFunctionTest extends SolrTestCaseJ4 {
pow.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
@@ -111,7 +111,7 @@ public class PowerFunctionTest extends SolrTestCaseJ4 {
pow.setValues();
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, no value
@@ -119,7 +119,7 @@ public class PowerFunctionTest extends SolrTestCaseJ4 {
pow.setValues(4L, 10023L);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Multiple values, one value
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RemoveFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RemoveFunctionTest.java
index cbaa11744e8..85990332cae 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RemoveFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/RemoveFunctionTest.java
@@ -125,7 +125,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
// Value exists
val.setValue(true).setExists(true);
remover.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValue(true).setExists(true);
@@ -135,7 +135,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
val.setValue(false).setExists(true);
remover.setValue(true).setExists(true);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
val.setValue(false).setExists(true);
@@ -145,7 +145,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
val.setValue(false).setExists(true);
remover.setExists(false);
- assertEquals(false, func.getBoolean());
+ assertFalse(func.getBoolean());
assertTrue(func.exists());
}
@@ -434,14 +434,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue(true).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -479,7 +479,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue(false).setExists(true);
func.streamBooleans(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -498,14 +498,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue(324).setExists(true);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -543,7 +543,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue(1).setExists(true);
func.streamInts(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -562,14 +562,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue(2323L).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -607,7 +607,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue(10L).setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -626,14 +626,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue(230.32F).setExists(true);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -673,7 +673,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue(23.56F).setExists(true);
func.streamFloats(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -692,14 +692,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue(234237.67).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -737,7 +737,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue(3124.96).setExists(true);
func.streamDoubles(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -760,14 +760,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue("1700-12-14").setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -821,7 +821,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue("1810-12-02T10:30:15Z").setExists(true);
func.streamLongs(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -840,14 +840,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue("ads").setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -886,7 +886,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue("abc123").setExists(true);
func.streamStrings(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
@@ -903,14 +903,14 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setExists(false);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
val.setValues();
remover.setValue("doesn't matter").setExists(true);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
// Values exist
@@ -949,7 +949,7 @@ public class RemoveFunctionTest extends SolrTestCaseJ4 {
remover.setValue(new Date(4)).setExists(true);
func.streamObjects(
value -> {
- assertTrue("There should be no values to stream", false);
+ fail("There should be no values to stream");
});
}
}
diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ReplaceFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ReplaceFunctionTest.java
index 4f732bcdbea..079bdabba08 100644
--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ReplaceFunctionTest.java
+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/ReplaceFunctionTest.java
@@ -145,20 +145,20 @@ public class ReplaceFunctionTest extends SolrTestCaseJ4 {
val.setValue(true).setExists(true);
comp.setExists(false);
fill.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
// Value exists
val.setValue(true).setExists(true);
comp.setValue(false).setExists(true);
fill.setValue(false).setExists(true);
- assertEquals(true, func.getBoolean());
+ assertTrue(func.getBoolean());
assertTrue(func.exists());
val.setValue(true).setExists(true);
comp.setValue(true).setExists(true);
fill.setValue(false).setExists(true);
... 19381 lines suppressed ...