Search in sources :

Example 81 with Mockery

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

the class DescribeDiskStoreFunctionJUnitTest method setup.

@Before
public void setup() {
    mockContext = new Mockery();
    mockContext.setImposteriser(ClassImposteriser.INSTANCE);
    mockContext.setThreadingPolicy(new Synchroniser());
}
Also used : Synchroniser(org.jmock.lib.concurrent.Synchroniser) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 82 with Mockery

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

the class ListIndexFunctionJUnitTest method setup.

@Before
public void setup() {
    mockContext = new Mockery() {

        {
            setImposteriser(ClassImposteriser.INSTANCE);
            setThreadingPolicy(new Synchroniser());
        }
    };
    mockCounter = new AtomicLong(0l);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Synchroniser(org.jmock.lib.concurrent.Synchroniser) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 83 with Mockery

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

the class LoginHandlerInterceptorJUnitTest method setUp.

@Before
public void setUp() {
    mockContext = new Mockery();
    mockContext.setImposteriser(ClassImposteriser.INSTANCE);
    mockContext.setThreadingPolicy(new Synchroniser());
    LoginHandlerInterceptor.getEnvironment().clear();
}
Also used : Synchroniser(org.jmock.lib.concurrent.Synchroniser) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 84 with Mockery

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

the class InitResourceTest method setup.

@Before
public void setup() throws Exception {
    context = new Mockery();
    req = context.mock(HttpServletRequest.class);
    resp = context.mock(HttpServletResponse.class);
    resourceResolver = context.mock(ResourceResolver.class);
    context.checking(new Expectations() {

        {
            allowing(req).getRequestURL();
            will(returnValue(new StringBuffer(requestURL)));
            allowing(req).getRequestURI();
            allowing(req).getPathInfo();
            will(returnValue(pathInfo));
            allowing(req).getServletPath();
            will(returnValue("/"));
            allowing(req).getMethod();
            will(returnValue("GET"));
            allowing(req).getAttribute(RequestData.REQUEST_RESOURCE_PATH_ATTR);
            will(returnValue(null));
            allowing(req).setAttribute(with(equal(RequestData.REQUEST_RESOURCE_PATH_ATTR)), with(any(Object.class)));
            allowing(req).getAttribute(RequestProgressTracker.class.getName());
            will(returnValue(null));
            // Verify that the ResourceResolver is called with the expected path
            allowing(resourceResolver).resolve(with(any(HttpServletRequest.class)), with(equal(expectedResolvePath)));
        }
    });
    requestData = new RequestData(null, req, resp);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Expectations(org.jmock.Expectations) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) HttpServletResponse(javax.servlet.http.HttpServletResponse) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 85 with Mockery

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

the class RequestDataTest method setup.

@Before
public void setup() throws Exception {
    context = new Mockery() {

        {
            setImposteriser(ClassImposteriser.INSTANCE);
        }
    };
    req = context.mock(HttpServletRequest.class);
    resp = context.mock(HttpServletResponse.class);
    final ContentData contentData = context.mock(ContentData.class);
    final Servlet servlet = context.mock(Servlet.class);
    final ServletConfig servletConfig = context.mock(ServletConfig.class);
    context.checking(new Expectations() {

        {
            allowing(req).getServletPath();
            will(returnValue("/"));
            allowing(req).getPathInfo();
            will(returnValue(""));
            allowing(req).getMethod();
            will(returnValue("GET"));
            allowing(req).setAttribute(with(any(String.class)), with(any(Object.class)));
            allowing(req).setAttribute(with(any(String.class)), with(aNull(Object.class)));
            allowing(contentData).getServlet();
            will(returnValue(servlet));
            allowing(servlet).getServletConfig();
            will(returnValue(servletConfig));
            allowing(servlet).service(with(any(ServletRequest.class)), with(any(ServletResponse.class)));
            allowing(servletConfig).getServletName();
            will(returnValue("SERVLET_NAME"));
            allowing(req).getAttribute(RequestProgressTracker.class.getName());
            will(returnValue(null));
        }
    });
    requestData = new RequestData(null, req, resp) {

        @Override
        public ContentData getContentData() {
            return contentData;
        }
    };
    slingRequest = new SlingHttpServletRequestImpl(requestData, req);
    slingResponse = new SlingHttpServletResponseImpl(requestData, resp);
    RequestData.setMaxCallCounter(2);
}
Also used : Expectations(org.jmock.Expectations) ServletRequest(javax.servlet.ServletRequest) SlingHttpServletRequest(org.apache.sling.api.SlingHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) SlingHttpServletResponse(org.apache.sling.api.SlingHttpServletResponse) ServletResponse(javax.servlet.ServletResponse) SlingHttpServletResponseImpl(org.apache.sling.engine.impl.SlingHttpServletResponseImpl) ServletConfig(javax.servlet.ServletConfig) HttpServletResponse(javax.servlet.http.HttpServletResponse) SlingHttpServletResponse(org.apache.sling.api.SlingHttpServletResponse) Mockery(org.jmock.Mockery) SlingHttpServletRequest(org.apache.sling.api.SlingHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) SlingHttpServletRequestImpl(org.apache.sling.engine.impl.SlingHttpServletRequestImpl) Servlet(javax.servlet.Servlet) 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