com.github.kristofa.test.http
Class MockAndProxyFacade

java.lang.Object
  extended by com.github.kristofa.test.http.MockAndProxyFacade

public class MockAndProxyFacade
extends Object

Facade that lets you easily configure and use either the LoggingHttpProxy for using real services and logging requests/responses or the MockHttpServer for running your code against mocked http requests/responses.

You can use MockHttpServer or LoggingHttpProxy by themselves but if you use both it is most likely that this class will make things easier for you.

Author:
kristof

Nested Class Summary
static class MockAndProxyFacade.Builder
           
static class MockAndProxyFacade.Mode
          Specifies the mode in which MockAndProxyFacade should be operating.
 
Method Summary
 void start()
          Starts either MockHttpServer or LoggingHttpProxy depending on operation mode.
 void stop()
          Stops either MockHttpServer or LoggingHttpProxy depending on operation mode.
 void verify()
          In case we are in Mocking operation mode we will verify if all expected requests have been invoked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

start

public void start()
           throws IOException
Starts either MockHttpServer or LoggingHttpProxy depending on operation mode.

Throws:
IOException - In case starting fails.

stop

public void stop()
          throws IOException
Stops either MockHttpServer or LoggingHttpProxy depending on operation mode.

Throws:
IOException - In case stopping fails.

verify

public void verify()
            throws UnsatisfiedExpectationException
In case we are in Mocking operation mode we will verify if all expected requests have been invoked.

In case we are in Logging operation mode nothing will be checked.

Throws:
UnsatisfiedExpectationException - In case we got unexpected requests and/or not all expected requests were invoked.


Copyright © 2014. All Rights Reserved.