neo4j/neo4j — pull request #2214 by benbc (2014-04-01 16:36:48+00:00)
Title: Make UDC user agent recording more testable.

o We have been getting sporadic failures of the UDC
CollectUserAgentFilter integration test. It looked like this was
because 1) we were testing the logic through an integration test and
2) the logic was complicated because of the sampling that was being
done (only recording one in a hundred requests).

o I have added a unit test to cover most of the logic.

o I have removed the sampling so that we now record every request. The
sampling was originally put in to reduce possible performance impacts
of the filter. I have changed the implementation so that it no longer
uses regular expressions (String#split() has a special case for
single-char delimeters) and read the Jersey code that we call to get
hold of the request headers; I'm convinced that everything that we do
now is very fast, so the sampling is not necessary.

o In order to make the whole thing more testable (to avoid problems with
static state), I have re-worked the way the state is stored. It's
somewhat convoluted to satisfy the various constraints that are put on
us by the way this code is used. See CollectUserAgentFilter for
details.

o Because the interface of CollectUserAgentFilter has changed, we need
to rework the UDC integration testing. This integration testing is
somewhat tricky because of the way our Maven modules are stiched
together. Previously we had a dummy implementation of the filter for
UDC testing, but that meant that it's easy for the interface to get
out of sync. Instead I've moved the integration testing into its own
project so that it can depend on both server and UDC without
introducing a circular dependency.