[TEST] add setHosts test and rename RestClientBuilderTests to RestClientTests

This commit is contained in:
javanna 2016-06-02 11:30:09 +02:00 committed by Luca Cavanna
parent 35dbdeeae5
commit 47e52044e4
1 changed files with 30 additions and 1 deletions

View File

@ -31,7 +31,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
public class RestClientBuilderTests extends LuceneTestCase {
public class RestClientTests extends LuceneTestCase {
public void testBuild() throws IOException {
try {
@ -105,4 +105,33 @@ public class RestClientBuilderTests extends LuceneTestCase {
assertNotNull(restClient);
}
}
public void testSetNodes() throws IOException {
try (RestClient restClient = RestClient.builder().setHosts(new HttpHost("localhost", 9200)).build()) {
try {
restClient.setHosts((HttpHost[]) null);
fail("setHosts should have failed");
} catch (IllegalArgumentException e) {
assertEquals("hosts must not be null nor empty", e.getMessage());
}
try {
restClient.setHosts();
fail("setHosts should have failed");
} catch (IllegalArgumentException e) {
assertEquals("hosts must not be null nor empty", e.getMessage());
}
try {
restClient.setHosts((HttpHost) null);
fail("setHosts should have failed");
} catch (NullPointerException e) {
assertEquals("host cannot be null", e.getMessage());
}
try {
restClient.setHosts(new HttpHost("localhost", 9200), null, new HttpHost("localhost", 9201));
fail("setHosts should have failed");
} catch (NullPointerException e) {
assertEquals("host cannot be null", e.getMessage());
}
}
}
}