Java Code Examples for org.ehcache.impl.config.resilience.DefaultResilienceStrategyProviderConfiguration

Following code examples demonstrate how to use org.ehcache.impl.config.resilience.DefaultResilienceStrategyProviderConfiguration from ehcache. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.ehcache.impl.config.resilience.DefaultResilienceStrategyProviderConfiguration and various code implementation of this class.
Example 1
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testDefaultLoaderWriterInstanceReturned() {
    ResilienceStrategy<?, ?> resilienceStrategy = mock(ResilienceStrategy.class);

    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.setDefaultLoaderWriterResilienceStrategy(resilienceStrategy);

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    assertThat(provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class), mock(CacheLoaderWriter.class)), sameInstance(resilienceStrategy));
  }
			
Example 2
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testPreconfiguredInstanceConstructed() {
    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.addResilienceStrategyFor("foo", TestResilienceStrategy.class, "FooBar");

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    ResilienceStrategy<?, ?> resilienceStrategy = provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class));
    assertThat(resilienceStrategy, instanceOf(TestResilienceStrategy.class));
    assertThat(((TestResilienceStrategy) resilienceStrategy).message, is("FooBar"));
  }
			
Example 3
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testDefaultInstanceConstructed() {
    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.setDefaultResilienceStrategy(TestResilienceStrategy.class, "FooBar");

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    ResilienceStrategy<?, ?> resilienceStrategy = provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class));
    assertThat(resilienceStrategy, instanceOf(TestResilienceStrategy.class));
    assertThat(((TestResilienceStrategy) resilienceStrategy).message, is("FooBar"));
  }
			
Example 4
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testDefaultInstanceReturned() {
    ResilienceStrategy<?, ?> resilienceStrategy = mock(ResilienceStrategy.class);

    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.setDefaultResilienceStrategy(resilienceStrategy);

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    assertThat(provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class)), sameInstance(resilienceStrategy));
  }
			
Example 5
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testPreconfiguredLoaderWriterInstanceReturned() {
    ResilienceStrategy<?, ?> resilienceStrategy = mock(ResilienceStrategy.class);

    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.addResilienceStrategyFor("foo", resilienceStrategy);

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    assertThat(provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class), mock(CacheLoaderWriter.class)), sameInstance(resilienceStrategy));
  }
			
Example 6
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testProvidedLoaderWriterInstanceConstructed() {
    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    CacheConfiguration<?, ?> cacheConfiguration = mock(CacheConfiguration.class);
    when(cacheConfiguration.getServiceConfigurations()).thenReturn(Collections.singleton(new DefaultResilienceStrategyConfiguration(TestResilienceStrategy.class, "FooBar")));

    ResilienceStrategy<?, ?> resilienceStrategy = provider.createResilienceStrategy("foo", cacheConfiguration, mock(RecoveryStore.class), mock(CacheLoaderWriter.class));
    assertThat(resilienceStrategy, instanceOf(TestResilienceStrategy.class));
    assertThat(((TestResilienceStrategy) resilienceStrategy).message, is("FooBar"));
  }
			
Example 7
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testProvidedLoaderWriterInstanceReturned() {
    ResilienceStrategy<?, ?> resilienceStrategy = mock(ResilienceStrategy.class);

    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    CacheConfiguration<?, ?> cacheConfiguration = mock(CacheConfiguration.class);
    when(cacheConfiguration.getServiceConfigurations()).thenReturn(Collections.singleton(new DefaultResilienceStrategyConfiguration(resilienceStrategy)));

    assertThat(provider.createResilienceStrategy("foo", cacheConfiguration, mock(RecoveryStore.class), mock(CacheLoaderWriter.class)), sameInstance(resilienceStrategy));
  }
			
Example 8
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testPreconfiguredLoaderWriterInstanceConstructed() {
    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.addResilienceStrategyFor("foo", TestResilienceStrategy.class, "FooBar");

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    ResilienceStrategy<?, ?> resilienceStrategy = provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class), mock(CacheLoaderWriter.class));
    assertThat(resilienceStrategy, instanceOf(TestResilienceStrategy.class));
    assertThat(((TestResilienceStrategy) resilienceStrategy).message, is("FooBar"));
  }
			
