Adapt to API and functional changes in Spring Framework 6 to fix tests.

These changes are also possibly applicable to SDG on Spring Framework 5 and are a candidate for backporting.

Resolves gh-538.
This commit is contained in:
John Blum
2021-09-24 18:07:42 -07:00
parent a460b42dcd
commit 02e1a14f9e
86 changed files with 615 additions and 448 deletions

View File

@@ -17,11 +17,11 @@ package org.springframework.data.gemfire;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.DependsOn;
import org.springframework.dao.support.DaoSupport;
import org.springframework.stereotype.Repository;
@@ -46,16 +46,20 @@ import org.springframework.stereotype.Repository;
@SuppressWarnings("unused")
public class AutoRegionLookupDao extends DaoSupport {
@Resource(name = "NativePartitionedRegion")
@Autowired
@Qualifier("NativePartitionedRegion")
private Region<?, ?> nativePartitionedRegion;
@Resource(name = "NativeReplicateParent")
@Autowired
@Qualifier("NativeReplicateParent")
private Region<?, ?> nativeReplicateParent;
@Resource(name = "/NativeReplicateParent/NativeReplicateChild")
@Autowired
@Qualifier("/NativeReplicateParent/NativeReplicateChild")
private Region<?, ?> nativeReplicateChild;
@Resource(name = "/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild")
@Autowired
@Qualifier("/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild")
private Region<?, ?> nativeReplicateGrandchild;
protected static void assertRegionMetaData(Region<?, ?> region, String expectedName, DataPolicy expectedDataPolicy) {

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,6 +24,7 @@ import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;
@@ -87,16 +86,20 @@ public class AutoRegionLookupWithAutowiringIntegrationTests extends IntegrationT
@Component
public static final class TestComponent {
@Resource(name = "NativePartitionedRegion")
@Autowired
@Qualifier("NativePartitionedRegion")
Region<?, ?> nativePartitionedRegion;
@Resource(name = "NativeReplicateParent")
@Autowired
@Qualifier("NativeReplicateParent")
Region<?, ?> nativeReplicateParent;
@Resource(name = "/NativeReplicateParent/NativeReplicateChild")
@Autowired
@Qualifier("/NativeReplicateParent/NativeReplicateChild")
Region<?, ?> nativeReplicateChild;
@Resource(name = "/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild")
@Autowired
@Qualifier("/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild")
Region<?, ?> nativeReplicateGrandchild;
}

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -28,6 +26,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.server.CacheServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -64,7 +63,7 @@ public class CacheServerIntegrationTests extends IntegrationTestsSupport {
path.delete();
}
@Resource(name = "testCacheServer")
@Autowired
private CacheServer cacheServer;
@BeforeClass

View File

@@ -17,16 +17,15 @@ package org.springframework.data.gemfire;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
@@ -43,15 +42,16 @@ import org.springframework.test.context.junit4.SpringRunner;
* @since 1.3.3
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(value = "colocated-region.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@GemFireUnitTest
@SuppressWarnings("unused")
public class CollocatedRegionIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "colocatedRegion")
@Autowired
@Qualifier("colocatedRegion")
private Region<?, ?> colocatedRegion;
@Resource(name = "sourceRegion")
@Autowired
@Qualifier("sourceRegion")
private Region<?, ?> sourceRegion;
protected static void assertRegionExists(String expectedRegionName, Region<?, ?> region) {

View File

@@ -19,17 +19,16 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Map;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.DiskStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
@@ -48,18 +47,28 @@ import org.springframework.test.context.junit4.SpringRunner;
* @since 1.3.4
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "diskstore-using-propertyplaceholders-config.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@GemFireUnitTest
@SuppressWarnings("unused")
public class DiskStoreBeanUsingPropertyPlaceholdersIntegrationTests extends IntegrationTestsSupport {
@Autowired
private DiskStore testDataStore;
@Resource(name="diskStoreConfiguration")
private Map<String, Object> diskStoreConfiguration;
@Autowired
@Qualifier("diskStoreConfiguration")
private Map<Object, Object> diskStoreConfiguration;
private Object getExpectedValue(final String propertyPlaceholderName) {
@Before
public void assertDiskStoreConfiguration() {
//System.err.printf("Map of Type [%s]%n", ObjectUtils.nullSafeClassName(this.diskStoreConfiguration));
//System.err.printf("Map with Contents [%s]%n", this.diskStoreConfiguration);
assertThat(this.diskStoreConfiguration).isNotNull();
assertThat(String.valueOf(this.diskStoreConfiguration.get("allowForceCompaction"))).isEqualTo("false");
assertThat(String.valueOf(this.diskStoreConfiguration.get("writeBufferSize"))).isEqualTo("65536");
}
private Object getExpectedValue(String propertyPlaceholderName) {
return this.diskStoreConfiguration.get(propertyPlaceholderName);
}

View File

@@ -27,8 +27,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,6 +36,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.query.SelectResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -91,7 +90,8 @@ public class GemfireTemplateIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemfireTemplate usersTemplate;
@Resource(name = "Users")
@Autowired
@Qualifier("Users")
private Region<String, User> users;
private static User newUser(String username) {
@@ -453,12 +453,11 @@ public class GemfireTemplateIntegrationTests extends IntegrationTestsSupport {
}
@Bean(name = "Users")
LocalRegionFactoryBean<Object, Object> usersRegion(GemFireCache gemfireCache) {
LocalRegionFactoryBean<String, User> usersRegion(GemFireCache gemfireCache) {
LocalRegionFactoryBean<Object, Object> usersRegion = new LocalRegionFactoryBean<>();
LocalRegionFactoryBean<String, User> usersRegion = new LocalRegionFactoryBean<>();
usersRegion.setCache(gemfireCache);
usersRegion.setClose(false);
usersRegion.setPersistent(false);
return usersRegion;

View File

@@ -23,9 +23,6 @@ import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -51,6 +48,7 @@ import org.springframework.data.gemfire.server.CacheServerFactoryBean;
import org.springframework.data.gemfire.support.ConnectionEndpoint;
import org.springframework.data.gemfire.support.ConnectionEndpointList;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.data.gemfire.tests.objects.geode.cache.RegionDataInitializingPostProcessor;
import org.springframework.data.gemfire.tests.process.ProcessWrapper;
import org.springframework.data.gemfire.util.PropertiesBuilder;
import org.springframework.test.context.ContextConfiguration;
@@ -331,23 +329,6 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
runSpringApplication(GemFireCacheServerOneConfiguration.class, args);
}
@Resource(name = "Cats")
private org.apache.geode.cache.Region<String, Cat> cats;
private Cat save(Cat cat) {
cats.put(cat.getName(), cat);
return cat;
}
@PostConstruct
public void postConstruct() {
save(Cat.newCat("Grey"));
save(Cat.newCat("Patchit"));
save(Cat.newCat("Tyger"));
save(Cat.newCat("Molly"));
save(Cat.newCat("Sammy"));
}
@Override
String groups() {
return "serverOne";
@@ -359,15 +340,27 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
}
@Bean(name = "Cats")
LocalRegionFactoryBean catsRegion(GemFireCache gemfireCache) {
LocalRegionFactoryBean<String, Cat> catsRegion(GemFireCache gemfireCache) {
LocalRegionFactoryBean catsRegion = new LocalRegionFactoryBean();
LocalRegionFactoryBean<String, Cat> catsRegion = new LocalRegionFactoryBean();
catsRegion.setCache(gemfireCache);
catsRegion.setPersistent(false);
return catsRegion;
}
@Bean
RegionDataInitializingPostProcessor<Cat> catsRegionDataInitializer() {
return RegionDataInitializingPostProcessor.<Cat>withRegion("Cats")
.useAsEntityIdentifier(Cat::getName)
.store(Cat.newCat("Grey"))
.store(Cat.newCat("Patchit"))
.store(Cat.newCat("Tyger"))
.store(Cat.newCat("Molly"))
.store(Cat.newCat("Sammy"));
}
}
@Configuration
@@ -378,20 +371,6 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
runSpringApplication(GemFireCacheServerTwoConfiguration.class, args);
}
@Resource(name = "Dogs")
private org.apache.geode.cache.Region<String, Dog> dogs;
private Dog save(Dog dog) {
dogs.put(dog.getName(), dog);
return dog;
}
@PostConstruct
public void postConstruct() {
save(Dog.newDog("Spuds"));
save(Dog.newDog("Maha"));
}
@Override
String groups() {
return "serverTwo";
@@ -407,5 +386,14 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
return dogsRegion;
}
@Bean
RegionDataInitializingPostProcessor<Dog> dogsRegionDataInitializer() {
return RegionDataInitializingPostProcessor.<Dog>withRegion("Dogs")
.useAsEntityIdentifier(Dog::getName)
.store(Dog.newDog("Spuds"))
.store(Dog.newDog("Maha"));
}
}
}

View File

@@ -25,8 +25,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,6 +49,8 @@ import org.apache.geode.cache.asyncqueue.AsyncEventListener;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -74,7 +74,8 @@ import org.springframework.util.StringUtils;
@SuppressWarnings("unused")
public class LookupPartitionRegionMutationIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<?, ?> example;
private void assertCacheListeners(CacheListener<?, ?>[] cacheListeners,

View File

@@ -24,8 +24,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,6 +48,8 @@ import org.apache.geode.cache.asyncqueue.AsyncEventListener;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -73,7 +73,8 @@ import org.springframework.util.StringUtils;
@SuppressWarnings("unused")
public class LookupRegionMutationIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<?, ?> example;
private void assertCacheListeners(CacheListener<?, ?>[] cacheListeners,

View File

@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.io.Serializable;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -31,6 +29,8 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.DiskStore;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
@@ -62,7 +62,8 @@ public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
protected static final int NUMBER_OF_REGION_ENTRIES = 1000;
@Resource(name = "pdxDataRegion")
@Autowired
@Qualifier("pdxDataRegion")
private Region<KeyHolder<String>, ValueHolder<Integer>> pdxDataRegion;
protected static void assertRegionExists(String expectedRegionName, String expectedRegionPath, Region<?, ?> region) {

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,6 +26,8 @@ import org.apache.geode.cache.EvictionAlgorithm;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.data.gemfire.util.RegionUtils;
@@ -52,28 +52,36 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "LocalWithDataPolicy")
@Autowired
@Qualifier("LocalWithDataPolicy")
private Region<?, ?> localWithDataPolicy;
@Resource(name = "LocalWithShortcut")
@Autowired
@Qualifier("LocalWithShortcut")
private Region<?, ?> localWithShortcut;
@Resource(name = "PartitionWithDataPolicy")
@Autowired
@Qualifier("PartitionWithDataPolicy")
private Region<?, ?> partitionWithDataPolicy;
@Resource(name = "PartitionWithShortcut")
@Autowired
@Qualifier("PartitionWithShortcut")
private Region<?, ?> partitionWithShortcut;
@Resource(name = "ReplicateWithDataPolicy")
@Autowired
@Qualifier("ReplicateWithDataPolicy")
private Region<?, ?> replicateWithDataPolicy;
@Resource(name = "ReplicateWithShortcut")
@Autowired
@Qualifier("ReplicateWithShortcut")
private Region<?, ?> replicateWithShortcut;
@Resource(name = "ShortcutDefaults")
@Autowired
@Qualifier("ShortcutDefaults")
private Region<?, ?> shortcutDefaults;
@Resource(name = "ShortcutOverrides")
@Autowired
@Qualifier("ShortcutOverrides")
private Region<?, ?> shortcutOverrides;
@Test

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,6 +31,7 @@ import org.apache.geode.cache.Scope;
import org.apache.geode.cache.SubscriptionAttributes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -58,10 +57,12 @@ public class SubRegionIntegrationTests extends IntegrationTestsSupport {
@Autowired
private Cache cache;
@Resource(name = "Customers")
@Autowired
@Qualifier("Customers")
private Region customers;
@Resource(name = "/Customers/Accounts")
@Autowired
@Qualifier("/Customers/Accounts")
private Region accounts;
@Test

View File

@@ -19,11 +19,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Map;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
@@ -49,10 +49,12 @@ import org.springframework.transaction.annotation.Transactional;
@SuppressWarnings("unused")
public class TxIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "rollback-region")
@Autowired
@Qualifier("rollback-region")
private Map<String, String> rollbackRegion;
@Resource(name = "commit-region")
@Autowired
@Qualifier("commit-region")
private Map<String, String> commitRegion;
private boolean txCommit = false;

View File

@@ -22,8 +22,6 @@ import java.io.Serializable;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +30,7 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
@@ -92,7 +91,8 @@ public class CompoundCachePutCacheEvictIntegrationTests extends IntegrationTests
@Autowired
private EmployeeService employeeService;
@Resource(name = "Employees")
@Autowired
@Qualifier("Employees")
private org.apache.geode.cache.Region<Long, Employee> employeesRegion;
private void assertNoEmployeeInDepartment(Department department) {

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.client;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,6 +28,8 @@ import org.apache.geode.cache.LoaderHelper;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.fork.ServerProcess;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
@@ -60,7 +60,8 @@ public class ClientCachePoolIntegrationTests extends ForkingClientServerIntegrat
getServerContextXmlFileLocation(ClientCachePoolIntegrationTests.class));
}
@Resource(name = "Factorials")
@Autowired
@Qualifier("Factorials")
private Region<Long, Long> factorials;
@Test

View File

@@ -21,8 +21,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +30,8 @@ import org.apache.geode.cache.CacheLoaderException;
import org.apache.geode.cache.LoaderHelper;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.gemfire.fork.ServerProcess;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
@@ -74,7 +74,8 @@ public class ClientCacheSecurityIntegrationTests extends ForkingClientServerInte
System.setProperty("javax.net.ssl.keyStore", trustedKeystore.getFile().getAbsolutePath());
}
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<String, String> example;
@Test

View File

@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -34,6 +32,8 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.Pool;
import org.apache.geode.cache.client.PoolManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.fork.ServerProcess;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
@@ -68,7 +68,8 @@ public class ClientCacheVariableLocatorsIntegrationTests extends ForkingClientSe
getServerContextXmlFileLocation(ClientCacheVariableLocatorsIntegrationTests.class));
}
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<String, Integer> example;
@Before

View File

@@ -24,8 +24,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -40,6 +38,7 @@ import org.apache.geode.cache.client.Pool;
import org.apache.geode.cache.server.CacheServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
@@ -98,7 +97,8 @@ public class ClientCacheVariableServersIntegrationTests extends ForkingClientSer
@Autowired
private Pool serverPool;
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<String, Integer> example;
@Before

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.client;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,6 +25,8 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
@@ -53,7 +53,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class ClientRegionIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<Object, Object> example;
@Test

View File

@@ -21,8 +21,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,6 +34,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.util.CacheWriterAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
@@ -66,7 +65,8 @@ public class ClientRegionWithCacheLoaderCacheWriterIntegrationTests extends Inte
@Autowired
private ApplicationContext applicationContext;
@Resource(name = "localAppDataRegion")
@Autowired
@Qualifier("localAppDataRegion")
private Region<Integer, Integer> localAppData;
@Test

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.client;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,6 +25,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.GemfireTemplate;
import org.springframework.data.gemfire.fork.ServerProcess;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
@@ -59,16 +58,20 @@ public class ClientSubRegionIntegrationTests extends ForkingClientServerIntegrat
@Autowired
private ClientCache clientCache;
@Resource(name = "parentTemplate")
@Autowired
@Qualifier("parentTemplate")
private GemfireTemplate parentTemplate;
@Resource(name = "childTemplate")
@Autowired
@Qualifier("childTemplate")
private GemfireTemplate childTemplate;
@Resource(name = "Parent")
@Autowired
@Qualifier("Parent")
private Region<?, ?> parent;
@Resource(name = "/Parent/Child")
@Autowired
@Qualifier("/Parent/Child")
private Region<?, ?> child;
private void assertRegion(Region<?, ?> region, String name) {

View File

@@ -30,8 +30,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -52,6 +50,7 @@ import org.apache.geode.cache.util.CacheListenerAdapter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.data.gemfire.fork.ServerProcess;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
@@ -122,7 +121,8 @@ public class DurableClientCacheIntegrationTests extends ForkingClientServerInteg
@Autowired
private ClientCache clientCache;
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<String, Integer> example;
@Before

View File

@@ -21,8 +21,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -32,6 +30,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.fork.ServerProcess;
@@ -91,13 +90,16 @@ public class GemFireDataSourceIntegrationTest extends ForkingClientServerIntegra
@Autowired
private ClientCache gemfireClientCache;
@Resource(name = "ClientOnlyRegion")
@Autowired
@Qualifier("ClientOnlyRegion")
private Region clientOnlyRegion;
@Resource(name = "ClientServerRegion")
@Autowired
@Qualifier("ClientServerRegion")
private Region clientServerRegion;
@Resource(name = "ServerOnlyRegion")
@Autowired
@Qualifier("ServerOnlyRegion")
private Region serverOnlyRegion;
@SuppressWarnings("unchecked")

View File

@@ -23,7 +23,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.junit.AfterClass;
@@ -36,6 +35,7 @@ import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.distributed.ServerLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.gemfire.GemfireUtils;
@@ -147,13 +147,16 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
@Autowired
private ClientCache gemfireClientCache;
@Resource(name = "LocalRegion")
@Autowired
@Qualifier("LocalRegion")
private Region localRegion;
@Resource(name = "ServerRegion")
@Autowired
@Qualifier("ServerRegion")
private Region serverRegion;
@Resource(name = "AnotherServerRegion")
@Autowired
@Qualifier("AnotherServerRegion")
private Region anotherServerRegion;
@SuppressWarnings("unchecked")

View File

@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.time.Month;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,6 +29,8 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions;
@@ -58,7 +58,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class LocalOnlyClientCacheIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "People")
@Autowired
@Qualifier("People")
private Region<Long, Person> people;
@Before

View File

@@ -19,14 +19,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Properties;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.client.ClientCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
@@ -54,7 +53,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class SpringJavaConfiguredClientCacheIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "&clientCache")
@Autowired
@Qualifier("&clientCache")
private ClientCacheFactoryBean clientCacheFactoryBean;
@Autowired

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.client.support;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -76,10 +74,12 @@ public class PoolManagerPoolResolverIntegrationTests extends IntegrationTestsSup
private final PoolResolver poolResolver = new PoolManagerPoolResolver();
@Resource(name = "RegionWithDefaultPool")
@Autowired
@Qualifier("RegionWithDefaultPool")
private Region<?, ?> regionWithDefaultPool;
@Resource(name = "RegionWithSwimmingPool")
@Autowired
@Qualifier("RegionWithSwimmingPool")
private Region<?, ?> regionWithSwimmingPool;
@Before

View File

@@ -29,7 +29,6 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -48,6 +47,7 @@ import org.apache.geode.security.NotAuthorizedException;
import org.apache.geode.security.ResourcePermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
@@ -124,7 +124,8 @@ public abstract class AbstractGeodeSecurityIntegrationTests extends ForkingClien
System.clearProperty(GEODE_SECURITY_PROFILE_PROPERTY);
}
@Resource(name = "Echo")
@Autowired
@Qualifier("Echo")
private Region<String, String> echo;
@Test

