S3FileObject extends S3CommonFileObject { @Override protected OutputStream doGetOutputStream( boolean bAppend ) throws Exception { SimpleEntry<String, String> newPath = fixFilePath( key, bucketName ); return new S3CommonPipedOutputStream( this.fileSystem, newPath.getValue(), newPath.getKey(), ( (S3FileSystem) this.fileSystem ).getPartSize() ); } protected  S3FileObject( final AbstractFileName name, final S3FileSystem fileSystem );   }
@Test public void testDoGetOutputStream() throws Exception { InitiateMultipartUploadResult initResponse = mock( InitiateMultipartUploadResult.class ); when( initResponse.getUploadId() ).thenReturn( "foo" ); when( s3ServiceMock.initiateMultipartUpload( any() ) ).thenReturn( initResponse ); UploadPartResult uploadPartResult = mock( UploadPartResult.class ); PartETag tag = mock( PartETag.class ); when( s3ServiceMock.uploadPart( any() ) ).thenReturn( uploadPartResult ); when( uploadPartResult.getPartETag() ).thenReturn( tag ); assertNotNull( s3FileObjectBucketSpy.doGetOutputStream( false ) ); OutputStream out = s3FileObjectBucketSpy.doGetOutputStream( true ); assertNotNull( out ); out.write( new byte[ 1024 * 1024 * 6 ] ); out.close(); verify(s3ServiceMock, times(2) ).uploadPart(any()); verify( s3ServiceMock, atMost( 1 ) ).completeMultipartUpload( any() ); }