### Question:
HttpHeaderUtils { public static long getTransactionTimeout( HttpServletRequest request, Log errorLog ) { String headerValue = request.getHeader( MAX_EXECUTION_TIME_HEADER ); if ( headerValue != null ) { try { return Long.parseLong( headerValue ); } catch ( NumberFormatException e ) { errorLog.error( String.format( "Fail to parse `%s` header with value: '%s'. Should be a positive number.", MAX_EXECUTION_TIME_HEADER, headerValue), e ); } } return GraphDatabaseSettings.UNSPECIFIED_TIMEOUT; } private  HttpHeaderUtils(); static MediaType mediaTypeWithCharsetUtf8( String mediaType ); static MediaType mediaTypeWithCharsetUtf8( MediaType mediaType ); static long getTransactionTimeout( HttpServletRequest request, Log errorLog ); static boolean isValidHttpHeaderName( String name ); static final String MAX_EXECUTION_TIME_HEADER; static final Map<String,String> CHARSET; }### Answer:
@Test public void retrieveCustomTransactionTimeout() { when( request.getHeader( MAX_EXECUTION_TIME_HEADER ) ).thenReturn( "100" ); Log log = logProvider.getLog( HttpServletRequest.class ); long transactionTimeout = getTransactionTimeout( request, log ); assertEquals( "Transaction timeout should be retrieved.", 100, transactionTimeout ); logProvider.assertNoLoggingOccurred(); }
@Test public void defaultValueWhenCustomTransactionTimeoutNotSpecified() { Log log = logProvider.getLog( HttpServletRequest.class ); long transactionTimeout = getTransactionTimeout( request, log ); assertEquals( "Transaction timeout not specified.", 0, transactionTimeout ); logProvider.assertNoLoggingOccurred(); }
@Test public void defaultValueWhenCustomTransactionTimeoutNotANumber() { when( request.getHeader( MAX_EXECUTION_TIME_HEADER ) ).thenReturn( "aa" ); Log log = logProvider.getLog( HttpServletRequest.class ); long transactionTimeout = getTransactionTimeout( request, log ); assertEquals( "Transaction timeout not specified.", 0, transactionTimeout ); logProvider.rawMessageMatcher().assertContains("Fail to parse `max-execution-time` " + "header with value: 'aa'. Should be a positive number."); }