View File

@@ -22,14 +22,14 @@ import static org.mockito.Mockito.verify;
import java.util.Arrays;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.InterestResultPolicy;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.Lifecycle;
import org.springframework.context.annotation.Bean;
@@ -67,10 +67,12 @@ public class CachingDefinedRegionsRegistersInterestsIntegrationTests extends Int
private static final Interest testInterest =
new Interest<>("TestKey", InterestResultPolicy.KEYS_VALUES, false, true);
@Resource(name = "CacheOne")
@Autowired
@Qualifier("CacheOne")
private Region cacheOne;
@Resource(name = "CacheTwo")
@Autowired
@Qualifier("CacheTwo")
private Region cacheTwo;
@Test

View File

@@ -22,8 +22,6 @@ import java.util.Collections;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -34,6 +32,7 @@ import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Bean;
@@ -74,16 +73,20 @@ public class CachingDefinedRegionsUsesCacheConfigCacheNamesIntegrationTests exte
@Autowired
private TestCacheableService service;
@Resource(name = "A")
@Autowired
@Qualifier("A")
private Region<Object, Object> a;
@Resource(name = "B")
@Autowired
@Qualifier("B")
private Region<Object, Object> b;
@Resource(name = "C")
@Autowired
@Qualifier("C")
private Region<Object, Object> c;
@Resource(name = "D")
@Autowired
@Qualifier("D")
private Region<Object, Object> d;
@Before

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +27,8 @@ import org.apache.geode.cache.LoaderHelper;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
@@ -55,7 +55,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class ClientCacheApplicationIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Echo")
@Autowired
@Qualifier("Echo")
private Region<String, String> echo;
@Test

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,6 +31,7 @@ import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
@@ -70,7 +69,8 @@ public class ClientServerCacheApplicationIntegrationTests extends ForkingClientS
@Autowired
private ClientCache clientCache;
@Resource(name = "Echo")
@Autowired
@Qualifier("Echo")
private Region<String, String> echo;
@Test

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -74,13 +72,16 @@ public class EnableClusterDefinedRegionsIntegrationTests extends ForkingClientSe
@Autowired
private ClientCache cache;
@Resource(name = "LocalRegion")
@Autowired
@Qualifier("LocalRegion")
private Region<?, ?> localClientProxyRegion;
@Resource(name = "PartitionRegion")
@Autowired
@Qualifier("PartitionRegion")
private Region<?, ?> partitionClientProxyRegion;
@Resource(name = "ReplicateRegion")
@Autowired
@Qualifier("ReplicateRegion")
private Region<?, ?> replicateClientProxyRegion;
private void assertRegion(Region<?, ?> region, String expectedName) {

View File

@@ -22,8 +22,6 @@ import java.io.Serializable;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -41,6 +39,8 @@ import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.query.CqEvent;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -89,7 +89,8 @@ public class EnableContinuousQueriesConfigurationIntegrationTests extends Forkin
startGemFireServer(GeodeServerTestConfiguration.class);
}
@Resource(name = "TemperatureReadings")
@Autowired
@Qualifier("TemperatureReadings")
private Region<Long, TemperatureReading> temperatureReadings;
@Before

