SGF-588 - Reorganize and repackage additional classes in the SDG API.

(cherry picked from commit 2dbc60854bc77fead46db05e219adeffd552ba4b)
Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
John Blum
2017-01-20 22:32:56 -08:00
parent c253508fca
commit 5472159198
29 changed files with 301 additions and 230 deletions

View File

@@ -28,7 +28,7 @@ import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.RegionShortcut;
import org.junit.Test;
import org.springframework.data.gemfire.support.AbstractRegionFactoryBeanTest;
import org.springframework.data.gemfire.test.support.AbstractRegionFactoryBeanTests;
/**
* The PartitionedRegionFactoryBeanTest class is a test suite of test cases testing the component functionality
@@ -42,7 +42,7 @@ import org.springframework.data.gemfire.support.AbstractRegionFactoryBeanTest;
* @since 1.3.x
*/
@SuppressWarnings("unchecked")
public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
private final LocalRegionFactoryBean factoryBean = new LocalRegionFactoryBean();
@@ -283,5 +283,4 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
factoryBean.resolveDataPolicy(mockRegionFactory, false, DataPolicy.PERSISTENT_REPLICATE);
verify(mockRegionFactory).setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
}
}

View File

@@ -53,7 +53,7 @@ import org.apache.geode.cache.SubscriptionAttributes;
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.junit.After;
import org.junit.Test;
import org.springframework.data.gemfire.support.AbstractRegionFactoryBeanTest;
import org.springframework.data.gemfire.test.support.AbstractRegionFactoryBeanTests;
import org.springframework.data.gemfire.util.ArrayUtils;
/**
@@ -72,7 +72,7 @@ import org.springframework.data.gemfire.util.ArrayUtils;
* @see org.apache.geode.cache.RegionShortcut
*/
@SuppressWarnings("unchecked")
public class RegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
public class RegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
private final RegionFactoryBean factoryBean = new TestRegionFactoryBean();
@@ -1062,5 +1062,4 @@ public class RegionFactoryBeanTest extends AbstractRegionFactoryBeanTest {
protected static class TestRegionFactoryBean<K, V> extends RegionFactoryBean<K, V> {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012 the original author or authors.
* Copyright 2016 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.
@@ -15,7 +15,7 @@
*
*/
package org.springframework.data.gemfire.support;
package org.springframework.data.gemfire.cache;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@@ -43,7 +43,8 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
/**
* Tests the adaption of the {@link java.util.concurrent.Callable} in to GemFire's {@link org.apache.geode.cache.CacheLoader} interface.
* Unit tests to test the adaption of the {@link java.util.concurrent.Callable}
* into GemFire's {@link org.apache.geode.cache.CacheLoader} interface.
*
* @author John Blum
* @see org.junit.Rule
@@ -57,7 +58,7 @@ import org.mockito.stubbing.Answer;
* @see org.apache.geode.cache.CacheLoader
* @see org.apache.geode.cache.LoaderHelper
* @see org.apache.geode.cache.Region
* @since 1.0.0
* @since 1.9.0
*/
@RunWith(MockitoJUnitRunner.class)
public class CallableCacheLoaderAdapterTest {
@@ -66,7 +67,7 @@ public class CallableCacheLoaderAdapterTest {
private CacheLoader<String, Object> mockCacheLoader;
@Rule
public ExpectedException expectedException = ExpectedException.none();
public ExpectedException exception = ExpectedException.none();
@Mock
private LoaderHelper<String, Object> mockLoaderHelper;
@@ -76,8 +77,8 @@ public class CallableCacheLoaderAdapterTest {
@Test
public void constructCallableCacheLoaderAdapterWithArgumentKeyAndRegion() {
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
mockCacheLoader, "key", mockRegion, "test");
CallableCacheLoaderAdapter<String, Object> instance =
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", mockRegion, "test");
assertThat(instance, is(notNullValue()));
assertThat(instance.getCacheLoader(), is(sameInstance(mockCacheLoader)));
@@ -88,8 +89,8 @@ public class CallableCacheLoaderAdapterTest {
@Test
public void constructCallableCacheLoaderAdapterWithKeyRegionAndNoArgument() {
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
mockCacheLoader, "key", mockRegion);
CallableCacheLoaderAdapter<String, Object> instance =
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", mockRegion);
assertThat(instance, is(notNullValue()));
assertThat(instance.getCacheLoader(), is(sameInstance(mockCacheLoader)));
@@ -101,7 +102,7 @@ public class CallableCacheLoaderAdapterTest {
@Test
public void constructCallableCacheLoaderAdapterWithNoArgumentKeyOrRegion() {
CallableCacheLoaderAdapter<String, Object> instance =
new CallableCacheLoaderAdapter<String, Object>(mockCacheLoader);
new CallableCacheLoaderAdapter<>(mockCacheLoader);
assertThat(instance, is(notNullValue()));
assertThat(instance.getCacheLoader(), is(sameInstance(mockCacheLoader)));
@@ -112,25 +113,25 @@ public class CallableCacheLoaderAdapterTest {
@Test
public void constructCallableCacheLoaderAdapterWithNullCacheLoader() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectCause(is(nullValue(Throwable.class)));
expectedException.expectMessage("CacheLoader must not be null");
exception.expect(IllegalArgumentException.class);
exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("CacheLoader must not be null");
new CallableCacheLoaderAdapter<Object, Object>(null);
new CallableCacheLoaderAdapter<>(null);
}
@Test
@SuppressWarnings("unchecked")
public void callDelegatesToLoad() throws Exception {
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
mockCacheLoader, "key", mockRegion, "test");
CallableCacheLoaderAdapter<String, Object> instance =
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", mockRegion, "test");
when(mockCacheLoader.load(any(LoaderHelper.class))).thenAnswer(new Answer<String>() {
public String answer(final InvocationOnMock invocation) throws Throwable {
LoaderHelper<String, Object> loaderHelper = invocation.getArgumentAt(0, LoaderHelper.class);
assertThat(loaderHelper, is(notNullValue()));
assertThat((String) loaderHelper.getArgument(), is(equalTo("test")));
assertThat(loaderHelper.getArgument(), is(equalTo("test")));
assertThat(loaderHelper.getKey(), is(equalTo("key")));
assertThat(loaderHelper.getRegion(), is(sameInstance(mockRegion)));
@@ -138,57 +139,55 @@ public class CallableCacheLoaderAdapterTest {
}
});
assertThat((String) instance.call(), is(equalTo("mockValue")));
assertThat(instance.call(), is(equalTo("mockValue")));
verify(mockCacheLoader, times(1)).load(isA(LoaderHelper.class));
}
@Test
public void callThrowsIllegalStateExceptionForNullKey() throws Exception {
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
mockCacheLoader, null, mockRegion);
CallableCacheLoaderAdapter<String, Object> instance =
new CallableCacheLoaderAdapter<>(mockCacheLoader, null, mockRegion);
assertThat(instance.getKey(), is(nullValue()));
assertThat(instance.getRegion(), is(sameInstance(mockRegion)));
expectedException.expect(IllegalStateException.class);
expectedException.expectCause(is(nullValue(Throwable.class)));
expectedException.expectMessage("The key for which the value is loaded for cannot be null");
exception.expect(IllegalStateException.class);
exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("The key for which the value is loaded for cannot be null");
instance.call();
}
@Test
public void callThrowsIllegalStateExceptionForNullRegion() throws Exception {
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<String, Object>(
mockCacheLoader, "key", null);
CallableCacheLoaderAdapter<String, Object> instance =
new CallableCacheLoaderAdapter<>(mockCacheLoader, "key", null);
assertThat(instance.getKey(), is(equalTo("key")));
assertThat(instance.getRegion(), is(nullValue()));
expectedException.expect(IllegalStateException.class);
expectedException.expectCause(is(nullValue(Throwable.class)));
expectedException.expectMessage("The Region to load cannot be null");
exception.expect(IllegalStateException.class);
exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("The Region to load cannot be null");
instance.call();
}
@Test
public void closeDelegatesToCacheLoaderClose() {
new CallableCacheLoaderAdapter<String, Object>(mockCacheLoader).close();
new CallableCacheLoaderAdapter<>(mockCacheLoader).close();
verify(mockCacheLoader, times(1)).close();
}
@Test
public void loadDelegatesToCacheLoaderLoad() {
CallableCacheLoaderAdapter<String, Object> instance =
new CallableCacheLoaderAdapter<String, Object>(mockCacheLoader);
CallableCacheLoaderAdapter<String, Object> instance = new CallableCacheLoaderAdapter<>(mockCacheLoader);
when(mockCacheLoader.load(eq(mockLoaderHelper))).thenReturn("test");
assertThat((String) instance.load(mockLoaderHelper), is(equalTo("test")));
assertThat(instance.load(mockLoaderHelper), is(equalTo("test")));
verify(mockCacheLoader, times(1)).load(eq(mockLoaderHelper));
}
}

View File

@@ -32,7 +32,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.data.gemfire.process.ProcessWrapper;
import org.springframework.data.gemfire.test.AbstractGemFireClientServerIntegrationTest;
import org.springframework.data.gemfire.test.support.AbstractGemFireClientServerIntegrationTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Assert;

View File

@@ -55,7 +55,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.process.ProcessWrapper;
import org.springframework.data.gemfire.test.AbstractGemFireClientServerIntegrationTest;
import org.springframework.data.gemfire.test.support.AbstractGemFireClientServerIntegrationTest;
import org.springframework.data.gemfire.test.support.ThreadUtils;
import org.springframework.data.gemfire.util.DistributedSystemUtils;
import org.springframework.test.annotation.DirtiesContext;
@@ -74,7 +74,7 @@ import org.springframework.util.SocketUtils;
* @see org.springframework.beans.factory.config.BeanPostProcessor
* @see org.springframework.context.ConfigurableApplicationContext
* @see org.springframework.data.gemfire.process.ProcessWrapper
* @see org.springframework.data.gemfire.test.AbstractGemFireClientServerIntegrationTest
* @see AbstractGemFireClientServerIntegrationTest
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @see org.apache.geode.cache.client.ClientCache

View File

@@ -58,7 +58,7 @@ import org.junit.rules.ExpectedException;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.data.gemfire.support.ListRegionsOnServerFunction;
import org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction;
/**
* The GemfireDataSourcePostProcessor class is a test suite of test cases testing the contract and functionality

View File

@@ -1,20 +1,21 @@
/*
* Copyright 2010-2013 the original author or authors.
* Copyright 2016 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://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.support;
package org.springframework.data.gemfire.client.function;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
@@ -49,7 +50,7 @@ import org.mockito.stubbing.Answer;
* @author John Blum
* @see org.junit.Test
* @see org.mockito.Mockito
* @see org.springframework.data.gemfire.support.ListRegionsOnServerFunction
* @see ListRegionsOnServerFunction
* @since 1.7.0
*/
public class ListRegionsOnServerFunctionTest {
@@ -69,14 +70,14 @@ public class ListRegionsOnServerFunctionTest {
ResultSender<Object> mockResultSender = mock(ResultSender.class, "MockGemFireResultSender");
when(mockCache.rootRegions()).thenReturn(new HashSet<Region<?, ?>>(
when(mockCache.rootRegions()).thenReturn(new HashSet<>(
Arrays.<Region<?, ?>>asList(mockRegionOne, mockRegionTwo, mockRegionThree)));
when(mockRegionOne.getName()).thenReturn("One");
when(mockRegionTwo.getName()).thenReturn("Two");
when(mockRegionThree.getName()).thenReturn("Three");
when(mockFunctionContext.getResultSender()).thenReturn(mockResultSender);
final AtomicReference<List<String>> regionNames = new AtomicReference<List<String>>(null);
final AtomicReference<List<String>> regionNames = new AtomicReference<>(null);
doAnswer(new Answer<Void>() {
@Override
@@ -118,10 +119,10 @@ public class ListRegionsOnServerFunctionTest {
ResultSender<Object> mockResultSender = mock(ResultSender.class, "MockGemFireResultSender");
when(mockCache.rootRegions()).thenReturn(Collections.<Region<?, ?>>emptySet());
when(mockCache.rootRegions()).thenReturn(Collections.emptySet());
when(mockFunctionContext.getResultSender()).thenReturn(mockResultSender);
final AtomicReference<List<String>> regionNames = new AtomicReference<List<String>>(null);
final AtomicReference<List<String>> regionNames = new AtomicReference<>(null);
doAnswer(new Answer<Void>() {
@Override
@@ -164,5 +165,4 @@ public class ListRegionsOnServerFunctionTest {
assertThat(function.isHA(), is(false));
assertThat(function.optimizeForWrite(), is(false));
}
}

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.gemfire.GemfireTransactionManager;
import org.springframework.data.gemfire.transaction.GemfireTransactionManager;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -0,0 +1,106 @@
/*
* Copyright 2016 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
*
* http://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.dao;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import org.apache.geode.cache.Region;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.data.gemfire.GemfireOperations;
import org.springframework.data.gemfire.GemfireTemplate;
/**
* Unit tests for {@link GemfireDaoSupport}.
*
* @author Costin Leau
* @author John Blum
* @see org.junit.Rule
* @see org.junit.Test
* @see org.mockito.Mock
* @see org.mockito.Mockito
* @see org.mockito.runners.MockitoJUnitRunner
*/
@RunWith(MockitoJUnitRunner.class)
public class GemfireDaoSupportUnitTests {
@Rule
public ExpectedException exception = ExpectedException.none();
@Mock
public Region<?, ?> mockRegion;
@Test
public void setAndGetGemfireTemplate() {
GemfireTemplate expectedGemfireTemplate = new GemfireTemplate(mockRegion);
GemfireDaoSupport dao = new TestGemfireDaoSupport();
assertThat(dao.getGemfireTemplate()).isNull();
dao.setGemfireTemplate(expectedGemfireTemplate);
assertThat(dao.getGemfireTemplate()).isSameAs(expectedGemfireTemplate);
dao.setGemfireTemplate(null);
assertThat(dao.getGemfireTemplate()).isNull();
}
@Test
public void setRegion() {
GemfireDaoSupport dao = new TestGemfireDaoSupport();
dao.setRegion(mockRegion);
GemfireOperations gemfireTemplate = dao.getGemfireTemplate();
assertThat(gemfireTemplate).isNotNull();
assertThat(gemfireTemplate).isInstanceOf(GemfireTemplate.class);
assertThat(((GemfireTemplate) gemfireTemplate).getRegion()).isSameAs(mockRegion);
}
@Test
@SuppressWarnings("rawtypes")
public void createProperlyInitializedGemfireDaoSupportWithTemplate() throws Exception {
GemfireTemplate expectedGemfireTemplate = new GemfireTemplate();
GemfireDaoSupport dao = new TestGemfireDaoSupport();
dao.setGemfireTemplate(expectedGemfireTemplate);
dao.afterPropertiesSet();
assertThat(dao.getGemfireTemplate()).isNotNull();
assertThat(dao.getGemfireTemplate()).isEqualTo(expectedGemfireTemplate);
}
@Test
public void invalidGemfireDaoSupportInstanceThrowsIllegalStateException() throws Exception {
exception.expect(IllegalStateException.class);
exception.expectCause(is(nullValue(Throwable.class)));
exception.expectMessage("A GemFire Cache Region or instance of GemfireTemplate is required");
new TestGemfireDaoSupport().afterPropertiesSet();
}
private static final class TestGemfireDaoSupport extends GemfireDaoSupport {
}
}

View File

@@ -1,17 +1,21 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2016 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
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://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.
*
* 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.support;
package org.springframework.data.gemfire.serialization.json;
import static org.junit.Assert.assertEquals;
@@ -34,23 +38,28 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.GemfireOperations;
import org.springframework.data.gemfire.repository.sample.Person;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
/**
* JSONRegionAdviceTest is a test suite of test cases testing SDG's support for storing and retrieving JSON data
* in GemFire Cache Regions (un)marshalled using Jackson.
* Integration test to test SDG support for storing and reading JSON data to/from
* a GemFire Cache {@link Region} by (un)marshalled JSON data using Jackson.
*
* @author David Turanski
* @author John Blum
* @see org.apache.geode.cache.Region
* @see org.springframework.data.gemfire.GemfireOperations
* @see org.springframework.data.gemfire.serialization.json.JSONRegionAdvice
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
*/
@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(SpringRunner.class)
@ContextConfiguration
@SuppressWarnings({ "unchecked", "unused" })
public class JSONRegionAdviceTest {
// TODO figure out why auto-proxying the Region for JSON support prevents the GemfireTemplate from being "auto-wired",
// as a GemfireTemplate rather than GemfireOperations, resulting in a NoSuchBeanDefinitionException thrown by the
// Spring container!?!?!?!?
// Spring container?
@Autowired
private GemfireOperations template;
@@ -132,5 +141,4 @@ public class JSONRegionAdviceTest {
SelectResults<String> results = template.query("firstname='Dave'");
assertEquals(toJson(daveTuranski), results.iterator().next());
}
}

View File

@@ -33,6 +33,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.cache.Cache;
import org.springframework.data.gemfire.GemfireUtils;
import org.springframework.data.gemfire.test.support.AbstractNativeCacheTests;
/**
* Integration Tests for {@link GemfireCache}.
@@ -261,5 +262,4 @@ public class GemfireCacheIntegrationTests extends AbstractNativeCacheTests<Regio
return value;
}
}
}

View File

@@ -1,60 +0,0 @@
/*
* Copyright 2011-2013 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
*
* http://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.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Test;
import org.springframework.data.gemfire.GemfireOperations;
import org.springframework.data.gemfire.GemfireTemplate;
/**
* @author Costin Leau
* @author John Blum
*/
public class GemfireDaoSupportTests {
@Test
@SuppressWarnings("rawtypes")
public void testGemfireDaoSupportWithTemplate() throws Exception {
final AtomicBoolean flag = new AtomicBoolean(false);
GemfireDaoSupport dao = new GemfireDaoSupport() {
protected void initDao() {
flag.set(true);
}
};
GemfireOperations expectedTemplate = new GemfireTemplate();
dao.setGemfireTemplate(expectedTemplate);
dao.afterPropertiesSet();
assertNotNull("template not created", dao.getGemfireTemplate());
assertEquals("incorrect template", expectedTemplate, dao.getGemfireTemplate());
assertTrue("initDao not called", flag.get());
}
@Test(expected = IllegalStateException.class)
public void testInvalidDaoTemplate() throws Exception {
new GemfireDaoSupport().afterPropertiesSet();
}
}

View File

@@ -92,6 +92,7 @@ public class WiringDeclarableSupportIntegrationTests {
@Data
@NoArgsConstructor
@SuppressWarnings("all")
public static class TestCacheLoader extends WiringDeclarableSupport implements CacheLoader<String, String> {
private Object propertyOne;

View File

@@ -1,20 +1,21 @@
/*
* Copyright 2010-2013 the original author or authors.
* Copyright 2016 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://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.test;
package org.springframework.data.gemfire.test.support;
import java.io.File;
import java.io.IOException;
@@ -25,8 +26,6 @@ import java.util.concurrent.TimeUnit;
import org.springframework.data.gemfire.fork.ServerProcess;
import org.springframework.data.gemfire.process.ProcessExecutor;
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.util.Assert;
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010 the original author or authors.
* Copyright 2016 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.
@@ -12,9 +12,10 @@
* 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.support;
package org.springframework.data.gemfire.test.support;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2013 the original author or authors.
* Copyright 2016 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.
@@ -12,9 +12,10 @@
* 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.support;
package org.springframework.data.gemfire.test.support;
import java.io.File;
import java.io.FilenameFilter;
@@ -33,19 +34,15 @@ import org.springframework.data.gemfire.test.StubCache;
* @author David Turanski
* @author John Blum
*/
public abstract class AbstractRegionFactoryBeanTest {
public abstract class AbstractRegionFactoryBeanTests {
private GemFireCache cache;
private Map<String, RegionFactoryBeanConfig> regionFactoryBeanConfigs = new HashMap<String, RegionFactoryBeanConfig>();
private Map<String, RegionFactoryBeanConfig> regionFactoryBeanConfigs = new HashMap<>();
@AfterClass
public static void cleanUp() {
for (String name : new File(".").list(new FilenameFilter() {
@Override public boolean accept(File dir, String name) {
return name.startsWith("BACKUP");
}
})) {
for (String name : new File(".").list((dir, name1) -> name1.startsWith("BACKUP"))) {
new File(name).delete();
}
}
@@ -114,5 +111,4 @@ public abstract class AbstractRegionFactoryBeanTest {
public abstract void verify();
}
}