@@ -190,7 +190,7 @@ public void testNotWrappedExceptionWithNoFallback() {
190190
191191 assertTrue (command .getExecutionTimeInMilliseconds () > -1 );
192192 assertTrue (command .isFailedExecution ());
193- assertCommandExecutionEvents (command , HystrixEventType .FAILURE );
193+ assertCommandExecutionEvents (command , HystrixEventType .FAILURE , HystrixEventType . FALLBACK_MISSING );
194194 assertNotNull (command .getExecutionException ());
195195 assertTrue (command .getExecutionException () instanceof NotWrappedByHystrixTestRuntimeException );
196196 assertEquals (0 , command .getBuilder ().metrics .getCurrentConcurrentExecutionCount ());
@@ -223,6 +223,28 @@ public void testNotWrappedBadRequestWithNoFallback() {
223223 assertSaneHystrixRequestLog (1 );
224224 }
225225
226+ @ Test
227+ public void testNotWrappedBadRequestWithFallback () throws Exception {
228+ TestHystrixCommand <Integer > command = getCommand (ExecutionIsolationStrategy .THREAD , AbstractTestHystrixCommand .ExecutionResult .BAD_REQUEST_NOT_WRAPPED , AbstractTestHystrixCommand .FallbackResult .SUCCESS );
229+ try {
230+ command .execute ();
231+ fail ("we shouldn't get here" );
232+ } catch (HystrixRuntimeException e ) {
233+ e .printStackTrace ();
234+ fail ("we shouldn't get a HystrixRuntimeException" );
235+ } catch (RuntimeException e ) {
236+ assertTrue (e instanceof NotWrappedByHystrixTestRuntimeException );
237+ }
238+
239+ assertTrue (command .getExecutionTimeInMilliseconds () > -1 );
240+ assertTrue (command .getEventCounts ().contains (HystrixEventType .BAD_REQUEST ));
241+ assertCommandExecutionEvents (command , HystrixEventType .BAD_REQUEST );
242+ assertNotNull (command .getExecutionException ());
243+ assertTrue (command .getExecutionException () instanceof HystrixBadRequestException );
244+ assertTrue (command .getExecutionException ().getCause () instanceof NotWrappedByHystrixTestRuntimeException );
245+ assertEquals (0 , command .getBuilder ().metrics .getCurrentConcurrentExecutionCount ());
246+ assertSaneHystrixRequestLog (1 );
247+ }
226248
227249 /**
228250 * Test a command execution that fails but has a fallback.
@@ -246,20 +268,12 @@ public void testExecutionFailureWithFallback() {
246268 @ Test
247269 public void testNotWrappedExceptionWithFallback () {
248270 TestHystrixCommand <Integer > command = getCommand (ExecutionIsolationStrategy .THREAD , AbstractTestHystrixCommand .ExecutionResult .NOT_WRAPPED_FAILURE , AbstractTestHystrixCommand .FallbackResult .SUCCESS );
249- try {
250- command .execute ();
251- fail ("we shouldn't get here" );
252- } catch (HystrixRuntimeException e ) {
253- e .printStackTrace ();
254- fail ("we shouldn't get a HystrixRuntimeException" );
255- } catch (RuntimeException e ) {
256- assertTrue (e instanceof NotWrappedByHystrixTestRuntimeException );
257- }
271+ assertEquals (FlexibleTestHystrixCommand .FALLBACK_VALUE , command .execute ());
272+ assertEquals ("Raw exception for TestHystrixCommand" , command .getFailedExecutionException ().getMessage ());
258273 assertTrue (command .getExecutionTimeInMilliseconds () > -1 );
259274 assertTrue (command .isFailedExecution ());
260- assertCommandExecutionEvents (command , HystrixEventType .FAILURE );
275+ assertCommandExecutionEvents (command , HystrixEventType .FAILURE , HystrixEventType . FALLBACK_SUCCESS );
261276 assertNotNull (command .getExecutionException ());
262- assertTrue (command .getExecutionException () instanceof NotWrappedByHystrixTestRuntimeException );
263277 assertEquals (0 , command .getBuilder ().metrics .getCurrentConcurrentExecutionCount ());
264278 assertSaneHystrixRequestLog (1 );
265279 }
@@ -2377,7 +2391,7 @@ public void onNext(Boolean args) {
23772391 assertTrue (t .get () instanceof NotWrappedByHystrixTestException );
23782392 assertTrue (command .getExecutionTimeInMilliseconds () > -1 );
23792393 assertTrue (command .isFailedExecution ());
2380- assertCommandExecutionEvents (command , HystrixEventType .FAILURE );
2394+ assertCommandExecutionEvents (command , HystrixEventType .FAILURE , HystrixEventType . FALLBACK_MISSING );
23812395 assertNotNull (command .getExecutionException ());
23822396 assertTrue (command .getExecutionException () instanceof NotWrappedByHystrixTestException );
23832397 assertEquals (0 , command .getBuilder ().metrics .getCurrentConcurrentExecutionCount ());
0 commit comments