Package com.amazonaws.services.s3

Examples of com.amazonaws.services.s3.AmazonS3


     * DefaultHost can load resource from S3.
     * @throws Exception If there is some problem inside
     */
    @Test
    public void loadsAmazonResourcesFrom() throws Exception {
        final AmazonS3 aws = Mockito.mock(AmazonS3.class);
        Mockito.doAnswer(
            new Answer<S3Object>() {
                @Override
                public S3Object answer(final InvocationOnMock invocation) {
                    final String key = GetObjectRequest.class.cast(
View Full Code Here


     * @throws Exception If there is some problem inside
     * @see <a href="http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html">S3 Error Responses</a>
     */
    @Test
    public void throwsExceptionForNonexistentBucket() throws Exception {
        final AmazonS3 aws = Mockito.mock(AmazonS3.class);
        final AmazonServiceException exp =
            new AmazonServiceException("No such bucket");
        exp.setErrorCode("NoSuchBucket");
        Mockito.doThrow(exp)
            .when(aws).getObject(Mockito.any(GetObjectRequest.class));
View Full Code Here

     * not exist and ends with "index.html".
     * @throws Exception If a problem occurs.
     */
    @Test
    public void showsDirectoryListing() throws Exception {
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final ObjectListing listing = Mockito.mock(ObjectListing.class);
        final S3ObjectSummary summary = new S3ObjectSummary();
        final String name = "foo/bar/boo";
        summary.setKey(name);
        Mockito.doReturn(Collections.singletonList(summary))
View Full Code Here

     * DefaultHost can return a version listing.
     * @throws Exception If a problem occurs.
     */
    @Test
    public void showsVersionListing() throws Exception {
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final VersionListing listing = Mockito.mock(VersionListing.class);
        final S3VersionSummary summary = new S3VersionSummary();
        final String key = "README.md";
        summary.setKey(key);
        summary.setVersionId("abc");
View Full Code Here

     * DefaultHost can correctly return index.html version listing.
     * @throws Exception If a problem occurs.
     */
    @Test
    public void showsVersionListingForIndexHtml() throws Exception {
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        final VersionListing listing = Mockito.mock(VersionListing.class);
        final S3VersionSummary summary = new S3VersionSummary();
        final String key = "hello/index.html";
        summary.setKey(key);
        summary.setVersionId("def");
View Full Code Here

     * DefaultHost can load error document from S3 if status code is 4xx.
     * @throws Exception If there is some problem inside
     */
    @Test
    public void loadsErrorDocument() throws Exception {
        final AmazonS3 aws = Mockito.mock(AmazonS3.class);
        final String suffix = "nonExistent.html";
        final String error = "error.html";
        final String message = "Test output for error page";
        Mockito.doAnswer(
            new Answer<S3Object>() {
View Full Code Here

     * @throws Exception If there is some problem inside
     */
    @Test(expected = IOException.class)
    public void throwsExceptionIfNoBucketWebsiteConfiguration()
        throws Exception {
        final AmazonS3 aws = Mockito.mock(AmazonS3.class);
        final AmazonServiceException ex =
            new AmazonServiceException("The object is not found");
        ex.setStatusCode(HttpStatus.SC_NOT_FOUND);
        Mockito.doThrow(ex).when(aws)
            .getObject(Mockito.any(GetObjectRequest.class));
View Full Code Here

    @Override
    @NotNull
    @Cacheable(lifetime = Tv.TEN, unit = TimeUnit.MINUTES)
    public AmazonS3 client() {
        final AmazonS3 client = new AmazonS3Client(
            new BasicAWSCredentials(this.domain.key(), this.domain.secret()),
            new ClientConfiguration()
                .withSocketTimeout(0)
                .withProtocol(Protocol.HTTP)
        );
        client.setEndpoint(
            String.format("%s.amazonaws.com", this.domain.region())
        );
        return client;
    }
View Full Code Here

     * Htpasswd can show some stats in {@code #toString()} with IO exception.
     * @throws Exception If there is some problem inside
     */
    @Test
    public void showsStatsInToStringWithIOException() throws Exception {
        final AmazonS3 aws = Mockito.mock(AmazonS3.class);
        Mockito.doThrow(new AmazonClientException("")).when(aws)
            .getObject(Mockito.any(GetObjectRequest.class));
        MatcherAssert.assertThat(
            new Htpasswd(
                new DefaultHost(
View Full Code Here

            new S3ObjectInputStream(
                IOUtils.toInputStream("TXT"),
                new HttpGet()
            )
        ).when(object).getObjectContent();
        final AmazonS3 client = Mockito.mock(AmazonS3.class);
        Mockito.doReturn(object).when(client)
            .getObject(Mockito.any(GetObjectRequest.class));
        this.withClient(client);
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.s3.AmazonS3

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.