View File

@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collection;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +27,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.DependsOn;
import org.springframework.data.gemfire.search.lucene.ProjectingLuceneOperations;
@@ -59,7 +58,8 @@ public class EnableLuceneIndexingConfigurationIntegrationTests extends Integrati
@Autowired
private ProjectingLuceneOperations luceneTemplate;
@Resource(name = "Books")
@Autowired
@Qualifier("Books")
private Region<Long, Book> books;
@Before

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,6 +25,8 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.query.Index;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.gemfire.GemfireUtils;
@@ -58,13 +58,16 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class EnableOqlIndexingConfigurationIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "People")
@Autowired
@Qualifier("People")
private Region<Long, Person> people;
@Resource(name = "PeopleIdKeyIdx")
@Autowired
@Qualifier("PeopleIdKeyIdx")
private Index personIdKeyIndex;
@Resource(name = "PeopleLastNameFunctionalIdx")
@Autowired
@Qualifier("PeopleLastNameFunctionalIdx")
private Index personLastNameHashIndex;
@Test

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,6 +28,8 @@ import org.apache.geode.cache.LoaderHelper;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
@@ -64,7 +64,8 @@ public class EnableSslConfigurationIntegrationTests extends ForkingClientServerI
private static ProcessWrapper gemfireServer;
@Resource(name = "Echo")
@Autowired
@Qualifier("Echo")
private Region<String, String> echo;
@BeforeClass

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +27,8 @@ import org.apache.geode.cache.CacheLoaderException;
import org.apache.geode.cache.LoaderHelper;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
@@ -52,7 +52,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("all")
public class PeerCacheApplicationIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Echo")
@Autowired
@Qualifier("Echo")
private Region<String, String> echo;
@Test

View File

@@ -21,8 +21,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
@@ -33,6 +31,8 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.support.RegionDataAccessTracingAspect;
@@ -82,7 +82,8 @@ public class RegionDataAccessTracingAspectUnitTests extends IntegrationTestsSupp
TestAppender.getInstance().clear();
}
@Resource(name = "ClientRegion")
@Autowired
@Qualifier("ClientRegion")
private Region<Object, Object> region;
private Runnable regionCallbackArgument(AtomicBoolean called) {

View File

@@ -24,8 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -94,7 +92,8 @@ public class DefinedIndexesIntegrationTests extends IntegrationTestsSupport {
@Qualifier("NameIdx")
private Index name;
@Resource(name = "People")
@Autowired
@Qualifier("People")
private Region<Long, Person> people;
protected static Person put(Region<Long, Person> people, Person person) {

View File

@@ -21,8 +21,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,6 +33,8 @@ import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter;
import org.apache.geode.cache.wan.GatewayQueueEvent;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -59,13 +59,16 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("all")
public class AsyncEventQueueNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "TestAsyncEventQueue")
@Autowired
@Qualifier("TestAsyncEventQueue")
private AsyncEventQueue asyncEventQueue;
@Resource(name = "TestAsyncEventQueueWithFilters")
@Autowired
@Qualifier("TestAsyncEventQueueWithFilters")
private AsyncEventQueue asyncEventQueueWithFilters;
@Resource(name = "TestPausedAsyncEventQueue")
@Autowired
@Qualifier("TestPausedAsyncEventQueue")
private AsyncEventQueue pausedAsyncEventQueue;
@Test

View File

@@ -22,8 +22,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;
import javax.annotation.Resource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,6 +31,7 @@ import org.apache.geode.cache.query.CqListener;
import org.apache.geode.cache.query.CqQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.TestUtils;
import org.springframework.data.gemfire.fork.CqCacheServerProcess;
import org.springframework.data.gemfire.listener.ContinuousQueryListener;
@@ -76,10 +75,12 @@ public class ContinuousQueryListenerContainerNamespaceIntegrationTests
@Autowired
private ContinuousQueryListenerContainer container;
@Resource(name = "testErrorHandler")
@Autowired
@Qualifier("testErrorHandler")
private ErrorHandler testErrorHandler;
@Resource(name = "testTaskExecutor")
@Autowired
@Qualifier("testTaskExecutor")
private Executor testTaskExecutor;
@Test

View File

@@ -17,13 +17,13 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
@@ -50,13 +50,14 @@ import org.springframework.util.StringUtils;
* @since 1.5.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "GatewayReceiverNamespaceTest-context.xml",
@ContextConfiguration(locations = "GatewayReceiverNamespaceIntegrationTests-context.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ActiveProfiles("autoStart")
@SuppressWarnings("unused")
public class GatewayReceiverAutoStartNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "&Auto")
@Autowired
@Qualifier("&Auto")
private GatewayReceiverFactoryBean autoGatewayReceiverFactory;
@Test

View File

@@ -17,13 +17,13 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
@@ -51,12 +51,13 @@ import org.springframework.util.StringUtils;
*/
@ActiveProfiles("defaultStart")
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "GatewayReceiverNamespaceTest-context.xml",
@ContextConfiguration(locations = "GatewayReceiverNamespaceIntegrationTests-context.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@SuppressWarnings("unused")
public class GatewayReceiverDefaultStartNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "&Default")
@Autowired
@Qualifier("&Default")
private GatewayReceiverFactoryBean defaultGatewayReceiverFactory;
@Test

View File

@@ -17,13 +17,13 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
@@ -49,20 +49,22 @@ import org.springframework.test.context.junit4.SpringRunner;
* @since 1.5.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "GatewayReceiverNamespaceTest-context.xml",
@ContextConfiguration(locations = "GatewayReceiverNamespaceIntegrationTests-context.xml",
initializers = GemFireMockObjectsApplicationContextInitializer.class)
@ActiveProfiles("manualStart")
@SuppressWarnings("unused")
public class GatewayReceiverManualStartNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "&Manual")
@Autowired
@Qualifier("&Manual")
private GatewayReceiverFactoryBean manualGatewayReceiverFactory;
@Test
public void testManual() throws Exception {
assertThat(this.manualGatewayReceiverFactory)
.as("The 'Manual' GatewayReceiverFactoryBean was not properly configured and initialized!").isNotNull();
.describedAs("The 'Manual' GatewayReceiverFactoryBean was not properly configured and initialized!")
.isNotNull();
GatewayReceiver manualGatewayReceiver = this.manualGatewayReceiverFactory.getObject();

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,6 +24,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.query.Index;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.IndexFactoryBean;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
@@ -42,10 +41,12 @@ public class IndexNamespaceIntegrationTests extends IntegrationTestsSupport {
@Autowired
private ApplicationContext applicationContext;
@Resource(name = "basic")
@Autowired
@Qualifier("basic")
private Index basic;
@Resource(name = "complex")
@Autowired
@Qualifier("complex")
private Index complex;
@Test

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,6 +25,8 @@ import org.apache.geode.cache.EvictionAction;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.Scope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -50,13 +50,16 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class LocalRegionWithEvictionPolicyActionNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "LocalDestroy")
@Autowired
@Qualifier("LocalDestroy")
private Region<?, ?> localDestroyRegion;
@Resource(name = "None")
@Autowired
@Qualifier("None")
private Region<?, ?> noneRegion;
@Resource(name = "Overflow")
@Autowired
@Qualifier("Overflow")
private Region<?, ?> overflowRegion;
@Test

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,6 +28,8 @@ import org.apache.geode.cache.asyncqueue.AsyncEventListener;
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.support.AbstractFactoryBeanSupport;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.lang.Nullable;
@@ -54,7 +54,8 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class LookupRegionWithAsyncEventQueuesAndGatewaySendersIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<?, ?> example;
@Test

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,6 +26,8 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.ResumptionAction;
import org.apache.geode.distributed.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -50,10 +50,12 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings({ "deprecation", "unused" })
public class MembershipAttributesIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "secure")
@Autowired
@Qualifier("secure")
private Region<?, ?> secure;
@Resource(name = "simple")
@Autowired
@Qualifier("simple")
private Region<?, ?> simple;
@Test

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,6 +26,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.PeerRegionFactoryBean;
import org.springframework.data.gemfire.TestUtils;
@@ -61,10 +60,12 @@ public class RegionDefinitionUsingBeansNamespaceIntegrationTests extends Integra
@Autowired
private ApplicationContext applicationContext;
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<?, ?> example;
@Resource(name = "AnotherExample")
@Autowired
@Qualifier("AnotherExample")
private Region<?, ?> anotherExample;
@Test

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,6 +26,8 @@ import org.apache.geode.cache.EvictionAlgorithm;
import org.apache.geode.cache.EvictionAttributes;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -51,22 +51,28 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class RegionEvictionAttributesNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "One")
@Autowired
@Qualifier("One")
private Region<?, ?> one;
@Resource(name = "Two")
@Autowired
@Qualifier("Two")
private Region<?, ?> two;
@Resource(name = "Three")
@Autowired
@Qualifier("Three")
private Region<?, ?> three;
@Resource(name = "Four")
@Autowired
@Qualifier("Four")
private Region<?, ?> four;
@Resource(name = "Five")
@Autowired
@Qualifier("Five")
private Region<?, ?> five;
@Resource(name = "Six")
@Autowired
@Qualifier("Six")
private Region<?, ?> six;
@Test

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +27,8 @@ import org.apache.geode.cache.ExpirationAction;
import org.apache.geode.cache.ExpirationAttributes;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -53,16 +53,20 @@ import org.springframework.util.Assert;
@SuppressWarnings("unused")
public class RegionExpirationAttributesNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "ReplicateExample")
@Autowired
@Qualifier("ReplicateExample")
private Region<?, ?> replicateExample;
@Resource(name = "PreloadedExample")
@Autowired
@Qualifier("PreloadedExample")
private Region<?, ?> preloadedExample;
@Resource(name = "PartitionExample")
@Autowired
@Qualifier("PartitionExample")
private Region<?, ?> partitionExample;
@Resource(name = "LocalExample")
@Autowired
@Qualifier("LocalExample")
private Region<?, ?> localExample;
private void assertRegionMetaData(final Region<?, ?> region, final String regionName, final DataPolicy dataPolicy) {

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,6 +25,8 @@ import org.apache.geode.cache.InterestPolicy;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.SubscriptionAttributes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -52,16 +52,20 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class RegionSubscriptionAttributesNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "NoSubscriptionRegion")
@Autowired
@Qualifier("NoSubscriptionRegion")
private Region<?, ?> noSubscriptionRegion;
@Resource(name = "AllSubscriptionRegion")
@Autowired
@Qualifier("AllSubscriptionRegion")
private Region<?, ?> allSubscriptionRegion;
@Resource(name = "CacheContentSubscriptionRegion")
@Autowired
@Qualifier("CacheContentSubscriptionRegion")
private Region<?, ?> cacheContentSubscriptionRegion;
@Resource(name = "DefaultSubscriptionRegion")
@Autowired
@Qualifier("DefaultSubscriptionRegion")
private Region<?, ?> defaultSubscriptionRegion;
private void assertSubscription(Region<?, ?> region, String expectedRegionName,

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,6 +25,8 @@ import org.apache.geode.cache.DiskStore;
import org.apache.geode.cache.EvictionAction;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -49,16 +49,20 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class RegionsWithDiskStoreAndPersistenceEvictionSettingsIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "NotPersistentNoOverflowRegion")
@Autowired
@Qualifier("NotPersistentNoOverflowRegion")
private Region<?, ?> notPersistentNoOverflowRegion;
@Resource(name = "NotPersistentOverflowRegion")
@Autowired
@Qualifier("NotPersistentOverflowRegion")
private Region<?, ?> notPersistentOverflowRegion;
@Resource(name = "PersistentNoOverflowRegion")
@Autowired
@Qualifier("PersistentNoOverflowRegion")
private Region<?, ?> persistentNoOverflowRegion;
@Resource(name = "PersistentOverflowRegion")
@Autowired
@Qualifier("PersistentOverflowRegion")
private Region<?, ?> persistentOverflowRegion;
@Test

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,6 +28,8 @@ import org.apache.geode.cache.asyncqueue.AsyncEvent;
import org.apache.geode.cache.asyncqueue.AsyncEventListener;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -54,10 +54,12 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class SubRegionSubElementNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "/Customers/Accounts")
@Autowired
@Qualifier("/Customers/Accounts")
private Region<?, ?> customersAccountsRegion;
@Resource(name = "/Parent/Child")
@Autowired
@Qualifier("/Parent/Child")
private Region<?, ?> parentChildRegion;
@Test

View File

@@ -20,8 +20,6 @@ import static org.junit.Assume.assumeNotNull;
import java.util.Arrays;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,6 +38,8 @@ import org.apache.geode.cache.util.CacheListenerAdapter;
import org.apache.geode.cache.util.CacheWriterAdapter;
import org.apache.geode.cache.util.ObjectSizer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -63,7 +63,8 @@ import org.springframework.util.StringUtils;
@SuppressWarnings("unused")
public class TemplateClientRegionNamespaceIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "TemplateBasedClientRegion")
@Autowired
@Qualifier("TemplateBasedClientRegion")
private Region<Integer, Object> templateBasedClientRegion;
private void assertCacheListeners(Region<?, ?> region, String... expectedNames) {

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,6 +32,7 @@ import org.apache.geode.cache.PartitionResolver;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
@@ -62,7 +61,8 @@ public class TemplatePersistentPartitionRegionNamespaceIntegrationTests extends
@Autowired
private DiskStore exampleDataStore;
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<?, ?> example;
@After

View File

@@ -24,8 +24,6 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -56,6 +54,7 @@ import org.apache.geode.cache.util.ObjectSizer;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanIsAbstractException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
@@ -83,22 +82,28 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
@Autowired
private ApplicationContext applicationContext;
@Resource(name = "NonTemplateBasedReplicateRegion")
@Autowired
@Qualifier("NonTemplateBasedReplicateRegion")
private Region<Integer, String> nonTemplateBasedReplicateRegion;
@Resource(name = "TemplateBasedReplicateRegion")
@Autowired
@Qualifier("TemplateBasedReplicateRegion")
private Region<String, Object> templateBasedReplicateRegion;
@Resource(name = "/TemplateBasedReplicateRegion/TemplateBasedReplicateSubRegion")
@Autowired
@Qualifier("/TemplateBasedReplicateRegion/TemplateBasedReplicateSubRegion")
private Region<Integer, String> templateBasedReplicateSubRegion;
@Resource(name = "TemplateBasedReplicateRegionNoOverrides")
@Autowired
@Qualifier("TemplateBasedReplicateRegionNoOverrides")
private Region<String, Object> templateBasedReplicateRegionNoOverrides;
@Resource(name = "TemplateBasedPartitionRegion")
@Autowired
@Qualifier("TemplateBasedPartitionRegion")
private Region<Date, Object> templateBasedPartitionRegion;
@Resource(name = "TemplateBasedLocalRegion")
@Autowired
@Qualifier("TemplateBasedLocalRegion")
private Region<Long, String> templateBasedLocalRegion;
private void assertAsyncEventQueues(Region<?, ?> region, String... expectedNames) {

View File

@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -76,7 +74,8 @@ public class AnnotationBasedExpirationConfigurationIntegrationTest extends Integ
@Autowired
private ExpirationAttributes defaultExpirationAttributes;
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<Object, Object> example;
@Before

View File

@@ -20,8 +20,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -30,6 +28,8 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.execute.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.fork.ServerProcess;
import org.springframework.data.gemfire.function.annotation.GemfireFunction;
import org.springframework.data.gemfire.function.annotation.RegionData;
@@ -62,7 +62,8 @@ public class FunctionIntegrationTests extends ForkingClientServerIntegrationTest
getServerContextXmlFileLocation(FunctionIntegrationTests.class));
}
@Resource(name = "TestRegion")
@Autowired
@Qualifier("TestRegion")
private Region<String, Integer> region;
@Before

View File

@@ -17,14 +17,13 @@ package org.springframework.data.gemfire.repository.sample;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -51,7 +50,8 @@ public class AlgorithmRepositoryIntegrationTests extends IntegrationTestsSupport
@Autowired
private AlgorithmRepository algorithmRepo;
@Resource(name = "Algorithms")
@Autowired
@Qualifier("Algorithms")
private Region<?, ?> algorithmsRegion;
@Test

View File

@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collection;
import java.util.Optional;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -35,6 +33,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
@@ -70,7 +69,8 @@ public class RepositoryDataAccessOnRegionUsingCacheLoaderIntegrationTests extend
@Autowired
private PersonRepository personRepository;
@Resource(name = "simple")
@Autowired
@Qualifier("simple")
private Region<Long, Person> people;
@Before

View File

@@ -23,8 +23,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +30,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.repository.Wrapper;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
@@ -55,9 +54,9 @@ import org.springframework.test.context.junit4.SpringRunner;
* @since 1.4.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration("subregionRepository.xml")
@ContextConfiguration
@SuppressWarnings("unused")
public class SubRegionRepositoryIntegrationTest extends IntegrationTestsSupport {
public class SubRegionRepositoryIntegrationTests extends IntegrationTestsSupport {
private static final Map<String, RootUser> ADMIN_USER_DATA = new HashMap<>(5, 0.90f);
@@ -94,13 +93,16 @@ public class SubRegionRepositoryIntegrationTest extends IntegrationTestsSupport
@Autowired
private ProgrammerRepository programmersRepo;
@Resource(name = "/Users/Programmers")
@Autowired
@Qualifier("/Users/Programmers")
private Region<String, Programmer> programmers;
@Resource(name = "/Local/Admin/Users")
@Autowired
@Qualifier("/Local/Admin/Users")
private Region<String, RootUser> adminUsers;
@Resource(name = "/Local/Guest/Users")
@Autowired
@Qualifier("/Local/Guest/Users")
private Region<String, GuestUser> guestUsers;
@Autowired

View File

@@ -22,8 +22,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,6 +29,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -47,11 +46,12 @@ import org.springframework.test.context.junit4.SpringRunner;
* @since 1.3.3
*/
@RunWith(SpringRunner.class)
@ContextConfiguration("userRepositoryQueriesIntegrationTest.xml")
@ContextConfiguration
@SuppressWarnings("unused")
public class UserRepositoryQueriesIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Users")
@Autowired
@Qualifier("Users")
@SuppressWarnings("rawtypes")
private Region users;

View File

@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +27,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.repository.Query;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
@@ -67,7 +66,8 @@ public class UsingQueryAnnotationExtensionsInUserRepositoryIntegrationTests exte
return users;
}
@Resource(name = "Users")
@Autowired
@Qualifier("Users")
private Region<String, User> users;
@Autowired

View File

@@ -21,8 +21,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,6 +32,7 @@ import org.apache.geode.cache.query.SelectResults;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -75,7 +74,8 @@ public class SimpleGemfireRepositoryIntegrationTests extends IntegrationTestsSup
@Autowired
private GemfireTemplate template;
@Resource(name = "People")
@Autowired
@Qualifier("People")
private Region<?, ?> people;
private RegionClearListener regionClearListener;

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import javax.annotation.Resource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -31,6 +29,7 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.data.gemfire.LocalRegionFactoryBean;
@@ -78,7 +77,8 @@ public class SimpleGemfireRepositoryRegionDeleteAllIntegrationTests extends Fork
startGemFireServer(GeodeServerTestConfiguration.class, "-Dspring.profiles.active=partition");
}
@Resource(name = "Users")
@Autowired
@Qualifier("Users")
private Region<Integer, User> users;
@Autowired

View File

