Search in sources :

Example 1 with S3Blob

use of cz.o2.proxima.direct.s3.S3BlobPath.S3Blob in project proxima-platform by O2-Czech-Republic.

the class S3BlobPathTest method testBlobGetSizeOnException.

@Test
public void testBlobGetSizeOnException() {
    final S3FileSystem fs = Mockito.mock(S3FileSystem.class, Mockito.RETURNS_DEEP_STUBS);
    Mockito.when(fs.getObject(Mockito.any())).thenThrow(new IllegalStateException());
    final S3Blob blob = new S3Blob("name", fs);
    Assert.assertEquals(0L, blob.getSize());
}
Also used : S3Blob(cz.o2.proxima.direct.s3.S3BlobPath.S3Blob) Test(org.junit.Test)

Example 2 with S3Blob

use of cz.o2.proxima.direct.s3.S3BlobPath.S3Blob in project proxima-platform by O2-Czech-Republic.

the class S3BlobPathTest method testBlobGetSize.

@Test
public void testBlobGetSize() {
    final S3FileSystem fs = Mockito.mock(S3FileSystem.class);
    final ObjectMetadata objectMetadata = new ObjectMetadata();
    objectMetadata.setContentLength(1337L);
    final S3Object object = new S3Object();
    object.setObjectMetadata(objectMetadata);
    Mockito.when(fs.getObject(Mockito.eq("name"))).thenReturn(object);
    final S3Blob blob = new S3Blob("name", fs);
    Assert.assertEquals(1337L, blob.getSize());
}
Also used : S3Object(com.amazonaws.services.s3.model.S3Object) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) S3Blob(cz.o2.proxima.direct.s3.S3BlobPath.S3Blob) Test(org.junit.Test)

Example 3 with S3Blob

use of cz.o2.proxima.direct.s3.S3BlobPath.S3Blob in project proxima-platform by O2-Czech-Republic.

the class S3BlobPathTest method testSerializable.

@Test
public void testSerializable() throws IOException, ClassNotFoundException {
    Context context = op.getContext();
    S3FileSystem fs = new S3FileSystem(new S3Accessor(TestUtils.createTestFamily(entity, URI.create("s3://bucket"), S3FileSystemTest.cfg())), context);
    S3BlobPath path = new S3BlobPath(context, fs, new S3Blob("name", fs));
    S3BlobPath path2 = TestUtils.assertSerializable(path);
    TestUtils.assertHashCodeAndEquals(path, path2);
}
Also used : Context(cz.o2.proxima.direct.core.Context) S3Blob(cz.o2.proxima.direct.s3.S3BlobPath.S3Blob) Test(org.junit.Test)

Aggregations

S3Blob (cz.o2.proxima.direct.s3.S3BlobPath.S3Blob)3 Test (org.junit.Test)3 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)1 S3Object (com.amazonaws.services.s3.model.S3Object)1 Context (cz.o2.proxima.direct.core.Context)1