Fix bug with cache data import when using @EnableClusterAware.

Resolves gh-90.
This commit is contained in:
John Blum
2020-06-09 13:34:12 -07:00
parent 895378be70
commit 1501d7fac6
2 changed files with 10 additions and 19 deletions

View File

@@ -39,7 +39,9 @@ import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.geode.boot.autoconfigure.support.PdxInstanceWrapperRegionAspect;
import org.springframework.geode.cache.SimpleCacheResolver;
import org.springframework.geode.data.AbstractCacheDataImporterExporter;
import org.springframework.geode.data.CacheDataImporterExporter;
import org.springframework.geode.data.json.JsonCacheDataImporterExporter;
import org.springframework.geode.data.support.LifecycleAwareCacheDataImporterExporter;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
@@ -78,8 +80,8 @@ public class DataImportExportAutoConfiguration {
"spring.boot.data.gemfire.cache.region.advice.enabled";
@Bean
JsonCacheDataImporterExporter jsonCacheDataImporterExporter() {
return new JsonCacheDataImporterExporter();
CacheDataImporterExporter jsonCacheDataImporterExporter() {
return new LifecycleAwareCacheDataImporterExporter(new JsonCacheDataImporterExporter());
}
@Bean

View File

@@ -32,20 +32,18 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.GemFireCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.data.gemfire.GemfireTemplate;
import org.springframework.data.gemfire.LocalRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.CacheServerApplication;
import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.geode.boot.autoconfigure.DataImportExportAutoConfiguration;
import org.springframework.geode.config.annotation.EnableClusterAware;
import org.springframework.geode.core.util.ObjectUtils;
import org.springframework.geode.util.CacheUtils;
import org.springframework.test.context.ActiveProfiles;
@@ -76,12 +74,13 @@ import example.app.books.model.ISBN;
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.3.0
*/
@ActiveProfiles("IMPORT")
@ActiveProfiles("IMPORT-CLIENT")
@RunWith(SpringRunner.class)
@SpringBootTest(
classes = ClientCacheDataImportExportAutoConfigurationIntegrationTests.TestGeodeClientConfiguration.class,
properties = {
"spring.boot.data.gemfire.cache.data.import.active-profiles=IMPORT",
"spring.data.gemfire.management.use-http=false",
"spring.boot.data.gemfire.cache.data.import.active-profiles=IMPORT-CLIENT",
"spring.boot.data.gemfire.cache.region.advice.enabled=true"
}
)
@@ -163,8 +162,9 @@ public class ClientCacheDataImportExportAutoConfigurationIntegrationTests
ISBN.of("978-1-492-04034-7"), Author.newAuthor("Alex Petrov").identifiedBy(2L));
}
@Profile("IMPORT")
@Profile("IMPORT-CLIENT")
@SpringBootApplication
@EnableClusterAware
@EnableEntityDefinedRegions(basePackageClasses = Book.class)
static class TestGeodeClientConfiguration { }
@@ -179,16 +179,5 @@ public class ClientCacheDataImportExportAutoConfigurationIntegrationTests
applicationContext.registerShutdownHook();
}
@Bean("Books")
LocalRegionFactoryBean<Object, Object> booksRegion(GemFireCache cache) {
LocalRegionFactoryBean<Object, Object> booksRegion = new LocalRegionFactoryBean<>();
booksRegion.setCache(cache);
booksRegion.setPersistent(false);
return booksRegion;
}
}
}