[TEST] add setHosts test and rename RestClientBuilderTests to RestClientTests
This commit is contained in:
parent
35dbdeeae5
commit
47e52044e4
|
@ -31,7 +31,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class RestClientBuilderTests extends LuceneTestCase {
|
public class RestClientTests extends LuceneTestCase {
|
||||||
|
|
||||||
public void testBuild() throws IOException {
|
public void testBuild() throws IOException {
|
||||||
try {
|
try {
|
||||||
|
@ -105,4 +105,33 @@ public class RestClientBuilderTests extends LuceneTestCase {
|
||||||
assertNotNull(restClient);
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue