SGF-833 - Polish log statements and log levels.
This commit is contained in:
@@ -42,27 +42,31 @@ import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.test.support.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.test.support.ThreadUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* The ClientCacheIndexingTest class is a test suite of test cases testing the creation and application of indexes
|
||||
* on client Regions of a Pivotal GemFireClientCache using the <gfe:index/> tag element in the SDG
|
||||
* XML namespace and configuration meta-data, which is backed by the IndexFactoryBean.
|
||||
=======
|
||||
* Integration tests for testing {@link ClientCache} {@link Index Indexes}.
|
||||
>>>>>>> 626076b0... DATAGEODE-180 - Polish log statements and log levels.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.data.gemfire.IndexFactoryBean
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.query.Index
|
||||
* @see org.apache.geode.cache.query.QueryService
|
||||
* @since 1.5.2
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientCacheIndexingTest {
|
||||
@@ -83,7 +87,7 @@ public class ClientCacheIndexingTest {
|
||||
File serverWorkingDirectory = new File(FileSystemUtils.WORKING_DIRECTORY, serverName.toLowerCase());
|
||||
|
||||
Assert.isTrue(serverWorkingDirectory.isDirectory() || serverWorkingDirectory.mkdirs(),
|
||||
String.format("Working directory [%s] could not be created", serverWorkingDirectory));
|
||||
String.format("Server working directory [%s] does not exist and could not be created", serverWorkingDirectory));
|
||||
|
||||
List<String> arguments = new ArrayList<>();
|
||||
|
||||
@@ -91,7 +95,7 @@ public class ClientCacheIndexingTest {
|
||||
arguments.add("/org/springframework/data/gemfire/client/ClientCacheIndexingTest-server-context.xml");
|
||||
|
||||
serverProcess = ProcessExecutor.launch(serverWorkingDirectory, ServerProcess.class,
|
||||
arguments.toArray(new String[arguments.size()]));
|
||||
arguments.toArray(new String[0]));
|
||||
|
||||
waitForServerStart(TimeUnit.SECONDS.toMillis(20));
|
||||
}
|
||||
@@ -99,10 +103,12 @@ public class ClientCacheIndexingTest {
|
||||
private static void waitForServerStart(final long milliseconds) {
|
||||
|
||||
ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.WaitCondition() {
|
||||
private File serverPidControlFile = new File(serverProcess.getWorkingDirectory(),
|
||||
ServerProcess.getServerProcessControlFilename());
|
||||
|
||||
@Override public boolean waiting() {
|
||||
private File serverPidControlFile =
|
||||
new File(serverProcess.getWorkingDirectory(), ServerProcess.getServerProcessControlFilename());
|
||||
|
||||
@Override
|
||||
public boolean waiting() {
|
||||
return !serverPidControlFile.isFile();
|
||||
}
|
||||
});
|
||||
@@ -118,10 +124,11 @@ public class ClientCacheIndexingTest {
|
||||
}
|
||||
}
|
||||
|
||||
private Index getIndex(GemFireCache gemfireCache, String indexName) {
|
||||
protected Index getIndex(GemFireCache gemfireCache, String indexName) {
|
||||
|
||||
QueryService queryService = gemfireCache instanceof ClientCache
|
||||
? ((ClientCache) gemfireCache).getLocalQueryService() : gemfireCache.getQueryService();
|
||||
? ((ClientCache) gemfireCache).getLocalQueryService()
|
||||
: gemfireCache.getQueryService();
|
||||
|
||||
for (Index index : queryService.getIndexes()) {
|
||||
if (index.getName().equals(indexName)) {
|
||||
@@ -136,7 +143,7 @@ public class ClientCacheIndexingTest {
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testIndexByName() {
|
||||
|
||||
assertNotNull("ClientCache was not properly configured and initialized", clientCache);
|
||||
assertNotNull("The GemFire ClientCache was not properly configured and initialized!", clientCache);
|
||||
|
||||
Index actualIndex = getIndex(clientCache, "ExampleIndex");
|
||||
|
||||
|
||||
@@ -34,16 +34,16 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.test.support.AbstractGemFireClientServerIntegrationTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The ClientCachePoolTests class...
|
||||
* Integration tests for {@link ClientCache} {@link Pool Pools}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("all")
|
||||
public class ClientCachePoolTests extends AbstractGemFireClientServerIntegrationTest {
|
||||
@@ -65,6 +65,7 @@ public class ClientCachePoolTests extends AbstractGemFireClientServerIntegration
|
||||
|
||||
@Test
|
||||
public void computeFactorials() {
|
||||
|
||||
assertThat(factorials.get(0l), is(equalTo(1l)));
|
||||
assertThat(factorials.get(1l), is(equalTo(1l)));
|
||||
assertThat(factorials.get(2l), is(equalTo(2l)));
|
||||
@@ -81,6 +82,7 @@ public class ClientCachePoolTests extends AbstractGemFireClientServerIntegration
|
||||
|
||||
@Override
|
||||
public Long load(LoaderHelper<Long, Long> helper) throws CacheLoaderException {
|
||||
|
||||
Long number = helper.getKey();
|
||||
|
||||
Assert.notNull(number, "number must not be null");
|
||||
@@ -100,7 +102,7 @@ public class ClientCachePoolTests extends AbstractGemFireClientServerIntegration
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
public void close() { }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
// TODO: merge with o.s.d.g.client.GemfireDataSoruceIntegrationTest
|
||||
@SuppressWarnings("unused")
|
||||
// TODO: merge with o.s.d.g.client.GemfireDataSourceIntegrationTest
|
||||
public class GemFireDataSourceIntegrationTests extends ClientServerIntegrationTestsSupport {
|
||||
|
||||
private static ProcessWrapper gemfireServer;
|
||||
@@ -53,6 +54,16 @@ public class GemFireDataSourceIntegrationTests extends ClientServerIntegrationTe
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@BeforeClass
|
||||
public static void setGemFireLogLevel() {
|
||||
System.setProperty("gemfire.log-level", "error");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void unsetGemFireLogLevel() {
|
||||
System.clearProperty("gemfire.log-level");
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void startGemFireServer() throws Exception {
|
||||
|
||||
|
||||
@@ -80,9 +80,9 @@ public class LocalOnlyClientCacheIntegrationTests {
|
||||
assertThat(this.people).hasSize(1);
|
||||
}
|
||||
|
||||
@ClientCacheApplication
|
||||
@ClientCacheApplication(logLevel = "error")
|
||||
@EnableEntityDefinedRegions(basePackageClasses = Person.class,
|
||||
clientRegionShortcut = ClientRegionShortcut.LOCAL, strict = true)
|
||||
static class GemFireClientCacheConfiguration {
|
||||
}
|
||||
static class GemFireClientCacheConfiguration { }
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.springframework.data.gemfire.config.annotation.PeerCacheApplication;
|
||||
import org.springframework.data.gemfire.test.model.Gender;
|
||||
import org.springframework.data.gemfire.test.model.Person;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link DefinedIndexesApplicationListener}.
|
||||
@@ -63,12 +63,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @see org.apache.geode.cache.query.QueryService
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class DefinedIndexesIntegrationTests {
|
||||
|
||||
private static final List<String> definedIndexNames = new ArrayList<String>(3);
|
||||
private static final List<String> definedIndexNames = new ArrayList<>(3);
|
||||
|
||||
@Autowired
|
||||
private Cache gemfireCache;
|
||||
@@ -99,6 +99,7 @@ public class DefinedIndexesIntegrationTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
put(people, newPerson("Jon", "Doe", newBirthDate(1989, Calendar.NOVEMBER, 11), Gender.MALE));
|
||||
put(people, newPerson("Jane", "Doe", newBirthDate(1991, Calendar.APRIL, 4), Gender.FEMALE));
|
||||
put(people, newPerson("Pie", "Doe", newBirthDate(2008, Calendar.JUNE, 21), Gender.FEMALE));
|
||||
@@ -107,6 +108,7 @@ public class DefinedIndexesIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void indexesCreated() {
|
||||
|
||||
QueryService queryService = gemfireCache.getQueryService();
|
||||
|
||||
List<String> expectedDefinedIndexNames = Arrays.asList(id.getName(), birthDate.getName(), name.getName());
|
||||
@@ -118,7 +120,7 @@ public class DefinedIndexesIntegrationTests {
|
||||
assertThat(name).isEqualTo(queryService.getIndex(people, name.getName()));
|
||||
}
|
||||
|
||||
@PeerCacheApplication(logLevel = "warning")
|
||||
@PeerCacheApplication(logLevel = "error")
|
||||
static class DefinedIndexesConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -129,15 +131,12 @@ public class DefinedIndexesIntegrationTests {
|
||||
|
||||
@Bean
|
||||
BeanPostProcessor indexBeanPostProcessor() {
|
||||
|
||||
return new BeanPostProcessor() {
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
if (bean instanceof Index) {
|
||||
if ("LastNameIdx".equals(beanName)) {
|
||||
assertThat(CacheFactory.getAnyInstance().getQueryService().getIndexes().contains(bean)).isTrue();
|
||||
@@ -155,7 +154,8 @@ public class DefinedIndexesIntegrationTests {
|
||||
|
||||
@Bean(name = "People")
|
||||
PartitionedRegionFactoryBean<Long, Person> peopleRegion(Cache gemfireCache) {
|
||||
PartitionedRegionFactoryBean<Long, Person> peopleRegion = new PartitionedRegionFactoryBean<Long, Person>();
|
||||
|
||||
PartitionedRegionFactoryBean<Long, Person> peopleRegion = new PartitionedRegionFactoryBean<>();
|
||||
|
||||
peopleRegion.setCache(gemfireCache);
|
||||
peopleRegion.setClose(false);
|
||||
@@ -167,6 +167,7 @@ public class DefinedIndexesIntegrationTests {
|
||||
@Bean(name = "IdIdx")
|
||||
@DependsOn("People")
|
||||
IndexFactoryBean idIndex(GemFireCache gemFireCache) {
|
||||
|
||||
IndexFactoryBean idIndex = new IndexFactoryBean();
|
||||
|
||||
idIndex.setCache(gemFireCache);
|
||||
@@ -182,6 +183,7 @@ public class DefinedIndexesIntegrationTests {
|
||||
@Bean(name = "BirthDateIdx")
|
||||
@DependsOn("People")
|
||||
IndexFactoryBean birthDateIndex(GemFireCache gemFireCache) {
|
||||
|
||||
IndexFactoryBean birthDateIndex = new IndexFactoryBean();
|
||||
|
||||
birthDateIndex.setCache(gemFireCache);
|
||||
@@ -197,6 +199,7 @@ public class DefinedIndexesIntegrationTests {
|
||||
@Bean(name = "LastNameIdx")
|
||||
@DependsOn("People")
|
||||
IndexFactoryBean lastNameIndex(GemFireCache gemFireCache) {
|
||||
|
||||
IndexFactoryBean lastNameIndex = new IndexFactoryBean();
|
||||
|
||||
lastNameIndex.setCache(gemFireCache);
|
||||
@@ -211,6 +214,7 @@ public class DefinedIndexesIntegrationTests {
|
||||
@Bean(name = "NameIdx")
|
||||
@DependsOn("People")
|
||||
IndexFactoryBean nameIndex(GemFireCache gemFireCache) {
|
||||
|
||||
IndexFactoryBean nameIndex = new IndexFactoryBean();
|
||||
|
||||
nameIndex.setCache(gemFireCache);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DiskStoreDirectoryBeanPostProcessorIntegrationTests {
|
||||
assertThat(new File("./gfe/ds/store3/local").isDirectory()).isTrue();
|
||||
}
|
||||
|
||||
@PeerCacheApplication(logLevel = "warning")
|
||||
@PeerCacheApplication(logLevel = "error")
|
||||
@SuppressWarnings("unused")
|
||||
static class DiskStoreDirectoryBeanPostProcessorConfiguration {
|
||||
|
||||
|
||||
@@ -170,6 +170,7 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
private Class[] getArgumentTypes(final Object... arguments) {
|
||||
|
||||
Class[] argumentTypes = new Class[arguments.length];
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (Object argument : arguments) {
|
||||
@@ -279,7 +280,7 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Gender {
|
||||
public enum Gender {
|
||||
FEMALE,
|
||||
MALE
|
||||
}
|
||||
@@ -348,12 +349,16 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
}
|
||||
|
||||
public static PdxSerializer compose(PdxSerializer... pdxSerializers) {
|
||||
return (pdxSerializers == null ? null : (pdxSerializers.length == 1 ? pdxSerializers[0]
|
||||
: new ComposablePdxSerializer(pdxSerializers)));
|
||||
|
||||
return pdxSerializers == null ? null
|
||||
: (pdxSerializers.length == 1
|
||||
? pdxSerializers[0]
|
||||
: new ComposablePdxSerializer(pdxSerializers));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toData(Object obj, PdxWriter out) {
|
||||
|
||||
for (PdxSerializer pdxSerializer : this.pdxSerializers) {
|
||||
if (pdxSerializer.toData(obj, out)) {
|
||||
return true;
|
||||
@@ -365,7 +370,9 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
|
||||
@Override
|
||||
public Object fromData(Class<?> type, final PdxReader in) {
|
||||
|
||||
for (PdxSerializer pdxSerializer : this.pdxSerializers) {
|
||||
|
||||
Object obj = pdxSerializer.fromData(type, in);
|
||||
|
||||
if (obj != null) {
|
||||
@@ -389,8 +396,7 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
pdxSerializer = ComposablePdxSerializer.compose(pdxSerializers.toArray(
|
||||
new PdxSerializer[pdxSerializers.size()]));
|
||||
pdxSerializer = ComposablePdxSerializer.compose(pdxSerializers.toArray(new PdxSerializer[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -400,7 +406,7 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return (pdxSerializer != null ? pdxSerializer.getClass() : PdxSerializer.class);
|
||||
return pdxSerializer != null ? pdxSerializer.getClass() : PdxSerializer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -415,11 +421,14 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
public boolean toData(Object obj, PdxWriter out) {
|
||||
|
||||
if (obj instanceof Address) {
|
||||
|
||||
Address address = (Address) obj;
|
||||
|
||||
out.writeString("street", address.getStreet());
|
||||
out.writeString("city", address.getCity());
|
||||
out.writeString("state", address.getState());
|
||||
out.writeString("zipCode", address.getZipCode());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -437,15 +446,19 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PersonPdxSerializer implements PdxSerializer {
|
||||
|
||||
@Override
|
||||
public boolean toData(Object obj, PdxWriter out) {
|
||||
|
||||
if (obj instanceof Person) {
|
||||
|
||||
Person person = (Person) obj;
|
||||
|
||||
out.writeString("firstName", person.getFirstName());
|
||||
out.writeString("lastName", person.getLastName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -454,6 +467,7 @@ public class ClientCacheFunctionExecutionWithPdxIntegrationTest extends ClientSe
|
||||
|
||||
@Override
|
||||
public Object fromData(Class<?> type, PdxReader in) {
|
||||
|
||||
if (Person.class.isAssignableFrom(type)) {
|
||||
return new Person(in.readString("firstName"), in.readString("lastName"));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FunctionExecutionClientCacheTests {
|
||||
ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
public void contextCreated() throws Exception {
|
||||
public void contextCreated() {
|
||||
|
||||
ClientCache cache = this.applicationContext.getBean("gemfireCache", ClientCache.class);
|
||||
|
||||
@@ -76,6 +76,7 @@ public class FunctionExecutionClientCacheTests {
|
||||
@Configuration
|
||||
@ImportResource("/org/springframework/data/gemfire/function/config/FunctionExecutionCacheClientTests-context.xml")
|
||||
@EnableGemfireFunctionExecutions(basePackages = "org.springframework.data.gemfire.function.config.three")
|
||||
@SuppressWarnings("unused")
|
||||
class TestClientCacheConfig {
|
||||
|
||||
@Bean
|
||||
@@ -87,38 +88,20 @@ class TestClientCacheConfig {
|
||||
@SuppressWarnings("rawtypes")
|
||||
class MyResultCollector implements ResultCollector {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.geode.cache.execute.ResultCollector#addResult(org.apache.geode.distributed.DistributedMember, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void addResult(DistributedMember arg0, Object arg1) {
|
||||
}
|
||||
public void addResult(DistributedMember arg0, Object arg1) { }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.geode.cache.execute.ResultCollector#clearResults()
|
||||
*/
|
||||
@Override
|
||||
public void clearResults() {
|
||||
}
|
||||
public void clearResults() { }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.geode.cache.execute.ResultCollector#endResults()
|
||||
*/
|
||||
@Override
|
||||
public void endResults() {
|
||||
}
|
||||
public void endResults() { }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.geode.cache.execute.ResultCollector#getResult()
|
||||
*/
|
||||
@Override
|
||||
public Object getResult() throws FunctionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.geode.cache.execute.ResultCollector#getResult(long, java.util.concurrent.TimeUnit)
|
||||
*/
|
||||
@Override
|
||||
public Object getResult(long arg0, TimeUnit arg1) throws FunctionException, InterruptedException {
|
||||
return null;
|
||||
|
||||
@@ -48,6 +48,7 @@ public class ContainerXmlSetupIntegrationTests extends ClientServerIntegrationTe
|
||||
|
||||
@BeforeClass
|
||||
public static void startGemFireServer() throws Exception {
|
||||
|
||||
int availablePort = findAvailablePort();
|
||||
|
||||
gemfireServer = run(CqCacheServerProcess.class,
|
||||
@@ -69,7 +70,8 @@ public class ContainerXmlSetupIntegrationTests extends ClientServerIntegrationTe
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
public void containerSetup() throws Exception {
|
||||
public void containerSetup() {
|
||||
|
||||
ContinuousQueryListenerContainer container =
|
||||
applicationContext.getBean(ContinuousQueryListenerContainer.class);
|
||||
|
||||
|
||||
@@ -43,11 +43,13 @@ public class QueryListenerAdapterTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
adapter = new ContinuousQueryListenerAdapter();
|
||||
this.adapter = new ContinuousQueryListenerAdapter();
|
||||
}
|
||||
|
||||
CqEvent event() {
|
||||
|
||||
return new CqEvent() {
|
||||
|
||||
final CqQuery cq = mock(CqQuery.class);
|
||||
final byte[] deltaValue = new byte[0];
|
||||
final Object key = new Object();
|
||||
@@ -105,22 +107,26 @@ public class QueryListenerAdapterTest {
|
||||
void handleAll(CqEvent event, CqQuery query, byte[] ba, Object key, Operation op, Throwable th, Operation qOp, Object v);
|
||||
|
||||
void handleInvalid(Object o1, Object o2, Object o3);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheListenerAdapterItself() throws Exception {
|
||||
public void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheListenerAdapterItself() {
|
||||
assertSame(adapter, adapter.getDelegate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatTheDefaultHandlingMethodNameIsTheConstantDefault() throws Exception {
|
||||
public void testThatTheDefaultHandlingMethodNameIsTheConstantDefault() {
|
||||
assertEquals(ContinuousQueryListenerAdapter.DEFAULT_LISTENER_METHOD_NAME, adapter.getDefaultListenerMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdapterWithListenerAndDefaultMessage() throws Exception {
|
||||
public void testAdapterWithListenerAndDefaultMessage() {
|
||||
|
||||
ContinuousQueryListener mockCqListener = mock(ContinuousQueryListener.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockCqListener);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.onEvent(event);
|
||||
@@ -129,9 +135,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEvent() throws Exception {
|
||||
public void testHandleEvent() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.onEvent(event);
|
||||
@@ -140,9 +149,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleArray() throws Exception {
|
||||
public void testHandleArray() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleArray");
|
||||
@@ -152,9 +164,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleKey() throws Exception {
|
||||
public void testHandleKey() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleKey");
|
||||
@@ -164,9 +179,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleKV() throws Exception {
|
||||
public void testHandleKV() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleKV");
|
||||
@@ -176,9 +194,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleEx() throws Exception {
|
||||
public void testHandleEx() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleEx");
|
||||
@@ -188,9 +209,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleOps() throws Exception {
|
||||
public void testHandleOps() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleOps");
|
||||
@@ -200,9 +224,12 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandleAll() throws Exception {
|
||||
public void testHandleAll() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
CqEvent event = event();
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleAll");
|
||||
@@ -214,8 +241,10 @@ public class QueryListenerAdapterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalid() throws Exception {
|
||||
public void testInvalid() {
|
||||
|
||||
Delegate mockDelegate = mock(Delegate.class);
|
||||
|
||||
ContinuousQueryListenerAdapter cqListenerAdapter = new ContinuousQueryListenerAdapter(mockDelegate);
|
||||
|
||||
cqListenerAdapter.setDefaultListenerMethod("handleInvalid");
|
||||
@@ -229,6 +258,7 @@ public class QueryListenerAdapterTest {
|
||||
*/
|
||||
@Test
|
||||
public void triggersListenerImplementingInterfaceCorrectly() {
|
||||
|
||||
SampleListener listener = new SampleListener();
|
||||
|
||||
ContinuousQueryListener listenerAdapter = new ContinuousQueryListenerAdapter(listener) {
|
||||
@@ -250,5 +280,4 @@ public class QueryListenerAdapterTest {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class QueryPostProcessorIntegrationTests {
|
||||
|
||||
private static final AtomicLong idSequence = new AtomicLong(0L);
|
||||
@@ -132,7 +133,7 @@ public class QueryPostProcessorIntegrationTests {
|
||||
);
|
||||
}
|
||||
|
||||
@ClientCacheApplication
|
||||
@ClientCacheApplication(logLevel = "error")
|
||||
@SuppressWarnings("unused")
|
||||
static class TestConfiguration {
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.gemfire.serialization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -26,7 +27,6 @@ import java.awt.Shape;
|
||||
import java.beans.Beans;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.geode.DataSerializable;
|
||||
@@ -36,23 +36,26 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("simple-config.xml")
|
||||
@SuppressWarnings("unused")
|
||||
public class WiringInstantiatorTest {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext ctx;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private WiringInstantiator instantiator;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class AnnotatedBean implements DataSerializable {
|
||||
|
||||
@Autowired
|
||||
Point point;
|
||||
Shape shape;
|
||||
@@ -62,69 +65,70 @@ public class WiringInstantiatorTest {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
|
||||
}
|
||||
public void fromData(DataInput in) { }
|
||||
|
||||
public void toData(DataOutput out) { }
|
||||
|
||||
public void toData(DataOutput out) throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class TemplateWiringBean implements DataSerializable {
|
||||
Point point;
|
||||
|
||||
Beans beans;
|
||||
Point point;
|
||||
|
||||
public void setBeans(Beans bs) {
|
||||
this.beans = bs;
|
||||
}
|
||||
|
||||
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
|
||||
}
|
||||
public void fromData(DataInput in) { }
|
||||
|
||||
public void toData(DataOutput out) { }
|
||||
|
||||
public void toData(DataOutput out) throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class TypeA implements DataSerializable {
|
||||
|
||||
public void fromData(DataInput arg0) throws IOException, ClassNotFoundException {
|
||||
}
|
||||
public void fromData(DataInput arg0) { }
|
||||
|
||||
public void toData(DataOutput arg0) { }
|
||||
|
||||
public void toData(DataOutput arg0) throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class TypeB implements DataSerializable {
|
||||
|
||||
public void fromData(DataInput arg0) throws IOException, ClassNotFoundException {
|
||||
}
|
||||
public void fromData(DataInput arg0) { }
|
||||
|
||||
public void toData(DataOutput arg0) { }
|
||||
|
||||
public void toData(DataOutput arg0) throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutowiredBean() throws Exception {
|
||||
public void testAutowiredBean() {
|
||||
|
||||
Object instance = instantiator.newInstance();
|
||||
|
||||
assertNotNull(instance);
|
||||
assertTrue(instance instanceof AnnotatedBean);
|
||||
|
||||
AnnotatedBean bean = (AnnotatedBean) instance;
|
||||
|
||||
assertNotNull(bean.point);
|
||||
assertNotNull(bean.shape);
|
||||
|
||||
assertSame(bean.point, ctx.getBean("point"));
|
||||
assertSame(bean.shape, ctx.getBean("area"));
|
||||
assertSame(bean.point, applicationContext.getBean("point"));
|
||||
assertSame(bean.shape, applicationContext.getBean("area"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateBean() throws Exception {
|
||||
WiringInstantiator instantiator2 = new WiringInstantiator(
|
||||
new AsmInstantiatorGenerator().getInstantiator(
|
||||
TemplateWiringBean.class, 99));
|
||||
instantiator2.setBeanFactory(ctx.getAutowireCapableBeanFactory());
|
||||
public void testTemplateBean() {
|
||||
|
||||
WiringInstantiator instantiator2 =
|
||||
new WiringInstantiator(new AsmInstantiatorGenerator().getInstantiator(TemplateWiringBean.class, 99));
|
||||
|
||||
instantiator2.setBeanFactory(applicationContext.getAutowireCapableBeanFactory());
|
||||
instantiator2.afterPropertiesSet();
|
||||
|
||||
Object instance = instantiator2.newInstance();
|
||||
@@ -132,15 +136,15 @@ public class WiringInstantiatorTest {
|
||||
assertTrue(instance instanceof TemplateWiringBean);
|
||||
TemplateWiringBean bean = (TemplateWiringBean) instance;
|
||||
|
||||
assertTrue(bean.point == null);
|
||||
assertNull(bean.point);
|
||||
assertNotNull(bean.beans);
|
||||
|
||||
assertSame(bean.beans, ctx.getBean("beans"));
|
||||
assertSame(bean.beans, applicationContext.getBean("beans"));
|
||||
}
|
||||
|
||||
public void testInstantiatorFactoryBean() throws Exception {
|
||||
public void testInstantiatorFactoryBean() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Instantiator> list = (List<Instantiator>) ctx.getBean("instantiator-factory");
|
||||
List<Instantiator> list = (List<Instantiator>) applicationContext.getBean("instantiator-factory");
|
||||
assertNotNull(list);
|
||||
assertEquals(2, list.size());
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.data.gemfire.test.support.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.test.support.ThreadUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -69,7 +69,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class SnapshotApplicationEventTriggeredImportsExportsIntegrationTest {
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* 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.util.function.Function;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import edu.umd.cs.mtc.MultithreadedTestCase;
|
||||
import edu.umd.cs.mtc.TestFramework;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.apache.geode.cache.CacheTransactionManager;
|
||||
import org.apache.geode.cache.CommitConflictException;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.gemfire.config.annotation.ClientCacheApplication;
|
||||
import org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions;
|
||||
import org.springframework.data.gemfire.mapping.GemfireMappingContext;
|
||||
import org.springframework.data.gemfire.mapping.annotation.Region;
|
||||
import org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean;
|
||||
import org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
*
|
||||
* Specifically, this test asserts that 2 concurrent threads modifying the same entity inside a cache transaction
|
||||
* leads to a {@link CommitConflictException}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.util.function.Function
|
||||
* @see edu.umd.cs.mtc.MultithreadedTestCase
|
||||
* @see edu.umd.cs.mtc.TestFramework
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.CacheTransactionManager
|
||||
* @see org.apache.geode.cache.CommitConflictException
|
||||
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnableEntityDefinedRegions
|
||||
* @see org.springframework.data.gemfire.repository.config.EnableGemfireRepositories
|
||||
* @see org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTransactions
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 2.2.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class CommitConflictExceptionTransactionalIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
|
||||
@Test
|
||||
public void concurrentTransactionalThreadsCauseCommitConflictException() throws Throwable {
|
||||
TestFramework.runOnce(new TransactionalCommitConflictMultithreadedTestCase(this.customerService));
|
||||
}
|
||||
|
||||
static class TransactionalCommitConflictMultithreadedTestCase extends MultithreadedTestCase {
|
||||
|
||||
private final CustomerService customerService;
|
||||
|
||||
TransactionalCommitConflictMultithreadedTestCase(CustomerService customerService) {
|
||||
|
||||
Assert.notNull(customerService, "CustomerService is required");
|
||||
|
||||
this.customerService = customerService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
super.initialize();
|
||||
|
||||
Customer jonDoe = this.customerService.save(Customer.newCustomer(1L, "Jon Doe"));
|
||||
Customer jonDoeLoaded = this.customerService.findById(jonDoe.getId());
|
||||
|
||||
assertThat(jonDoeLoaded).isEqualTo(jonDoe);
|
||||
}
|
||||
|
||||
public void thread1() {
|
||||
|
||||
assertTick(0);
|
||||
|
||||
Thread.currentThread().setName("Customer Processing Thread One");
|
||||
|
||||
this.customerService.process(1L, customer -> {
|
||||
|
||||
assertThat(customer.getId()).isEqualTo(1L);
|
||||
assertThat(customer.getName()).isEqualTo("Jon Doe");
|
||||
|
||||
customer.setName("Pie Doe");
|
||||
|
||||
waitForTick(2);
|
||||
assertTick(2);
|
||||
|
||||
return customer;
|
||||
|
||||
}, Function.identity());
|
||||
}
|
||||
|
||||
public void thread2() {
|
||||
|
||||
assertTick(0);
|
||||
|
||||
Thread.currentThread().setName("Customer Processing Thread Two");
|
||||
|
||||
waitForTick(1);
|
||||
assertTick(1);
|
||||
|
||||
try {
|
||||
|
||||
this.customerService.process(1L, customer -> {
|
||||
|
||||
assertThat(customer.getId()).isEqualTo(1L);
|
||||
assertThat(customer.getName()).isEqualTo("Jon Doe");
|
||||
|
||||
customer.setName("Sour Doe");
|
||||
|
||||
waitForTick(3);
|
||||
assertTick(3);
|
||||
|
||||
return customer;
|
||||
|
||||
}, Function.identity());
|
||||
|
||||
fail("Expected CommitConflictException!");
|
||||
|
||||
}
|
||||
catch (RuntimeException expected) {
|
||||
assertThat(expected).isInstanceOf(GemfireTransactionCommitException.class);
|
||||
assertThat(expected).hasCauseInstanceOf(CommitConflictException.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
|
||||
Customer customer = this.customerService.findById(1L);
|
||||
|
||||
assertThat(customer).isNotNull();
|
||||
assertThat(customer.getId()).isEqualTo(1L);
|
||||
assertThat(customer.getName()).isEqualTo("Pie Doe");
|
||||
}
|
||||
}
|
||||
|
||||
@ClientCacheApplication(logLevel = "error")
|
||||
@EnableEntityDefinedRegions(
|
||||
basePackageClasses = Customer.class,
|
||||
clientRegionShortcut = ClientRegionShortcut.LOCAL
|
||||
)
|
||||
@EnableGemfireCacheTransactions
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
GemfireRepositoryFactoryBean<CustomerRepository, Customer, Long> customerRepositoryFactoryBean() {
|
||||
|
||||
GemfireRepositoryFactoryBean<CustomerRepository, Customer, Long> customerRepositoryFactoryBean
|
||||
= new GemfireRepositoryFactoryBean<>(CustomerRepository.class);
|
||||
|
||||
customerRepositoryFactoryBean.setGemfireMappingContext(new GemfireMappingContext());
|
||||
|
||||
return customerRepositoryFactoryBean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
CustomerService customerService(CustomerRepository customerRepository) {
|
||||
return new CustomerService(customerRepository);
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@Region("Customers")
|
||||
@RequiredArgsConstructor(staticName = "newCustomer")
|
||||
static class Customer implements Serializable {
|
||||
|
||||
@NonNull @Id
|
||||
private Long id;
|
||||
|
||||
@NonNull
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
public interface CustomerRepository extends CrudRepository<Customer, Long> { }
|
||||
|
||||
@Service
|
||||
public static class CustomerService {
|
||||
|
||||
private final CustomerRepository customerRepository;
|
||||
|
||||
public CustomerService(CustomerRepository customerRepository) {
|
||||
|
||||
Assert.notNull(customerRepository, "CustomerRepository is required");
|
||||
|
||||
this.customerRepository = customerRepository;
|
||||
}
|
||||
|
||||
protected Customer findById(Long id) {
|
||||
|
||||
Assert.notNull(id, "ID is required");
|
||||
|
||||
return this.customerRepository.findById(id)
|
||||
.orElseThrow(() -> newIllegalStateException("No Customer with ID [%d] was found", id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Customer process(Long id, Function<Customer, Customer> beforeSave,
|
||||
Function<Customer, Customer> afterSave) {
|
||||
|
||||
return afterSave.apply(save(beforeSave.apply(findById(id))));
|
||||
}
|
||||
|
||||
protected Customer save(Customer customer) {
|
||||
|
||||
Assert.notNull(customer, "Customer is required");
|
||||
|
||||
return this.customerRepository.save(customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -2,17 +2,24 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/gemfire https://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ClientCacheIndexingTestServer</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties" pool-name="serverConnectionPool"/>
|
||||
|
||||
<gfe:pool id="serverConnectionPool">
|
||||
<gfe:server host="localhost" port="42424"/>
|
||||
</gfe:pool>
|
||||
|
||||
<gfe:client-cache pool-name="serverConnectionPool"/>
|
||||
|
||||
<gfe:client-region id="Example" shortcut="LOCAL"/>
|
||||
|
||||
<gfe:index id="ExampleIndex" expression="id" from="/Example" type="HASH"/>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<context:property-placeholder properties-ref="client.properties"/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<context:property-placeholder properties-ref="clientProperties"/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties" pool-name="serverPool"/>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ClientCacheWithRegionUsingCacheLoaderWriterTest</prop>
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<bean class="org.springframework.data.gemfire.test.GemfireTestBeanPostProcessor"/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<bean id="reflectionPdxSerializer" class="org.apache.geode.pdx.ReflectionBasedAutoSerializer"/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties" pool-name="clientPool"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">LuceneNamespaceUnitTests</prop>
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<bean class="org.springframework.data.gemfire.test.GemfireTestBeanPostProcessor"/>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<context:property-placeholder location="classpath:port.properties"/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache cache-xml-location="/clientcache-with-regions.xml" properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<context:property-placeholder/>
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">config</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<bean id="addressPdxSerializer"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:pool id="serverPool">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">ContainerXmlSetupIntegrationTests</prop>
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache cache-xml-location="/clientcache-with-regions.xml" properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
">
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:client-cache cache-xml-location="/clientcache-with-regions.xml" properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
|
||||
">
|
||||
|
||||
<context:annotation-config/>
|
||||
|
||||
<bean id="point" class="java.awt.Point"/>
|
||||
|
||||
<bean id="area" class="java.awt.geom.Area"/>
|
||||
<bean id="beans" class="java.beans.Beans"/>
|
||||
<bean id="point" class="java.awt.Point"/>
|
||||
|
||||
<bean id="generator" class="org.springframework.data.gemfire.serialization.AsmInstantiatorGenerator"/>
|
||||
|
||||
<bean id="generator" class="org.springframework.data.gemfire.serialization.AsmInstantiatorGenerator"/>
|
||||
|
||||
<bean id="instantiator" class="org.springframework.data.gemfire.serialization.WiringInstantiator">
|
||||
<constructor-arg>
|
||||
<bean factory-bean="generator" factory-method="getInstantiator">
|
||||
@@ -23,9 +24,9 @@
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean class="org.springframework.data.gemfire.serialization.WiringInstantiatorTest$TemplateWiringBean" abstract="true" p:beans-ref="beans"/>
|
||||
|
||||
|
||||
<bean id="instantiator-factory" class="org.springframework.data.gemfire.serialization.InstantiatorFactoryBean">
|
||||
<property name="customTypes">
|
||||
<map>
|
||||
@@ -34,4 +35,5 @@
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">SnapshotApplicationEventTriggeredImportsExportsIntegrationTest</prop>
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">WiringDeclarableSupportIntegrationTests</prop>
|
||||
<prop key="log-level">warning</prop>
|
||||
<prop key="log-level">error</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache cache-xml-location="cache-with-declarable.xml" properties-ref="gemfireProperties"
|
||||
|
||||
Reference in New Issue
Block a user