Adapt to API and TestContext behavior changes in Spring Framework 5.2.
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.geode.config.annotation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -22,21 +21,17 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link EnableDurableClient} and {@link DurableClientConfiguration}.
|
||||
@@ -44,45 +39,41 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.springframework.context.ConfigurableApplicationContext
|
||||
* @see org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
* @see org.springframework.data.gemfire.client.ClientCacheFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
|
||||
* @see org.springframework.geode.config.annotation.DurableClientConfiguration
|
||||
* @see org.springframework.geode.config.annotation.EnableDurableClient
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class DurableClientConfigurationIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
private static final AtomicReference<ConfigurableApplicationContext> applicationContextReference =
|
||||
new AtomicReference<>(null);
|
||||
private static ConfigurableApplicationContext applicationContext;
|
||||
|
||||
private static final AtomicReference<ClientCache> clientCacheReference =
|
||||
new AtomicReference<>(null);
|
||||
private static ClientCache clientCache;
|
||||
|
||||
@Autowired
|
||||
private ConfigurableApplicationContext applicationContext;
|
||||
private static ClientCacheFactoryBean clientCacheFactoryBean;
|
||||
|
||||
@Autowired
|
||||
private GemFireCache gemfireCache;
|
||||
@BeforeClass
|
||||
public static void newApplicationContext() {
|
||||
|
||||
@Autowired
|
||||
private ClientCacheFactoryBean clientCacheFactoryBean;
|
||||
applicationContext = new AnnotationConfigApplicationContext(TestConfiguration.class);
|
||||
|
||||
clientCache = applicationContext.getBean("gemfireCache", ClientCache.class);
|
||||
|
||||
clientCacheFactoryBean = applicationContext.getBean("&gemfireCache", ClientCacheFactoryBean.class);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void closeApplicationContext() {
|
||||
|
||||
Optional.ofNullable(applicationContextReference.get()).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
ClientCache clientCache = clientCacheReference.get();
|
||||
Optional.ofNullable(applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
assertThat(clientCache).isNotNull();
|
||||
|
||||
@@ -92,30 +83,25 @@ public class DurableClientConfigurationIntegrationTests extends IntegrationTests
|
||||
@Test
|
||||
public void durableClientWasConfiguredSuccessfully() {
|
||||
|
||||
assertThat(this.gemfireCache).isInstanceOf(ClientCache.class);
|
||||
assertThat(this.gemfireCache.getDistributedSystem()).isNotNull();
|
||||
assertThat(this.gemfireCache.getDistributedSystem().getProperties()).isNotNull();
|
||||
assertThat(this.gemfireCache.getDistributedSystem().getProperties().getProperty("durable-client-id"))
|
||||
.isEqualTo("abc123");
|
||||
assertThat(this.gemfireCache.getDistributedSystem().getProperties().getProperty("durable-client-timeout"))
|
||||
.isEqualTo("600");
|
||||
|
||||
applicationContextReference.set(this.applicationContext);
|
||||
clientCacheReference.set((ClientCache) this.gemfireCache);
|
||||
assertThat(clientCache).isInstanceOf(ClientCache.class);
|
||||
assertThat(clientCache.getDistributedSystem()).isNotNull();
|
||||
assertThat(clientCache.getDistributedSystem().getProperties()).isNotNull();
|
||||
assertThat(clientCache.getDistributedSystem().getProperties().getProperty("durable-client-id")).isEqualTo("abc123");
|
||||
assertThat(clientCache.getDistributedSystem().getProperties().getProperty("durable-client-timeout")).isEqualTo("600");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setClientCacheFactoryBeanSetsKeepAliveOnClose() {
|
||||
|
||||
assertThat(this.clientCacheFactoryBean).isNotNull();
|
||||
assertThat(this.clientCacheFactoryBean.isKeepAlive()).isTrue();
|
||||
assertThat(clientCacheFactoryBean).isNotNull();
|
||||
assertThat(clientCacheFactoryBean.isKeepAlive()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setClientCacheFactoryBeanSetsReadyForEventOnContextRefreshedEvent() {
|
||||
|
||||
assertThat(this.clientCacheFactoryBean).isNotNull();
|
||||
assertThat(this.clientCacheFactoryBean.isReadyForEvents()).isTrue();
|
||||
assertThat(clientCacheFactoryBean).isNotNull();
|
||||
assertThat(clientCacheFactoryBean.isReadyForEvents()).isTrue();
|
||||
}
|
||||
|
||||
@ClientCacheApplication
|
||||
|
||||
Reference in New Issue
Block a user