Search in sources :

Example 86 with Mockery

use of org.jmock.Mockery in project sling by apache.

the class ClientAbortExceptionTest method setup.

@Before
public void setup() throws IOException {
    context = new Mockery();
    final ServletOutputStream sos = new ServletOutputStream() {

        @Override
        public void write(int b) throws IOException {
            throw new IOException("Always fails, on purpose");
        }

        @Override
        public void flush() throws IOException {
            throw new IOException("Always fails, on purpose");
        }

        @Override
        public void close() throws IOException {
            throw new IOException("Always fails, on purpose");
        }

        @Override
        public boolean isReady() {
            return true;
        }

        @Override
        public void setWriteListener(WriteListener writeListener) {
        }
    };
    final HttpServletResponse raw = context.mock(HttpServletResponse.class);
    context.checking(new Expectations() {

        {
            allowing(raw).getOutputStream();
            will(returnValue(sos));
        }
    });
    r = new RequestLoggerResponse(raw);
}
Also used : Expectations(org.jmock.Expectations) ServletOutputStream(javax.servlet.ServletOutputStream) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) Mockery(org.jmock.Mockery) WriteListener(javax.servlet.WriteListener) Before(org.junit.Before)

Example 87 with Mockery

use of org.jmock.Mockery in project sling by apache.

the class RepositoryTestHelper method mockResourceResolverFactory.

public static ResourceResolverFactory mockResourceResolverFactory(final SlingRepository repositoryOrNull) throws Exception {
    Mockery context = new JUnit4Mockery() {

        {
            // @see http://www.jmock.org/threading-synchroniser.html
            setThreadingPolicy(new Synchroniser());
        }
    };
    final ResourceResolverFactory resourceResolverFactory = context.mock(ResourceResolverFactory.class);
    // final ResourceResolver resourceResolver = new MockResourceResolver();
    // final ResourceResolver resourceResolver = new
    // MockedResourceResolver();
    context.checking(new Expectations() {

        {
            allowing(resourceResolverFactory).getServiceResourceResolver(null);
            will(new Action() {

                @Override
                public Object invoke(Invocation invocation) throws Throwable {
                    return new MockedResourceResolver(repositoryOrNull);
                }

                @Override
                public void describeTo(Description arg0) {
                    arg0.appendText("whateva - im going to create a new mockedresourceresolver");
                }
            });
        }
    });
    return resourceResolverFactory;
}
Also used : Expectations(org.jmock.Expectations) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Action(org.jmock.api.Action) ResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory) Description(org.hamcrest.Description) Invocation(org.jmock.api.Invocation) Synchroniser(org.jmock.lib.concurrent.Synchroniser) Mockery(org.jmock.Mockery) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery)

Example 88 with Mockery

use of org.jmock.Mockery in project gocd by gocd.

the class BackgroundEmailSenderTest method setUp.

@Before
public void setUp() {
    mockery = new Mockery();
    sender = mockery.mock(GoMailSender.class);
}
Also used : Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 89 with Mockery

use of org.jmock.Mockery in project gocd by gocd.

the class AntTaskDetectorTest method setUp.

@Before
public void setUp() {
    context = new Mockery();
    reporter = context.mock(Reporter.class);
    detector = new AntTaskDetector(reporter);
}
Also used : Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 90 with Mockery

use of org.jmock.Mockery in project gocd by gocd.

the class AntTestFailureDetectorTest method setUp.

@Before
public void setUp() {
    context = new Mockery();
    reporter = context.mock(Reporter.class);
    detector = new AntTestFailureDetector(reporter);
}
Also used : Mockery(org.jmock.Mockery) Before(org.junit.Before)

Aggregations

Mockery (org.jmock.Mockery)148 Expectations (org.jmock.Expectations)118 Test (org.junit.Test)77 Before (org.junit.Before)28 ArrayList (java.util.ArrayList)24 Date (java.util.Date)21 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)17 File (java.io.File)15 BeforeMethod (org.testng.annotations.BeforeMethod)15 Synchroniser (org.jmock.lib.concurrent.Synchroniser)14 List (java.util.List)11 ActorDTO (com.management.dto.ActorDTO)7 FanZoneDTO (com.management.dto.FanZoneDTO)6 PropsDTO (com.management.dto.PropsDTO)6 ActorPerformancesRepository (com.management.repositories.ActorPerformancesRepository)6 ActorRepository (com.management.repositories.ActorRepository)6 CinemaTheatreRepository (com.management.repositories.CinemaTheatreRepository)6 EventRepository (com.management.repositories.EventRepository)6 FriendsListRepository (com.management.repositories.FriendsListRepository)6 PerformanceRepository (com.management.repositories.PerformanceRepository)6