@Test public void testResolveWithProperty() { CacheProvider testCacheProvider1 = addMockProvider("testCacheProvider1"); CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2"); // Test that the bean specified in the property is used extensions.property(DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider1"); replay(testCacheProvider1, testCacheProvider2); CacheProvider provider = DefaultCacheProvider.findProvider(); assertThat(provider, sameInstance(testCacheProvider1)); verify(testCacheProvider1, testCacheProvider2); // Retry with the property changed to ensure we weren't jsut lucky before reset(testCacheProvider1, testCacheProvider2); extensions.property(DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider2"); replay(testCacheProvider1, testCacheProvider2); provider = DefaultCacheProvider.findProvider(); assertThat(provider, sameInstance(testCacheProvider2)); verify(testCacheProvider1, testCacheProvider2); }
@Test public void testPropertyPriority() { CacheProvider testCacheProvider3 = addMockProvider("testCacheProvider3"); CacheProvider testCacheProvider2 = addMockProvider("testCacheProvider2"); // Test that the bean specified in the property is used extensions.property( DefaultCacheProvider.BEAN_NAME_PROPERTY, "testCacheProvider1,testCacheProvider2,testCacheProvider3"); replay(testCacheProvider3, testCacheProvider2); CacheProvider provider = DefaultCacheProvider.findProvider(); assertThat(provider, sameInstance(testCacheProvider2)); verify(testCacheProvider3, testCacheProvider2); } }