@@ -22,8 +22,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicLong;
import javax.annotation.Resource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -32,6 +30,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.GemfireTemplate;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.mapping.GemfireMappingContext;
@@ -72,7 +71,8 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTests extends Integr
@Autowired
private CustomerService customerService;
@Resource(name = "Customers")
@Autowired
@Qualifier("Customers")
private Region<?, ?> customers;
private static Customer createCustomer(String firstName, String lastName) {

View File

@@ -22,8 +22,6 @@ import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newI
import java.util.Arrays;
import java.util.Map;
import javax.annotation.Resource;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -35,6 +33,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.query.SelectResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.GemfireOperations;
import org.springframework.data.gemfire.repository.sample.Person;
import org.springframework.data.gemfire.test.support.MapBuilder;
@@ -74,7 +73,8 @@ public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemfireOperations template;
@Resource(name = "JsonRegion")
@Autowired
@Qualifier("JsonRegion")
private Region<Object, Object> jsonRegion;
@Before

View File

@@ -25,8 +25,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -36,6 +34,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.snapshot.SnapshotFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.gemfire.repository.sample.Person;
@@ -80,16 +79,20 @@ public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTests ext
@Autowired
private ApplicationEventPublisher eventPublisher;
@Resource(name = "Doe")
@Autowired
@Qualifier("Doe")
private Region<Long, Person> doe;
@Resource(name = "EveryoneElse")
@Autowired
@Qualifier("EveryoneElse")
private Region<Long, Person> everyoneElse;
@Resource(name = "Handy")
@Autowired
@Qualifier("Handy")
private Region<Long, Person> handy;
@Resource(name = "People")
@Autowired
@Qualifier("People")
private Region<Long, Person> people;
@BeforeClass

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.support;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,6 +29,7 @@ import org.apache.geode.cache.Region;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -62,7 +61,8 @@ public class WiringDeclarableSupportIntegrationTests extends IntegrationTestsSup
@SuppressWarnings("unused")
private BeanFactory beanFactory;
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
@SuppressWarnings("unused")
private Region<String, String> example;

View File

@@ -13,17 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.gemfire.transaction;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalStateException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Optional;
import java.util.function.Function;
import javax.transaction.Transactional;
import edu.umd.cs.mtc.MultithreadedTestCase;
import edu.umd.cs.mtc.TestFramework;
@@ -32,6 +31,7 @@ import org.junit.runner.RunWith;
import org.apache.geode.cache.CacheTransactionManager;
import org.apache.geode.cache.CommitConflictException;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
import org.springframework.beans.factory.annotation.Autowired;
@@ -45,23 +45,26 @@ import org.springframework.data.gemfire.repository.support.GemfireRepositoryFact
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions;
import org.springframework.data.repository.CrudRepository;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import lombok.Data;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
/**
* Integration Tests asserting the proper configuration and behavior of Apache Geode/Pivotal GemFire
* cache Transactions inside a Spring application context when using SDG to configure
* the {@link CacheTransactionManager}.
* Integration Tests asserting the proper configuration and behavior of Apache Geode {@link GemFireCache} Transactions
* within the context of the Spring container when using SDG to configure the {@link CacheTransactionManager}.
*
* Specifically, this test asserts that 2 concurrent threads modifying the same entity inside a cache transaction
* leads to a {@link CommitConflictException}.
* leading to a {@link CommitConflictException}.
*
* @author John Blum
* @see java.util.function.Function
@@ -70,13 +73,18 @@ import lombok.RequiredArgsConstructor;
* @see org.junit.Test
* @see org.apache.geode.cache.CacheTransactionManager
* @see org.apache.geode.cache.CommitConflictException
* @see org.apache.geode.cache.GemFireCache
* @see org.springframework.context.annotation.Bean
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
* @see org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions
* @see org.springframework.data.gemfire.mapping.annotation.Region
* @see org.springframework.data.gemfire.repository.config.EnableGemfireRepositories
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions
* @see org.springframework.stereotype.Service
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @see org.springframework.transaction.annotation.Transactional
* @since 2.2.0
*/
@RunWith(SpringRunner.class)
@@ -85,22 +93,35 @@ import lombok.RequiredArgsConstructor;
public class CommitConflictExceptionTransactionalIntegrationTests extends IntegrationTestsSupport {
@Autowired
private CustomerService customerService;
private GemFireCache cache;
@Autowired
private AutomatedTellerMachine atm;
@Test
public void cacheTransactionManagementIsConfigured() {
assertThat(this.cache).isNotNull();
assertThat(this.cache.getName()).isEqualTo("CommitConflictExceptionTransactionalIntegrationTests");
assertThat(this.cache.getCopyOnRead()).isTrue();
assertThat(this.cache.getCacheTransactionManager()).isNotNull();
}
@Test
public void concurrentTransactionalThreadsCauseCommitConflictException() throws Throwable {
TestFramework.runOnce(new TransactionalCommitConflictMultithreadedTestCase(this.customerService));
TestFramework.runOnce(new TransactionalCommitConflictMultithreadedTestCase(this.atm));
}
static class TransactionalCommitConflictMultithreadedTestCase extends MultithreadedTestCase {
private final CustomerService customerService;
@Getter(AccessLevel.PROTECTED)
private final AutomatedTellerMachine atm;
TransactionalCommitConflictMultithreadedTestCase(CustomerService customerService) {
TransactionalCommitConflictMultithreadedTestCase(AutomatedTellerMachine atm) {
Assert.notNull(customerService, "CustomerService is required");
Assert.notNull(atm, "The ATM must not be null");
this.customerService = customerService;
this.atm = atm;
}
@Override
@@ -108,29 +129,29 @@ public class CommitConflictExceptionTransactionalIntegrationTests extends Integr
super.initialize();
Customer jonDoe = this.customerService.save(Customer.newCustomer(1L, "Jon Doe"));
Customer jonDoeLoaded = this.customerService.findById(jonDoe.getId());
Account account = getAtm().save(Account.open(1).deposit(BigDecimal.valueOf(100.0d)));
Account accountLoaded = getAtm().findByAccountNumber(account.getNumber());
assertThat(jonDoeLoaded).isEqualTo(jonDoe);
assertThat(accountLoaded).isEqualTo(account);
}
public void thread1() {
assertTick(0);
Thread.currentThread().setName("Customer Processing Thread One");
Thread.currentThread().setName("Account Processing Thread One");
this.customerService.process(1L, customer -> {
getAtm().process(1, account -> {
assertThat(customer.getId()).isEqualTo(1L);
assertThat(customer.getName()).isEqualTo("Jon Doe");
assertThat(account.getNumber()).isEqualTo(1);
assertThat(account.getBalance()).isEqualTo(BigDecimal.valueOf(100.0d));
customer.setName("Pie Doe");
account.withdrawal(BigDecimal.valueOf(50.0d));
waitForTick(2);
assertTick(2);
return customer;
return account;
}, Function.identity());
}
@@ -139,24 +160,24 @@ public class CommitConflictExceptionTransactionalIntegrationTests extends Integr
assertTick(0);
Thread.currentThread().setName("Customer Processing Thread Two");
Thread.currentThread().setName("Account Processing Thread Two");
waitForTick(1);
assertTick(1);
try {
this.customerService.process(1L, customer -> {
getAtm().process(1, account -> {
assertThat(customer.getId()).isEqualTo(1L);
assertThat(customer.getName()).isEqualTo("Jon Doe");
assertThat(account.getNumber()).isEqualTo(1);
assertThat(account.getBalance()).isEqualTo(BigDecimal.valueOf(100.0d));
customer.setName("Sour Doe");
account.withdrawal(BigDecimal.valueOf(75.0d));
waitForTick(3);
assertTick(3);
return customer;
return account;
}, Function.identity());
@@ -172,87 +193,128 @@ public class CommitConflictExceptionTransactionalIntegrationTests extends Integr
@Override
public void finish() {
Customer customer = this.customerService.findById(1L);
Account account = getAtm().findByAccountNumber(1);
assertThat(customer).isNotNull();
assertThat(customer.getId()).isEqualTo(1L);
assertThat(customer.getName()).isEqualTo("Pie Doe");
assertThat(account).isNotNull();
assertThat(account.getNumber()).isEqualTo(1);
assertThat(account.getBalance()).isEqualTo(BigDecimal.valueOf(50.0d));
}
}
@ClientCacheApplication(logLevel = "error")
@EnableEntityDefinedRegions(
basePackageClasses = Customer.class,
clientRegionShortcut = ClientRegionShortcut.LOCAL
)
@ClientCacheApplication(name = "CommitConflictExceptionTransactionalIntegrationTests")
@EnableEntityDefinedRegions(basePackageClasses = Account.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemfireCacheTransactions
static class TestConfiguration {
@Bean
GemfireRepositoryFactoryBean<CustomerRepository, Customer, Long> customerRepositoryFactoryBean() {
GemfireRepositoryFactoryBean<AccountRepository, Account, Integer> accountRepository() {
GemfireRepositoryFactoryBean<CustomerRepository, Customer, Long> customerRepositoryFactoryBean
= new GemfireRepositoryFactoryBean<>(CustomerRepository.class);
GemfireRepositoryFactoryBean<AccountRepository, Account, Integer> accountRepository
= new GemfireRepositoryFactoryBean<>(AccountRepository.class);
customerRepositoryFactoryBean.setGemfireMappingContext(new GemfireMappingContext());
accountRepository.setGemfireMappingContext(new GemfireMappingContext());
return customerRepositoryFactoryBean;
return accountRepository;
}
@Bean
CustomerService customerService(CustomerRepository customerRepository) {
return new CustomerService(customerRepository);
AutomatedTellerMachine automatedTellerMachine(AccountRepository accountRepository) {
return new AutomatedTellerMachine(accountRepository);
}
}
@Data
@Getter
@ToString
@EqualsAndHashCode
@Region("Customers")
@RequiredArgsConstructor(staticName = "newCustomer")
static class Customer implements Serializable {
@Region("Accounts")
@RequiredArgsConstructor(staticName = "open")
static class Account implements Serializable {
@NonNull @Id
private Long id;
@Id @lombok.NonNull
private final Integer number;
@NonNull
private String name;
private BigDecimal balance = BigDecimal.valueOf(0.0d);
public synchronized Account deposit(@NonNull BigDecimal value) {
this.balance = Optional.ofNullable(value)
.map(BigDecimal::abs)
.map(this.balance::add)
.orElse(this.balance);
return this;
}
public synchronized @NonNull Account withdrawal(@NonNull BigDecimal value) {
this.balance = Optional.ofNullable(value)
.map(BigDecimal::abs)
.map(this::verifyWithdrawal)
.map(this.balance::subtract)
.orElse(this.balance);
return this;
}
private BigDecimal verifyWithdrawal(@NonNull BigDecimal value) {
Assert.state(getBalance().compareTo(value) >= 0,
String.format("Withdrawal [%1$s] cannot exceed balance [%2$s]", value, getBalance()));
return value;
}
}
public interface CustomerRepository extends CrudRepository<Customer, Long> { }
public interface AccountRepository extends CrudRepository<Account, Integer> { }
@Service
public static class CustomerService {
public static class AutomatedTellerMachine {
private final CustomerRepository customerRepository;
@Getter(AccessLevel.PROTECTED)
private final AccountRepository accountRepository;
public CustomerService(CustomerRepository customerRepository) {
Assert.notNull(customerRepository, "CustomerRepository is required");
this.customerRepository = customerRepository;
public AutomatedTellerMachine(@NonNull AccountRepository accountRepository) {
Assert.notNull(accountRepository, "AccountRepository must not be null");
this.accountRepository = accountRepository;
}
protected Customer findById(Long id) {
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
public @NonNull Account findByAccountNumber(@NonNull Integer accountNumber) {
Assert.notNull(id, "ID is required");
return this.customerRepository.findById(id)
.orElseThrow(() -> newIllegalStateException("No Customer with ID [%d] was found", id));
return getAccountRepository().findById(accountNumber)
.orElseThrow(() -> newIllegalStateException("Failed to find Account by number [%d]", accountNumber));
}
@Transactional
public Customer process(Long id, Function<Customer, Customer> beforeSave,
Function<Customer, Customer> afterSave) {
public @NonNull Account process(@NonNull Integer accountNumber, @NonNull Function<Account, Account> beforeSave,
@NonNull Function<Account, Account> afterSave) {
return afterSave.apply(save(beforeSave.apply(findById(id))));
return afterSave.apply(save(beforeSave.apply(findByAccountNumber(accountNumber))));
}
protected Customer save(Customer customer) {
@Transactional(propagation = Propagation.REQUIRED)
public @NonNull Account save(@NonNull Account account) {
Assert.notNull(customer, "Customer is required");
Assert.notNull(account, "Account must not be null");
return this.customerRepository.save(customer);
return getAccountRepository().save(account);
}
}
static class OverdraftException extends RuntimeException {
public OverdraftException() { }
public OverdraftException(String message) {
super(message);
}
public OverdraftException(Throwable cause) {
super(cause);
}
public OverdraftException(String message, Throwable cause) {
super(message, cause);
}
}
}

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.transaction;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,6 +25,7 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.LocalRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.PeerCacheApplication;
@@ -60,7 +59,8 @@ import org.springframework.util.Assert;
@SuppressWarnings("unused")
public class GemfireTransactionManagerIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<Object, Object> example;
@Autowired

View File

@@ -17,8 +17,6 @@ package org.springframework.data.gemfire.transaction.config;
import static org.assertj.core.api.Assertions.assertThat;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -26,6 +24,7 @@ import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.LocalRegionFactoryBean;
import org.springframework.data.gemfire.config.annotation.PeerCacheApplication;
@@ -59,15 +58,16 @@ import org.springframework.transaction.annotation.Transactional;
@SuppressWarnings("unused")
public class EnableGemfireCacheTransactionsIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Example")
private Region<Object, Object> example;
@Autowired
private GemFireCache gemfireCache;
@Autowired
private GemfireTransactionManager transactionManager;
@Autowired
@Qualifier("Example")
private Region<Object, Object> example;
@Autowired
private TestTransactionalService transactionalService;
@@ -75,6 +75,8 @@ public class EnableGemfireCacheTransactionsIntegrationTests extends IntegrationT
public void transactionManagerIsConfigured() {
assertThat(this.gemfireCache).isNotNull();
assertThat(this.gemfireCache.getName()).isEqualTo("EnableGemfireCacheTransactionsIntegrationTests");
assertThat(this.gemfireCache.getRegion("Example")).isNotNull();
assertThat(this.transactionManager).isNotNull();
assertThat(this.transactionManager.getCache()).isSameAs(this.gemfireCache);
}
@@ -82,20 +84,22 @@ public class EnableGemfireCacheTransactionsIntegrationTests extends IntegrationT
@Test
public void doInTransactionCommits() {
assertThat(example).isNotNull();
assertThat(example).isEmpty();
assertThat(transactionalService.doInTransactionCommits(1, "pass")).isTrue();
assertThat(example).hasSize(1);
assertThat(example).containsKey(1);
assertThat(example.get(1)).isEqualTo("pass");
assertThat(this.example).isNotNull();
assertThat(this.example).isEmpty();
assertThat(this.transactionalService.doInTransactionCommits(1, "pass")).isTrue();
assertThat(this.example).hasSize(1);
assertThat(this.example).containsKey(1);
assertThat(this.example.get(1)).isEqualTo("pass");
}
@Test(expected = RuntimeException.class)
public void doInTransactionRollsback() {
try {
assertThat(example).doesNotContainKey(2);
transactionalService.doInTransactionRollsBack(2, "fail");
assertThat(this.example).isNotNull();
assertThat(this.example).doesNotContainKey(2);
this.transactionalService.doInTransactionRollsBack(2, "fail");
}
catch (RuntimeException expected) {
assertThat(expected).hasMessage("test");
@@ -119,7 +123,6 @@ public class EnableGemfireCacheTransactionsIntegrationTests extends IntegrationT
LocalRegionFactoryBean<Object, Object> example = new LocalRegionFactoryBean<>();
example.setCache(gemFireCache);
example.setClose(false);
example.setPersistent(false);
return example;
@@ -135,7 +138,8 @@ public class EnableGemfireCacheTransactionsIntegrationTests extends IntegrationT
@SuppressWarnings("all")
static class TestTransactionalService {
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<Object, Object> example;
@Transactional

View File

@@ -20,8 +20,6 @@ import static org.mockito.Mockito.mock;
import java.io.IOException;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -35,6 +33,7 @@ import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.asyncqueue.AsyncEventListener;
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.PartitionedRegionFactoryBean;
@@ -87,7 +86,8 @@ public class AsyncEventQueueByIdXmlConfigurationIntegrationTests extends Forking
stop(geodeServer);
}
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<?, ?> example;
@Test

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +27,8 @@ import org.apache.geode.cache.asyncqueue.AsyncEventListener;
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -56,13 +56,16 @@ import org.springframework.util.StringUtils;
@SuppressWarnings("unused")
public class AsyncEventQueueWithListenerIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Q1")
@Autowired
@Qualifier("Q1")
private AsyncEventQueue queueOne;
@Resource(name = "Q2")
@Autowired
@Qualifier("Q2")
private AsyncEventQueue queueTwo;
@Resource(name = "Q3")
@Autowired
@Qualifier("Q3")
private AsyncEventQueue queueThree;
@Test

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +30,7 @@ import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
@@ -64,7 +63,8 @@ public class CachePartitionRegionWithConcurrentParallelAsyncEventQueueAndGateway
@Autowired
private GatewaySender exampleGateway;
@Resource(name = "ExampleRegion")
@Autowired
@Qualifier("ExampleRegion")
private Region<?, ?> exampleRegion;
@Test

View File

@@ -19,13 +19,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -49,10 +49,12 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused")
public class GatewayReceiverManualStartIntegrationTests extends IntegrationTestsSupport {
@Resource(name = "Auto")
@Autowired
@Qualifier("Auto")
private GatewayReceiver autoGatewayReceiver;
@Resource(name = "Manual")
@Autowired
@Qualifier("Manual")
private GatewayReceiver manualGatewayReceiver;
private void assertGreaterThanEqualToLessThanEqualTo(String message,

View File

@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -33,6 +31,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
@@ -85,7 +84,8 @@ public class GatewaySenderByIdXmlConfigurationIntegrationTests extends ForkingCl
stop(geodeServer);
}
@Resource(name = "Example")
@Autowired
@Qualifier("Example")
private Region<?, ?> example;
@Test

View File

@@ -18,8 +18,6 @@ package org.springframework.data.gemfire.wan;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,10 +28,12 @@ import org.apache.geode.cache.asyncqueue.AsyncEventListener;
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
import org.apache.geode.cache.wan.GatewaySender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.gemfire.support.AbstractFactoryBeanSupport;
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
import org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest;
import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
/**
@@ -45,25 +45,30 @@ import org.springframework.test.context.junit4.SpringRunner;
* @see org.apache.geode.cache.asyncqueue.AsyncEventQueue
* @see org.apache.geode.cache.wan.GatewaySender
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.unit.annotation.GemFireUnitTest
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 2.0.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration
@GemFireUnitTest
@SuppressWarnings("unused")
public class RegionsWithAsyncEventQueuesAndGatewaySendersUnitTests extends IntegrationTestsSupport {
@Resource(name = "TemplateBasedLocalRegion")
@Autowired
@Qualifier("TemplateBasedLocalRegion")
private Region<?, ?> templateBasedLocalRegion;
@Resource(name = "LocalRegion")
@Autowired
@Qualifier("LocalRegion")
private Region<?, ?> localRegion;
@Resource(name = "PartitionRegion")
@Autowired
@Qualifier("PartitionRegion")
private Region<?, ?> partitionRegion;
@Resource(name = "ReplicateRegion")
@Autowired
@Qualifier("ReplicateRegion")
private Region<?, ?> replicateRegion;
private void assertRegion(Region<?, ?> region, String name, DataPolicy dataPolicy) {

View File

@@ -15,9 +15,10 @@
<context:component-scan base-package="org.springframework.data.gemfire">
<context:include-filter type="assignable" expression="org.springframework.data.gemfire.AutoRegionLookupDao"/>
<context:exclude-filter type="annotation" expression="org.springframework.context.annotation.Configuration"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:exclude-filter type="assignable" expression="org.springframework.data.gemfire.AutoRegionLookupWithAutowiringIntegrationTests$TestComponent"/>
<context:exclude-filter type="assignable" expression="org.springframework.data.gemfire.tests.objects.geode.cache.RegionDataInitializingPostProcessor"/>
<context:exclude-filter type="assignable" expression="org.springframework.data.gemfire.transaction.GemfireTransactionManagerIntegrationTests$SuspendAndResumeCacheTransactionsRepository"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:exclude-filter type="regex" expression="org.springframework.data.gemfire.*.sample.*"/>
</context:component-scan>

View File

@@ -14,7 +14,7 @@
">
<util:properties id="gemfireProperties">
<prop key="name">UserRepositoryQueriesIntegrationTest</prop>
<prop key="name">UserRepositoryQueriesIntegrationTests</prop>
<prop key="log-level">error</prop>
</util:properties>