Package com.netflix.hystrix.strategy.concurrency

Examples of com.netflix.hystrix.strategy.concurrency.HystrixRequestContext.shutdown()


            com.netflix.hystrix.HystrixCommand getUserCommand = getHystrixCommandByKey(COMMAND_KEY);
            // will not affect metrics
            assertFalse(getUserCommand.getExecutionEvents().contains(HystrixEventType.FAILURE));
            // and will not trigger fallback logic
            verify(failoverService, never()).getDefUser();
            context.shutdown();
        }
    }

    @Test(expected = NotFoundException.class)
    public void testGetNonExistentUser() throws NotFoundException {
View Full Code Here


            com.netflix.hystrix.HystrixCommand getUserCommand = getHystrixCommandByKey(COMMAND_KEY);
            // will not affect metrics
            assertFalse(getUserCommand.getExecutionEvents().contains(HystrixEventType.FAILURE));
            // and will not trigger fallback logic
            verify(failoverService, never()).getDefUser();
            context.shutdown();
        }
    }

    @Test // don't expect any exceptions because fallback must be triggered
    public void testActivateUser() throws NotFoundException, ActivationException {
View Full Code Here

            // will not affect metrics
            assertTrue(activateUserCommand.getExecutionEvents().contains(HystrixEventType.FAILURE));
            assertTrue(activateUserCommand.getExecutionEvents().contains(HystrixEventType.FALLBACK_SUCCESS));
            // and will not trigger fallback logic
            verify(failoverService, atLeastOnce()).activate();
            context.shutdown();
        }
    }

    @Test(expected = HystrixRuntimeException.class)
    public void testBlockUser() throws NotFoundException, ActivationException, OperationException {
View Full Code Here

            assertEquals(2, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
            com.netflix.hystrix.HystrixCommand activateUserCommand = getHystrixCommandByKey("blockUser");
            // will not affect metrics
            assertTrue(activateUserCommand.getExecutionEvents().contains(HystrixEventType.FAILURE));
            assertTrue(activateUserCommand.getExecutionEvents().contains(HystrixEventType.FALLBACK_FAILURE));
            context.shutdown();
        }
    }

    public static class UserService {
View Full Code Here

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        try {
            chain.doFilter(request, response);
        } finally {
            context.shutdown();
        }
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
View Full Code Here

            // confirm that it was a COLLAPSED command execution
            assertTrue(command.getExecutionEvents().contains(HystrixEventType.COLLAPSED));
            // and that it was successful
            assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS));
        } finally {
            context.shutdown();
        }
    }

    /**
     * This test covers situation when fallback isn't enabled in collapser.
View Full Code Here

            System.out.println(f3.get().getName()); // this line will not be executed
            System.out.println(f4.get().getName()); // this line will not be executed
            System.out.println(f5.get().getName()); // this line will not be executed

        } finally {
            context.shutdown();
        }
    }

    /**
     * This test covers situation when fallback is enabled in collapser.
View Full Code Here

            // confirm that it was a COLLAPSED command execution
            assertTrue(getUserCommand.getExecutionEvents().contains(HystrixEventType.COLLAPSED));
            assertTrue(getUserCommand.getExecutionEvents().contains(HystrixEventType.SUCCESS));

        } finally {
            context.shutdown();
        }
    }


    /**
 
View Full Code Here

            // confirm that it was a COLLAPSED command execution
            assertTrue(getUserCommand.getExecutionEvents().contains(HystrixEventType.COLLAPSED));
            assertTrue(getUserCommand.getExecutionEvents().contains(HystrixEventType.SUCCESS));

        } finally {
            context.shutdown();
        }
    }


    @Test
View Full Code Here

            // confirm that it was a COLLAPSED command execution
            assertTrue(command.getExecutionEvents().contains(HystrixEventType.COLLAPSED));
            // and that it was successful
            assertTrue(command.getExecutionEvents().contains(HystrixEventType.SUCCESS));
        } finally {
            context.shutdown();
        }
    }

    @Test
    public void testCollapserSyncWithFallbackCommand() throws ExecutionException, InterruptedException {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.