### Question:
HTTPUtilitiesImplementation implements HTTPUtilities { public String valueFromLocationURI(final String tokenName) throws GrinderException { final HTTPResponse response = getLastResponse(); if (response == null) { return ""; } final String location; try { location = response.getHeader("Location"); } catch (Exception e) { throw new AssertionError("HTTPResponse not initialised (" + e + ")"); } final String[] result = { "" }; if (location != null) { m_uriParser.parse(location, new URIParser.AbstractParseListener() { public boolean pathParameterNameValue(String name, String value) { if (name.equals(tokenName)) { result[0] = value; return false; } return true; } public boolean queryStringNameValue(String name, String value) { if (name.equals(tokenName)) { result[0] = value; return false; } return true; } }); } return result[0]; } HTTPUtilitiesImplementation(PluginProcessContext processContext); NVPair basicAuthorizationHeader(String userID, String password); HTTPResponse getLastResponse(); String valueFromLocationURI(final String tokenName); String valueFromBodyInput(final String tokenName); String valueFromBodyInput(String tokenName, String afterText); List<String> valuesFromBodyInput(final String tokenName); List<String> valuesFromBodyInput(String tokenName, String afterText); String valueFromHiddenInput(final String tokenName); String valueFromHiddenInput(String tokenName, String afterText); List<String> valuesFromHiddenInput(final String tokenName); List<String> valuesFromHiddenInput(String tokenName, String afterText); String valueFromBodyURI(final String tokenName); String valueFromBodyURI(final String tokenName, String afterText); List<String> valuesFromBodyURI(final String tokenName); List<String> valuesFromBodyURI(final String tokenName,
                                        String afterText);  }### Answer:
@Test public void testValueFromLocationHeader() throws Exception { final HTTPRequest request = new HTTPRequest(); final HTTPUtilities httpUtilities = new HTTPUtilitiesImplementation(m_pluginProcessContext); assertEquals("", httpUtilities.valueFromLocationURI("foo")); final HTTPRequestHandler handler = new HTTPRequestHandler(); handler.start(); request.GET(handler.getURL()); assertEquals("", httpUtilities.valueFromLocationURI("foo")); handler.addHeader("Location", "http: request.GET(handler.getURL()); assertEquals("", httpUtilities.valueFromLocationURI("foo")); handler.clearHeaders(); handler.addHeader( "Location", "http: request.GET(handler.getURL()); assertEquals("bah", httpUtilities.valueFromLocationURI("foo")); assertEquals("", httpUtilities.valueFromLocationURI("bah")); handler.clearHeaders(); handler.addHeader( "Location", "http: request.GET(handler.getURL()); assertEquals("", httpUtilities.valueFromLocationURI("foo")); assertEquals("dah", httpUtilities.valueFromLocationURI("lah")); handler.clearHeaders(); handler.addHeader( "Location", "http: request.GET(handler.getURL()); assertEquals("1234", httpUtilities.valueFromLocationURI("JSESSIONID")); assertEquals("", httpUtilities.valueFromLocationURI("foo")); handler.shutdown(); }