Search in sources :

Example 26 with Mockery

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

the class ClientHttpRequestJUnitTest 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 27 with Mockery

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

the class PidFileJUnitTest method before.

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

        {
            setImposteriser(ClassImposteriser.INSTANCE);
            setThreadingPolicy(new Synchroniser());
        }
    };
    this.futures = Executors.newFixedThreadPool(2);
}
Also used : Synchroniser(org.jmock.lib.concurrent.Synchroniser) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 28 with Mockery

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

the class GfshCommandJUnitTest method setup.

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

Example 29 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 30 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)

Aggregations

Mockery (org.jmock.Mockery)32 Before (org.junit.Before)21 Expectations (org.jmock.Expectations)14 Synchroniser (org.jmock.lib.concurrent.Synchroniser)12 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)4 Test (org.junit.Test)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 ParameterSetter (com.ibatis.sqlmap.client.extensions.ParameterSetter)2 ResultGetter (com.ibatis.sqlmap.client.extensions.ResultGetter)2 StageDao (com.thoughtworks.go.server.dao.StageDao)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Dictionary (java.util.Dictionary)2 HashMap (java.util.HashMap)2 Servlet (javax.servlet.Servlet)2 BundleContext (org.osgi.framework.BundleContext)2 ComponentContext (org.osgi.service.component.ComponentContext)2 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)1