From f6992a3a3bd069b2926f613c021e9f4f39489ea8 Mon Sep 17 00:00:00 2001 From: Joel Bernstein Date: Tue, 30 Jul 2019 10:01:15 -0400 Subject: [PATCH] SOLR-13625: Fix broken test cases --- .../org/apache/solr/client/solrj/io/Lang.java | 2 +- .../client/solrj/io/eval/ConcatEvaluator.java | 63 ++++++++++ .../solrj/io/eval/RecursiveEvaluator.java | 21 ++++ .../io/eval/RecursiveNumericEvaluator.java | 11 +- .../eval/RecursiveNumericListEvaluator.java | 2 + .../io/eval/SetColumnLabelsEvaluator.java | 12 +- .../solrj/io/eval/SetRowLabelsEvaluator.java | 14 ++- .../client/solrj/io/eval/UuidEvaluator.java | 2 +- .../client/solrj/io/stream/CsvStream.java | 3 +- .../client/solrj/io/stream/SolrStream.java | 13 ++ .../solrj/io/stream/MathExpressionTest.java | 117 ++++++++++++++++++ .../solrj/io/stream/StreamDecoratorTest.java | 102 --------------- .../eval/AbsoluteValueEvaluatorTest.java | 4 +- .../io/stream/eval/AddEvaluatorTest.java | 6 +- .../stream/eval/ArcCosineEvaluatorTest.java | 4 +- .../io/stream/eval/ArcSineEvaluatorTest.java | 4 +- .../stream/eval/ArcTangentEvaluatorTest.java | 4 +- .../io/stream/eval/CeilingEvaluatorTest.java | 4 +- .../io/stream/eval/CosineEvaluatorTest.java | 4 +- .../stream/eval/CubedRootEvaluatorTest.java | 4 +- .../io/stream/eval/DivideEvaluatorTest.java | 10 +- .../io/stream/eval/FloorEvaluatorTest.java | 4 +- .../eval/HyperbolicCosineEvaluatorTest.java | 4 +- .../eval/HyperbolicSineEvaluatorTest.java | 4 +- .../eval/HyperbolicTangentEvaluatorTest.java | 4 +- .../io/stream/eval/ModuloEvaluatorTest.java | 10 +- .../io/stream/eval/MultiplyEvaluatorTest.java | 6 +- .../stream/eval/NaturalLogEvaluatorTest.java | 4 +- .../io/stream/eval/PowerEvaluatorTest.java | 2 +- .../io/stream/eval/RoundEvaluatorTest.java | 4 +- .../io/stream/eval/SineEvaluatorTest.java | 4 +- .../stream/eval/SquareRootEvaluatorTest.java | 4 +- .../io/stream/eval/SubtractEvaluatorTest.java | 6 +- .../io/stream/eval/TangentEvaluatorTest.java | 4 +- .../io/stream/eval/UuidEvaluatorTest.java | 12 +- 35 files changed, 311 insertions(+), 167 deletions(-) create mode 100644 solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConcatEvaluator.java diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.java index 60ce437c945..a83afd7d9b4 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/Lang.java @@ -107,7 +107,6 @@ public class Lang { // tuple manipulation operations .withFunctionName("replace", ReplaceOperation.class) - .withFunctionName("concat", ConcatOperation.class) // stream reduction operations .withFunctionName("group", GroupOperation.class) @@ -297,6 +296,7 @@ public class Lang { .withFunctionName("double", DoubleEvaluator.class) .withFunctionName("long", LongEvaluator.class) .withFunctionName("dateTime", DateEvaluator.class) + .withFunctionName("concat", ConcatEvaluator.class) // Boolean Stream Evaluators diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConcatEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConcatEvaluator.java new file mode 100644 index 00000000000..124faf5b66e --- /dev/null +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConcatEvaluator.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.client.solrj.io.eval; + +import java.io.IOException; +import java.util.List; + +import org.apache.solr.client.solrj.io.stream.expr.StreamExpression; +import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter; +import org.apache.solr.client.solrj.io.stream.expr.StreamFactory; + +public class ConcatEvaluator extends RecursiveObjectEvaluator implements ManyValueWorker { + protected static final long serialVersionUID = 1L; + private String delim = ""; + + public ConcatEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{ + super(expression, factory); + + List namedParams = factory.getNamedOperands(expression); + + for(StreamExpressionNamedParameter namedParam : namedParams){ + if(namedParam.getName().equals("delim")){ + this.delim = namedParam.getParameter().toString().trim(); + } else { + throw new IOException("Unexpected named parameter:"+namedParam.getName()); + } + } + + } + + @Override + public Object doWork(Object values[]) throws IOException { + + StringBuilder buff = new StringBuilder(); + + for(Object o : values) { + if(buff.length() > 0) { + buff.append(delim); + } + String s = o.toString(); + if(s.startsWith("\"") && s.endsWith("\"")) { + s = s.substring(1, s.length()-1); + } + buff.append(s.toString()); + } + + return buff.toString(); + } +} diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveEvaluator.java index 0278839e06c..a5fae7e6af0 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveEvaluator.java @@ -73,6 +73,27 @@ public abstract class RecursiveEvaluator implements StreamEvaluator, ValueWorker return new BigDecimal(value.toString()); } else if(value instanceof Collection){ + //Let's first check to see if we have a List of Strings. + //If we do let's try and convert to a list of doubles and see what happens + try { + List vector = new ArrayList(); + boolean allDoubles = true; + for(Object o : (Collection)value) { + if(o instanceof String) { + Double d = Double.parseDouble(o.toString()); + vector.add(d); + } else { + allDoubles = false; + break; + } + } + if(allDoubles) { + return vector; + } + } catch(Exception e) { + + } + return ((Collection)value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList()); } else if(value.getClass().isArray()){ diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericEvaluator.java index 948f003be57..b589f6e6859 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericEvaluator.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -46,12 +47,20 @@ public abstract class RecursiveNumericEvaluator extends RecursiveEvaluator { } else if(value instanceof BigDecimal){ return value; + } else if(value instanceof String) { + return new BigDecimal((String)value); } else if(value instanceof Number){ return new BigDecimal(value.toString()); } else if(value instanceof Collection){ - return ((Collection)value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList()); + if(value instanceof List) { + if(((List)value).get(0) instanceof Number) { + return value; + } + } + + return ((Collection) value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList()); } else if(value.getClass().isArray()){ Stream stream = Stream.empty(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericListEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericListEvaluator.java index 08305b11aec..e6dce630f91 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericListEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveNumericListEvaluator.java @@ -52,6 +52,8 @@ public abstract class RecursiveNumericListEvaluator extends RecursiveEvaluator { return null; } return new BigDecimal(value.toString()); + } else if (value instanceof String) { + return new BigDecimal(value.toString()); } else if(value instanceof BigDecimal){ return (BigDecimal)value; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetColumnLabelsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetColumnLabelsEvaluator.java index 1d589aff71f..a178c2e9dab 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetColumnLabelsEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetColumnLabelsEvaluator.java @@ -18,6 +18,7 @@ package org.apache.solr.client.solrj.io.eval; import java.io.IOException; +import java.util.ArrayList; import java.util.Locale; import java.util.List; @@ -39,8 +40,15 @@ public class SetColumnLabelsEvaluator extends RecursiveObjectEvaluator implement throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array of labels.",toExpression(constructingFactory), value2.getClass().getSimpleName())); } else { Matrix matrix = (Matrix)value1; - List colLabels = (List)value2; - matrix.setColumnLabels(colLabels); + + List colLabels = (List)value2; + //Convert numeric labels to strings. + List strLabels = new ArrayList(colLabels.size()); + for(Object o : colLabels) { + strLabels.add(o.toString()); + } + + matrix.setColumnLabels(strLabels); return matrix; } } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetRowLabelsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetRowLabelsEvaluator.java index 66a59c8b122..390299e3338 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetRowLabelsEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SetRowLabelsEvaluator.java @@ -18,6 +18,7 @@ package org.apache.solr.client.solrj.io.eval; import java.io.IOException; +import java.util.ArrayList; import java.util.Locale; import java.util.List; @@ -39,8 +40,17 @@ public class SetRowLabelsEvaluator extends RecursiveObjectEvaluator implements T throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - found type %s for value, expecting an array of labels.",toExpression(constructingFactory), value2.getClass().getSimpleName())); } else { Matrix matrix = (Matrix)value1; - List rowlabels = (List)value2; - matrix.setRowLabels(rowlabels); + List rowlabels = (List)value2; + + //Convert numeric labels to strings. + + List strLabels = new ArrayList(rowlabels.size()); + + for(Object o : rowlabels) { + strLabels.add(o.toString()); + } + + matrix.setRowLabels(strLabels); return matrix; } } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/UuidEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/UuidEvaluator.java index ee0f9ebe516..a7115a9bd43 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/UuidEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/UuidEvaluator.java @@ -35,7 +35,7 @@ public class UuidEvaluator extends SourceEvaluator { @Override public Object evaluate(Tuple tuple) throws IOException { - return UUID.randomUUID(); + return UUID.randomUUID().toString(); } @Override diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CsvStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CsvStream.java index b8c479e9aba..15ab6841766 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CsvStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CsvStream.java @@ -131,6 +131,7 @@ public class CsvStream extends TupleStream implements Expressible { throw new IOException("Headers and lines must have the same number of fields [file:"+file+" line number:"+lineNumber+"]"); } Tuple out = new Tuple(new HashMap()); + out.put("id", file+"_"+lineNumber); for(int i=0; i 0) { out.put(headers[i], fields[i]); @@ -147,7 +148,7 @@ public class CsvStream extends TupleStream implements Expressible { } protected String[] split(String line) { - String[] fields = line.split(",(?=([^\"]|\"[^\"]*\")*$)",-1); + String[] fields = line.split(",(?=(?:[^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)",-1); for(int i=0; i genericResponse = server.request(query); InputStream stream = (InputStream) genericResponse.get("stream"); this.closeableHttpResponse = (CloseableHttpResponse)genericResponse.get("closeableResponse"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java index bf60f810cf9..25a07deef80 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java @@ -209,6 +209,26 @@ public class MathExpressionTest extends SolrCloudTestCase { } } + @Test + public void testConcat() throws Exception { + String expr = " select(list(tuple(field1=\"a\", field2=\"b\"), tuple(field1=\"c\", field2=\"d\")), concat(field1, field2, \"hello\", delim=\"-\") as field3)"; + ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); + paramsLoc.set("expr", expr); + paramsLoc.set("qt", "/stream"); + + String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; + TupleStream solrStream = new SolrStream(url, paramsLoc); + + StreamContext context = new StreamContext(); + solrStream.setStreamContext(context); + List tuples = getTuples(solrStream); + assertEquals(tuples.size(), 2); + String s1= tuples.get(0).getString("field3"); + assertEquals(s1, "a-b-hello"); + String s2= tuples.get(1).getString("field3"); + assertEquals(s2, "c-d-hello"); + } + @Test public void testMemset() throws Exception { String expr = "let(echo=\"b, c\"," + @@ -4461,6 +4481,103 @@ public class MathExpressionTest extends SolrCloudTestCase { assertEquals(predictions.get(1).doubleValue(), 4, 0); } + @Test + public void testDateTime() throws Exception { + String expr = "select(list(tuple(a=20001011:10:11:01), tuple(a=20071011:14:30:20)), dateTime(a, yyyyMMdd:kk:mm:ss) as date)"; + ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); + paramsLoc.set("expr", expr); + paramsLoc.set("qt", "/stream"); + + String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; + TupleStream solrStream = new SolrStream(url, paramsLoc); + + StreamContext context = new StreamContext(); + solrStream.setStreamContext(context); + List tuples = getTuples(solrStream); + String date = (String)tuples.get(0).get("date"); + assertEquals(date, "2000-10-11T10:11:01Z"); + date = (String)tuples.get(1).get("date"); + assertEquals(date, "2007-10-11T14:30:20Z"); + } + + @Test + public void testDateTimeTZ() throws Exception { + String expr = "select(list(tuple(a=20001011), tuple(a=20071011)), dateTime(a, yyyyMMdd, UTC) as date, dateTime(a, yyyyMMdd, EST) as date1, dateTime(a, yyyyMMdd) as date2)"; + ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); + paramsLoc.set("expr", expr); + paramsLoc.set("qt", "/stream"); + + String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; + TupleStream solrStream = new SolrStream(url, paramsLoc); + + StreamContext context = new StreamContext(); + solrStream.setStreamContext(context); + List tuples = getTuples(solrStream); + String date = (String)tuples.get(0).get("date"); + String date1 = (String)tuples.get(0).get("date1"); + String date2 = (String)tuples.get(0).get("date2"); + + assertEquals(date, "2000-10-11T00:00:00Z"); + assertEquals(date1, "2000-10-11T05:00:00Z"); + assertEquals(date2, "2000-10-11T00:00:00Z"); + + + date = (String)tuples.get(1).get("date"); + date1 = (String)tuples.get(1).get("date1"); + date2 = (String)tuples.get(1).get("date2"); + + assertEquals(date, "2007-10-11T00:00:00Z"); + assertEquals(date1, "2007-10-11T05:00:00Z"); + assertEquals(date2, "2007-10-11T00:00:00Z"); + } + + + + @Test + public void testDoubleLong() throws Exception { + String expr = "select(tuple(d=\"1.1\", l=\"5000\"), double(d) as d, long(l) as l)"; + ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); + paramsLoc.set("expr", expr); + paramsLoc.set("qt", "/stream"); + + String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; + TupleStream solrStream = new SolrStream(url, paramsLoc); + + StreamContext context = new StreamContext(); + solrStream.setStreamContext(context); + List tuples = getTuples(solrStream); + assertEquals(tuples.size(), 1); + assertTrue(tuples.get(0).get("d") instanceof Double); + assertTrue(tuples.get(0).get("l") instanceof Long); + + assertEquals(tuples.get(0).getDouble("d"), 1.1D, 0); + assertEquals(tuples.get(0).getLong("l").longValue(), 5000L); + + } + + + public void testDoubleArray() throws Exception { + String expr = "let(a=list(tuple(d=\"1.1\", l=\"5000\"), tuple(d=\"1.3\", l=\"7000\"))," + + " b=col(a, d)," + + " tuple(doubles=double(b)))"; + ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); + paramsLoc.set("expr", expr); + paramsLoc.set("qt", "/stream"); + + String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; + TupleStream solrStream = new SolrStream(url, paramsLoc); + + StreamContext context = new StreamContext(); + solrStream.setStreamContext(context); + List tuples = getTuples(solrStream); + assertEquals(tuples.size(), 1); + + List doubles = (List)tuples.get(0).get("doubles"); + assertEquals(doubles.get(0), 1.1, 0); + assertEquals(doubles.get(1), 1.3, 0); + + } + @Test public void testGaussfit() throws Exception { String cexpr = "let(echo=true, " + diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java index 65815e10cfa..75474a4f768 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamDecoratorTest.java @@ -3217,108 +3217,6 @@ public class StreamDecoratorTest extends SolrCloudTestCase { } - @Test - public void testDateTime() throws Exception { - String expr = "select(list(tuple(a=20001011:10:11:01), tuple(a=20071011:14:30:20)), dateTime(a, yyyyMMdd:kk:mm:ss) as date)"; - ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); - paramsLoc.set("expr", expr); - paramsLoc.set("qt", "/stream"); - - String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; - TupleStream solrStream = new SolrStream(url, paramsLoc); - - StreamContext context = new StreamContext(); - solrStream.setStreamContext(context); - List tuples = getTuples(solrStream); - String date = (String)tuples.get(0).get("date"); - assertEquals(date, "2000-10-11T10:11:01Z"); - date = (String)tuples.get(1).get("date"); - assertEquals(date, "2007-10-11T14:30:20Z"); - } - - @Test - public void testDateTimeTZ() throws Exception { - String expr = "select(list(tuple(a=20001011), tuple(a=20071011)), dateTime(a, yyyyMMdd, UTC) as date, dateTime(a, yyyyMMdd, EST) as date1, dateTime(a, yyyyMMdd) as date2)"; - ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); - paramsLoc.set("expr", expr); - paramsLoc.set("qt", "/stream"); - - String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; - TupleStream solrStream = new SolrStream(url, paramsLoc); - - StreamContext context = new StreamContext(); - solrStream.setStreamContext(context); - List tuples = getTuples(solrStream); - String date = (String)tuples.get(0).get("date"); - String date1 = (String)tuples.get(0).get("date1"); - String date2 = (String)tuples.get(0).get("date2"); - - assertEquals(date, "2000-10-11T00:00:00Z"); - assertEquals(date1, "2000-10-11T05:00:00Z"); - assertEquals(date2, "2000-10-11T00:00:00Z"); - - - date = (String)tuples.get(1).get("date"); - date1 = (String)tuples.get(1).get("date1"); - date2 = (String)tuples.get(1).get("date2"); - - assertEquals(date, "2007-10-11T00:00:00Z"); - assertEquals(date1, "2007-10-11T05:00:00Z"); - assertEquals(date2, "2007-10-11T00:00:00Z"); - } - - - - @Test - public void testDoubleLong() throws Exception { - String expr = "select(tuple(d=\"1.1\", l=\"5000\"), double(d) as d, long(l) as l)"; - ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); - paramsLoc.set("expr", expr); - paramsLoc.set("qt", "/stream"); - - String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; - TupleStream solrStream = new SolrStream(url, paramsLoc); - - StreamContext context = new StreamContext(); - solrStream.setStreamContext(context); - List tuples = getTuples(solrStream); - assertEquals(tuples.size(), 1); - assertTrue(tuples.get(0).get("d") instanceof Double); - assertTrue(tuples.get(0).get("l") instanceof Long); - - assertEquals(tuples.get(0).getDouble("d"), 1.1D, 0); - assertEquals(tuples.get(0).getLong("l").longValue(), 5000L); - - } - - - public void testDoubleLongArray() throws Exception { - String expr = "let(a=list(tuple(d=\"1.1\", l=\"5000\"), tuple(d=\"1.3\", l=\"7000\"))," + - " b=col(a, d)," + - " c=col(a, l)," + - " tuple(doubles=double(b)," + - " longs=long(c)))"; - ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); - paramsLoc.set("expr", expr); - paramsLoc.set("qt", "/stream"); - - String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString() + "/" + COLLECTIONORALIAS; - TupleStream solrStream = new SolrStream(url, paramsLoc); - - StreamContext context = new StreamContext(); - solrStream.setStreamContext(context); - List tuples = getTuples(solrStream); - assertEquals(tuples.size(), 1); - - List doubles = (List)tuples.get(0).get("doubles"); - List longs = (List)tuples.get(0).get("longs"); - assertEquals(doubles.get(0), 1.1, 0); - assertEquals(doubles.get(1), 1.3, 0); - - assertEquals(longs.get(0).longValue(), 5000L); - assertEquals(longs.get(1).longValue(), 7000L); - } - @Test public void testCommitStream() throws Exception { diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java index f98ac71a860..75cde6e59ce 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java @@ -107,7 +107,7 @@ public class AbsoluteValueEvaluatorTest extends SolrTestCase { factory.constructEvaluator("abs(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void absNoValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("abs(a)"); @@ -116,7 +116,7 @@ public class AbsoluteValueEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void absNullValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("abs(a)"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java index 3b85953b9ba..0e431d8125a 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java @@ -69,7 +69,7 @@ public class AddEvaluatorTest extends SolrTestCase { Assert.assertEquals(3.2D, result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void addTwoFieldWithNulls() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)"); Object result; @@ -79,7 +79,7 @@ public class AddEvaluatorTest extends SolrTestCase { Assert.assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void addTwoFieldsWithNull() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)"); Object result; @@ -103,7 +103,7 @@ public class AddEvaluatorTest extends SolrTestCase { Assert.assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void addTwoFieldsWithMissingField() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)"); Object result; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcCosineEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcCosineEvaluatorTest.java index a0fb968d1c5..850ab3d7995 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcCosineEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcCosineEvaluatorTest.java @@ -76,7 +76,7 @@ public class ArcCosineEvaluatorTest extends SolrTestCase { factory.constructEvaluator("acos(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("acos(a)"); @@ -84,7 +84,7 @@ public class ArcCosineEvaluatorTest extends SolrTestCase { Object result = evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcSineEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcSineEvaluatorTest.java index 23808f2a951..b754159d052 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcSineEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcSineEvaluatorTest.java @@ -76,7 +76,7 @@ public class ArcSineEvaluatorTest extends SolrTestCase { factory.constructEvaluator("asin(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("asin(a)"); @@ -85,7 +85,7 @@ public class ArcSineEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcTangentEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcTangentEvaluatorTest.java index 07c28f26a23..87f5e3e5f2f 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcTangentEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ArcTangentEvaluatorTest.java @@ -76,7 +76,7 @@ public class ArcTangentEvaluatorTest extends SolrTestCase { factory.constructEvaluator("atan(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("atan(a)"); @@ -84,7 +84,7 @@ public class ArcTangentEvaluatorTest extends SolrTestCase { Object result = evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CeilingEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CeilingEvaluatorTest.java index 38c494a99bd..9a8a65e8492 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CeilingEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CeilingEvaluatorTest.java @@ -76,7 +76,7 @@ public class CeilingEvaluatorTest extends SolrTestCase { factory.constructEvaluator("ceil(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void ceilNoValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("ceil(a)"); @@ -85,7 +85,7 @@ public class CeilingEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void ceilNullValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("ceil(a)"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CosineEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CosineEvaluatorTest.java index f5e9c6d5cb2..894d66ef220 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CosineEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CosineEvaluatorTest.java @@ -76,7 +76,7 @@ public class CosineEvaluatorTest extends SolrTestCase { factory.constructEvaluator("cos(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("cos(a)"); @@ -84,7 +84,7 @@ public class CosineEvaluatorTest extends SolrTestCase { Object result = evaluator.evaluate(new Tuple(values)); assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CubedRootEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CubedRootEvaluatorTest.java index 2d112ae6aa6..07762612f2b 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CubedRootEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CubedRootEvaluatorTest.java @@ -76,7 +76,7 @@ public class CubedRootEvaluatorTest extends SolrTestCase { factory.constructEvaluator("cbrt(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("cbrt(a)"); @@ -84,7 +84,7 @@ public class CubedRootEvaluatorTest extends SolrTestCase { Object result = evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java index 60d93ac93b0..88e4b77a222 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java @@ -74,7 +74,7 @@ public class DivideEvaluatorTest extends SolrTestCase { factory.constructEvaluator("div(a)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void divTwoFieldWithNulls() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)"); @@ -82,7 +82,7 @@ public class DivideEvaluatorTest extends SolrTestCase { evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void divTwoFieldsWithNullDenominator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)"); @@ -91,7 +91,7 @@ public class DivideEvaluatorTest extends SolrTestCase { evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void divTwoFieldsWithNullNumerator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)"); @@ -101,7 +101,7 @@ public class DivideEvaluatorTest extends SolrTestCase { } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void divTwoFieldsWithMissingDenominator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)"); @@ -110,7 +110,7 @@ public class DivideEvaluatorTest extends SolrTestCase { evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void divTwoFieldsWithMissingNumerator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/FloorEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/FloorEvaluatorTest.java index 43203083f4a..d51ef9ea52a 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/FloorEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/FloorEvaluatorTest.java @@ -76,14 +76,14 @@ public class FloorEvaluatorTest extends SolrTestCase { factory.constructEvaluator("floor(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void floorNoValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("floor(a)"); values.clear(); Object result = evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void floorNullValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("floor(a)"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicCosineEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicCosineEvaluatorTest.java index 92d34ae5e41..3c3f696658e 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicCosineEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicCosineEvaluatorTest.java @@ -76,7 +76,7 @@ public class HyperbolicCosineEvaluatorTest extends SolrTestCase { factory.constructEvaluator("cosh(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("cosh(a)"); @@ -85,7 +85,7 @@ public class HyperbolicCosineEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicSineEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicSineEvaluatorTest.java index 259a8467a4c..d807c297745 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicSineEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicSineEvaluatorTest.java @@ -76,7 +76,7 @@ public class HyperbolicSineEvaluatorTest extends SolrTestCase { factory.constructEvaluator("sinh(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("sinh(a)"); @@ -85,7 +85,7 @@ public class HyperbolicSineEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicTangentEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicTangentEvaluatorTest.java index a5bc93fec02..53cc6c0b880 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicTangentEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/HyperbolicTangentEvaluatorTest.java @@ -76,7 +76,7 @@ public class HyperbolicTangentEvaluatorTest extends SolrTestCase { factory.constructEvaluator("tanh(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("tanh(a)"); @@ -85,7 +85,7 @@ public class HyperbolicTangentEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ModuloEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ModuloEvaluatorTest.java index d72b55f66c7..06a13386a08 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ModuloEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ModuloEvaluatorTest.java @@ -74,7 +74,7 @@ public class ModuloEvaluatorTest extends SolrTestCase { factory.constructEvaluator("mod(a)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void modTwoFieldWithNulls() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)"); @@ -82,7 +82,7 @@ public class ModuloEvaluatorTest extends SolrTestCase { evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void modTwoFieldsWithNullDenominator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)"); @@ -91,7 +91,7 @@ public class ModuloEvaluatorTest extends SolrTestCase { evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void modTwoFieldsWithNullNumerator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)"); @@ -101,7 +101,7 @@ public class ModuloEvaluatorTest extends SolrTestCase { } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void modTwoFieldsWithMissingDenominator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)"); @@ -110,7 +110,7 @@ public class ModuloEvaluatorTest extends SolrTestCase { evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void modTwoFieldsWithMissingNumerator() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mod(a,b)"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java index 49d0cfef87d..1bc3ccc7ccf 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java @@ -87,7 +87,7 @@ public class MultiplyEvaluatorTest extends SolrTestCase { Assert.assertEquals(6.5D, result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void multTwoFieldWithNulls() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)"); Object result; @@ -97,7 +97,7 @@ public class MultiplyEvaluatorTest extends SolrTestCase { Assert.assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void multTwoFieldsWithNull() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)"); Object result; @@ -121,7 +121,7 @@ public class MultiplyEvaluatorTest extends SolrTestCase { Assert.assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void multTwoFieldsWithMissingField() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)"); Object result; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NaturalLogEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NaturalLogEvaluatorTest.java index 5c15a5d7dfc..4592e477df5 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NaturalLogEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NaturalLogEvaluatorTest.java @@ -78,7 +78,7 @@ public class NaturalLogEvaluatorTest extends SolrTestCase { factory.constructEvaluator("log(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void logNoValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("log(a)"); @@ -87,7 +87,7 @@ public class NaturalLogEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void logNullValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("log(a)"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/PowerEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/PowerEvaluatorTest.java index 2de054d8dd1..c4c02d39666 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/PowerEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/PowerEvaluatorTest.java @@ -94,7 +94,7 @@ public class PowerEvaluatorTest extends SolrTestCase { factory.constructEvaluator("pow(a)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void powTwoFieldWithNulls() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("pow(a,b)"); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RoundEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RoundEvaluatorTest.java index 19809db73ef..f6f2a967076 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RoundEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RoundEvaluatorTest.java @@ -80,7 +80,7 @@ public class RoundEvaluatorTest extends SolrTestCase { factory.constructEvaluator("round(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("round(a)"); @@ -88,7 +88,7 @@ public class RoundEvaluatorTest extends SolrTestCase { Object result = evaluator.evaluate(new Tuple(values)); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SineEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SineEvaluatorTest.java index b8b29b96996..fad1ba2c931 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SineEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SineEvaluatorTest.java @@ -76,7 +76,7 @@ public class SineEvaluatorTest extends SolrTestCase { factory.constructEvaluator("sin(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("sin(a)"); @@ -85,7 +85,7 @@ public class SineEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SquareRootEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SquareRootEvaluatorTest.java index 5608763b212..b4f69402ded 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SquareRootEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SquareRootEvaluatorTest.java @@ -76,7 +76,7 @@ public class SquareRootEvaluatorTest extends SolrTestCase { factory.constructEvaluator("sqrt(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("sqrt(a)"); @@ -85,7 +85,7 @@ public class SquareRootEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java index 4d56b8d562b..48f1adbc1b7 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java @@ -74,7 +74,7 @@ public class SubtractEvaluatorTest extends SolrTestCase { factory.constructEvaluator("sub(a)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void subTwoFieldWithNulls() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)"); Object result; @@ -84,7 +84,7 @@ public class SubtractEvaluatorTest extends SolrTestCase { Assert.assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void subTwoFieldsWithNull() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)"); Object result; @@ -108,7 +108,7 @@ public class SubtractEvaluatorTest extends SolrTestCase { Assert.assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void subTwoFieldsWithMissingField() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)"); Object result; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/TangentEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/TangentEvaluatorTest.java index 8ad81dc3167..145261804d7 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/TangentEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/TangentEvaluatorTest.java @@ -76,7 +76,7 @@ public class TangentEvaluatorTest extends SolrTestCase { factory.constructEvaluator("tan(a,b)"); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void noValue() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("tan(a)"); @@ -85,7 +85,7 @@ public class TangentEvaluatorTest extends SolrTestCase { assertNull(result); } - @Test(expected = IOException.class) + @Test(expected = NumberFormatException.class) public void nullValue() throws Exception{ test(null); } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/UuidEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/UuidEvaluatorTest.java index 8bf5b5776f8..5b434e63d4d 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/UuidEvaluatorTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/UuidEvaluatorTest.java @@ -43,10 +43,12 @@ public class UuidEvaluatorTest extends SolrTestCase { } @Test - public void isUuidType() throws Exception{ + public void testUuid() throws Exception{ StreamEvaluator evaluator = factory.constructEvaluator("uuid()"); - - Assert.assertTrue(evaluator.evaluate(null) instanceof UUID); - Assert.assertTrue(evaluator.evaluate(new Tuple(values)) instanceof UUID); - } + Assert.assertTrue(evaluator.evaluate(null) instanceof String); + String uuid = (String)evaluator.evaluate(null); + assertEquals(uuid.split("-").length, 5); + String uuid1 = (String)evaluator.evaluate(new Tuple(values)); + assertNotEquals(uuid, uuid1); + } }