aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/searchchain
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahooinc.com>2022-07-28 12:54:37 +0200
committerBjørn Christian Seime <bjorncs@yahooinc.com>2022-07-28 14:51:34 +0200
commit34ec3d76225844cfed51e407b2f41cd3e311bf47 (patch)
tree8e8dccbd556c4fce1fba37cdf379538d61fe4922 /container-search/src/test/java/com/yahoo/search/searchchain
parent30b533c56ff0286aa3831889f46ba7c19e393ec0 (diff)
Convert container-search to junit5
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/searchchain')
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java51
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java42
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java53
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java39
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java38
9 files changed, 140 insertions, 157 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java
index f0be6a25f92..298bcc82d99 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionOfOneChainTestCase.java
@@ -7,7 +7,7 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.result.HitGroup;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Iterator;
@@ -17,7 +17,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -28,16 +28,16 @@ public class AsyncExecutionOfOneChainTestCase {
/** Tests having a result with some slow source data which should pass directly to rendering */
@Test
- public void testParallelExecutionOfOneChain() {
+ void testParallelExecutionOfOneChain() {
ExecutorService executor = Executors.newFixedThreadPool(16);
// Setup
- Chain<Searcher> mainChain=new Chain<>(new ParallelExecutor(executor),new ResultProcessor(),new RegularProvider());
+ Chain<Searcher> mainChain = new Chain<>(new ParallelExecutor(executor), new ResultProcessor(), new RegularProvider());
// Execute
- Result result=new Execution(mainChain, Execution.Context.createContextStub()).search(new Query());
+ Result result = new Execution(mainChain, Execution.Context.createContextStub()).search(new Query());
// Verify
- assertEquals("Received 2 hits from 3 threads",3*2,result.hits().size());
+ assertEquals(3 * 2, result.hits().size(), "Received 2 hits from 3 threads");
assertEquals(1.0, result.hits().get("thread-0:hit-0").getRelevance().getScore(), delta);
assertEquals(1.0, result.hits().get("thread-1:hit-0").getRelevance().getScore(), delta);
assertEquals(1.0, result.hits().get("thread-2:hit-0").getRelevance().getScore(), delta);
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java
index 8f23c7eef83..0e4d1350a03 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/AsyncExecutionTestCase.java
@@ -7,17 +7,14 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Test for aynchrounous execution
@@ -56,10 +53,10 @@ public class AsyncExecutionTestCase {
// This should take ~50+ ms
@Test
- public void testAsync() {
+ void testAsync() {
List<Searcher> searchList = new ArrayList<>();
- searchList.add(new WaitingSearcher("one",60000));
- searchList.add(new WaitingSearcher("two",0));
+ searchList.add(new WaitingSearcher("one", 60000));
+ searchList.add(new WaitingSearcher("two", 0));
Chain<Searcher> searchChain = new Chain<>(new ComponentId("chain"), searchList);
AsyncExecution asyncExecution = new AsyncExecution(searchChain, Execution.Context.createContextStub());
@@ -70,23 +67,23 @@ public class AsyncExecutionTestCase {
}
@Test
- public void testWaitForAll() {
+ void testWaitForAll() {
Chain<Searcher> slowChain = new Chain<>(
new ComponentId("slow"),
- Arrays.asList(new Searcher[]{new WaitingSearcher("slow",30000)}
+ Arrays.asList(new Searcher[]{new WaitingSearcher("slow", 30000)}
)
);
Chain<Searcher> fastChain = new Chain<>(
new ComponentId("fast"),
Arrays.asList(new Searcher[]{new SimpleSearcher()})
- );
+ );
FutureResult slowFuture = new AsyncExecution(slowChain, Execution.Context.createContextStub()).search(new Query("?hits=0"));
FutureResult fastFuture = new AsyncExecution(fastChain, Execution.Context.createContextStub()).search(new Query("?hits=0"));
fastFuture.get();
- FutureResult [] reslist = new FutureResult[]{slowFuture,fastFuture};
- List<Result> results = AsyncExecution.waitForAll(Arrays.asList(reslist),0);
+ FutureResult [] reslist = new FutureResult[]{slowFuture, fastFuture};
+ List<Result> results = AsyncExecution.waitForAll(Arrays.asList(reslist), 0);
//assertTrue(slowFuture.isCancelled());
assertTrue(fastFuture.isDone() && !fastFuture.isCancelled());
@@ -96,27 +93,27 @@ public class AsyncExecutionTestCase {
}
@Test
- public void testSync() {
- Query query=new Query("?query=test");
- Searcher searcher=new ResultProducingSearcher();
- Result result=new Execution(searcher, Execution.Context.createContextStub()).search(query);
+ void testSync() {
+ Query query = new Query("?query=test");
+ Searcher searcher = new ResultProducingSearcher();
+ Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
- assertEquals(1,result.hits().size());
- assertEquals("hello",result.hits().get(0).getField("test"));
+ assertEquals(1, result.hits().size());
+ assertEquals("hello", result.hits().get(0).getField("test"));
}
@Test
- public void testSyncThroughSync() {
- Query query=new Query("?query=test");
- Searcher searcher=new ResultProducingSearcher();
- Result result=new Execution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
+ void testSyncThroughSync() {
+ Query query = new Query("?query=test");
+ Searcher searcher = new ResultProducingSearcher();
+ Result result = new Execution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
- assertEquals(1,result.hits().size());
- assertEquals("hello",result.hits().get(0).getField("test"));
+ assertEquals(1, result.hits().size());
+ assertEquals("hello", result.hits().get(0).getField("test"));
}
@Test
- public void testAsyncThroughSync() {
+ void testAsyncThroughSync() {
Query query = new Query("?query=test");
Searcher searcher = new ResultProducingSearcher();
FutureResult futureResult = new AsyncExecution(new Execution(searcher, Execution.Context.createContextStub())).search(query);
@@ -144,7 +141,7 @@ public class AsyncExecutionTestCase {
}
@Test
- public void testAsyncExecutionTimeout() {
+ void testAsyncExecutionTimeout() {
Chain<Searcher> chain = new Chain<>(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java b/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java
index 341e55df777..e25a946c18b 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/VespaAsyncSearcherTest.java
@@ -5,16 +5,16 @@ import com.yahoo.component.chain.Chain;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests async execution of search chains.
@@ -26,12 +26,12 @@ public class VespaAsyncSearcherTest {
private ExecutorService executor;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
executor = Executors.newFixedThreadPool(16);
}
- @After
+ @AfterEach
public void tearDown() {
assertEquals(0, executor.shutdownNow().size());
}
@@ -69,7 +69,7 @@ public class VespaAsyncSearcherTest {
}
@Test
- public void testAsyncExecution() {
+ void testAsyncExecution() {
Chain<Searcher> chain = new Chain<>(new FirstSearcher(), new SecondSearcher());
Execution execution = new Execution(chain, Execution.Context.createContextStub());
Query query = new Query();
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java
index 553a9233bf1..614d481cf77 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/DependencyConfigTestCase.java
@@ -6,6 +6,8 @@ import java.io.IOException;
import java.util.Arrays;
import com.yahoo.component.chain.dependencies.After;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.yahoo.component.chain.dependencies.Before;
import com.yahoo.component.chain.dependencies.Dependencies;
import com.yahoo.component.chain.dependencies.Provides;
@@ -17,11 +19,9 @@ import com.yahoo.search.handler.SearchHandler;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
/**
* @author Tony Vaagenes
@@ -34,14 +34,14 @@ public class DependencyConfigTestCase {
public static final String root = "src/test/java/com/yahoo/search/searchchain/config/test/dependencyConfig";
- @BeforeClass
+ @BeforeAll
public static void createComponentsConfig() throws IOException {
SearchChainConfigurerTestCase.
createComponentsConfig(root + "/chains.cfg", root + "/handlers.cfg", root + "/components.cfg");
setUp();
}
- @AfterClass
+ @AfterAll
public static void removeComponentsConfig() {
new File(root + "/components.cfg").delete();
tearDown();
@@ -69,7 +69,7 @@ public class DependencyConfigTestCase {
}
@Test
- public void test() {
+ void test() {
Dependencies dependencies = registry.getSearcherRegistry().getComponent(Searcher1.class.getName()).getDependencies();
assertTrue(dependencies.provides().containsAll(Arrays.asList("P", "P1", "P2", Searcher1.class.getSimpleName())));
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java
index 781370d9e25..e851d221116 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/config/test/SearchChainConfigurerTestCase.java
@@ -14,9 +14,9 @@ import com.yahoo.search.searchchain.ExecutionFactory;
import com.yahoo.search.searchchain.SearchChain;
import com.yahoo.search.searchchain.SearchChainRegistry;
import com.yahoo.search.searchchain.SearcherRegistry;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.File;
@@ -36,13 +36,7 @@ import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -65,12 +59,12 @@ public class SearchChainConfigurerTestCase {
}
}
- @BeforeClass
+ @BeforeAll
public static void createDefaultComponentsConfigs() throws IOException {
createComponentsConfig(testDir + "chains.cfg", testDir + "handlers.cfg", testDir + "components.cfg");
}
- @AfterClass
+ @AfterAll
public static void removeDefaultComponentsConfigs() {
new File(testDir + "components.cfg").delete();
}
@@ -81,7 +75,7 @@ public class SearchChainConfigurerTestCase {
}
@Test
- public synchronized void testConfiguration() {
+ synchronized void testConfiguration() {
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir);
SearchChain simple = getSearchChainRegistryFrom(configurer).getComponent("simple");
@@ -130,7 +124,7 @@ public class SearchChainConfigurerTestCase {
public static final class DeclaredTestSearcher extends TestSearcher {}
@Test
- public void testConfigurableSearcher() {
+ void testConfigurableSearcher() {
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper("dir:" + testDir);
SearchChain configurable = getSearchChainRegistryFrom(configurer).getComponent("configurable");
@@ -138,9 +132,9 @@ public class SearchChainConfigurerTestCase {
Searcher s = configurable.searchers().get(0);
assertTrue(s instanceof ConfigurableSearcher);
- ConfigurableSearcher searcher = (ConfigurableSearcher)s;
- assertEquals("Value from int.cfg file", 7, searcher.intConfig.intVal());
- assertEquals("Value from string.cfg file", "com.yahoo.search.searchchain.config.test", searcher.stringConfig.stringVal());
+ ConfigurableSearcher searcher = (ConfigurableSearcher) s;
+ assertEquals(7, searcher.intConfig.intVal(), "Value from int.cfg file");
+ assertEquals("com.yahoo.search.searchchain.config.test", searcher.stringConfig.stringVal(), "Value from string.cfg file");
configurer.shutdown();
}
@@ -149,7 +143,7 @@ public class SearchChainConfigurerTestCase {
* that does not contain any bootstrap configs.
*/
@Test
- public void testSearcherConfigUpdate() throws IOException {
+ void testSearcherConfigUpdate() throws IOException {
File cfgDir = getCfgDir();
copyFile(testDir + "handlers.cfg", cfgDir + "/handlers.cfg");
copyFile(testDir + "qr-search.cfg", cfgDir + "/qr-search.cfg");
@@ -167,11 +161,11 @@ public class SearchChainConfigurerTestCase {
SearcherRegistry searchers = getSearchChainRegistryFrom(configurer).getSearcherRegistry();
assertEquals(3, searchers.getComponentCount());
- IntSearcher intSearcher = (IntSearcher)searchers.getComponent(IntSearcher.class.getName());
+ IntSearcher intSearcher = (IntSearcher) searchers.getComponent(IntSearcher.class.getName());
assertEquals(16, intSearcher.intConfig.intVal());
- StringSearcher stringSearcher = (StringSearcher)searchers.getComponent(StringSearcher.class.getName());
+ StringSearcher stringSearcher = (StringSearcher) searchers.getComponent(StringSearcher.class.getName());
DeclaredTestSearcher noConfigSearcher =
- (DeclaredTestSearcher)searchers.getComponent(DeclaredTestSearcher.class.getName());
+ (DeclaredTestSearcher) searchers.getComponent(DeclaredTestSearcher.class.getName());
// Update int config for IntSearcher,
printFile(new File(cfgDir + "/int.cfg"), "intVal 17\n");
@@ -183,7 +177,7 @@ public class SearchChainConfigurerTestCase {
assertEquals(3, searchers.getComponentCount());
// Searcher with updated config is re-instantiated.
- IntSearcher intSearcher2 = (IntSearcher)searchers.getComponent(IntSearcher.class.getName());
+ IntSearcher intSearcher2 = (IntSearcher) searchers.getComponent(IntSearcher.class.getName());
assertNotSame(intSearcher, intSearcher2);
assertEquals(17, intSearcher2.intConfig.intVal());
@@ -203,7 +197,7 @@ public class SearchChainConfigurerTestCase {
* and that a searcher that has been removed from the configuration is not in the new registry.
*/
@Test
- public void testChainsConfigUpdate() throws IOException {
+ void testChainsConfigUpdate() throws IOException {
File cfgDir = getCfgDir();
copyFile(testDir + "handlers.cfg", cfgDir + "/handlers.cfg");
copyFile(testDir + "qr-search.cfg", cfgDir + "/qr-search.cfg");
@@ -225,7 +219,7 @@ public class SearchChainConfigurerTestCase {
assertNull(searchers.getComponent(ConfigurableSearcher.class.getName()));
assertNull(searchers.getComponent(DeclaredTestSearcher.class.getName()));
- IntSearcher intSearcher = (IntSearcher)searchers.getComponent(IntSearcher.class.getName());
+ IntSearcher intSearcher = (IntSearcher) searchers.getComponent(IntSearcher.class.getName());
// Update chains config
copyFile(testDir + "chainsConfigUpdate_2.cfg", cfgDir + "/chains.cfg");
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java
index 129437a5429..bc535e4e214 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/ExecutionTestCase.java
@@ -17,14 +17,9 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests basic search chain execution functionality
@@ -34,31 +29,31 @@ import static org.junit.Assert.assertTrue;
public class ExecutionTestCase {
@Test
- public void testLinearExecutions() {
+ void testLinearExecutions() {
// Make a chain
- List<Searcher> searchers1=new ArrayList<>();
+ List<Searcher> searchers1 = new ArrayList<>();
searchers1.add(new TestSearcher("searcher1"));
searchers1.add(new TestSearcher("searcher2"));
searchers1.add(new TestSearcher("searcher3"));
searchers1.add(new TestSearcher("searcher4"));
- Chain<Searcher> chain1=new Chain<>(new ComponentId("chain1"), searchers1);
+ Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
// Make another chain containing two of the same searcher instances and two new
- List<Searcher> searchers2=new ArrayList<>(searchers1);
- searchers2.set(1,new TestSearcher("searcher5"));
- searchers2.set(3,new TestSearcher("searcher6"));
- Chain<Searcher> chain2=new Chain<>(new ComponentId("chain2"), searchers2);
+ List<Searcher> searchers2 = new ArrayList<>(searchers1);
+ searchers2.set(1, new TestSearcher("searcher5"));
+ searchers2.set(3, new TestSearcher("searcher6"));
+ Chain<Searcher> chain2 = new Chain<>(new ComponentId("chain2"), searchers2);
// Execute both
- Query query=new Query("test");
- Result result1=new Execution(chain1, Execution.Context.createContextStub()).search(query);
- Result result2=new Execution(chain2, Execution.Context.createContextStub()).search(query);
+ Query query = new Query("test");
+ Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
+ Result result2 = new Execution(chain2, Execution.Context.createContextStub()).search(query);
// Verify results
- assertEquals(4,result1.getConcreteHitCount());
+ assertEquals(4, result1.getConcreteHitCount());
assertNotNull(result1.hits().get("searcher1-1"));
assertNotNull(result1.hits().get("searcher2-1"));
assertNotNull(result1.hits().get("searcher3-1"));
assertNotNull(result1.hits().get("searcher4-1"));
- assertEquals(4,result2.getConcreteHitCount());
+ assertEquals(4, result2.getConcreteHitCount());
assertNotNull(result2.hits().get("searcher1-2"));
assertNotNull(result2.hits().get("searcher5-1"));
assertNotNull(result2.hits().get("searcher3-2"));
@@ -66,20 +61,20 @@ public class ExecutionTestCase {
}
@Test
- public void testNestedExecution() {
+ void testNestedExecution() {
// Make a chain
- List<Searcher> searchers1=new ArrayList<>();
+ List<Searcher> searchers1 = new ArrayList<>();
searchers1.add(new FillableTestSearcher("searcher1"));
searchers1.add(new WorkflowSearcher());
searchers1.add(new TestSearcher("searcher2"));
searchers1.add(new FillingSearcher());
searchers1.add(new FillableTestSearcherAtTheEnd("searcher3"));
- Chain<Searcher> chain1=new Chain<>(new ComponentId("chain1"), searchers1);
+ Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
// Execute it
- Query query=new Query("test");
- Result result1=new Execution(chain1, Execution.Context.createContextStub()).search(query);
+ Query query = new Query("test");
+ Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
// Verify results
- assertEquals(7,result1.getConcreteHitCount());
+ assertEquals(7, result1.getConcreteHitCount());
assertNotNull(result1.hits().get("searcher1-1"));
assertNotNull(result1.hits().get("searcher2-1"));
assertNotNull(result1.hits().get("searcher3-1"));
@@ -90,7 +85,7 @@ public class ExecutionTestCase {
}
@Test
- public void testContextCacheSingleLengthSearchChain() {
+ void testContextCacheSingleLengthSearchChain() {
IndexFacts[] contextsBefore = new IndexFacts[1];
IndexFacts[] contextsAfter = new IndexFacts[1];
List<Searcher> l = new ArrayList<>(1);
@@ -103,7 +98,7 @@ public class ExecutionTestCase {
}
@Test
- public void testContextCache() {
+ void testContextCache() {
IndexFacts[] contextsBefore = new IndexFacts[5];
IndexFacts[] contextsAfter = new IndexFacts[5];
List<Searcher> l = new ArrayList<>(5);
@@ -129,7 +124,7 @@ public class ExecutionTestCase {
}
@Test
- public void testContextCacheMoreSearchers() {
+ void testContextCacheMoreSearchers() {
IndexFacts[] contextsBefore = new IndexFacts[7];
IndexFacts[] contextsAfter = new IndexFacts[7];
List<Searcher> l = new ArrayList<>(7);
@@ -161,7 +156,7 @@ public class ExecutionTestCase {
}
@Test
- public void testBasicFill() {
+ void testBasicFill() {
Chain<Searcher> chain = new Chain<Searcher>(new FillableResultSearcher());
Execution execution = new Execution(chain, Execution.Context.createContextStub());
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java
index 15517270cb9..c78c0d75477 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java
@@ -14,16 +14,15 @@ import com.yahoo.search.result.HitGroup;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests using the async capabilities of the Processing parent framework of searchers.
@@ -33,16 +32,16 @@ import static org.junit.Assert.assertTrue;
public class FutureDataTestCase {
@Test
- public void testAsyncFederation() throws InterruptedException, ExecutionException {
+ void testAsyncFederation() throws InterruptedException, ExecutionException {
// Setup environment
AsyncProviderSearcher asyncProviderSearcher = new AsyncProviderSearcher();
Searcher syncProviderSearcher = new SyncProviderSearcher();
Chain<Searcher> asyncSource = new Chain<>(new ComponentId("async"), asyncProviderSearcher);
Chain<Searcher> syncSource = new Chain<>(new ComponentId("sync"), syncProviderSearcher);
- SearchChainResolver searchChainResolver=
+ SearchChainResolver searchChainResolver =
new SearchChainResolver.Builder().addSearchChain(new ComponentId("sync"), new FederationOptions().setUseByDefault(true)).
- addSearchChain(new ComponentId("async"), new FederationOptions().setUseByDefault(true)).
- build();
+ addSearchChain(new ComponentId("async"), new FederationOptions().setUseByDefault(true)).
+ build();
Chain<Searcher> main = new Chain<>(new FederationSearcher(new ComponentId("federator"), searchChainResolver));
SearchChainRegistry searchChainRegistry = new SearchChainRegistry();
searchChainRegistry.register(main);
@@ -54,32 +53,32 @@ public class FutureDataTestCase {
Result result = new Execution(main, Execution.Context.createContextStub(searchChainRegistry)).search(query);
assertNotNull(result);
- HitGroup syncGroup = (HitGroup)result.hits().get("source:sync");
+ HitGroup syncGroup = (HitGroup) result.hits().get("source:sync");
assertNotNull(syncGroup);
- HitGroup asyncGroup = (HitGroup)result.hits().get("source:async");
+ HitGroup asyncGroup = (HitGroup) result.hits().get("source:async");
assertNotNull(asyncGroup);
- assertEquals("Got all sync data", 3, syncGroup.size());
+ assertEquals(3, syncGroup.size(), "Got all sync data");
assertEquals("sync:0", syncGroup.get(0).getId().toString());
assertEquals("sync:1", syncGroup.get(1).getId().toString());
assertEquals("sync:2", syncGroup.get(2).getId().toString());
- assertTrue(asyncGroup.incoming()==asyncProviderSearcher.incomingData);
- assertEquals("Got no async data yet", 0, asyncGroup.size());
+ assertEquals(asyncGroup.incoming(), asyncProviderSearcher.incomingData);
+ assertEquals(0, asyncGroup.size(), "Got no async data yet");
asyncProviderSearcher.simulateOneHitIOComplete(new Hit("async:0"));
- assertEquals("Got no async data yet, as we haven't completed the incoming buffer and there is no data listener", 0, asyncGroup.size());
+ assertEquals(0, asyncGroup.size(), "Got no async data yet, as we haven't completed the incoming buffer and there is no data listener");
asyncProviderSearcher.simulateOneHitIOComplete(new Hit("async:1"));
asyncProviderSearcher.simulateAllHitsIOComplete();
- assertEquals("Got no async data yet, as we haven't pulled it", 0, asyncGroup.size());
+ assertEquals(0, asyncGroup.size(), "Got no async data yet, as we haven't pulled it");
asyncGroup.completeFuture().get();
- assertEquals("Completed, so we have the data", 2, asyncGroup.size());
+ assertEquals(2, asyncGroup.size(), "Completed, so we have the data");
assertEquals("async:0", asyncGroup.get(0).getId().toString());
assertEquals("async:1", asyncGroup.get(1).getId().toString());
}
@Test
- public void testFutureData() throws InterruptedException, ExecutionException, TimeoutException {
+ void testFutureData() throws InterruptedException, ExecutionException, TimeoutException {
// Set up
AsyncProviderSearcher futureDataSource = new AsyncProviderSearcher();
Chain<Searcher> chain = new Chain<>(Collections.<Searcher>singletonList(futureDataSource));
@@ -89,16 +88,14 @@ public class FutureDataTestCase {
Result result = new Execution(chain, Execution.Context.createContextStub()).search(query);
// Verify the result prior to completion of delayed data
- assertEquals("The result has been returned, but no hits are available yet",
- 0, result.hits().getConcreteSize());
+ assertEquals(0, result.hits().getConcreteSize(), "The result has been returned, but no hits are available yet");
// pretend we're the IO layer and complete delayed data - this is typically done in a callback from jDisc
futureDataSource.simulateOneHitIOComplete(new Hit("hit:0"));
futureDataSource.simulateOneHitIOComplete(new Hit("hit:1"));
futureDataSource.simulateAllHitsIOComplete();
- assertEquals("Async arriving hits are still not visible because we haven't asked for them",
- 0, result.hits().getConcreteSize());
+ assertEquals(0, result.hits().getConcreteSize(), "Async arriving hits are still not visible because we haven't asked for them");
// Results with future hit groups will be passed to rendering directly and start rendering immediately.
// For this test we block and wait for the data instead:
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java
index d7fd73a81e6..3e7a152122e 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/SearchChainTestCase.java
@@ -2,7 +2,7 @@
package com.yahoo.search.searchchain.test;
import static com.yahoo.search.searchchain.test.SimpleSearchChain.searchChain;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
@@ -19,7 +19,7 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChain;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests basic search chain functionality - creation, inheritance and ordering
@@ -30,17 +30,17 @@ import org.junit.Test;
public class SearchChainTestCase {
@Test
- public void testEmptySearchChain() {
+ void testEmptySearchChain() {
SearchChain empty = new SearchChain(new ComponentId("empty"));
assertEquals("empty", empty.getId().getName());
}
@Test
- public void testSearchChainCreation() {
- assertEquals("test",searchChain.getId().stringValue());
- assertEquals("test",searchChain.getId().getName());
+ void testSearchChainCreation() {
+ assertEquals("test", searchChain.getId().stringValue());
+ assertEquals("test", searchChain.getId().getName());
assertEquals(Version.emptyVersion, searchChain.getId().getVersion());
- assertEquals(new Version(),searchChain.getId().getVersion());
+ assertEquals(new Version(), searchChain.getId().getVersion());
assertEqualMembers(Arrays.asList("one", "two"), searcherNames(searchChain.searchers()));
}
@@ -60,28 +60,28 @@ public class SearchChainTestCase {
}
@Test
- public void testSearchChainToStringEmpty() {
+ void testSearchChainToStringEmpty() {
assertEquals("chain 'test' []", new Chain<>(new ComponentId("test"), createSearchers(0)).toString());
}
@Test
- public void testSearchChainToStringVeryShort() {
- assertEquals("chain 'test' [s1]", new Chain<>(new ComponentId("test"),createSearchers(1)).toString());
+ void testSearchChainToStringVeryShort() {
+ assertEquals("chain 'test' [s1]", new Chain<>(new ComponentId("test"), createSearchers(1)).toString());
}
@Test
- public void testSearchChainToStringShort() {
- assertEquals("chain 'test' [s1 -> s2 -> s3]", new Chain<>(new ComponentId("test"),createSearchers(3)).toString());
+ void testSearchChainToStringShort() {
+ assertEquals("chain 'test' [s1 -> s2 -> s3]", new Chain<>(new ComponentId("test"), createSearchers(3)).toString());
}
@Test
- public void testSearchChainToStringLong() {
- assertEquals("chain 'test' [s1 -> s2 -> ... -> s4]", new Chain<>(new ComponentId("test"),createSearchers(4)).toString());
+ void testSearchChainToStringLong() {
+ assertEquals("chain 'test' [s1 -> s2 -> ... -> s4]", new Chain<>(new ComponentId("test"), createSearchers(4)).toString());
}
@Test
- public void testSearchChainToStringVeryLong() {
- assertEquals("chain 'test' [s1 -> s2 -> ... -> s10]", new Chain<>(new ComponentId("test"),createSearchers(10)).toString());
+ void testSearchChainToStringVeryLong() {
+ assertEquals("chain 'test' [s1 -> s2 -> ... -> s10]", new Chain<>(new ComponentId("test"), createSearchers(10)).toString());
}
private List<Searcher> createSearchers(int count) {
diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java
index 04b1fd85872..f2c8551126b 100644
--- a/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/TraceTestCase.java
@@ -10,7 +10,7 @@ import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.yolean.trace.TraceNode;
import com.yahoo.yolean.trace.TraceVisitor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
@@ -19,8 +19,8 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Tests tracing scenarios where traces from multiple executions over the same query are involved.
@@ -30,27 +30,27 @@ import static org.junit.Assert.assertFalse;
public class TraceTestCase {
@Test
- public void testTracingOnCorrectAPIUseNonParallel() {
- assertTracing(true,false);
+ void testTracingOnCorrectAPIUseNonParallel() {
+ assertTracing(true, false);
}
@Test
- public void testTracingOnIncorrectAPIUseNonParallel() {
- assertTracing(false,false);
+ void testTracingOnIncorrectAPIUseNonParallel() {
+ assertTracing(false, false);
}
@Test
- public void testTracingOnCorrectAPIUseParallel() {
+ void testTracingOnCorrectAPIUseParallel() {
assertTracing(true, true);
}
@Test
- public void testTracingOnIncorrectAPIUseParallel() {
- assertTracing(false,true);
+ void testTracingOnIncorrectAPIUseParallel() {
+ assertTracing(false, true);
}
@Test
- public void testTraceWithQuery() {
+ void testTraceWithQuery() {
testQueryInTrace(true, "trace.query=true");
testQueryInTrace(false, "trace.query=false");
testQueryInTrace(true, "");
@@ -71,13 +71,13 @@ public class TraceTestCase {
assertEquals(" During tracer1: 0", trace.next());
}
- @Test
- public void testTraceInvocationsUnfillableHits() {
+ @Test
+ void testTraceInvocationsUnfillableHits() {
final int traceLevel = 5;
Query query = new Query("?trace.level=" + traceLevel);
- Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"),
- new Tracer("tracer2"),
- new Backend("backend1", false));
+ Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"),
+ new Tracer("tracer2"),
+ new Backend("backend1", false));
Execution execution = new Execution(forkingChain, Execution.Context.createContextStub());
Result result = execution.search(query);
execution.fill(result, "mySummary");
@@ -104,12 +104,12 @@ public class TraceTestCase {
}
@Test
- public void testTraceInvocationsFillableHits() {
+ void testTraceInvocationsFillableHits() {
final int traceLevel = 5;
Query query = new Query("?tracelevel=" + traceLevel);
Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"),
- new Tracer("tracer2"),
- new Backend("backend1", true));
+ new Tracer("tracer2"),
+ new Backend("backend1", true));
Execution execution = new Execution(forkingChain, Execution.Context.createContextStub());
Result result = execution.search(query);
execution.fill(result, "mySummary");