use of org.mockito.ArgumentMatchers.anyString in project ExoPlayer by google.
the class CronetDataSourceTest method requestHeadersSet.
@Test
public void requestHeadersSet() throws HttpDataSourceException {
Map<String, String> headersSet = new HashMap<>();
doAnswer((invocation) -> {
String key = invocation.getArgument(0);
String value = invocation.getArgument(1);
headersSet.put(key, value);
return null;
}).when(mockUrlRequestBuilder).addHeader(ArgumentMatchers.anyString(), ArgumentMatchers.anyString());
dataSourceUnderTest.setRequestProperty("defaultHeader2", "dataSourceOverridesDefault");
dataSourceUnderTest.setRequestProperty("dataSourceHeader1", "dataSourceValue1");
dataSourceUnderTest.setRequestProperty("dataSourceHeader2", "dataSourceValue2");
Map<String, String> dataSpecRequestProperties = new HashMap<>();
dataSpecRequestProperties.put("defaultHeader3", "dataSpecOverridesAll");
dataSpecRequestProperties.put("dataSourceHeader2", "dataSpecOverridesDataSource");
dataSpecRequestProperties.put("dataSpecHeader1", "dataSpecValue1");
testDataSpec = new DataSpec.Builder().setUri(TEST_URL).setHttpRequestHeaders(dataSpecRequestProperties).build();
mockResponseStartSuccess();
dataSourceUnderTest.open(testDataSpec);
assertThat(headersSet.get("defaultHeader1")).isEqualTo("defaultValue1");
assertThat(headersSet.get("defaultHeader2")).isEqualTo("dataSourceOverridesDefault");
assertThat(headersSet.get("defaultHeader3")).isEqualTo("dataSpecOverridesAll");
assertThat(headersSet.get("dataSourceHeader1")).isEqualTo("dataSourceValue1");
assertThat(headersSet.get("dataSourceHeader2")).isEqualTo("dataSpecOverridesDataSource");
assertThat(headersSet.get("dataSpecHeader1")).isEqualTo("dataSpecValue1");
verify(mockUrlRequest).start();
}
use of org.mockito.ArgumentMatchers.anyString in project alluxio by Alluxio.
the class LostStorageIntegrationTest method lostStorageWhenRestart.
@Test
@Ignore
public void lostStorageWhenRestart() throws Exception {
File ssdDir = Files.createTempDir();
String ssdPath = ssdDir.getAbsolutePath();
File hddDir = Files.createTempDir();
String hddPath = hddDir.getAbsolutePath();
// Mock no write permission so worker storage paths cannot be initialize
PowerMockito.mockStatic(DefaultStorageDir.class);
Mockito.when(DefaultStorageDir.newStorageDir(ArgumentMatchers.any(DefaultStorageTier.class), ArgumentMatchers.anyInt(), ArgumentMatchers.anyLong(), ArgumentMatchers.anyLong(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenCallRealMethod();
Mockito.when(DefaultStorageDir.newStorageDir(ArgumentMatchers.any(DefaultStorageTier.class), ArgumentMatchers.anyInt(), ArgumentMatchers.anyLong(), ArgumentMatchers.anyLong(), ArgumentMatchers.startsWith(ssdPath), ArgumentMatchers.anyString())).thenThrow(new IOException("mock no write permission exception"));
startClusterWithWorkerStorage(ssdPath, hddPath);
FileUtils.deleteDirectory(hddDir);
// Make sure lost storage is detected and reported to master
Thread.sleep(10 * ServerConfiguration.getMs(PropertyKey.WORKER_BLOCK_HEARTBEAT_INTERVAL_MS));
checkLostStorageResults(ssdPath, hddPath);
mLocalAlluxioCluster.restartMasters();
mLocalAlluxioCluster.waitForWorkersRegistered(6 * Constants.SECOND_MS);
checkLostStorageResults(ssdPath, hddPath);
}
Aggregations