[[_resteasy_server_side_mock_framework]]
== Server-side Mock Framework

Although RESTEasy has an Embeddable Container, you may not be comfortable with the idea of starting and stopping a web server within unit tests.
In reality, the embedded container starts in milliseconds.
You might not like the idea of using Apache HTTP Client or `java.net.URL` to test your code.
RESTEasy provides a mock framework so that you can invoke on your resource directly. 


[source,java]
----
public void testMocking() throws Exception {

    Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();

    POJOResourceFactory noDefaults = new POJOResourceFactory(LocatingResource.class);
    dispatcher.getRegistry().addResourceFactory(noDefaults);
    MockHttpRequest request = MockHttpRequest.get("/locating/basic");
    MockHttpResponse response = new MockHttpResponse();

    dispatcher.invoke(request, response);

    Assertions.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
    Assertions.assertEquals("basic", response.getContentAsString());
}
----

See the RESTEasy Javadoc for all the ease-of-use methods associated with `MockHttpRequest`, and `MockHttpResponse`.

