diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java index 4b0e4546b17..bcda78870c2 100644 --- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java +++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/CloudAuthStreamTest.java @@ -50,7 +50,7 @@ /** * tests various streaming expressions (via the SolrJ {@link SolrStream} API) against a SolrCloud - * cluster using both Authenticationand Role based Authorization + * cluster using both Authentication and Role based Authorization */ public class CloudAuthStreamTest extends SolrCloudTestCase { @@ -67,8 +67,8 @@ public class CloudAuthStreamTest extends SolrCloudTestCase { private static String solrUrl = null; /** - * Helper that returns the original {@link SolrRequest} with it's original type so it can - * be chained. This menthod knows that for the purpose of this test, every user name is it's own + * Helper that returns the original {@link SolrRequest} with its original type so it can + * be chained. This method knows that for the purpose of this test, every username is its own * password * * @see SolrRequest#setBasicAuthCredentials @@ -254,7 +254,7 @@ public void testEchoStream() throws Exception { assertEquals("hello world", tuples.get(0).get("echo")); } - public void testEchoStreamNoCredentials() throws Exception { + public void testEchoStreamNoCredentials() { final SolrStream solrStream = new SolrStream( solrUrl + "/" + COLLECTION_X, @@ -271,7 +271,7 @@ public void testEchoStreamNoCredentials() throws Exception { }); } - public void testEchoStreamInvalidCredentials() throws Exception { + public void testEchoStreamInvalidCredentials() { final SolrStream solrStream = new SolrStream( solrUrl + "/" + COLLECTION_X, @@ -490,7 +490,7 @@ public void testExecutorUpdateStreamInsufficientCredentials() throws Exception { params("qt", "/stream", "_trace", "executor_via_" + trace, "expr", expr)); solrStream.setCredentials(user, user); - // NOTE: Becaue of the backgroun threads, no failures will to be returned to client... + // NOTE: Because of the background threads, no failures will to be returned to client... final List tuples = getTuples(solrStream); assertEquals(0, tuples.size()); @@ -512,7 +512,7 @@ public void testDaemonUpdateStream() throws Exception { { // NOTE: in spite of what is implied by 'terminate=true', this daemon will NEVER terminate on - // it's own as long as the updates are successful (apparently that requires usage of a topic() + // its own as long as the updates are successful (apparently that requires usage of a topic() // stream to set a "sleepMillis"?!) final String expr = "daemon(id=daemonId,runInterval=1000,terminate=true,update(" @@ -937,7 +937,7 @@ protected static long countDocsInCollection(final String collection, final Strin /** Slurps a stream into a List */ protected static List getTuples(final TupleStream tupleStream) throws IOException { - List tuples = new ArrayList(); + List tuples = new ArrayList<>(); try { log.trace("TupleStream: {}", tupleStream); tupleStream.open(); @@ -953,8 +953,8 @@ protected static List getTuples(final TupleStream tupleStream) throws IOE return tuples; } - /** Sigh. DaemonStream requires polling the same core where the stream was exectured. */ - protected static String getRandomCoreUrl(final String collection) throws Exception { + /** Sigh. DaemonStream requires polling the same core where the stream was executed. */ + protected static String getRandomCoreUrl(final String collection) { final List replicaUrls = cluster .getZkStateReader() diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java index a76ac4eb41c..030e6ffd3ef 100644 --- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java +++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/JDBCStreamTest.java @@ -25,7 +25,6 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; -import java.util.Locale; import java.util.Map; import org.apache.lucene.tests.util.LuceneTestCase; import org.apache.solr.SolrTestCaseJ4.SuppressPointFields; @@ -95,7 +94,7 @@ public static void setupCluster() throws Exception { public static void setupDatabase() throws Exception { // Initialize Database - // Ok, so.....hsqldb is doing something totally weird so I thought I'd take a moment to explain + // Ok, so.....hsqldb is doing something totally weird, so I thought I'd take a moment to explain // it. // According to http://www.hsqldb.org/doc/1.8/guide/guide.html#N101EF, section "Components of // SQL Expressions", clause "name", "When an SQL statement is issued, any lowercase characters @@ -280,7 +279,7 @@ public void testJDBCSolrMerge() throws Exception { // Load Solr new UpdateRequest() - .add(id, "0", "code_s", "GB", "name_s", "Great Britian") + .add(id, "0", "code_s", "GB", "name_s", "Great Britain") .add(id, "1", "code_s", "CA", "name_s", "Canada") .commit(cluster.getSolrClient(), COLLECTIONORALIAS); @@ -324,7 +323,7 @@ public void testJDBCSolrMerge() throws Exception { "name_s", "Algeria", "Canada", - "Great Britian", + "Great Britain", "Netherlands", "Norway", "Nepal", @@ -774,7 +773,7 @@ protected List getTuples(TupleStream tupleStream) throws IOException { return tuples; } - protected boolean assertOrderOf(List tuples, String fieldName, int... values) + protected void assertOrderOf(List tuples, String fieldName, int... values) throws Exception { int i = 0; for (int val : values) { @@ -785,11 +784,9 @@ protected boolean assertOrderOf(List tuples, String fieldName, int... val } ++i; } - return true; } - protected boolean assertOrderOf(List tuples, String fieldName, double... values) - throws Exception { + protected void assertOrderOf(List tuples, String fieldName, double... values) { int i = 0; for (double val : values) { Tuple t = tuples.get(i); @@ -797,10 +794,9 @@ protected boolean assertOrderOf(List tuples, String fieldName, double... assertEquals("Found value:" + tip + " expecting:" + val, val, tip, 0.00001); ++i; } - return true; } - protected boolean assertOrderOf(List tuples, String fieldName, String... values) + protected void assertOrderOf(List tuples, String fieldName, String... values) throws Exception { int i = 0; for (String val : values) { @@ -808,7 +804,7 @@ protected boolean assertOrderOf(List tuples, String fieldName, String... if (null == val) { if (null != t.get(fieldName)) { - throw new Exception("Found value:" + (String) t.get(fieldName) + " expecting:null"); + throw new Exception("Found value:" + t.get(fieldName) + " expecting:null"); } } else { String tip = (String) t.get(fieldName); @@ -818,29 +814,6 @@ protected boolean assertOrderOf(List tuples, String fieldName, String... } ++i; } - return true; - } - - protected boolean assertFields(List tuples, String... fields) throws Exception { - for (Tuple tuple : tuples) { - for (String field : fields) { - if (!tuple.getFields().containsKey(field)) { - throw new Exception(String.format(Locale.ROOT, "Expected field '%s' not found", field)); - } - } - } - return true; - } - - protected boolean assertNotFields(List tuples, String... fields) throws Exception { - for (Tuple tuple : tuples) { - for (String field : fields) { - if (tuple.getFields().containsKey(field)) { - throw new Exception(String.format(Locale.ROOT, "Unexpected field '%s' found", field)); - } - } - } - return true; } public boolean assertLong(Tuple tuple, String fieldName, long l) throws Exception { @@ -863,9 +836,7 @@ public boolean assertDouble(Tuple tuple, String fieldName, double d) throws Exce public boolean assertString(Tuple tuple, String fieldName, String expected) throws Exception { String actual = (String) tuple.get(fieldName); - if ((null == expected && null != actual) - || (null != expected && null == actual) - || (null != expected && !expected.equals(actual))) { + if ((null == expected && null != actual) || (null != expected && !expected.equals(actual))) { throw new Exception("Longs not equal:" + expected + " : " + actual); } diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/ParallelFacetStreamOverAliasTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/ParallelFacetStreamOverAliasTest.java index d7e90a09c42..347894bae42 100644 --- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/ParallelFacetStreamOverAliasTest.java +++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/ParallelFacetStreamOverAliasTest.java @@ -100,7 +100,7 @@ public static void setupCluster() throws Exception { solrClientCache = new SolrClientCache(); } - /** setup the testbed with necessary collections, documents, and alias */ + /** set up the testbed with necessary collections, documents, and alias */ public static void setupCollectionsAndAlias() throws Exception { final NormalDistribution[] dists = new NormalDistribution[CARDINALITY]; @@ -299,7 +299,7 @@ public void testParallelStats() throws Exception { assertNull(statsStream.parallelizedStream); } - // execute the provided expression with tiered=true and compare to results of tiered=false + // execute the provided expression with tiered=true and compare to result of tiered=false private void compareTieredStreamWithNonTiered(String facetExprTmpl, int dims) throws IOException { String facetExpr = String.format(Locale.US, facetExprTmpl, ALIAS_NAME, "true"); diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java index db4d4cc2b22..13f7606c640 100644 --- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java +++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import java.util.Map; import org.apache.lucene.tests.util.LuceneTestCase; import org.apache.solr.client.solrj.io.SolrClientCache; import org.apache.solr.client.solrj.io.Tuple; @@ -47,8 +46,6 @@ public class SelectWithEvaluatorsTest extends SolrCloudTestCase { private static final int TIMEOUT = DEFAULT_TIMEOUT; private static final String id = "id"; - private static boolean useAlias; - @BeforeClass public static void setupCluster() throws Exception { configureCluster(4) @@ -71,7 +68,7 @@ public static void setupCluster() throws Exception { .configure(); String collection; - useAlias = random().nextBoolean(); + boolean useAlias = random().nextBoolean(); if (useAlias) { collection = COLLECTIONORALIAS + "_collection"; } else { @@ -146,39 +143,7 @@ protected List getTuples(TupleStream tupleStream) throws IOException { return tuples; } - protected boolean assertOrder(List tuples, int... ids) throws Exception { - return assertOrderOf(tuples, "id", ids); - } - - protected boolean assertOrderOf(List tuples, String fieldName, int... ids) - throws Exception { - int i = 0; - for (int val : ids) { - Tuple t = tuples.get(i); - String tip = t.getString(fieldName); - if (!tip.equals(Integer.toString(val))) { - throw new Exception("Found value:" + tip + " expecting:" + val); - } - ++i; - } - return true; - } - - protected boolean assertMapOrder(List tuples, int... ids) throws Exception { - int i = 0; - for (int val : ids) { - Tuple t = tuples.get(i); - List> tip = t.getMaps("group"); - int id = (int) tip.get(0).get("id"); - if (id != val) { - throw new Exception("Found value:" + id + " expecting:" + val); - } - ++i; - } - return true; - } - - protected boolean assertFields(List tuples, String... fields) throws Exception { + protected void assertFields(List tuples, String... fields) throws Exception { for (Tuple tuple : tuples) { for (String field : fields) { if (!tuple.getFields().containsKey(field)) { @@ -186,10 +151,9 @@ protected boolean assertFields(List tuples, String... fields) throws Exce } } } - return true; } - protected boolean assertNotFields(List tuples, String... fields) throws Exception { + protected void assertNotFields(List tuples, String... fields) throws Exception { for (Tuple tuple : tuples) { for (String field : fields) { if (tuple.getFields().containsKey(field)) { @@ -197,21 +161,6 @@ protected boolean assertNotFields(List tuples, String... fields) throws E } } } - return true; - } - - protected boolean assertGroupOrder(Tuple tuple, int... ids) throws Exception { - List group = (List) tuple.get("tuples"); - int i = 0; - for (int val : ids) { - Map t = (Map) group.get(i); - Long tip = (Long) t.get("id"); - if (tip.intValue() != val) { - throw new Exception("Found value:" + tip.intValue() + " expecting:" + val); - } - ++i; - } - return true; } public boolean assertLong(Tuple tuple, String fieldName, long l) throws Exception { @@ -236,12 +185,9 @@ public boolean assertDouble(Tuple tuple, String fieldName, double expectedValue) public boolean assertString(Tuple tuple, String fieldName, String expected) throws Exception { String actual = (String) tuple.get(fieldName); - if ((null == expected && null != actual) - || (null != expected && null == actual) - || (null != expected && !expected.equals(actual))) { - throw new Exception("Longs not equal:" + expected + " : " + actual); + if ((null != expected || null == actual) && (null == expected || expected.equals(actual))) { + return true; } - - return true; + throw new Exception("Longs not equal:" + expected + " : " + actual); } } diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java index 6d80d8e9cde..f90274409cb 100644 --- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java +++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java @@ -5169,12 +5169,11 @@ protected List getTuples(TupleStream tupleStream) throws IOException { return tuples; } - protected boolean assertOrder(List tuples, int... ids) throws Exception { - return assertOrderOf(tuples, "id", ids); + protected void assertOrder(List tuples, int... ids) throws Exception { + assertOrderOf(tuples, "id", ids); } - protected boolean assertOrderOf(List tuples, String fieldName, int... ids) - throws Exception { + protected void assertOrderOf(List tuples, String fieldName, int... ids) throws Exception { int i = 0; for (int val : ids) { Tuple t = tuples.get(i); @@ -5184,10 +5183,9 @@ protected boolean assertOrderOf(List tuples, String fieldName, int... ids } ++i; } - return true; } - protected boolean assertFields(List tuples, String... fields) throws Exception { + protected void assertFields(List tuples, String... fields) throws Exception { for (Tuple tuple : tuples) { for (String field : fields) { if (!tuple.getFields().containsKey(field)) { @@ -5195,10 +5193,9 @@ protected boolean assertFields(List tuples, String... fields) throws Exce } } } - return true; } - protected boolean assertNotFields(List tuples, String... fields) throws Exception { + protected void assertNotFields(List tuples, String... fields) throws Exception { for (Tuple tuple : tuples) { for (String field : fields) { if (tuple.getFields().containsKey(field)) { @@ -5206,7 +5203,6 @@ protected boolean assertNotFields(List tuples, String... fields) throws E } } } - return true; } protected boolean assertGroupOrder(Tuple tuple, int... ids) throws Exception { diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExecutorHelperTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExecutorHelperTest.java index ae80cea1060..287aa851734 100644 --- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExecutorHelperTest.java +++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExecutorHelperTest.java @@ -36,7 +36,7 @@ public void submitAllTest() throws IOException { List results = new ArrayList<>(); results.addAll(StreamExecutorHelper.submitAllAndAwaitAggregatingExceptions(tasks, "test")); Collections.sort(results); - List expected = List.of(0l, 1l, 2l, 3l, 4l); + List expected = List.of(0L, 1L, 2L, 3L, 4L); assertEquals(expected, results); } diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java index 050b5726ff2..1541312d02e 100644 --- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java +++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java @@ -73,7 +73,6 @@ public class StreamExpressionTest extends SolrCloudTestCase { private static final String COLLECTIONORALIAS = "collection1"; private static final String FILESTREAM_COLLECTION = "filestream_collection"; - private static final int TIMEOUT = DEFAULT_TIMEOUT; private static final String id = "id"; private static boolean useAlias; @@ -256,7 +255,7 @@ public void testCloudSolrStream() throws Exception { assertOrder(tuples, 0, 2, 1, 3, 4); assertLong(tuples.get(0), "a_i", 0); - // Execersise the /stream hander + // Exercise the /stream handler // Add the shards http parameter for the myCollection StringBuilder buf = new StringBuilder(); @@ -1040,7 +1039,7 @@ public void testStatsStream() throws Exception { assertEquals(6.0D, perf, 0.0); assertEquals(10, count, 0.0); - // Execersise the /stream hander + // Exercise the /stream handler // Add the shards http parameter for the myCollection StringBuilder buf = new StringBuilder(); @@ -1112,8 +1111,7 @@ public void testFacet2DStream() throws Exception { .add(id, "9", "diseases_s", "diabetes", "symptoms_s", "thirsty", "cases_i", "20") .add(id, "10", "diseases_s", "diabetes", "symptoms_s", "thirsty", "cases_i", "20") .commit(cluster.getSolrClient(), COLLECTIONORALIAS); - StreamExpression expression; - TupleStream stream; + List tuples; ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); @@ -3667,15 +3665,6 @@ public void testSearchBacktick() throws Exception { assertEquals("l b c d color`s e", tuple2.get("test_t")); } - private Map getIdToLabel(TupleStream stream, String outField) throws IOException { - Map idToLabel = new HashMap<>(); - List tuples = getTuples(stream); - for (Tuple tuple : tuples) { - idToLabel.put(tuple.getString("id"), tuple.getDouble(outField)); - } - return idToLabel; - } - @Test public void testBasicTextLogitStream() throws Exception { Assume.assumeTrue(!useAlias); @@ -4047,7 +4036,7 @@ public void testSignificantTermsStream() throws Exception { assertEquals(5600, tuples.get(1).getLong("background").longValue()); assertEquals(5000, tuples.get(1).getLong("foreground").longValue()); - // Execersise the /stream hander + // Exercise the /stream handler // Add the shards http parameter for the myCollection StringBuilder buf = new StringBuilder(); @@ -4108,7 +4097,7 @@ public void tooLargeForGetRequest() throws IOException, SolrServerException { StreamContext streamContext = new StreamContext(); streamContext.setSolrClientCache(cache); // use filter() to allow being parsed as 'terms in set' query instead of a (weighted/scored) - // BooleanQuery so we don't trip too many boolean clauses + // BooleanQuery, so we don't trip too many boolean clauses String longQuery = "\"filter(id:(" + IntStream.range(0, 4000).mapToObj(i -> "a").collect(Collectors.joining(" ", "", "")) @@ -4374,7 +4363,7 @@ private static Path findUserFilesDataDir() { /** * Creates a tree of files underneath a provided data-directory. * - *

The filetree created looks like: + *

The file tree created looks like: * *

    * dataDir
diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpressionTest.java
similarity index 98%
rename from solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java
rename to solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpressionTest.java
index 2c941f142d7..37429f7a939 100644
--- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java
+++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpressionTest.java
@@ -30,11 +30,11 @@
 import org.junit.Test;
 
 /** */
-public class StreamExpressionToExpessionTest extends SolrTestCase {
+public class StreamExpressionToExpressionTest extends SolrTestCase {
 
-  private StreamFactory factory;
+  private final StreamFactory factory;
 
-  public StreamExpressionToExpessionTest() {
+  public StreamExpressionToExpressionTest() {
     super();
 
     factory =
@@ -77,7 +77,6 @@ public void testCloudSolrStream() throws Exception {
                 "search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_i asc\", fq=\"a_s:one\", fq=\"a_s:two\")"),
             factory)) {
       expressionString = stream.toExpression(factory).toString();
-      System.out.println("ExpressionString: " + expressionString.toString());
       assertTrue(expressionString.contains("search(collection1,"));
       assertTrue(expressionString.contains("q=\"*:*\""));
       assertTrue(expressionString.contains("fl=\"id,a_s,a_i,a_f\""));
@@ -550,7 +549,7 @@ public void testCloudSolrStreamWithEscapedQuote() throws Exception {
 
     // The purpose of this test is to ensure that a parameter with a contained " character is
     // properly escaped when it is turned back into an expression. This is important when an
-    // expression is passedto a worker (parallel stream) or even for other reasons when an
+    // expression is passed to a worker (parallel stream) or even for other reasons when an
     // expression is string-ified.
 
     // Basic test
diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java
index d8770711876..42252add70c 100644
--- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java
+++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java
@@ -89,13 +89,12 @@ public class StreamingTest extends SolrCloudTestCase {
 
   private static String zkHost;
 
-  private static int numShards;
   private static int numWorkers;
   private static boolean useAlias;
 
   @BeforeClass
   public static void configureCluster() throws Exception {
-    numShards = random().nextInt(2) + 1; // 1 - 3
+    int numShards = random().nextInt(2) + 1; // 1 - 3
     numWorkers = numShards > 2 ? random().nextInt(numShards - 1) + 1 : numShards;
     configureCluster(numShards)
         .addConfig(