From d3c1a0028851bff7aed73a7f195f48e7ff4246e8 Mon Sep 17 00:00:00 2001 From: Udo Kohlmeyer Date: Wed, 1 Feb 2023 13:35:42 +1100 Subject: [PATCH] Add test to verify product Name is correctly looked up --- spring-data-vmware-gemfire/build.gradle | 3 ++ .../CacheProductNameIntegrationTest.java | 39 +++++++++++++++++++ ...eCanResolveProductNameIntegrationTests.xml | 23 +++++++++++ 3 files changed, 65 insertions(+) create mode 100644 spring-data-vmware-gemfire/src/test/java/com/vmware/gemfire/cache/CacheProductNameIntegrationTest.java create mode 100644 spring-data-vmware-gemfire/src/test/resources/com/vmware/gemfire/cache/cacheCanResolveProductNameIntegrationTests.xml diff --git a/spring-data-vmware-gemfire/build.gradle b/spring-data-vmware-gemfire/build.gradle index 70ffd785..c2db2a3b 100644 --- a/spring-data-vmware-gemfire/build.gradle +++ b/spring-data-vmware-gemfire/build.gradle @@ -34,6 +34,7 @@ dependencies { api "com.vmware.gemfire:geode-lucene:$gemfireVersion" api "com.vmware.gemfire:geode-tcp-server:$gemfireVersion" api "com.vmware.gemfire:geode-deployment-legacy:$gemfireVersion" + api "com.vmware.gemfire:gemfire-version:$gemfireVersion" implementation 'javax.cache:cache-api:1.1.1' implementation 'org.springframework:spring-context-support:5.3.25' @@ -135,3 +136,5 @@ repositories { } } } + +tasks.withType(Copy).all { duplicatesStrategy 'exclude' } diff --git a/spring-data-vmware-gemfire/src/test/java/com/vmware/gemfire/cache/CacheProductNameIntegrationTest.java b/spring-data-vmware-gemfire/src/test/java/com/vmware/gemfire/cache/CacheProductNameIntegrationTest.java new file mode 100644 index 00000000..0456c6d6 --- /dev/null +++ b/spring-data-vmware-gemfire/src/test/java/com/vmware/gemfire/cache/CacheProductNameIntegrationTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) VMware, Inc. 2023. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.vmware.gemfire.cache; + +import org.apache.geode.cache.Cache; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.data.gemfire.GemfireUtils; +import org.springframework.data.gemfire.config.xml.GemfireConstants; + +import java.io.File; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CacheProductNameIntegrationTest { + protected Cache getCache(String configLocation) { + + String baseConfigLocation = + File.separator.concat(getClass().getPackage().getName().replace('.', File.separatorChar)); + + String resolvedConfigLocation = baseConfigLocation.concat(File.separator).concat(configLocation); + + ClassPathXmlApplicationContext applicationContext = + new ClassPathXmlApplicationContext(resolvedConfigLocation); + + return applicationContext.getBean(GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME, Cache.class); + } + + @Test + public void testCacheCanRetrieveProductName() { + System.setProperty("logback.log.level", "info"); + Cache cache = getCache( + "cacheCanResolveProductNameIntegrationTests.xml"); + assertThat(GemfireUtils.apacheGeodeProductName()).isEqualTo("VMware GemFire"); + } +} diff --git a/spring-data-vmware-gemfire/src/test/resources/com/vmware/gemfire/cache/cacheCanResolveProductNameIntegrationTests.xml b/spring-data-vmware-gemfire/src/test/resources/com/vmware/gemfire/cache/cacheCanResolveProductNameIntegrationTests.xml new file mode 100644 index 00000000..38fa12cf --- /dev/null +++ b/spring-data-vmware-gemfire/src/test/resources/com/vmware/gemfire/cache/cacheCanResolveProductNameIntegrationTests.xml @@ -0,0 +1,23 @@ + + + + + + + CacheProductNameIntegrationTest + info + + + +