aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/cluster
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/cluster')
-rw-r--r--container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java114
2 files changed, 67 insertions, 67 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java
index bf44c57a777..33d86658f8e 100644
--- a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusterSearcherTestCase.java
@@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import com.yahoo.component.ComponentId;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.Ping;
import com.yahoo.prelude.Pong;
import com.yahoo.search.Query;
@@ -16,9 +18,7 @@ import com.yahoo.search.cluster.PingableSearcher;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
public class ClusterSearcherTestCase {
@@ -144,26 +144,26 @@ public class ClusterSearcherTestCase {
}
@Test
- public void testSimple() {
+ void testSimple() {
Hit blockingHit = new Hit("blocking");
Hit nonblockingHit = new Hit("nonblocking");
BlockingBackendSearcher blockingSearcher = new BlockingBackendSearcher(blockingHit);
- List<Searcher> searchers=new ArrayList<>();
+ List<Searcher> searchers = new ArrayList<>();
searchers.add(blockingSearcher);
searchers.add(new TestingBackendSearcher(nonblockingHit));
- ClusterSearcher<?> provider = new SearcherClusterSearcher(new ComponentId("simple"),searchers,new SimpleHasher<>());
+ ClusterSearcher<?> provider = new SearcherClusterSearcher(new ComponentId("simple"), searchers, new SimpleHasher<>());
Result blockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals(blockingHit,blockingResult.hits().get(0));
+ assertEquals(blockingHit, blockingResult.hits().get(0));
Result nonblockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals(nonblockingHit,nonblockingResult.hits().get(0));
+ assertEquals(nonblockingHit, nonblockingResult.hits().get(0));
blockingSearcher.setBlocking(true);
blockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals(blockingResult.hits().get(0),nonblockingHit);
+ assertEquals(blockingResult.hits().get(0), nonblockingHit);
nonblockingResult = new Execution(provider, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals(nonblockingResult.hits().get(0),nonblockingHit);
+ assertEquals(nonblockingResult.hits().get(0), nonblockingHit);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java
index fa8d237aee0..8c98b344394 100644
--- a/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/cluster/test/ClusteredConnectionTestCase.java
@@ -12,14 +12,14 @@ import com.yahoo.search.cluster.Hasher;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author bratseth
@@ -27,83 +27,83 @@ import static org.junit.Assert.assertNull;
public class ClusteredConnectionTestCase {
@Test
- public void testClustering() {
- Connection connection0=new Connection("0");
- Connection connection1=new Connection("1");
- Connection connection2=new Connection("2");
- List<Connection> connections=new ArrayList<>();
+ void testClustering() {
+ Connection connection0 = new Connection("0");
+ Connection connection1 = new Connection("1");
+ Connection connection2 = new Connection("2");
+ List<Connection> connections = new ArrayList<>();
connections.add(connection0);
connections.add(connection1);
connections.add(connection2);
MyBackend myBackend = new MyBackend(new ComponentId("test"), connections);
Result r;
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:2",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:1",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:2", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:1", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection2.setInService(false);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:1",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:1", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection1.setInService(false);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection0.setInService(false);
r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertEquals("Failed calling connection '2' in searcher 'test' for query 'NULL': Connection failed",
- r.hits().getError().getDetailedMessage());
+ r.hits().getError().getDetailedMessage());
connection0.setInService(true);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
connection1.setInService(true);
connection2.setInService(true);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
- assertEquals("from:2",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
- assertEquals("from:1",r.hits().get(0).getId().stringValue());
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
- assertEquals("from:0",r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(1));
+ assertEquals("from:2", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(2));
+ assertEquals("from:1", r.hits().get(0).getId().stringValue());
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(3));
+ assertEquals("from:0", r.hits().get(0).getId().stringValue());
}
@Test
- public void testClusteringWithPing() {
- Connection connection0=new Connection("0");
- Connection connection1=new Connection("1");
- Connection connection2=new Connection("2");
- List<Connection> connections=new ArrayList<>();
+ void testClusteringWithPing() {
+ Connection connection0 = new Connection("0");
+ Connection connection1 = new Connection("1");
+ Connection connection2 = new Connection("2");
+ List<Connection> connections = new ArrayList<>();
connections.add(connection0);
connections.add(connection1);
connections.add(connection2);
- MyBackend myBackend=new MyBackend(new ComponentId("test"),connections);
+ MyBackend myBackend = new MyBackend(new ComponentId("test"), connections);
Result r;
@@ -114,14 +114,14 @@ public class ClusteredConnectionTestCase {
connection1.setInService(false);
connection0.setInService(false);
forcePing(myBackend);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertEquals("No backends in service. Try later", r.hits().getError().getMessage());
connection2.setInService(true);
connection1.setInService(true);
connection0.setInService(true);
forcePing(myBackend);
- r=new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
+ r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertNull(r.hits().getError());
}