下面列出了怎么用org.elasticsearch.common.settings.SettingsException的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Validates a given blobs data path
*/
public void validateBlobsPath(File blobsPath) {
if (blobsPath.exists()) {
if (blobsPath.isFile()) {
throw new SettingsException(
String.format(Locale.ENGLISH, "blobs path '%s' is a file, must be a directory", blobsPath.getAbsolutePath()));
}
if (!blobsPath.canWrite()) {
throw new SettingsException(
String.format(Locale.ENGLISH, "blobs path '%s' is not writable", blobsPath.getAbsolutePath()));
}
} else {
try {
Files.createDirectories(blobsPath.toPath());
} catch (IOException e) {
throw new SettingsException(
String.format(Locale.ENGLISH, "blobs path '%s' could not be created", blobsPath.getAbsolutePath()));
}
}
}
/**
* Try to extract and parse value from settings for given key.
* First it tries to parse it as a RatioValue (pct) then as byte size value.
* It assigns parsed value to corresponding argument references (passed via array hack).
* If parsing fails the method fires exception, however, this should not happen - we rely on Elasticsearch
* to already have parsed and validated these values before. Unless we screwed something up...
*/
private void parseValue(Settings s, String key, Long[] bytesPointer, Double[] pctPointer) {
String value = s.get(key);
if (value != null && pctPointer[0] == null) {
try {
pctPointer[0] = RatioValue.parseRatioValue(s.get(key, null)).getAsPercent();
} catch (SettingsException | ElasticsearchParseException | NullPointerException e1) {
if (bytesPointer[0] == null) {
try {
bytesPointer[0] = s.getAsBytesSize(key, null).getBytes();
} catch (SettingsException | ElasticsearchParseException | NullPointerException e2) {
// TODO(lvlcek): log.debug("This went wrong, but 'Keep Calm and Carry On'")
// We should avoid using logs in this class (due to perf impact), instead we should
// consider moving this logic to some static helper class/method going forward.
}
}
}
}
}
/**
* EsType_getメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_getメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncGet()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy"));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncGet(Mockito.anyString(), Mockito.anyBoolean());
// メソッド呼び出し
DcGetResponse result = esTypeObject.get("dummyId", true);
assertNull(result);
}
/**
* EsType_updateメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_updateメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncIndex()が呼ばれた場合に、IndexMissingExceptionを投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy"));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncIndex(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class),
(OpType) Mockito.anyObject(), Mockito.anyLong());
// メソッド呼び出し
try {
esTypeObject.update("dummyId", null, 1);
fail("EsClientException should be thrown.");
} catch (EsClientException.EsIndexMissingException e) {
assertTrue(e.getCause() instanceof SettingsException);
assertTrue(e.getCause().getCause() instanceof IndexNotFoundException);
}
}
/**
* EsType_searchメソッドで初回にIndexNotFoundExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_searchメソッドで初回にIndexNotFoundExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncSearch()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy"));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncSearch(Mockito.anyMapOf(String.class, Object.class));
// メソッド呼び出し
DcSearchResponse result = esTypeObject.search(null);
assertTrue(result.isNullResponse());
}
/**
* EsType_deleteメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_deleteメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncDelete()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy"));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncDelete(Mockito.anyString(), Mockito.anyLong());
// メソッド呼び出し
try {
esTypeObject.delete("dummyId", 1);
fail("EsClientException should be thrown.");
} catch (EsClientException.EsIndexMissingException e) {
assertTrue(e.getCause() instanceof SettingsException);
assertTrue(e.getCause().getCause() instanceof IndexNotFoundException);
}
}
/**
* EsType_putMappingメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_putMappingメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncPutMapping()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy"));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncPutMapping(Mockito.anyMapOf(String.class, Object.class));
// メソッド呼び出し
try {
esTypeObject.putMapping(null);
fail("EsClientException should be thrown.");
} catch (EsClientException.EsIndexMissingException e) {
assertTrue(e.getCause() instanceof SettingsException);
assertTrue(e.getCause().getCause() instanceof IndexNotFoundException);
}
}
/**
* EsIndex_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsIndex_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsIndexImpl esIndexObject = Mockito.spy(new EsIndexImpl("dummy", "", 0, 0, null));
// EsIndex#asyncIndexSearch()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexNotFoundException("dummy"));
Mockito.doThrow(toBeThrown)
.when(esIndexObject)
.asyncIndexSearch(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class));
// メソッド呼び出し
DcSearchResponse result = esIndexObject.search("dummyRoutingId", (Map<String, Object>) null);
assertNull(result);
}
/**
* 初回リクエストの特定例外処理からContinueRetryが投げられた後、リトライ処理に移行すること.
*/
@Test
public void 初回リクエストの特定例外処理からContinueRetryが投げられた後_リトライ処理に移行すること() {
TestRequest requestMock = Mockito.spy(new TestRequest());
NodeDisconnectedException toBeThrown = Mockito.mock(NodeDisconnectedException.class);
Mockito.doThrow(new SettingsException("foo")) // 初回リクエスト
.doThrow(toBeThrown) // リトライ1回目
.doReturn(SUCCESS_RESPONSE)
.when(requestMock)
.doProcess();
String result = requestMock.doRequest();
assertEquals(SUCCESS_RESPONSE, result);
Mockito.verify(requestMock, Mockito.times(3)).doProcess();
Mockito.verify(requestMock, Mockito.times(1)).onParticularError(Mockito.any(ElasticsearchException.class));
}
/**
* リトライ処理中の特定例外処理からContinueRetryが投げられた後、リトライ処理に移行すること.
*/
@Test
public void リトライ処理中の特定例外処理からContinueRetryが投げられた後_リトライ処理に移行すること() {
TestRequest requestMock = Mockito.spy(new TestRequest());
NodeDisconnectedException toBeThrown = Mockito.mock(NodeDisconnectedException.class);
Mockito.doThrow(toBeThrown) // 初回リクエスト
.doThrow(toBeThrown) // リトライ1回目
.doThrow(new SettingsException("foo")) // リトライ2回目. この時は、 #onParticularError()でリトライ継続のために
// ContinueRetryが投げられる.
.doThrow(toBeThrown) // リトライ3回目
.doReturn(SUCCESS_RESPONSE)
.when(requestMock)
.doProcess();
String result = requestMock.doRequest();
assertEquals(SUCCESS_RESPONSE, result);
// 初回 + リトライ3回 + 処理成功で、5回呼ばれるはず.
Mockito.verify(requestMock, Mockito.times(5)).doProcess();
Mockito.verify(requestMock, Mockito.times(1)).onParticularError(Mockito.any(ElasticsearchException.class));
}
/**
* EsType_getメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_getメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncGet()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexMissingException(new Index("dummy")));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncGet(Mockito.anyString(), Mockito.anyBoolean());
// メソッド呼び出し
DcGetResponse result = esTypeObject.get("dummyId", true);
assertNull(result);
}
/**
* EsType_updateメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_updateメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncIndex()が呼ばれた場合に、IndexMissingExceptionを投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexMissingException(new Index("dummy")));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncIndex(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class),
(OpType) Mockito.anyObject(), Mockito.anyLong());
// メソッド呼び出し
try {
esTypeObject.update("dummyId", null, 1);
fail("EsClientException should be thrown.");
} catch (EsClientException.EsIndexMissingException e) {
assertTrue(e.getCause() instanceof SettingsException);
assertTrue(e.getCause().getCause() instanceof IndexMissingException);
}
}
/**
* EsType_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncSearch()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexMissingException(new Index("dummy")));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncSearch(Mockito.anyMapOf(String.class, Object.class));
// メソッド呼び出し
DcSearchResponse result = esTypeObject.search(null);
assertTrue(result.isNullResponse());
}
/**
* EsType_deleteメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_deleteメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncDelete()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexMissingException(new Index("dummy")));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncDelete(Mockito.anyString(), Mockito.anyLong());
// メソッド呼び出し
try {
esTypeObject.delete("dummyId", 1);
fail("EsClientException should be thrown.");
} catch (EsClientException.EsIndexMissingException e) {
assertTrue(e.getCause() instanceof SettingsException);
assertTrue(e.getCause().getCause() instanceof IndexMissingException);
}
}
/**
* EsType_putMappingメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsType_putMappingメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsTypeImpl esTypeObject = Mockito.spy(new EsTypeImpl("dummy", "Test", "TestRoutingId", 0, 0, null));
// EsType#asyncPutMapping()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexMissingException(new Index("dummy")));
Mockito.doThrow(toBeThrown)
.when(esTypeObject)
.asyncPutMapping(Mockito.anyMapOf(String.class, Object.class));
// メソッド呼び出し
try {
esTypeObject.putMapping(null);
fail("EsClientException should be thrown.");
} catch (EsClientException.EsIndexMissingException e) {
assertTrue(e.getCause() instanceof SettingsException);
assertTrue(e.getCause().getCause() instanceof IndexMissingException);
}
}
/**
* EsIndex_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト.
*/
@Test
public void EsIndex_searchメソッドで初回にIndexMissingExceptionを根本原因に持つ例外が投げられた場合のテスト() {
PowerMockito.mockStatic(EsClientException.class);
EsIndexImpl esIndexObject = Mockito.spy(new EsIndexImpl("dummy", "", 0, 0, null));
// EsIndex#asyncIndexSearch()が呼ばれた場合に、IndexMissingExceptionを根本原因に持つ例外を投げる。
// 送出する例外オブジェクトを作成
SettingsException toBeThrown = new SettingsException("foo", new IndexMissingException(new Index("dummy")));
Mockito.doThrow(toBeThrown)
.when(esIndexObject)
.asyncIndexSearch(Mockito.anyString(), Mockito.anyMapOf(String.class, Object.class));
// メソッド呼び出し
DcSearchResponse result = esIndexObject.search("dummyRoutingId", (Map<String, Object>) null);
assertNull(result);
}
/**
* 初回リクエストの特定例外処理からContinueRetryが投げられた後、リトライ処理に移行すること.
*/
@Test
public void 初回リクエストの特定例外処理からContinueRetryが投げられた後_リトライ処理に移行すること() {
TestRequest requestMock = Mockito.spy(new TestRequest());
NodeDisconnectedException toBeThrown = Mockito.mock(NodeDisconnectedException.class);
Mockito.doThrow(new SettingsException("foo")) // 初回リクエスト
.doThrow(toBeThrown) // リトライ1回目
.doReturn(SUCCESS_RESPONSE)
.when(requestMock)
.doProcess();
String result = requestMock.doRequest();
assertEquals(SUCCESS_RESPONSE, result);
Mockito.verify(requestMock, Mockito.times(3)).doProcess();
Mockito.verify(requestMock, Mockito.times(1)).onParticularError(Mockito.any(ElasticsearchException.class));
}
/**
* リトライ処理中の特定例外処理からContinueRetryが投げられた後、リトライ処理に移行すること.
*/
@Test
public void リトライ処理中の特定例外処理からContinueRetryが投げられた後_リトライ処理に移行すること() {
TestRequest requestMock = Mockito.spy(new TestRequest());
NodeDisconnectedException toBeThrown = Mockito.mock(NodeDisconnectedException.class);
Mockito.doThrow(toBeThrown) // 初回リクエスト
.doThrow(toBeThrown) // リトライ1回目
.doThrow(new SettingsException("foo")) // リトライ2回目. この時は、 #onParticularError()でリトライ継続のために
// ContinueRetryが投げられる.
.doThrow(toBeThrown) // リトライ3回目
.doReturn(SUCCESS_RESPONSE)
.when(requestMock)
.doProcess();
String result = requestMock.doRequest();
assertEquals(SUCCESS_RESPONSE, result);
// 初回 + リトライ3回 + 処理成功で、5回呼ばれるはず.
Mockito.verify(requestMock, Mockito.times(5)).doProcess();
Mockito.verify(requestMock, Mockito.times(1)).onParticularError(Mockito.any(ElasticsearchException.class));
}
static boolean ensureExistsAndWritable(Path blobsPath) {
if (Files.exists(blobsPath)) {
if (!Files.isDirectory(blobsPath)) {
throw new SettingsException(
String.format(Locale.ENGLISH, "blobs path '%s' is a file, must be a directory", blobsPath));
}
if (!Files.isWritable(blobsPath)) {
throw new SettingsException(
String.format(Locale.ENGLISH, "blobs path '%s' is not writable", blobsPath));
}
} else {
try {
Files.createDirectories(blobsPath);
} catch (IOException e) {
throw new SettingsException(
String.format(Locale.ENGLISH, "blobs path '%s' could not be created", blobsPath));
}
}
return true;
}
static void loadConfig(Path file, Settings.Builder settingsBuilder) {
try {
settingsBuilder.loadFromPath(file);
} catch (SettingsException | NoClassDefFoundError e) {
// ignore
}
}
/**
* A thread pool size can also be unbounded and is represented by -1, which is not supported by SizeValue (which only supports positive numbers)
*/
private SizeValue getAsSizeOrUnbounded(Settings settings, String setting, SizeValue defaultValue) throws SettingsException {
if ("-1".equals(settings.get(setting))) {
return null;
}
return parseSizeValue(settings.get(setting), defaultValue);
}
@Override
public String onParticularError(ElasticsearchException e) {
if (e instanceof EsExceptionForTest) {
return ON_ERROR_RESPONSE;
}
if (e instanceof SettingsException) {
throw new ContinueRetry();
}
throw e;
}
@Override
public String onParticularError(ElasticsearchException e) {
if (e instanceof EsExceptionForTest) {
return ON_ERROR_RESPONSE;
}
if (e instanceof SettingsException) {
throw new ContinueRetry();
}
throw e;
}
static Netty4CorsConfig buildCorsConfig(Settings settings) {
if (SETTING_CORS_ENABLED.get(settings) == false) {
return Netty4CorsConfigBuilder.forOrigins().disable().build();
}
String origin = SETTING_CORS_ALLOW_ORIGIN.get(settings);
final Netty4CorsConfigBuilder builder;
if (Strings.isNullOrEmpty(origin)) {
builder = Netty4CorsConfigBuilder.forOrigins();
} else if (origin.equals(ANY_ORIGIN)) {
builder = Netty4CorsConfigBuilder.forAnyOrigin();
} else {
try {
Pattern p = RestUtils.checkCorsSettingForRegex(origin);
if (p == null) {
builder = Netty4CorsConfigBuilder.forOrigins(RestUtils.corsSettingAsArray(origin));
} else {
builder = Netty4CorsConfigBuilder.forPattern(p);
}
} catch (PatternSyntaxException e) {
throw new SettingsException("Bad regex in [" + SETTING_CORS_ALLOW_ORIGIN.getKey() + "]: [" + origin + "]", e);
}
}
if (SETTING_CORS_ALLOW_CREDENTIALS.get(settings)) {
builder.allowCredentials();
}
String[] strMethods = Strings.tokenizeToStringArray(SETTING_CORS_ALLOW_METHODS.get(settings), ",");
HttpMethod[] methods = Arrays.stream(strMethods)
.map(HttpMethod::valueOf)
.toArray(HttpMethod[]::new);
return builder.allowedRequestMethods(methods)
.maxAge(SETTING_CORS_MAX_AGE.get(settings))
.allowedRequestHeaders(Strings.tokenizeToStringArray(SETTING_CORS_ALLOW_HEADERS.get(settings), ","))
.shortCircuit()
.build();
}
private static void applyDistanceErrorPct(Map<String, Object> mapping, Settings geoSettings) {
try {
Float errorPct = geoSettings.getAsFloat("distance_error_pct", null);
if (errorPct != null) {
mapping.put("distance_error_pct", errorPct);
}
} catch (SettingsException e) {
throw new IllegalArgumentException(
String.format(Locale.ENGLISH, "Value '%s' of setting distance_error_pct is not a float value", geoSettings.get("distance_error_pct"))
);
}
}
@Test
public void testErrorWithDuplicateSettingInConfigFile() throws Exception {
HashMap<String, String> settings = new HashMap<>();
settings.put("path.home", ".");
Path config = PathUtils.get(getClass().getResource("config_invalid").toURI());
settings.put("path.conf", config.toString());
expectedException.expect(SettingsException.class);
expectedException.expectMessage("Failed to load settings from");
expectedException.expectCause(Matchers.hasProperty("message", containsString("Duplicate field 'stats.enabled'")));
InternalSettingsPreparer.prepareEnvironment(Settings.EMPTY, settings, config, () -> "node1");
}
public void testProxyNoHost() {
final Settings settings = Settings.builder()
.put(buildClientCredSettings())
.put("proxy_port", 8080)
.put("proxy_type", randomFrom("socks", "http"))
.build();
final SettingsException e = expectThrows(SettingsException.class, () -> storageServiceWithSettings(settings));
assertEquals("Azure Proxy type has been set but proxy host or port is not defined.", e.getMessage());
}
public void testProxyNoPort() {
final Settings settings = Settings.builder()
.put(buildClientCredSettings())
.put("proxy_host", "127.0.0.1")
.put("proxy_type", randomFrom("socks", "http"))
.build();
final SettingsException e = expectThrows(SettingsException.class, () -> storageServiceWithSettings(settings));
assertEquals("Azure Proxy type has been set but proxy host or port is not defined.", e.getMessage());
}
public void testProxyNoType() {
final Settings settings = Settings.builder()
.put(buildClientCredSettings())
.put("proxy_host", "127.0.0.1")
.put("proxy_port", 8080)
.build();
final SettingsException e = expectThrows(SettingsException.class, () -> storageServiceWithSettings(settings));
assertEquals("Azure Proxy port or host have been set but proxy type is not defined.", e.getMessage());
}
public void testProxyWrongHost() {
final Settings settings = Settings.builder()
.put(buildClientCredSettings())
.put("proxy_type", randomFrom("socks", "http"))
.put("proxy_host", "thisisnotavalidhostorwehavebeensuperunlucky")
.put("proxy_port", 8080)
.build();
final SettingsException e = expectThrows(SettingsException.class,
() -> storageServiceWithSettings(settings));
assertEquals("Azure proxy host is unknown.", e.getMessage());
}