Polish GemFire
* Remove Compile Warnings * Correct @since * Add tests * Add to What's New in documentation
This commit is contained in:
@@ -773,6 +773,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
@Test
|
||||
public void sessionToData() throws Exception {
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSession session = new GemFireSession("1") {
|
||||
@Override void writeObject(Object obj, DataOutput out) throws IOException {
|
||||
assertThat(obj).isInstanceOf(GemFireSessionAttributes.class);
|
||||
@@ -811,6 +812,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
when(mockDataInput.readLong()).thenReturn(expectedCreationTime).thenReturn(expectedLastAccessedTime);
|
||||
when(mockDataInput.readInt()).thenReturn(expectedMaxInactiveIntervalInSeconds);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSession session = new GemFireSession("1") {
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
<T> T readObject(DataInput in) throws ClassNotFoundException, IOException {
|
||||
@@ -852,6 +854,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
final long beforeOrAtCreationTime = System.currentTimeMillis();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSession expectedSession = new GemFireSession("123") {
|
||||
@Override void writeObject(Object obj, DataOutput out) throws IOException {
|
||||
assertThat(obj).isInstanceOf(GemFireSessionAttributes.class);
|
||||
@@ -869,6 +872,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
|
||||
expectedSession.toData(new DataOutputStream(outBytes));
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSession deserializedSession = new GemFireSession("0") {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override <T> T readObject(DataInput in) throws ClassNotFoundException, IOException {
|
||||
@@ -946,6 +950,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
public void sessionToDelta() throws Exception {
|
||||
final DataOutput mockDataOutput = mock(DataOutput.class);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSession session = new GemFireSession() {
|
||||
@Override void writeObject(Object obj, DataOutput out) throws IOException {
|
||||
assertThat(String.valueOf(obj)).isEqualTo("test");
|
||||
@@ -976,6 +981,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
when(mockDataInput.readLong()).thenReturn(1l);
|
||||
when(mockDataInput.readInt()).thenReturn(600).thenReturn(0);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSession session = new GemFireSession() {
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
<T> T readObject(DataInput in) throws ClassNotFoundException, IOException {
|
||||
@@ -1086,6 +1092,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
public void sessionAttributesToData() throws Exception {
|
||||
final DataOutput mockDataOutput = mock(DataOutput.class);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSessionAttributes sessionAttributes = new GemFireSessionAttributes() {
|
||||
private int count = 0;
|
||||
@Override void writeObject(Object obj, DataOutput out) throws IOException {
|
||||
@@ -1111,6 +1118,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
when(mockDataInput.readInt()).thenReturn(2);
|
||||
when(mockDataInput.readUTF()).thenReturn("attrOne").thenReturn("attrTwo");
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSessionAttributes sessionAttributes = new GemFireSessionAttributes() {
|
||||
private int count = 0;
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
@@ -1154,6 +1162,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
public void sessionAttributesToDelta() throws Exception {
|
||||
final DataOutput mockDataOutput = mock(DataOutput.class);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSessionAttributes sessionAttributes = new GemFireSessionAttributes() {
|
||||
private int count = 0;
|
||||
@Override void writeObject(Object obj, DataOutput out) throws IOException {
|
||||
@@ -1203,6 +1212,7 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
when(mockDataInput.readInt()).thenReturn(2);
|
||||
when(mockDataInput.readUTF()).thenReturn("attrOne").thenReturn("attrTwo");
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
GemFireSessionAttributes sessionAttributes = new GemFireSessionAttributes() {
|
||||
private int count = 0;
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
@@ -1262,7 +1272,6 @@ public class AbstractGemFireOperationsSessionRepositoryTest {
|
||||
TestFramework.runOnce(new ThreadSafeSessionTest());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected static final class ThreadSafeSessionTest extends MultithreadedTestCase {
|
||||
|
||||
private final long beforeOrAtCreationTime = System.currentTimeMillis();
|
||||
|
||||
@@ -65,7 +65,7 @@ import com.gemstone.gemfire.cache.query.SelectResults;
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.runners.MockitoJUnitRunner
|
||||
* @see org.springframework.session.data.gemfire.GemFireOperationsSessionRepository
|
||||
* @since 1.0.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GemFireOperationsSessionRepositoryTest {
|
||||
@@ -120,9 +120,9 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
when(mockSessionTwo.getId()).thenReturn("2");
|
||||
when(mockSessionThree.getId()).thenReturn("3");
|
||||
|
||||
SelectResults mockSelectResults = mock(SelectResults.class);
|
||||
SelectResults<Object> mockSelectResults = mock(SelectResults.class);
|
||||
|
||||
when(mockSelectResults.asList()).thenReturn(Arrays.asList(mockSessionOne, mockSessionTwo, mockSessionThree));
|
||||
when(mockSelectResults.asList()).thenReturn(Arrays.<Object>asList(mockSessionOne, mockSessionTwo, mockSessionThree));
|
||||
|
||||
String principalName = "jblum";
|
||||
|
||||
@@ -149,7 +149,7 @@ public class GemFireOperationsSessionRepositoryTest {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void findByPrincipalNameReturnsNoMatchingSessions() {
|
||||
SelectResults mockSelectResults = mock(SelectResults.class);
|
||||
SelectResults<Object> mockSelectResults = mock(SelectResults.class);
|
||||
|
||||
when(mockSelectResults.asList()).thenReturn(Collections.emptyList());
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @since 1.0.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class GemFireHttpSessionConfigurationTest {
|
||||
|
||||
@@ -196,7 +196,7 @@ public class GemFireHttpSessionConfigurationTest {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void createAndInitializeSpringSessionGemFireRegionTemplate() {
|
||||
GemFireCache mockGemFireCache = mock(GemFireCache.class);
|
||||
Region mockRegion = mock(Region.class);
|
||||
Region<Object,Object> mockRegion = mock(Region.class);
|
||||
|
||||
when(mockGemFireCache.getRegion(eq("Example"))).thenReturn(mockRegion);
|
||||
|
||||
|
||||
@@ -23,7 +23,11 @@ import org.junit.Before;
|
||||
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.client.Interest;
|
||||
import org.springframework.session.ExpiringSession;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
@@ -51,34 +55,37 @@ import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
* @see com.gemstone.gemfire.cache.RegionShortcut
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see com.gemstone.gemfire.cache.client.ClientRegionShortcut
|
||||
* @since 1.0.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GemFireCacheTypeAwareRegionFactoryBeanTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
private GemFireCacheTypeAwareRegionFactoryBean regionFactoryBean;
|
||||
@Mock
|
||||
Region<Object,ExpiringSession> mockClientRegion;
|
||||
@Mock
|
||||
Region<Object,ExpiringSession> mockServerRegion;
|
||||
@Mock
|
||||
ClientCache mockClientCache;
|
||||
|
||||
private GemFireCacheTypeAwareRegionFactoryBean<Object,ExpiringSession> regionFactoryBean;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
regionFactoryBean = new GemFireCacheTypeAwareRegionFactoryBean();
|
||||
regionFactoryBean = new GemFireCacheTypeAwareRegionFactoryBean<Object,ExpiringSession>();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void afterPropertiesSetCreatesClientRegionForClientCache() throws Exception {
|
||||
final ClientCache mockClientCache = mock(ClientCache.class);
|
||||
|
||||
final Region mockClientRegion = mock(Region.class, "MockClientRegion");
|
||||
final Region mockServerRegion = mock(Region.class, "MockServerRegion");
|
||||
|
||||
regionFactoryBean = new GemFireCacheTypeAwareRegionFactoryBean() {
|
||||
@Override protected Region newClientRegion(GemFireCache gemfireCache) throws Exception {
|
||||
regionFactoryBean = new GemFireCacheTypeAwareRegionFactoryBean<Object,ExpiringSession>() {
|
||||
@Override protected Region<Object,ExpiringSession> newClientRegion(GemFireCache gemfireCache) throws Exception {
|
||||
assertThat(gemfireCache).isSameAs(mockClientCache);
|
||||
return mockClientRegion;
|
||||
}
|
||||
|
||||
@Override protected Region newServerRegion(final GemFireCache gemfireCache) throws Exception {
|
||||
@Override protected Region<Object,ExpiringSession> newServerRegion(final GemFireCache gemfireCache) throws Exception {
|
||||
assertThat(gemfireCache).isSameAs(mockClientCache);
|
||||
return mockServerRegion;
|
||||
}
|
||||
@@ -95,16 +102,13 @@ public class GemFireCacheTypeAwareRegionFactoryBeanTest {
|
||||
public void afterPropertiesSetCreatesServerRegionForPeerCache() throws Exception {
|
||||
final Cache mockCache = mock(Cache.class);
|
||||
|
||||
final Region mockClientRegion = mock(Region.class, "MockClientRegion");
|
||||
final Region mockServerRegion = mock(Region.class, "MockServerRegion");
|
||||
|
||||
regionFactoryBean = new GemFireCacheTypeAwareRegionFactoryBean() {
|
||||
@Override protected Region newClientRegion(GemFireCache gemfireCache) throws Exception {
|
||||
regionFactoryBean = new GemFireCacheTypeAwareRegionFactoryBean<Object,ExpiringSession>() {
|
||||
@Override protected Region<Object,ExpiringSession> newClientRegion(GemFireCache gemfireCache) throws Exception {
|
||||
assertThat(gemfireCache).isSameAs(mockCache);
|
||||
return mockClientRegion;
|
||||
}
|
||||
|
||||
@Override protected Region newServerRegion(final GemFireCache gemfireCache) throws Exception {
|
||||
@Override protected Region<Object,ExpiringSession> newServerRegion(final GemFireCache gemfireCache) throws Exception {
|
||||
assertThat(gemfireCache).isSameAs(mockCache);
|
||||
return mockServerRegion;
|
||||
}
|
||||
@@ -119,7 +123,7 @@ public class GemFireCacheTypeAwareRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void allKeysInterestRegistration() {
|
||||
Interest[] interests = regionFactoryBean.registerInterests(true);
|
||||
Interest<Object>[] interests = regionFactoryBean.registerInterests(true);
|
||||
|
||||
assertThat(interests).isNotNull();
|
||||
assertThat(interests.length).isEqualTo(1);
|
||||
@@ -131,16 +135,15 @@ public class GemFireCacheTypeAwareRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void emptyInterestsRegistration() {
|
||||
Interest[] interests = regionFactoryBean.registerInterests(false);
|
||||
Interest<Object>[] interests = regionFactoryBean.registerInterests(false);
|
||||
|
||||
assertThat(interests).isNotNull();
|
||||
assertThat(interests.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getObjectTypeBeforeInitializationIsRegionClass() {
|
||||
assertThat((Class<Region>) regionFactoryBean.getObjectType()).isEqualTo(Region.class);
|
||||
assertThat(regionFactoryBean.getObjectType()).isEqualTo(Region.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -189,7 +192,7 @@ public class GemFireCacheTypeAwareRegionFactoryBeanTest {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setAndGetRegionAttributes() {
|
||||
RegionAttributes mockRegionAttributes = mock(RegionAttributes.class);
|
||||
RegionAttributes<Object,ExpiringSession> mockRegionAttributes = mock(RegionAttributes.class);
|
||||
|
||||
assertThat(regionFactoryBean.getRegionAttributes()).isNull();
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.session.data.gemfire.support.GemFireUtils
|
||||
* @since 1.0.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class GemFireUtilsTest {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user