Search in sources :

Example 11 with HystrixConcurrencyStrategy

use of com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy in project Hystrix by Netflix.

the class HystrixRequestCacheTest method testClearCache.

@Test
public void testClearCache() {
    HystrixConcurrencyStrategy strategy = HystrixConcurrencyStrategyDefault.getInstance();
    HystrixRequestContext context = HystrixRequestContext.initializeContext();
    try {
        HystrixRequestCache cache1 = HystrixRequestCache.getInstance(HystrixCommandKey.Factory.asKey("command1"), strategy);
        cache1.putIfAbsent("valueA", new TestObservable("a1"));
        assertEquals("a1", cache1.get("valueA").toObservable().toBlocking().last());
        cache1.clear("valueA");
        assertNull(cache1.get("valueA"));
    } catch (Exception e) {
        fail("Exception: " + e.getMessage());
        e.printStackTrace();
    } finally {
        context.shutdown();
    }
}
Also used : HystrixConcurrencyStrategy(com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy) HystrixRequestContext(com.netflix.hystrix.strategy.concurrency.HystrixRequestContext) Test(org.junit.Test)

Aggregations

HystrixConcurrencyStrategy (com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy)11 Test (org.junit.Test)11 HystrixRequestContext (com.netflix.hystrix.strategy.concurrency.HystrixRequestContext)6