private void testCheckBlockMd5(final boolean expectMd5Checked) throws Exception { assumeNotNull(testAccount); Path testFilePath = new Path("/testFile"); // Add a hook to check that for GET/PUT requests we set/don't set // the block-level MD5 field as configured. I tried to do clever // testing by also messing with the raw data to see if we actually // validate the data as expected, but the HttpURLConnection wasn't // pluggable enough for me to do that. testAccount.getFileSystem().getStore() .addTestHookToOperationContext(new TestHookOperationContext() { @Override public OperationContext modifyOperationContext( OperationContext original) { original.getResponseReceivedEventHandler().addListener( new ContentMD5Checker(expectMd5Checked)); return original; } }); OutputStream outStream = testAccount.getFileSystem().create(testFilePath); outStream.write(new byte[] { 5, 15 }); outStream.close(); InputStream inStream = testAccount.getFileSystem().open(testFilePath); byte[] inBuf = new byte[100]; while (inStream.read(inBuf) > 0){ //nothing; } inStream.close(); }
private void injectTransientError(NativeAzureFileSystem fs, final ConnectionRecognizer connectionRecognizer) { fs.getStore().addTestHookToOperationContext(new TestHookOperationContext() { @Override public OperationContext modifyOperationContext(OperationContext original) { original.getSendingRequestEventHandler().addListener( new TransientErrorInjector(connectionRecognizer)); return original; } }); }