Package com.s3auth.hosts

Examples of com.s3auth.hosts.Resource


        Mockito.doAnswer(
            new Answer<Resource>() {
                @Override
                public Resource answer(final InvocationOnMock inv)
                    throws InterruptedException {
                    final Resource answer = Mockito.mock(Resource.class);
                    Mockito.doReturn(new Date(5000L))
                        .when(answer).lastModified();
                    Mockito.doReturn(HttpURLConnection.HTTP_OK)
                        .when(answer).status();
                    return answer;
View Full Code Here


        Mockito.doAnswer(
            new Answer<Resource>() {
                @Override
                public Resource answer(final InvocationOnMock inv)
                    throws InterruptedException {
                    final Resource answer = Mockito.mock(Resource.class);
                    Mockito.doReturn(date)
                        .when(answer).lastModified();
                    Mockito.doReturn(HttpURLConnection.HTTP_OK)
                        .when(answer).status();
                    return answer;
View Full Code Here

        Mockito.doAnswer(
            new Answer<Resource>() {
                @Override
                public Resource answer(final InvocationOnMock inv)
                    throws InterruptedException {
                    final Resource answer = Mockito.mock(Resource.class);
                    Mockito.doReturn(HttpURLConnection.HTTP_OK)
                        .when(answer).status();
                    Thread.sleep(1100L);
                    return answer;
                }
View Full Code Here

                    throws InterruptedException {
                    MatcherAssert.assertThat(
                        ((Version) inv.getArguments()[2]).version(),
                        Matchers.is(version)
                    );
                    final Resource answer = Mockito.mock(Resource.class);
                    Mockito.doReturn(HttpURLConnection.HTTP_OK)
                        .when(answer).status();
                    return answer;
                }
            }
View Full Code Here

                    throws InterruptedException {
                    MatcherAssert.assertThat(
                        (Version) inv.getArguments()[2],
                        Matchers.is(Version.LATEST)
                    );
                    final Resource answer = Mockito.mock(Resource.class);
                    Mockito.doReturn(HttpURLConnection.HTTP_OK)
                        .when(answer).status();
                    return answer;
                }
            }
View Full Code Here

                public Resource answer(final InvocationOnMock inv) {
                    MatcherAssert.assertThat(
                        (Version) inv.getArguments()[2],
                        Matchers.is(Version.LIST)
                    );
                    final Resource answer = Mockito.mock(Resource.class);
                    Mockito.doReturn(HttpURLConnection.HTTP_OK)
                        .when(answer).status();
                    return answer;
                }
            }
View Full Code Here

        final String body = "compressed";
        Mockito.doAnswer(
            new Answer<Resource>() {
                @Override
                public Resource answer(final InvocationOnMock inv) {
                    final Resource answer = new ResourceMocker()
                        .withContent(body).mock();
                    Mockito.doReturn("text/plain")
                        .when(answer).contentType();
                    return answer;
                }
View Full Code Here

    @org.junit.Ignore
    @Test
    public void getsContentOverSSL() throws Exception {
        final Host host = Mockito.mock(Host.class);
        final String body = "secured";
        final Resource answer = new ResourceMocker().withContent(body).mock();
        Mockito.doReturn(answer).when(host).fetch(
            Mockito.any(URI.class),
            Mockito.any(Range.class),
            Mockito.any(Version.class)
        );
View Full Code Here

     * @throws Exception If there is some problem inside
     */
    @Test
    public void closesUnderlyingResource() throws Exception {
        final Host host = Mockito.mock(Host.class);
        final Resource resource = new ResourceMocker().mock();
        Mockito.doReturn(resource).when(host).fetch(
            Mockito.any(URI.class),
            Mockito.any(Range.class),
            Mockito.any(Version.class)
        );
View Full Code Here

    @Test
    @SuppressWarnings("PMD.DoNotUseThreads")
    public void sendsDataFromSlowResource() throws Exception {
        final String content = "\u0433 some text";
        // @checkstyle AnonInnerLength (50 lines)
        final Resource res = new Resource() {
            @Override
            public long writeTo(final OutputStream stream) {
                try {
                    TimeUnit.SECONDS.sleep(2L);
                } catch (final InterruptedException ex) {
View Full Code Here

TOP

Related Classes of com.s3auth.hosts.Resource

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.