dana-i2cat/opennaas — pull request #767 by adrian-rosello (2013-12-20 11:26:51+00:00)
Title: Feature/http server

Pull request introduces the HTTP server for testing.

HTTPServer creates a Jetty server. In order to start it, it requires a port, a base uri (where the servlet will be published) and a list of behaviours. These behaviours are passed to the servlet (HTTPServerServlet) and will contain the association between a client request and the desired response the test wants to response and checks.

Due to servlet is started before the URL is published, a WSEndpointListener has been created. It's used to listen for endpoints publications publications (so it can be used for dOSGI endpoints to). In integration tests there are some examples on how to use it, but the main idea is:

1) Create and register a WSEndpointListener. Nowadays one can register to listen all endpoints publications or filtering by interface. For example
listenerHandler.registerWSEndpointListener(context, IOpenflowForwardingCapability.class);
will listen only for endpoints published with this interface.

2) Use the listenerHandler.waitForEndpointToBePublished() method in order to block execution until the desired endpoint is published.

3) Use the listenerHandler.waitForEndpointToBeUnPublished(); method whenever you want to block execution until the desired endpoint is unpublished (Very useful for testing where resources are started and stopped many times!).

It contains tests for both REST clients we have: floodlight and opener.

Some tests of OFNetwork has been corrected, too.