From 7da8325cee2a3f5d0603772b7536de20ea1e9267 Mon Sep 17 00:00:00 2001 From: Joel Bernstein Date: Sat, 23 Sep 2017 21:31:22 -0400 Subject: [PATCH] SOLR-11388: Add test case --- .../solrj/io/stream/StreamExpressionTest.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java index ded65b8b84b..e1075e3d6fb 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java @@ -6519,12 +6519,38 @@ public class StreamExpressionTest extends SolrCloudTestCase { List tuples = getTuples(solrStream); assertTrue(tuples.size() == 1); List out = (List)tuples.get(0).get("return-value"); - assertTrue(out.size()==3); + assertTrue(out.size() == 3); assertEquals(out.get(0).doubleValue(), 6.0, .0); assertEquals(out.get(1).doubleValue(), 9.0, .0); assertEquals(out.get(2).doubleValue(), 10.0, .0); } + @Test + public void testMonteCarlo() throws Exception { + String cexpr = "let(a=constantDistribution(10), b=constantDistribution(20), c=monteCarlo(add(sample(a), sample(b)), 10))"; + ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); + paramsLoc.set("expr", cexpr); + 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); + assertTrue(tuples.size() == 1); + List out = (List)tuples.get(0).get("c"); + assertTrue(out.size()==10); + assertEquals(out.get(0).doubleValue(), 30.0, .0); + assertEquals(out.get(1).doubleValue(), 30.0, .0); + assertEquals(out.get(2).doubleValue(), 30.0, .0); + assertEquals(out.get(3).doubleValue(), 30.0, .0); + assertEquals(out.get(4).doubleValue(), 30.0, .0); + assertEquals(out.get(5).doubleValue(), 30.0, .0); + assertEquals(out.get(6).doubleValue(), 30.0, .0); + assertEquals(out.get(7).doubleValue(), 30.0, .0); + assertEquals(out.get(8).doubleValue(), 30.0, .0); + assertEquals(out.get(9).doubleValue(), 30.0, .0); + } + @Test public void testScale() throws Exception {