DATAGEODE-180 - Polish log statements and log levels.

This commit is contained in:
John Blum
2019-04-10 19:56:34 -07:00
parent 6d679fc462
commit 626076b05e
36 changed files with 218 additions and 153 deletions

View File

@@ -42,27 +42,25 @@ 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;
/**
* The ClientCacheIndexingTest class is a test suite of test cases testing the creation and application of indexes
* on client Regions of a GemFire ClientCache using the <gfe:index/> tag element in the Spring Data GemFire
* XML namespace and configuration meta-data, which is backed by the IndexFactoryBean.
* Integration tests for testing {@link ClientCache} {@link Index Indexes}.
*
* @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 {
@@ -77,29 +75,34 @@ public class ClientCacheIndexingTest {
@BeforeClass
public static void setup() throws IOException {
String serverName = "GemFireIndexingCacheServer";
File serverWorkingDirectory = new File(FileSystemUtils.WORKING_DIRECTORY, serverName.toLowerCase());
Assert.isTrue(serverWorkingDirectory.isDirectory() || serverWorkingDirectory.mkdirs());
Assert.isTrue(serverWorkingDirectory.isDirectory() || serverWorkingDirectory.mkdirs(),
String.format("Server working directory [%s] does not exist and could not be created", serverWorkingDirectory));
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
arguments.add("-Dgemfire.name=" + serverName);
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));
}
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() {
ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.WaitCondition() {
private File serverPidControlFile =
new File(serverProcess.getWorkingDirectory(), ServerProcess.getServerProcessControlFilename());
@Override
public boolean waiting() {
return !serverPidControlFile.isFile();
}
});
@@ -107,6 +110,7 @@ public class ClientCacheIndexingTest {
@AfterClass
public static void tearDown() {
serverProcess.shutdown();
if (Boolean.valueOf(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) {
@@ -115,8 +119,10 @@ public class ClientCacheIndexingTest {
}
protected Index getIndex(final GemFireCache gemfireCache, final String indexName) {
QueryService queryService = (gemfireCache instanceof ClientCache
? ((ClientCache) gemfireCache).getLocalQueryService() : gemfireCache.getQueryService());
QueryService queryService = gemfireCache instanceof ClientCache
? ((ClientCache) gemfireCache).getLocalQueryService()
: gemfireCache.getQueryService();
for (Index index : queryService.getIndexes()) {
if (index.getName().equals(indexName)) {
@@ -130,6 +136,7 @@ public class ClientCacheIndexingTest {
@Test
@SuppressWarnings("deprecation")
public void testIndexByName() {
assertNotNull("The GemFire ClientCache was not properly configured and initialized!", clientCache);
Index actualIndex = getIndex(clientCache, "ExampleIndex");
@@ -139,5 +146,4 @@ public class ClientCacheIndexingTest {
assertEquals(IndexType.HASH, actualIndex.getType());
assertSame(exampleIndex, actualIndex);
}
}

View File

@@ -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() { }
}
}

View File

@@ -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 {

View File

@@ -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 { }
}

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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"));
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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++;
}
}
}

View File

@@ -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 {

View File

@@ -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());
}

View File

@@ -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 {

View File

@@ -27,6 +27,11 @@ 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;
@@ -47,11 +52,6 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.Assert;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
/**
* 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
@@ -176,7 +176,7 @@ public class CommitConflictExceptionTransactionalIntegrationTests {
}
}
@ClientCacheApplication
@ClientCacheApplication(logLevel = "error")
@EnableEntityDefinedRegions(
basePackageClasses = Customer.class,
clientRegionShortcut = ClientRegionShortcut.LOCAL