Skip to content

Commit

Permalink
adds a failing unit test for isResponseTimedOut() when accessed from …
Browse files Browse the repository at this point in the history
…within fallbacks
  • Loading branch information
UnquietCode committed Jun 12, 2013
1 parent 16b004b commit a300d93
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,37 @@ public void cleanup() {
ConfigurationManager.getConfigInstance().clear();
}

@Test
public void testExecutionTimeoutValue() {
HystrixCommand.Setter properties = HystrixCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("TestKey"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationThreadTimeoutInMilliseconds(1000))
;

HystrixCommand<String> command = new HystrixCommand<String>(properties) {
@Override
protected String run() throws Exception {
Thread.sleep(3000);

String value = "1";
value += "23";

// should never reach here
return value;
}

@Override
protected String getFallback() {
assertTrue("expected response to be timed out", isResponseTimedOut());
return "abc";
}
};

assertEquals("expected fallback value", "abc", command.execute());
assertTrue("expected response to be timed out", command.isResponseTimedOut());
}

/**
* Test a successful command execution.
*/
Expand Down

0 comments on commit a300d93

Please sign in to comment.