Example 9
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testPreconfiguredInstanceReturned() {
    ResilienceStrategy<?, ?> resilienceStrategy = mock(ResilienceStrategy.class);

    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.addResilienceStrategyFor("foo", resilienceStrategy);

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    assertThat(provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class)), sameInstance(resilienceStrategy));
  }
			
Example 10
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testDefaultLoaderWriterInstanceConstructed() {
    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.setDefaultLoaderWriterResilienceStrategy(TestResilienceStrategy.class, "FooBar");

    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    ResilienceStrategy<?, ?> resilienceStrategy = provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class), mock(CacheLoaderWriter.class));
    assertThat(resilienceStrategy, instanceOf(TestResilienceStrategy.class));
    assertThat(((TestResilienceStrategy) resilienceStrategy).message, is("FooBar"));
  }
			
Example 11
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testProvidedInstanceConstructed() {
    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    CacheConfiguration<?, ?> cacheConfiguration = mock(CacheConfiguration.class);
    when(cacheConfiguration.getServiceConfigurations()).thenReturn(Collections.singleton(new DefaultResilienceStrategyConfiguration(TestResilienceStrategy.class, "FooBar")));

    ResilienceStrategy<?, ?> resilienceStrategy = provider.createResilienceStrategy("foo", cacheConfiguration, mock(RecoveryStore.class));
    assertThat(resilienceStrategy, instanceOf(TestResilienceStrategy.class));
    assertThat(((TestResilienceStrategy) resilienceStrategy).message, is("FooBar"));
  }
			
Example 12
Project : ehcache Source File : DefaultResilienceStrategyProviderTest.java View Source Code on GitHub

  public void testProvidedInstanceReturned() {
    ResilienceStrategy<?, ?> resilienceStrategy = mock(ResilienceStrategy.class);

    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    DefaultResilienceStrategyProvider provider = new DefaultResilienceStrategyProvider(configuration);

    CacheConfiguration<?, ?> cacheConfiguration = mock(CacheConfiguration.class);
    when(cacheConfiguration.getServiceConfigurations()).thenReturn(Collections.singleton(new DefaultResilienceStrategyConfiguration(resilienceStrategy)));

    assertThat(provider.createResilienceStrategy("foo", cacheConfiguration, mock(RecoveryStore.class)), sameInstance(resilienceStrategy));
  }
			
Example 13
Project : ehcache Source File : DefaultResilienceStrategyProviderFactoryTest.java View Source Code on GitHub

  public void testSpecifiedConfigIsPassed() {
    ResilienceStrategy resilienceStrategy = mock(ResilienceStrategy.class);

    DefaultResilienceStrategyProviderConfiguration configuration = new DefaultResilienceStrategyProviderConfiguration();
    configuration.setDefaultResilienceStrategy(resilienceStrategy);
    ResilienceStrategyProvider provider = new DefaultResilienceStrategyProviderFactory().create(configuration);

    assertThat(provider.createResilienceStrategy("foo", mock(CacheConfiguration.class), mock(RecoveryStore.class)), sameInstance(resilienceStrategy));
  }
			
Example 14
Project : ehcache Source File : DefaultResilienceStrategyProviderFactory.java View Source Code on GitHub

  public ResilienceStrategyProvider create(ServiceCreationConfiguration<ResilienceStrategyProvider> configuration) {
    if (configuration == null) {
      return new DefaultResilienceStrategyProvider();
    } else if (configuration instanceof DefaultResilienceStrategyProviderConfiguration) {
      return new DefaultResilienceStrategyProvider((DefaultResilienceStrategyProviderConfiguration) configuration);
    } else {
      throw new IllegalArgumentException("Expected a configuration of type DefaultResilienceStrategyProviderConfiguration (or none) but got " + configuration
        .getClass()
        .getName());
    }
  }