Java源码示例:com.couchbase.client.core.config.ConfigurationException
示例1
@Test(expected = ConfigurationException.class)
public void shouldFailWithEmptySeedNodeList() {
CouchbaseCore core = new CouchbaseCore(ENV);
core.send(new SeedNodesRequest(Collections.<String>emptyList()));
OpenBucketRequest request = new OpenBucketRequest(TestProperties.bucket(), TestProperties.username(), TestProperties.password());
core.send(request).toBlocking().single();
}
示例2
@Test(expected = ConfigurationException.class)
public void shouldFailOpeningNonExistentBucket() {
CouchbaseCore core = new CouchbaseCore(ENV);
core.send(new SeedNodesRequest(Arrays.asList(TestProperties.seedNode())));
OpenBucketRequest request = new OpenBucketRequest(TestProperties.bucket() + "asd", TestProperties.password());
core.send(request).toBlocking().single();
}
示例3
@Test(expected = ConfigurationException.class)
public void shouldFailOpeningBucketWithWrongPassword() {
CouchbaseCore core = new CouchbaseCore(ENV);
core.send(new SeedNodesRequest(Arrays.asList(TestProperties.seedNode())));
OpenBucketRequest request = new OpenBucketRequest(TestProperties.bucket(), TestProperties.username(), TestProperties.password() + "asd");
core.send(request).toBlocking().single();
}
示例4
@Test(expected = ConfigurationException.class)
public void shouldFailOpeningWithWrongHost() {
CouchbaseCore core = new CouchbaseCore(ENV);
core.send(new SeedNodesRequest(Arrays.asList("certainlyInvalidHostname")));
OpenBucketRequest request = new OpenBucketRequest(TestProperties.bucket(), TestProperties.username(), TestProperties.password() + "asd");
core.send(request).toBlocking().single();
}
示例5
/**
* Creates a {@link SeedNodesRequest} with the given list of hostnames.
*
* @param nodes the seed node hostnames.
*/
public SeedNodesRequest(final List<String> nodes) {
super(null, null);
if (nodes == null || nodes.isEmpty()) {
throw new ConfigurationException("Empty or null bootstrap list provided.");
}
Set<String> parsedNodes = new HashSet<>();
for (String node : nodes) {
if (node == null || node.isEmpty()) {
LOGGER.info("Empty or null host in bootstrap list.");
continue;
}
try {
parsedNodes.add(node);
} catch (Exception e) {
LOGGER.info("Unknown host {} in bootstrap list.", system(node), e);
}
}
if (parsedNodes.isEmpty()) {
throw new ConfigurationException("No valid node found to bootstrap from. "
+ "Please check your network configuration.");
}
this.nodes = parsedNodes;
}
示例6
@Test(expected = ConfigurationException.class)
public void shouldFailWithNoSeedNodeList() {
OpenBucketRequest request = new OpenBucketRequest(TestProperties.bucket(), TestProperties.username(), TestProperties.password());
new CouchbaseCore(ENV).send(request).toBlocking().single();
}
示例7
@Test(expected = ConfigurationException.class)
public void shouldFailOnNullHostname() {
List<String> nodes = null;
new SeedNodesRequest(nodes);
}
示例8
@Test(expected = ConfigurationException.class)
public void shouldFailOnEmptyHostname() {
new SeedNodesRequest(new ArrayList<String>());
}