Adapt server not running check

The upgrade to the Couchbase SDK v3 changed how errors are reported
when the cluster is not available. This commit updates the check to
look for the new exception in the hope a more solid check can be found
shortly.
This commit is contained in:
Stephane Nicoll 2020-03-17 17:55:57 +01:00
parent 58eb0ba4d3
commit 988d650304

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -15,8 +15,7 @@
*/
package smoketest.data.couchbase;
import java.net.ConnectException;
import com.couchbase.client.core.error.FeatureNotAvailableException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -47,9 +46,10 @@ class SampleCouchbaseApplicationTests {
@SuppressWarnings("serial")
NestedCheckedException nested = new NestedCheckedException("failed", ex) {
};
if (nested.contains(ConnectException.class)) {
if (nested.contains(FeatureNotAvailableException.class)) {
Throwable root = nested.getRootCause();
if (root.getMessage().contains("Connection refused")) {
// This is not ideal, we should have a better way to know what is going on
if (root.getMessage().contains("The cluster does not support cluster-level queries")) {
return true;
}
}