use of org.apache.hop.vfs.s3.s3n.vfs.S3NFileName in project hop by apache.
the class S3NFileObjectTest method testDoCreateFolder.
@Test
public void testDoCreateFolder() throws Exception {
S3NFileObject notRootBucket = spy(new S3NFileObject(new S3NFileName(SCHEME, BUCKET_NAME, "/" + BUCKET_NAME + "/" + origKey, FileType.IMAGINARY), fileSystemSpy));
notRootBucket.createFolder();
ArgumentCaptor<PutObjectRequest> putObjectRequestArgumentCaptor = ArgumentCaptor.forClass(PutObjectRequest.class);
verify(s3ServiceMock).putObject(putObjectRequestArgumentCaptor.capture());
assertEquals(BUCKET_NAME, putObjectRequestArgumentCaptor.getValue().getBucketName());
assertEquals("some/key/", putObjectRequestArgumentCaptor.getValue().getKey());
}
use of org.apache.hop.vfs.s3.s3n.vfs.S3NFileName in project hop by apache.
the class S3NFileSystemTest method setUp.
@Before
public void setUp() throws Exception {
fileName = new S3NFileName(S3FileNameTest.SCHEME, "/", "", FileType.FOLDER);
fileSystem = new S3NFileSystem(fileName, new FileSystemOptions());
}
use of org.apache.hop.vfs.s3.s3n.vfs.S3NFileName in project hop by apache.
the class S3NFileObjectTest method testDoRename.
@Test
public void testDoRename() throws Exception {
String someNewBucketName = "someNewBucketName";
String someNewKey = "some/newKey";
S3NFileName newFileName = new S3NFileName(SCHEME, someNewBucketName, "/" + someNewBucketName + "/" + someNewKey, FileType.FILE);
S3NFileObject newFile = new S3NFileObject(newFileName, fileSystemSpy);
ArgumentCaptor<CopyObjectRequest> copyObjectRequestArgumentCaptor = ArgumentCaptor.forClass(CopyObjectRequest.class);
when(s3ServiceMock.doesBucketExistV2(someNewBucketName)).thenReturn(true);
s3FileObjectFileSpy.moveTo(newFile);
verify(s3ServiceMock).copyObject(copyObjectRequestArgumentCaptor.capture());
assertEquals(someNewBucketName, copyObjectRequestArgumentCaptor.getValue().getDestinationBucketName());
assertEquals(someNewKey, copyObjectRequestArgumentCaptor.getValue().getDestinationKey());
assertEquals(BUCKET_NAME, copyObjectRequestArgumentCaptor.getValue().getSourceBucketName());
assertEquals(origKey, copyObjectRequestArgumentCaptor.getValue().getSourceKey());
}
use of org.apache.hop.vfs.s3.s3n.vfs.S3NFileName in project hop by apache.
the class S3NFileNameParserTest method testParseUri.
@Test
public void testParseUri() throws Exception {
VfsComponentContext context = mock(VfsComponentContext.class);
FileName fileName = mock(FileName.class);
String uri = "s3n://bucket/file";
FileName noBaseFile = parser.parseUri(context, null, uri);
assertNotNull(noBaseFile);
assertEquals("bucket", ((S3NFileName) noBaseFile).getBucketId());
FileName withBaseFile = parser.parseUri(context, fileName, uri);
assertNotNull(withBaseFile);
assertEquals("bucket", ((S3NFileName) withBaseFile).getBucketId());
// assumption is that the whole URL is valid until it comes time to resolve to S3 objects
uri = "s3n://s3n/bucket/file";
withBaseFile = parser.parseUri(context, fileName, uri);
assertEquals("s3n", ((S3NFileName) withBaseFile).getBucketId());
}
use of org.apache.hop.vfs.s3.s3n.vfs.S3NFileName in project hop by apache.
the class S3NFileNameTest method testAppendRootUriWithNonDefaultPort.
@Test
public void testAppendRootUriWithNonDefaultPort() {
fileName = new S3NFileName(SCHEME, "", "FooFolder", FileType.FOLDER);
String expectedUri = SCHEME + "://" + "FooFolder";
assertEquals(expectedUri, fileName.getURI());
fileName = new S3NFileName(SCHEME, "FooBucket", "/FooBucket/FooFolder", FileType.FOLDER);
expectedUri = SCHEME + "://FooBucket/FooBucket/" + "FooFolder";
assertEquals(expectedUri, fileName.getURI());
}
Aggregations