### Question:
RescriptTransportCommandProcessor extends AbstractTerminateableHttpCommandProcessor<Void> { @Override protected CommandResolver<HttpCommand> createCommandResolver(final HttpCommand command, final Tracer tracer) { String uri = stripMinorVersionFromUri(command.getOperationPath()); final RescriptOperationBinding binding = bindings.get(uri); return new SingleExecutionCommandResolver<HttpCommand>(tracer) { private DehydratedExecutionContext context; private ExecutionCommand executionCommand; @Override public DehydratedExecutionContext resolveExecutionContext() { if (context == null) { context = RescriptTransportCommandProcessor.this.resolveExecutionContext(command, null); } return context; } @Override public ExecutionCommand resolveExecutionCommand(Tracer tracer) { if (binding!=null) { if (executionCommand == null) { executionCommand = RescriptTransportCommandProcessor.this.resolveExecutionCommand( binding, command, resolveExecutionContext(), tracer); } return executionCommand; } throw new CougarValidationException(ServerFaultCode.NoSuchOperation, "The request could not be resolved to an operation"); } }; } RescriptTransportCommandProcessor(DehydratedExecutionContextResolution contextResolution, String requestTimeoutHeader); @Override void onCougarStart(); void bindOperation(ServiceBindingDescriptor serviceBindingDescriptor, OperationBindingDescriptor bindingDescriptor);  }### Answer:
@Test public void createCommandResolver_NoTimeout() { command.setPathInfo("/FirstTestOp"); when(request.getParameter("FirstOpFirstParam")).thenReturn("hello"); when(request.getScheme()).thenReturn("http"); CommandResolver<HttpCommand> cr = rescriptCommandProcessor.createCommandResolver(command, tracer); Iterable<ExecutionCommand> executionCommands = cr.resolveExecutionCommands(); ExecutionCommand executionCommand = executionCommands.iterator().next(); TimeConstraints constraints = executionCommand.getTimeConstraints(); assertNull(constraints.getExpiryTime()); }
@Test public void createCommandResolver_WithTimeout() { command.setPathInfo("/FirstTestOp"); when(request.getParameter("FirstOpFirstParam")).thenReturn("hello"); when(request.getScheme()).thenReturn("http"); when(request.getHeader("X-RequestTimeout")).thenReturn("10000"); when(context.getRequestTime()).thenReturn(new Date()); CommandResolver<HttpCommand> cr = rescriptCommandProcessor.createCommandResolver(command, tracer); Iterable<ExecutionCommand> executionCommands = cr.resolveExecutionCommands(); ExecutionCommand executionCommand = executionCommands.iterator().next(); TimeConstraints constraints = executionCommand.getTimeConstraints(); assertNotNull(constraints.getExpiryTime()); }
@Test public void createCommandResolver_WithTimeoutAndOldRequestTime() { command.setPathInfo("/FirstTestOp"); when(request.getParameter("FirstOpFirstParam")).thenReturn("hello"); when(request.getScheme()).thenReturn("http"); when(request.getHeader("X-RequestTimeout")).thenReturn("10000"); when(context.getRequestTime()).thenReturn(new Date(System.currentTimeMillis()-10001)); CommandResolver<HttpCommand> cr = rescriptCommandProcessor.createCommandResolver(command, tracer); Iterable<ExecutionCommand> executionCommands = cr.resolveExecutionCommands(); ExecutionCommand executionCommand = executionCommands.iterator().next(); TimeConstraints constraints = executionCommand.getTimeConstraints(); assertTrue(constraints.getExpiryTime() < System.currentTimeMillis()); }