@@ -190,7 +190,7 @@ public void testNotWrappedExceptionWithNoFallback() {
190
190
191
191
assertTrue (command .getExecutionTimeInMilliseconds () > -1 );
192
192
assertTrue (command .isFailedExecution ());
193
- assertCommandExecutionEvents (command , HystrixEventType .FAILURE );
193
+ assertCommandExecutionEvents (command , HystrixEventType .FAILURE , HystrixEventType . FALLBACK_MISSING );
194
194
assertNotNull (command .getExecutionException ());
195
195
assertTrue (command .getExecutionException () instanceof NotWrappedByHystrixTestRuntimeException );
196
196
assertEquals (0 , command .getBuilder ().metrics .getCurrentConcurrentExecutionCount ());
@@ -223,6 +223,28 @@ public void testNotWrappedBadRequestWithNoFallback() {
223
223
assertSaneHystrixRequestLog (1 );
224
224
}
225
225
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
+ }
226
248
227
249
/**
228
250
* Test a command execution that fails but has a fallback.
@@ -246,20 +268,12 @@ public void testExecutionFailureWithFallback() {
246
268
@ Test
247
269
public void testNotWrappedExceptionWithFallback () {
248
270
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 ());
258
273
assertTrue (command .getExecutionTimeInMilliseconds () > -1 );
259
274
assertTrue (command .isFailedExecution ());
260
- assertCommandExecutionEvents (command , HystrixEventType .FAILURE );
275
+ assertCommandExecutionEvents (command , HystrixEventType .FAILURE , HystrixEventType . FALLBACK_SUCCESS );
261
276
assertNotNull (command .getExecutionException ());
262
- assertTrue (command .getExecutionException () instanceof NotWrappedByHystrixTestRuntimeException );
263
277
assertEquals (0 , command .getBuilder ().metrics .getCurrentConcurrentExecutionCount ());
264
278
assertSaneHystrixRequestLog (1 );
265
279
}
@@ -2377,7 +2391,7 @@ public void onNext(Boolean args) {
2377
2391
assertTrue (t .get () instanceof NotWrappedByHystrixTestException );
2378
2392
assertTrue (command .getExecutionTimeInMilliseconds () > -1 );
2379
2393
assertTrue (command .isFailedExecution ());
2380
- assertCommandExecutionEvents (command , HystrixEventType .FAILURE );
2394
+ assertCommandExecutionEvents (command , HystrixEventType .FAILURE , HystrixEventType . FALLBACK_MISSING );
2381
2395
assertNotNull (command .getExecutionException ());
2382
2396
assertTrue (command .getExecutionException () instanceof NotWrappedByHystrixTestException );
2383
2397
assertEquals (0 , command .getBuilder ().metrics .getCurrentConcurrentExecutionCount ());
0 commit comments