Replace all JUnit assertions with AssertJ.
Resolves gh-296.
This commit is contained in:
@@ -13,12 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -41,8 +38,6 @@ import org.springframework.stereotype.Repository;
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @since 1.5.0
|
||||
*/
|
||||
/*
|
||||
*/
|
||||
@DependsOn("gemfireCache")
|
||||
//@Lazy
|
||||
@Repository("autoRegionLookupDao")
|
||||
@@ -61,24 +56,31 @@ public class AutoRegionLookupDao extends DaoSupport {
|
||||
@Resource(name = "/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild")
|
||||
private Region<?, ?> nativeReplicateGrandchild;
|
||||
|
||||
protected static void assertRegionMetaData(final Region<?, ?> region,
|
||||
final String expectedName, final DataPolicy expectedDataPolicy) {
|
||||
protected static void assertRegionMetaData(Region<?, ?> region, String expectedName, DataPolicy expectedDataPolicy) {
|
||||
assertRegionMetaData(region, expectedName, Region.SEPARATOR + expectedName, expectedDataPolicy);
|
||||
}
|
||||
|
||||
protected static void assertRegionMetaData(final Region<?, ?> region, final String expectedName,
|
||||
final String expectedFullPath, final DataPolicy expectedDataPolicy) {
|
||||
assertNotNull(String.format("Region (%1$s) was not properly configured and initialized!", expectedName), region);
|
||||
assertEquals(expectedName, region.getName());
|
||||
assertEquals(expectedFullPath, region.getFullPath());
|
||||
assertNotNull(String.format("Region (%1$s) must have RegionAttributes defined!", expectedName),
|
||||
region.getAttributes());
|
||||
assertEquals(expectedDataPolicy, region.getAttributes().getDataPolicy());
|
||||
assertFalse(region.getAttributes().getDataPolicy().withPersistence());
|
||||
protected static void assertRegionMetaData(Region<?, ?> region, String expectedName, String expectedFullPath,
|
||||
DataPolicy expectedDataPolicy) {
|
||||
|
||||
assertThat(region)
|
||||
.describedAs("Region (%1$s) was not properly configured and initialized!", expectedName)
|
||||
.isNotNull();
|
||||
|
||||
assertThat(region.getName()).isEqualTo(expectedName);
|
||||
assertThat(region.getFullPath()).isEqualTo(expectedFullPath);
|
||||
|
||||
assertThat(region.getAttributes())
|
||||
.describedAs("Region (%1$s) must have RegionAttributes defined!", expectedName)
|
||||
.isNotNull();
|
||||
|
||||
assertThat(region.getAttributes().getDataPolicy()).isEqualTo(expectedDataPolicy);
|
||||
assertThat(region.getAttributes().getDataPolicy().withPersistence()).isFalse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkDaoConfig() throws IllegalArgumentException {
|
||||
|
||||
assertRegionMetaData(nativePartitionedRegion, "NativePartitionedRegion", DataPolicy.PARTITION);
|
||||
assertRegionMetaData(nativeReplicateParent, "NativeReplicateParent", DataPolicy.REPLICATE);
|
||||
assertRegionMetaData(nativeReplicateChild, "NativeReplicateChild",
|
||||
@@ -86,5 +88,4 @@ public class AutoRegionLookupDao extends DaoSupport {
|
||||
assertRegionMetaData(nativeReplicateGrandchild, "NativeReplicateGrandchild",
|
||||
"/NativeReplicateParent/NativeReplicateChild/NativeReplicateGrandchild", DataPolicy.REPLICATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,34 +13,34 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeNotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
|
||||
/**
|
||||
* The CacheAutoReconnectIntegrationTests class is a tests suite of test cases testing Spring Data GemFire's support
|
||||
* of GemFire's Auto-Reconnect functionality release in 8.0.
|
||||
* Integration Tests testing SDG support of Apache Geode Auto-Reconnect functionality.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.springframework.data.gemfire.CacheFactoryBean
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class CacheAutoReconnectIntegrationTests {
|
||||
public class CacheAutoReconnectIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
private ConfigurableApplicationContext applicationContext;
|
||||
|
||||
@@ -51,28 +51,36 @@ public class CacheAutoReconnectIntegrationTests {
|
||||
}
|
||||
|
||||
protected Cache getCache(String configLocation) {
|
||||
String baseConfigLocation = File.separator.concat(
|
||||
getClass().getPackage().getName().replace('.', File.separatorChar));
|
||||
|
||||
String baseConfigLocation =
|
||||
File.separator.concat(getClass().getPackage().getName().replace('.', File.separatorChar));
|
||||
|
||||
applicationContext = new ClassPathXmlApplicationContext(baseConfigLocation.concat(File.separator).concat(configLocation));
|
||||
|
||||
return applicationContext.getBean(GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME, Cache.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoReconnectDisabled() {
|
||||
|
||||
Cache cache = getCache("cacheAutoReconnectDisabledIntegrationTests.xml");
|
||||
assertNotNull(cache);
|
||||
assertNotNull(cache.getDistributedSystem());
|
||||
assertNotNull(cache.getDistributedSystem().getProperties());
|
||||
assertTrue(Boolean.valueOf(cache.getDistributedSystem().getProperties().getProperty("disable-auto-reconnect")));
|
||||
|
||||
assertThat(cache).isNotNull();
|
||||
assertThat(cache.getDistributedSystem()).isNotNull();
|
||||
assertThat(cache.getDistributedSystem().getProperties()).isNotNull();
|
||||
assertThat(Boolean.valueOf(cache.getDistributedSystem().getProperties().getProperty("disable-auto-reconnect")))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAutoReconnectEnabled() {
|
||||
Cache cache = getCache("cacheAutoReconnectEnabledIntegrationTests.xml");
|
||||
assertNotNull(cache);
|
||||
assertNotNull(cache.getDistributedSystem());
|
||||
assertNotNull(cache.getDistributedSystem().getProperties());
|
||||
assertFalse(Boolean.valueOf(cache.getDistributedSystem().getProperties().getProperty("disable-auto-reconnect")));
|
||||
}
|
||||
|
||||
Cache cache = getCache("cacheAutoReconnectEnabledIntegrationTests.xml");
|
||||
|
||||
assertThat(cache).isNotNull();
|
||||
assertThat(cache.getDistributedSystem()).isNotNull();
|
||||
assertThat(cache.getDistributedSystem().getProperties()).isNotNull();
|
||||
assertThat(Boolean.valueOf(cache.getDistributedSystem().getProperties().getProperty("disable-auto-reconnect")))
|
||||
.isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newRuntimeException;
|
||||
|
||||
import java.io.File;
|
||||
@@ -141,7 +138,7 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ
|
||||
|
||||
locatorWorkingDirectory = new File(System.getProperty("java.io.tmpdir"), locatorName.toLowerCase());
|
||||
|
||||
assertTrue(locatorWorkingDirectory.isDirectory() || locatorWorkingDirectory.mkdirs());
|
||||
assertThat(locatorWorkingDirectory.isDirectory() || locatorWorkingDirectory.mkdirs()).isTrue();
|
||||
|
||||
ZipUtils.unzip(new ClassPathResource("/cluster_config.zip"), locatorWorkingDirectory);
|
||||
|
||||
@@ -206,20 +203,20 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ
|
||||
|
||||
private Region<?, ?> assertRegion(Region<?, ?> actualRegion, String expectedRegionName, String expectedRegionFullPath) {
|
||||
|
||||
assertNotNull(String.format("The [%s] was not properly configured and initialized!",
|
||||
expectedRegionName), actualRegion);
|
||||
assertEquals(expectedRegionName, actualRegion.getName());
|
||||
assertEquals(expectedRegionFullPath, actualRegion.getFullPath());
|
||||
assertThat(actualRegion).as(String.format("The [%s] was not properly configured and initialized!",
|
||||
expectedRegionName)).isNotNull();
|
||||
assertThat(actualRegion.getName()).isEqualTo(expectedRegionName);
|
||||
assertThat(actualRegion.getFullPath()).isEqualTo(expectedRegionFullPath);
|
||||
|
||||
return actualRegion;
|
||||
}
|
||||
|
||||
private Region<?, ?> assertRegionAttributes(Region<?, ?> actualRegion, DataPolicy expectedDataPolicy, Scope expectedScope) {
|
||||
|
||||
assertNotNull(actualRegion);
|
||||
assertNotNull(actualRegion.getAttributes());
|
||||
assertEquals(expectedDataPolicy, actualRegion.getAttributes().getDataPolicy());
|
||||
assertEquals(expectedScope, actualRegion.getAttributes().getScope());
|
||||
assertThat(actualRegion).isNotNull();
|
||||
assertThat(actualRegion.getAttributes()).isNotNull();
|
||||
assertThat(actualRegion.getAttributes().getDataPolicy()).isEqualTo(expectedDataPolicy);
|
||||
assertThat(actualRegion.getAttributes().getScope()).isEqualTo(expectedScope);
|
||||
|
||||
return actualRegion;
|
||||
}
|
||||
@@ -282,8 +279,9 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ
|
||||
|
||||
assertThat(expected).hasCauseInstanceOf(BeanInitializationException.class);
|
||||
|
||||
assertTrue(String.format("Message was [%s]", expected.getMessage()), expected.getCause().getMessage()
|
||||
.matches("Region \\[ClusterConfigRegion\\] in Cache \\[.*\\] not found"));
|
||||
assertThat(expected.getCause().getMessage()
|
||||
.matches("Region \\[ClusterConfigRegion\\] in Cache \\[.*\\] not found"))
|
||||
.as(String.format("Message was [%s]", expected.getMessage())).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,54 +13,48 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The CacheServerIntegrationTest class is a test suite of test cases testing the functionality of GemFire Cache Servers
|
||||
* configured using the Spring Data GemFire XML namespace.
|
||||
* Integration Tests for {@link CacheServer} configuration using SDG XML namespace configuration metadata.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.springframework.data.gemfire.server.CacheServerFactoryBean
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("cache-server-with-subscription-disk-store.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class CacheServerIntegrationTest {
|
||||
@SuppressWarnings("unused")
|
||||
public class CacheServerIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Resource(name = "testCacheServer")
|
||||
private CacheServer cacheServer;
|
||||
|
||||
protected static boolean createDirectory(final File path) {
|
||||
return (path != null && (path.isDirectory() || path.mkdirs()));
|
||||
}
|
||||
|
||||
protected static File createFile(final String pathname) {
|
||||
private static File createFile(final String pathname) {
|
||||
return new File(pathname);
|
||||
}
|
||||
|
||||
protected static void deleteRecursive(final File path) {
|
||||
private static void deleteRecursive(final File path) {
|
||||
|
||||
if (path.isDirectory()) {
|
||||
for (File file : path.listFiles()) {
|
||||
deleteRecursive(file);
|
||||
@@ -70,9 +64,12 @@ public class CacheServerIntegrationTest {
|
||||
path.delete();
|
||||
}
|
||||
|
||||
@Resource(name = "testCacheServer")
|
||||
private CacheServer cacheServer;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() {
|
||||
assertTrue(createDirectory(createFile("./gemfire/subscription-disk-store")));
|
||||
assertThat(createDirectory(createFile("./gemfire/subscription-disk-store")).isDirectory()).isTrue();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -83,17 +80,17 @@ public class CacheServerIntegrationTest {
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testCacheServerRunningWithSubscription() {
|
||||
assertNotNull(cacheServer);
|
||||
assertTrue(cacheServer.isRunning());
|
||||
assertEquals("localhost", cacheServer.getBindAddress());
|
||||
assertNotNull(cacheServer.getGroups());
|
||||
assertEquals(1, cacheServer.getGroups().length);
|
||||
assertEquals("test-server", cacheServer.getGroups()[0]);
|
||||
assertEquals(1, cacheServer.getMaxConnections());
|
||||
assertNotNull(cacheServer.getClientSubscriptionConfig());
|
||||
assertEquals(512, cacheServer.getClientSubscriptionConfig().getCapacity());
|
||||
assertEquals("testSubscriptionDiskStore", cacheServer.getClientSubscriptionConfig().getDiskStoreName());
|
||||
assertTrue("ENTRY".equalsIgnoreCase(cacheServer.getClientSubscriptionConfig().getEvictionPolicy()));
|
||||
}
|
||||
|
||||
assertThat(cacheServer).isNotNull();
|
||||
assertThat(cacheServer.isRunning()).isTrue();
|
||||
assertThat(cacheServer.getBindAddress()).isEqualTo("localhost");
|
||||
assertThat(cacheServer.getGroups()).isNotNull();
|
||||
assertThat(cacheServer.getGroups().length).isEqualTo(1);
|
||||
assertThat(cacheServer.getGroups()[0]).isEqualTo("test-server");
|
||||
assertThat(cacheServer.getMaxConnections()).isEqualTo(1);
|
||||
assertThat(cacheServer.getClientSubscriptionConfig()).isNotNull();
|
||||
assertThat(cacheServer.getClientSubscriptionConfig().getCapacity()).isEqualTo(512);
|
||||
assertThat(cacheServer.getClientSubscriptionConfig().getDiskStoreName()).isEqualTo("testSubscriptionDiskStore");
|
||||
assertThat("ENTRY".equalsIgnoreCase(cacheServer.getClientSubscriptionConfig().getEvictionPolicy())).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests for JIRA issue SGF-195,concerning collocated cache {@link Region Regions}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @link https://jira.springsource.org/browse/SGF-195
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(value = "colocated-region.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class CollocatedRegionIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Resource(name = "colocatedRegion")
|
||||
private Region<?, ?> colocatedRegion;
|
||||
|
||||
@Resource(name = "sourceRegion")
|
||||
private Region<?, ?> sourceRegion;
|
||||
|
||||
protected static void assertRegionExists(String expectedRegionName, Region<?, ?> region) {
|
||||
|
||||
assertThat(region).isNotNull();
|
||||
|
||||
assertThat(region.getName())
|
||||
.describedAs("Expected Region with name %1$s; but was %2$s!", expectedRegionName, region.getName())
|
||||
.isEqualTo(expectedRegionName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionsColocated() {
|
||||
|
||||
assertRegionExists("Source", sourceRegion);
|
||||
assertRegionExists("Colocated", colocatedRegion);
|
||||
assertThat(colocatedRegion.getAttributes()).isNotNull();
|
||||
assertThat(colocatedRegion.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(colocatedRegion.getAttributes().getPartitionAttributes().getColocatedWith()).isEqualTo(sourceRegion.getName());
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* The ColocatedRegionIntegrationTest class is a test suite class containing test cases for JIRA issue SGF-195,
|
||||
* concerning colocated Regions in GemFire.
|
||||
*
|
||||
* @author John Blum
|
||||
* @link https://jira.springsource.org/browse/SGF-195
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@ContextConfiguration("colocated-region.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class ColocatedRegionIntegrationTest {
|
||||
|
||||
@Resource(name = "colocatedRegion")
|
||||
private Region colocatedRegion;
|
||||
|
||||
@Resource(name = "sourceRegion")
|
||||
private Region sourceRegion;
|
||||
|
||||
protected static void assertRegionExists(final String expectedRegionName, final Region region) {
|
||||
assertNotNull(region);
|
||||
assertEquals(String.format("Expected Region with name %1$s; but was %2$s!",
|
||||
expectedRegionName, region.getName()), expectedRegionName, region.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionsColocated() {
|
||||
assertRegionExists("Source", sourceRegion);
|
||||
assertRegionExists("Colocated", colocatedRegion);
|
||||
assertNotNull(colocatedRegion.getAttributes());
|
||||
assertNotNull(colocatedRegion.getAttributes().getPartitionAttributes());
|
||||
assertEquals(sourceRegion.getName(), colocatedRegion.getAttributes().getPartitionAttributes().getColocatedWith());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
*/
|
||||
public class DataPolicyConverterTest {
|
||||
|
||||
private final DataPolicyConverter converter = new DataPolicyConverter();
|
||||
|
||||
protected int getDataPolicyEnumerationSize() {
|
||||
int count = 0;
|
||||
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
try {
|
||||
if (DataPolicy.fromOrdinal(ordinal) != null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
break;
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void policyToDataPolicyConversion() {
|
||||
assertEquals(getDataPolicyEnumerationSize(), DataPolicyConverter.Policy.values().length - 1);
|
||||
assertEquals(DataPolicy.EMPTY, DataPolicyConverter.Policy.EMPTY.toDataPolicy());
|
||||
assertEquals(DataPolicy.NORMAL, DataPolicyConverter.Policy.NORMAL.toDataPolicy());
|
||||
assertEquals(DataPolicy.PRELOADED, DataPolicyConverter.Policy.PRELOADED.toDataPolicy());
|
||||
assertEquals(DataPolicy.PARTITION, DataPolicyConverter.Policy.PARTITION.toDataPolicy());
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, DataPolicyConverter.Policy.PERSISTENT_PARTITION.toDataPolicy());
|
||||
assertEquals(DataPolicy.REPLICATE, DataPolicyConverter.Policy.REPLICATE.toDataPolicy());
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, DataPolicyConverter.Policy.PERSISTENT_REPLICATE.toDataPolicy());
|
||||
assertEquals(DataPolicy.DEFAULT, DataPolicyConverter.Policy.DEFAULT.toDataPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertDataPolicyStrings() {
|
||||
assertEquals(DataPolicy.EMPTY, converter.convert("empty"));
|
||||
assertEquals(DataPolicy.PARTITION, converter.convert("Partition"));
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, converter.convert("PERSISTENT_REPLICATE"));
|
||||
assertNull(converter.convert("invalid"));
|
||||
assertNull(converter.convert(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link DataPolicyConverter}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.DataPolicyConverter
|
||||
*/
|
||||
public class DataPolicyConverterUnitTests {
|
||||
|
||||
private final DataPolicyConverter converter = new DataPolicyConverter();
|
||||
|
||||
private int getDataPolicyEnumerationSize() {
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
try {
|
||||
if (DataPolicy.fromOrdinal(ordinal) != null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
break;
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void policyToDataPolicyConversion() {
|
||||
|
||||
assertThat(DataPolicyConverter.Policy.values().length - 1).isEqualTo(getDataPolicyEnumerationSize());
|
||||
assertThat(DataPolicyConverter.Policy.EMPTY.toDataPolicy()).isEqualTo(DataPolicy.EMPTY);
|
||||
assertThat(DataPolicyConverter.Policy.NORMAL.toDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(DataPolicyConverter.Policy.PRELOADED.toDataPolicy()).isEqualTo(DataPolicy.PRELOADED);
|
||||
assertThat(DataPolicyConverter.Policy.PARTITION.toDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
assertThat(DataPolicyConverter.Policy.PERSISTENT_PARTITION.toDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
assertThat(DataPolicyConverter.Policy.REPLICATE.toDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(DataPolicyConverter.Policy.PERSISTENT_REPLICATE.toDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
assertThat(DataPolicyConverter.Policy.DEFAULT.toDataPolicy()).isEqualTo(DataPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertDataPolicyStrings() {
|
||||
|
||||
assertThat(converter.convert("empty")).isEqualTo(DataPolicy.EMPTY);
|
||||
assertThat(converter.convert("Partition")).isEqualTo(DataPolicy.PARTITION);
|
||||
assertThat(converter.convert("PERSISTENT_REPLICATE")).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
assertThat(converter.convert("invalid")).isNull();
|
||||
assertThat(converter.convert(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -13,16 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DiskStoreFactoryBean}.
|
||||
* Unit Tests for {@link DiskStoreFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -30,7 +29,7 @@ import org.junit.Test;
|
||||
* @see org.springframework.data.gemfire.DiskStoreFactoryBean
|
||||
* @since 1.3.4
|
||||
*/
|
||||
public class DiskStoreFactoryBeanTest {
|
||||
public class DiskStoreFactoryBeanUnitTests {
|
||||
|
||||
private final DiskStoreFactoryBean factoryBean = new DiskStoreFactoryBean();
|
||||
|
||||
@@ -46,6 +45,7 @@ public class DiskStoreFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testValidateCompactionThresholdWhenValid() {
|
||||
|
||||
factoryBean.validateCompactionThreshold(0);
|
||||
factoryBean.validateCompactionThreshold(50);
|
||||
factoryBean.validateCompactionThreshold(100);
|
||||
@@ -53,24 +53,28 @@ public class DiskStoreFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testValidateCompactionThresholdWhenLessThan0() {
|
||||
|
||||
try {
|
||||
factoryBean.validateCompactionThreshold(-1);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals(String.format("The DiskStore's (%1$s) compaction threshold (%2$d) must be an integer value between 0 and 100 inclusive.",
|
||||
factoryBean.resolveDiskStoreName(), -1), expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo(String.format(
|
||||
"The DiskStore's (%1$s) compaction threshold (%2$d) must be an integer value between 0 and 100 inclusive.",
|
||||
factoryBean.resolveDiskStoreName(), -1));
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testValidateCompactionThresholdWhenGreaterThan100() {
|
||||
|
||||
try {
|
||||
factoryBean.validateCompactionThreshold(101);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals(String.format("The DiskStore's (%1$s) compaction threshold (%2$d) must be an integer value between 0 and 100 inclusive.",
|
||||
factoryBean.resolveDiskStoreName(), 101), expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo(String.format(
|
||||
"The DiskStore's (%1$s) compaction threshold (%2$d) must be an integer value between 0 and 100 inclusive.",
|
||||
factoryBean.resolveDiskStoreName(), 101));
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -82,24 +86,26 @@ public class DiskStoreFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSetCompactionThreadWithIllegalArgument() {
|
||||
|
||||
try {
|
||||
factoryBean.setCompactionThreshold(200);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals(String.format(
|
||||
assertThat(expected.getMessage()).isEqualTo(String.format(
|
||||
"The DiskStore's (%1$s) compaction threshold (%2$d) must be an integer value between 0 and 100 inclusive.",
|
||||
factoryBean.resolveDiskStoreName(), 200), expected.getMessage());
|
||||
factoryBean.resolveDiskStoreName(), 200));
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testAfterPropertiesSetWithNoCacheReference() throws Exception {
|
||||
|
||||
try {
|
||||
factoryBean.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalStateException expected) {
|
||||
assertEquals("Cache is required to create DiskStore [testDiskStore]", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Cache is required to create DiskStore [testDiskStore]");
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.gemfire.tests.util.FileSystemUtils.FileExtensionFilter.newFileExtensionFilter;
|
||||
|
||||
import java.io.FileFilter;
|
||||
@@ -31,19 +30,22 @@ import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.Scope;
|
||||
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.util.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.util.CacheUtils;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link GenericRegionFactoryBean}.
|
||||
* Integration Tests for {@link GenericRegionFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.GenericRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class GenericRegionFactoryBeanTest {
|
||||
public class GenericRegionFactoryBeanIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
// As defined in com.gemstone.gemfire.internal.cache.AbstractRegion
|
||||
private static final Scope DEFAULT_SCOPE = Scope.DISTRIBUTED_NO_ACK;
|
||||
@@ -60,7 +62,7 @@ public class GenericRegionFactoryBeanTest {
|
||||
public static void setup() throws Exception {
|
||||
|
||||
Cache gemfireCache = new CacheFactory()
|
||||
.set("name", GenericRegionFactoryBeanTest.class.getSimpleName())
|
||||
.set("name", GenericRegionFactoryBeanIntegrationTests.class.getSimpleName())
|
||||
.set("log-level", "error")
|
||||
.create();
|
||||
|
||||
@@ -153,12 +155,12 @@ public class GenericRegionFactoryBeanTest {
|
||||
protected void assertRegionAttributes(Region<?, ?> region, String expectedRegionName, String expectedRegionPath,
|
||||
DataPolicy expectedDataPolicy, Scope expectedScope) {
|
||||
|
||||
assertNotNull("The GemFire Cache Region must not be null!", region);
|
||||
assertEquals(expectedRegionName, region.getName());
|
||||
assertEquals(expectedRegionPath, region.getFullPath());
|
||||
assertNotNull("The RegionAttributes must be specified!", region.getAttributes());
|
||||
assertEquals(expectedDataPolicy, region.getAttributes().getDataPolicy());
|
||||
assertEquals(expectedScope, region.getAttributes().getScope());
|
||||
assertThat(region).as("The GemFire Cache Region must not be null!").isNotNull();
|
||||
assertThat(region.getName()).isEqualTo(expectedRegionName);
|
||||
assertThat(region.getFullPath()).isEqualTo(expectedRegionPath);
|
||||
assertThat(region.getAttributes()).as("The RegionAttributes must be specified!").isNotNull();
|
||||
assertThat(region.getAttributes().getDataPolicy()).isEqualTo(expectedDataPolicy);
|
||||
assertThat(region.getAttributes().getScope()).isEqualTo(expectedScope);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -13,11 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -30,13 +28,21 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
@@ -45,25 +51,17 @@ import org.apache.geode.cache.query.IndexNameConflictException;
|
||||
import org.apache.geode.cache.query.IndexStatistics;
|
||||
import org.apache.geode.cache.query.QueryService;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link IndexFactoryBean}.
|
||||
* Unit Tests for {@link IndexFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.mockito.Mock
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.Spy
|
||||
@@ -76,7 +74,7 @@ import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
* @since 1.5.2
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class IndexFactoryBeanTest {
|
||||
public class IndexFactoryBeanUnitTests {
|
||||
|
||||
@Mock
|
||||
private BeanFactory mockBeanFactory;
|
||||
@@ -153,7 +151,6 @@ public class IndexFactoryBeanTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
public void afterPropertiesSetIsSuccessful() throws Exception {
|
||||
|
||||
ConfigurableBeanFactory mockConfigurableBeanFactory = mock(ConfigurableBeanFactory.class);
|
||||
@@ -188,7 +185,8 @@ public class IndexFactoryBeanTest {
|
||||
.registerAlias(eq("KeyIndexBean"), eq("TestKeyIndex"));
|
||||
verify(mockQueryService, times(1))
|
||||
.createKeyIndex(eq("TestKeyIndex"), eq("id"), eq("/Example"));
|
||||
verifyZeroInteractions(mockCache);
|
||||
|
||||
verifyNoInteractions(mockCache);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -536,7 +534,7 @@ public class IndexFactoryBeanTest {
|
||||
|
||||
indexFactoryBean.registerAlias("IndexBean", "TestIndex");
|
||||
|
||||
verifyZeroInteractions(mockBeanFactory);
|
||||
verifyNoInteractions(mockBeanFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -551,7 +549,7 @@ public class IndexFactoryBeanTest {
|
||||
|
||||
assertThat(indexFactoryBean.getBeanFactory()).isSameAs(mockConfigurableBeanFactory);
|
||||
|
||||
verifyZeroInteractions(mockConfigurableBeanFactory);
|
||||
verifyNoInteractions(mockConfigurableBeanFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -922,7 +920,7 @@ public class IndexFactoryBeanTest {
|
||||
.createFunctionalIndex(eq(mockQueryService), eq("TestIndex"),
|
||||
eq("id"), eq("/Example"), eq(null));
|
||||
|
||||
verifyZeroInteractions(mockLogger);
|
||||
verifyNoInteractions(mockLogger);
|
||||
|
||||
verify(mockQueryService, times(1)).getIndexes();
|
||||
}
|
||||
@@ -970,7 +968,7 @@ public class IndexFactoryBeanTest {
|
||||
.createFunctionalIndex(eq(mockQueryService), eq("TestIndex"),
|
||||
eq("id"), eq("/Example"), eq(null));
|
||||
|
||||
verifyZeroInteractions(mockLogger);
|
||||
verifyNoInteractions(mockLogger);
|
||||
|
||||
verify(mockQueryService, times(1)).getIndexes();
|
||||
}
|
||||
@@ -1004,7 +1002,7 @@ public class IndexFactoryBeanTest {
|
||||
.createFunctionalIndex(eq(mockQueryService), eq("TestIndex"), eq("price"),
|
||||
eq("/Orders"), eq(null));
|
||||
|
||||
verifyZeroInteractions(mockLogger);
|
||||
verifyNoInteractions(mockLogger);
|
||||
|
||||
verify(mockQueryService, times(1)).getIndexes();
|
||||
}
|
||||
@@ -1086,7 +1084,7 @@ public class IndexFactoryBeanTest {
|
||||
verify(indexFactoryBean, times(1))
|
||||
.createKeyIndex(eq(mockQueryService), eq("TestIndex"), eq("id"), eq("/Example"));
|
||||
|
||||
verifyZeroInteractions(mockLogger);
|
||||
verifyNoInteractions(mockLogger);
|
||||
|
||||
verify(mockQueryService, times(1)).getIndexes();
|
||||
}
|
||||
@@ -1557,7 +1555,7 @@ public class IndexFactoryBeanTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getObjectReturnsLookedUpIndex() throws Exception {
|
||||
public void getObjectReturnsLookedUpIndex() {
|
||||
|
||||
Index mockIndexOne = mockIndex("MockIndexOne");
|
||||
Index mockIndexTwo = mockIndex("MockIndexTwo");
|
||||
@@ -1658,8 +1656,8 @@ public class IndexFactoryBeanTest {
|
||||
|
||||
doAnswer(invocation -> {
|
||||
|
||||
assertEquals(GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE,
|
||||
invocation.getArgument(0));
|
||||
assertThat(invocation.<Object>getArgument(0))
|
||||
.isEqualTo(GemfireConstants.DEFAULT_GEMFIRE_INDEX_DEFINITION_QUERY_SERVICE);
|
||||
|
||||
queryServiceReference.compareAndSet(null, invocation.getArgument(1));
|
||||
|
||||
@@ -13,63 +13,67 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.AttributesFactory;
|
||||
import org.apache.geode.cache.RegionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The IndexMaintenanceTypeTest class is a test suite of test cases testing the contract and functionality of the
|
||||
* IndexMaintenanceType enum type.
|
||||
* Unit Tests for {@link IndexMaintenancePolicyType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see IndexMaintenancePolicyType
|
||||
* @see org.springframework.data.gemfire.IndexMaintenancePolicyType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class IndexMaintenancePolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertSame(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.DEFAULT);
|
||||
assertThat(IndexMaintenancePolicyType.DEFAULT).isSameAs(IndexMaintenancePolicyType.SYNCHRONOUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("SYNCHRONOUS"));
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("Synchronous"));
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("synchronous"));
|
||||
assertEquals(IndexMaintenancePolicyType.SYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("SynCHrOnOus"));
|
||||
assertEquals(IndexMaintenancePolicyType.ASYNCHRONOUS, IndexMaintenancePolicyType.valueOfIgnoreCase("ASYNChronous"));
|
||||
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("SYNCHRONOUS"))
|
||||
.isEqualTo(IndexMaintenancePolicyType.SYNCHRONOUS);
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("Synchronous"))
|
||||
.isEqualTo(IndexMaintenancePolicyType.SYNCHRONOUS);
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("synchronous"))
|
||||
.isEqualTo(IndexMaintenancePolicyType.SYNCHRONOUS);
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("SynCHrOnOus"))
|
||||
.isEqualTo(IndexMaintenancePolicyType.SYNCHRONOUS);
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("ASYNChronous"))
|
||||
.isEqualTo(IndexMaintenancePolicyType.ASYNCHRONOUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("synchronicity"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("SYNC"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("ASYNC"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("Concurrent"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase("parallel"));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase(" "));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase(""));
|
||||
assertNull(IndexMaintenancePolicyType.valueOfIgnoreCase(null));
|
||||
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("synchronicity")).isNull();
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("SYNC")).isNull();
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("ASYNC")).isNull();
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("Concurrent")).isNull();
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("parallel")).isNull();
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(IndexMaintenancePolicyType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testAttributesFactorySetIndexMaintenanceAsynchronous() {
|
||||
AttributesFactory mockAttributesFactory = mock(AttributesFactory.class,
|
||||
|
||||
AttributesFactory<?, ?> mockAttributesFactory = mock(AttributesFactory.class,
|
||||
"testAttributesFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenancePolicyType.ASYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
@@ -80,8 +84,9 @@ public class IndexMaintenancePolicyTypeTest {
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testAttributesFactorySetIndexMaintenanceSynchronous() {
|
||||
AttributesFactory mockAttributesFactory = mock(AttributesFactory.class,
|
||||
"testAttributesFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
AttributesFactory<?, ?> mockAttributesFactory =
|
||||
mock(AttributesFactory.class, "testAttributesFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenancePolicyType.SYNCHRONOUS.setIndexMaintenance(mockAttributesFactory);
|
||||
|
||||
@@ -90,7 +95,9 @@ public class IndexMaintenancePolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testRegionFactorySetIndexMaintenanceAsynchronous() {
|
||||
RegionFactory mockRegionFactory = mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
RegionFactory<?, ?> mockRegionFactory =
|
||||
mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceAsynchronous");
|
||||
|
||||
IndexMaintenancePolicyType.ASYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
|
||||
@@ -99,7 +106,9 @@ public class IndexMaintenancePolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testRegionFactorySetIndexMaintenanceSynchronous() {
|
||||
RegionFactory mockRegionFactory = mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceSynchronous");
|
||||
|
||||
RegionFactory<?, ?> mockRegionFactory =
|
||||
mock(RegionFactory.class, "testRegionFactorySetIndexMaintenanceSynchronous");
|
||||
|
||||
IndexMaintenancePolicyType.SYNCHRONOUS.setIndexMaintenance(mockRegionFactory);
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The IndexTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the IndexType enum class.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.IndexType
|
||||
* @since 1.5.2
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IndexTypeTest {
|
||||
|
||||
@Test
|
||||
public void testGetGemfireIndexType() {
|
||||
assertEquals(org.apache.geode.cache.query.IndexType.FUNCTIONAL, IndexType.FUNCTIONAL.getGemfireIndexType());
|
||||
assertEquals(org.apache.geode.cache.query.IndexType.HASH, IndexType.HASH.getGemfireIndexType());
|
||||
assertEquals(org.apache.geode.cache.query.IndexType.PRIMARY_KEY, IndexType.KEY.getGemfireIndexType());
|
||||
assertEquals(org.apache.geode.cache.query.IndexType.PRIMARY_KEY, IndexType.PRIMARY_KEY.getGemfireIndexType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
assertEquals(IndexType.FUNCTIONAL, IndexType.valueOf(org.apache.geode.cache.query.IndexType.FUNCTIONAL));
|
||||
assertEquals(IndexType.HASH, IndexType.valueOf(org.apache.geode.cache.query.IndexType.HASH));
|
||||
assertEquals(IndexType.PRIMARY_KEY, IndexType.valueOf(org.apache.geode.cache.query.IndexType.PRIMARY_KEY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(IndexType.valueOf((org.apache.geode.cache.query.IndexType) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(IndexType.FUNCTIONAL, IndexType.valueOfIgnoreCase("functional"));
|
||||
assertEquals(IndexType.HASH, IndexType.valueOfIgnoreCase("HasH"));
|
||||
assertEquals(IndexType.KEY, IndexType.valueOfIgnoreCase("Key"));
|
||||
assertEquals(IndexType.PRIMARY_KEY, IndexType.valueOfIgnoreCase("PriMary_Key"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(IndexType.valueOfIgnoreCase("Prime_Index"));
|
||||
assertNull(IndexType.valueOfIgnoreCase("SECONDARY_INDEX"));
|
||||
assertNull(IndexType.valueOfIgnoreCase("unique_index"));
|
||||
assertNull(IndexType.valueOfIgnoreCase(null));
|
||||
assertNull(IndexType.valueOfIgnoreCase(" "));
|
||||
assertNull(IndexType.valueOfIgnoreCase(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsFunctional() {
|
||||
assertTrue(IndexType.FUNCTIONAL.isFunctional());
|
||||
assertFalse(IndexType.HASH.isFunctional());
|
||||
assertFalse(IndexType.KEY.isFunctional());
|
||||
assertFalse(IndexType.PRIMARY_KEY.isFunctional());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNullSafeFunctional() {
|
||||
assertFalse(IndexType.isFunctional(null));
|
||||
assertTrue(IndexType.isFunctional(IndexType.FUNCTIONAL));
|
||||
assertFalse(IndexType.isFunctional(IndexType.HASH));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsHash() {
|
||||
assertFalse(IndexType.FUNCTIONAL.isHash());
|
||||
assertTrue(IndexType.HASH.isHash());
|
||||
assertFalse(IndexType.KEY.isHash());
|
||||
assertFalse(IndexType.PRIMARY_KEY.isHash());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNullSafeHash() {
|
||||
assertFalse(IndexType.isHash(null));
|
||||
assertTrue(IndexType.isHash(IndexType.HASH));
|
||||
assertFalse(IndexType.isHash(IndexType.KEY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsKey() {
|
||||
assertFalse(IndexType.FUNCTIONAL.isKey());
|
||||
assertFalse(IndexType.HASH.isKey());
|
||||
assertTrue(IndexType.KEY.isKey());
|
||||
assertTrue(IndexType.PRIMARY_KEY.isKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNullSafeKey() {
|
||||
assertFalse(IndexType.isKey(null));
|
||||
assertFalse(IndexType.isKey(IndexType.FUNCTIONAL));
|
||||
assertTrue(IndexType.isKey(IndexType.KEY));
|
||||
assertTrue(IndexType.isKey(IndexType.PRIMARY_KEY));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link IndexType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.IndexType
|
||||
* @since 1.5.2
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IndexTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testGetGemfireIndexType() {
|
||||
|
||||
assertThat(IndexType.FUNCTIONAL.getGemfireIndexType()).isEqualTo(org.apache.geode.cache.query.IndexType.FUNCTIONAL);
|
||||
assertThat(IndexType.HASH.getGemfireIndexType()).isEqualTo(org.apache.geode.cache.query.IndexType.HASH);
|
||||
assertThat(IndexType.KEY.getGemfireIndexType()).isEqualTo(org.apache.geode.cache.query.IndexType.PRIMARY_KEY);
|
||||
assertThat(IndexType.PRIMARY_KEY.getGemfireIndexType()).isEqualTo(org.apache.geode.cache.query.IndexType.PRIMARY_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
|
||||
assertThat(IndexType.valueOf(org.apache.geode.cache.query.IndexType.FUNCTIONAL)).isEqualTo(IndexType.FUNCTIONAL);
|
||||
assertThat(IndexType.valueOf(org.apache.geode.cache.query.IndexType.HASH)).isEqualTo(IndexType.HASH);
|
||||
assertThat(IndexType.valueOf(org.apache.geode.cache.query.IndexType.PRIMARY_KEY)).isEqualTo(IndexType.PRIMARY_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertThat(IndexType.valueOf((org.apache.geode.cache.query.IndexType) null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(IndexType.valueOfIgnoreCase("functional")).isEqualTo(IndexType.FUNCTIONAL);
|
||||
assertThat(IndexType.valueOfIgnoreCase("HasH")).isEqualTo(IndexType.HASH);
|
||||
assertThat(IndexType.valueOfIgnoreCase("Key")).isEqualTo(IndexType.KEY);
|
||||
assertThat(IndexType.valueOfIgnoreCase("PriMary_Key")).isEqualTo(IndexType.PRIMARY_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
|
||||
assertThat(IndexType.valueOfIgnoreCase("Prime_Index")).isNull();
|
||||
assertThat(IndexType.valueOfIgnoreCase("SECONDARY_INDEX")).isNull();
|
||||
assertThat(IndexType.valueOfIgnoreCase("unique_index")).isNull();
|
||||
assertThat(IndexType.valueOfIgnoreCase(null)).isNull();
|
||||
assertThat(IndexType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(IndexType.valueOfIgnoreCase("")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsFunctional() {
|
||||
|
||||
assertThat(IndexType.FUNCTIONAL.isFunctional()).isTrue();
|
||||
assertThat(IndexType.HASH.isFunctional()).isFalse();
|
||||
assertThat(IndexType.KEY.isFunctional()).isFalse();
|
||||
assertThat(IndexType.PRIMARY_KEY.isFunctional()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNullSafeFunctional() {
|
||||
|
||||
assertThat(IndexType.isFunctional(null)).isFalse();
|
||||
assertThat(IndexType.isFunctional(IndexType.FUNCTIONAL)).isTrue();
|
||||
assertThat(IndexType.isFunctional(IndexType.HASH)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsHash() {
|
||||
|
||||
assertThat(IndexType.FUNCTIONAL.isHash()).isFalse();
|
||||
assertThat(IndexType.HASH.isHash()).isTrue();
|
||||
assertThat(IndexType.KEY.isHash()).isFalse();
|
||||
assertThat(IndexType.PRIMARY_KEY.isHash()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNullSafeHash() {
|
||||
|
||||
assertThat(IndexType.isHash(null)).isFalse();
|
||||
assertThat(IndexType.isHash(IndexType.HASH)).isTrue();
|
||||
assertThat(IndexType.isHash(IndexType.KEY)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsKey() {
|
||||
|
||||
assertThat(IndexType.FUNCTIONAL.isKey()).isFalse();
|
||||
assertThat(IndexType.HASH.isKey()).isFalse();
|
||||
assertThat(IndexType.KEY.isKey()).isTrue();
|
||||
assertThat(IndexType.PRIMARY_KEY.isKey()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNullSafeKey() {
|
||||
|
||||
assertThat(IndexType.isKey(null)).isFalse();
|
||||
assertThat(IndexType.isKey(IndexType.FUNCTIONAL)).isFalse();
|
||||
assertThat(IndexType.isKey(IndexType.KEY)).isTrue();
|
||||
assertThat(IndexType.isKey(IndexType.PRIMARY_KEY)).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
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 org.apache.geode.cache.InterestPolicy;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The InterestPolicyTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the InterestPolicyType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.InterestPolicyType
|
||||
* @see org.apache.geode.cache.InterestPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class InterestPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestPolicy() {
|
||||
assertEquals(InterestPolicy.ALL, InterestPolicyType.getInterestPolicy(InterestPolicyType.ALL));
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, InterestPolicyType.getInterestPolicy(InterestPolicyType.CACHE_CONTENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestPolicyWithNull() {
|
||||
assertNull(InterestPolicyType.getInterestPolicy(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInterestPolicy() {
|
||||
assertEquals(InterestPolicy.ALL, InterestPolicyType.ALL.getInterestPolicy());
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, InterestPolicyType.CACHE_CONTENT.getInterestPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(InterestPolicy.DEFAULT, InterestPolicyType.DEFAULT.getInterestPolicy());
|
||||
assertSame(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
try {
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
InterestPolicy interestPolicy = InterestPolicy.fromOrdinal(ordinal);
|
||||
InterestPolicyType interestPolicyType = InterestPolicyType.valueOf(interestPolicy);
|
||||
|
||||
assertNotNull(interestPolicyType);
|
||||
assertEquals(interestPolicy, interestPolicyType.getInterestPolicy());
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(InterestPolicyType.valueOf((InterestPolicy) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(InterestPolicyType.ALL, InterestPolicyType.valueOfIgnoreCase("all"));
|
||||
assertEquals(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.valueOfIgnoreCase("Cache_Content"));
|
||||
assertEquals(InterestPolicyType.ALL, InterestPolicyType.valueOfIgnoreCase("ALL"));
|
||||
assertEquals(InterestPolicyType.CACHE_CONTENT, InterestPolicyType.valueOfIgnoreCase("CACHE_ConTent"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("@11"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("CACHE_KEYS"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("invalid"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase("test"));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase(" "));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase(""));
|
||||
assertNull(InterestPolicyType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.InterestPolicy;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link InterestPolicyType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.InterestPolicy
|
||||
* @see org.springframework.data.gemfire.InterestPolicyType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class InterestPolicyTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestPolicy() {
|
||||
|
||||
assertThat(InterestPolicyType.getInterestPolicy(InterestPolicyType.ALL)).isEqualTo(InterestPolicy.ALL);
|
||||
assertThat(InterestPolicyType.getInterestPolicy(InterestPolicyType.CACHE_CONTENT)).isEqualTo(InterestPolicy.CACHE_CONTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestPolicyWithNull() {
|
||||
assertThat(InterestPolicyType.getInterestPolicy(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInterestPolicy() {
|
||||
|
||||
assertThat(InterestPolicyType.ALL.getInterestPolicy()).isEqualTo(InterestPolicy.ALL);
|
||||
assertThat(InterestPolicyType.CACHE_CONTENT.getInterestPolicy()).isEqualTo(InterestPolicy.CACHE_CONTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
|
||||
assertThat(InterestPolicyType.DEFAULT.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
assertThat(InterestPolicyType.DEFAULT).isSameAs(InterestPolicyType.CACHE_CONTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
|
||||
try {
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
InterestPolicy interestPolicy = InterestPolicy.fromOrdinal(ordinal);
|
||||
InterestPolicyType interestPolicyType = InterestPolicyType.valueOf(interestPolicy);
|
||||
|
||||
assertThat(interestPolicyType).isNotNull();
|
||||
assertThat(interestPolicyType.getInterestPolicy()).isEqualTo(interestPolicy);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) { }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertThat(InterestPolicyType.valueOf((InterestPolicy) null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("all")).isEqualTo(InterestPolicyType.ALL);
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("Cache_Content")).isEqualTo(InterestPolicyType.CACHE_CONTENT);
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("ALL")).isEqualTo(InterestPolicyType.ALL);
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("CACHE_ConTent")).isEqualTo(InterestPolicyType.CACHE_CONTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("@11")).isNull();
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("CACHE_KEYS")).isNull();
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("invalid")).isNull();
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("test")).isNull();
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(InterestPolicyType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The JndiDataSourceTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the JndiDataSourceType enumerated values.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.JndiDataSourceType
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class JndiDataSourceTypeTest {
|
||||
|
||||
@Test
|
||||
public void testNames() {
|
||||
assertEquals("ManagedDataSource", JndiDataSourceType.MANAGED.getName());
|
||||
assertEquals("PooledDataSource", JndiDataSourceType.POOLED.getName());
|
||||
assertEquals("SimpleDataSource", JndiDataSourceType.SIMPLE.getName());
|
||||
assertEquals("XAPooledDataSource", JndiDataSourceType.XA.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(JndiDataSourceType.MANAGED, JndiDataSourceType.valueOfIgnoreCase("managedDataSource "));
|
||||
assertEquals(JndiDataSourceType.MANAGED, JndiDataSourceType.valueOfIgnoreCase(" ManAGEd"));
|
||||
assertEquals(JndiDataSourceType.POOLED, JndiDataSourceType.valueOfIgnoreCase("POOLedDataSource"));
|
||||
assertEquals(JndiDataSourceType.POOLED, JndiDataSourceType.valueOfIgnoreCase("PoolED "));
|
||||
assertEquals(JndiDataSourceType.SIMPLE, JndiDataSourceType.valueOfIgnoreCase(" SIMPLEDATASOURCE"));
|
||||
assertEquals(JndiDataSourceType.SIMPLE, JndiDataSourceType.valueOfIgnoreCase(" SIMPLE "));
|
||||
assertEquals(JndiDataSourceType.XA, JndiDataSourceType.valueOfIgnoreCase(" xapooleddatasource "));
|
||||
assertEquals(JndiDataSourceType.XA, JndiDataSourceType.valueOfIgnoreCase(" xa "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidNames() {
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("ManageDataSource"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("ManagedDataSink"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("ManedDataSrc"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("PoolingDataSource"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("ComplexDataSource"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("SimplifiedDataSource"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("XA Pooled DataSource"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("X A"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("XADATASOURCE"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("XAPOOLED"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase("XA POOLED"));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase(" "));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase(""));
|
||||
assertNull(JndiDataSourceType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link JndiDataSourceType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.JndiDataSourceType
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class JndiDataSourceTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testNames() {
|
||||
|
||||
assertThat(JndiDataSourceType.MANAGED.getName()).isEqualTo("ManagedDataSource");
|
||||
assertThat(JndiDataSourceType.POOLED.getName()).isEqualTo("PooledDataSource");
|
||||
assertThat(JndiDataSourceType.SIMPLE.getName()).isEqualTo("SimpleDataSource");
|
||||
assertThat(JndiDataSourceType.XA.getName()).isEqualTo("XAPooledDataSource");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("managedDataSource ")).isEqualTo(JndiDataSourceType.MANAGED);
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase(" ManAGEd")).isEqualTo(JndiDataSourceType.MANAGED);
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("POOLedDataSource")).isEqualTo(JndiDataSourceType.POOLED);
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("PoolED ")).isEqualTo(JndiDataSourceType.POOLED);
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase(" SIMPLEDATASOURCE")).isEqualTo(JndiDataSourceType.SIMPLE);
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase(" SIMPLE ")).isEqualTo(JndiDataSourceType.SIMPLE);
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase(" xapooleddatasource ")).isEqualTo(JndiDataSourceType.XA);
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase(" xa ")).isEqualTo(JndiDataSourceType.XA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidNames() {
|
||||
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("ManageDataSource")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("ManagedDataSink")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("ManedDataSrc")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("PoolingDataSource")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("ComplexDataSource")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("SimplifiedDataSource")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("XA Pooled DataSource")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("X A")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("XADATASOURCE")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("XAPOOLED")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("XA POOLED")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(JndiDataSourceType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -15,20 +15,19 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
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.test.support.AbstractRegionFactoryBeanTests;
|
||||
|
||||
/**
|
||||
@@ -36,8 +35,8 @@ import org.springframework.data.gemfire.test.support.AbstractRegionFactoryBeanTe
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.apache.geode.cache.DataPolicy
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.RegionFactory
|
||||
@@ -45,12 +44,11 @@ import org.springframework.data.gemfire.test.support.AbstractRegionFactoryBeanTe
|
||||
* @see org.springframework.data.gemfire.LocalRegionFactoryBean
|
||||
* @since 1.3.x
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class LocalRegionFactoryBeanUnitTests extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
private final LocalRegionFactoryBean factoryBean = new LocalRegionFactoryBean();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private RegionFactoryBeanConfig defaultConfig() {
|
||||
|
||||
return new RegionFactoryBeanConfig(new LocalRegionFactoryBean(), "default") {
|
||||
@@ -63,13 +61,12 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
Region region = regionFactoryBean.getRegion();
|
||||
|
||||
assertNotNull(region);
|
||||
assertEquals(DataPolicy.DEFAULT, region.getAttributes().getDataPolicy());
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.DEFAULT);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
private RegionFactoryBeanConfig invalidConfig() {
|
||||
|
||||
return new RegionFactoryBeanConfig(new LocalRegionFactoryBean(), "local-replicate") {
|
||||
@@ -81,7 +78,7 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
@Override
|
||||
public void verify() {
|
||||
assertNotNull(this.exception);
|
||||
assertThat(this.exception).isNotNull();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -137,7 +134,7 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, " ");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [ ] is invalid", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [ ] is invalid");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -157,7 +154,7 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [] is invalid", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [] is invalid");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -177,7 +174,7 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "INVALID_DATA_POLICY_NAME");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [INVALID_DATA_POLICY_NAME] is invalid", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [INVALID_DATA_POLICY_NAME] is invalid");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -197,7 +194,7 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "PARTITION");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [PARTITION] is not supported for Local Regions", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [PARTITION] is not supported for Local Regions");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -282,8 +279,8 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, DataPolicy.PERSISTENT_REPLICATE);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PERSISTENT_REPLICATE] is not supported for Local Regions",
|
||||
expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_REPLICATE] is not supported for Local Regions");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -304,8 +301,8 @@ public class LocalRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, DataPolicy.PERSISTENT_REPLICATE);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PERSISTENT_REPLICATE] is not supported for Local Regions",
|
||||
expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_REPLICATE] is not supported for Local Regions");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -13,20 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.same;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.AttributesMutator;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.CacheListener;
|
||||
@@ -40,33 +40,37 @@ import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
|
||||
import org.apache.geode.cache.wan.GatewaySender;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The LookupRegionFactoryBeanTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the LookupRegionFactoryBean class.
|
||||
* Unit Tests for {@link LookupRegionFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.LookupRegionFactoryBean
|
||||
* @see org.apache.geode.cache.AttributesMutator
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.EvictionAttributesMutator
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.LookupRegionFactoryBean
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class LookupRegionFactoryBeanTest {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class LookupRegionFactoryBeanUnitTests {
|
||||
|
||||
private AsyncEventQueue mockAsyncEventQueue(String id) {
|
||||
|
||||
private AsyncEventQueue mockAsyncEventQueue(final String id) {
|
||||
AsyncEventQueue mockQueue = mock(AsyncEventQueue.class, String.format("MockAsyncEventQueue.%1$s", id));
|
||||
|
||||
when(mockQueue.getId()).thenReturn(id);
|
||||
|
||||
return mockQueue;
|
||||
}
|
||||
|
||||
private GatewaySender mockGatewaySender(final String id) {
|
||||
private GatewaySender mockGatewaySender(String id) {
|
||||
|
||||
GatewaySender mockGatewaySender = mock(GatewaySender.class, String.format("MockGatewaySender.%1$s", id));
|
||||
|
||||
when(mockGatewaySender.getId()).thenReturn(id);
|
||||
|
||||
return mockGatewaySender;
|
||||
}
|
||||
|
||||
@@ -193,14 +197,14 @@ public class LookupRegionFactoryBeanTest {
|
||||
factoryBean.setEntryTimeToLive(mockExpirationAttributesEntryTtl);
|
||||
//factoryBean.setStatisticsEnabled(true);
|
||||
|
||||
assertTrue(factoryBean.isStatisticsEnabled());
|
||||
assertThat(factoryBean.isStatisticsEnabled()).isTrue();
|
||||
|
||||
try {
|
||||
factoryBean.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalStateException expected) {
|
||||
assertEquals("Statistics for Region [/Example] must be enabled to change Entry & Region TTL/TTI Expiration settings",
|
||||
expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo(
|
||||
"Statistics for Region [/Example] must be enabled to change Entry & Region TTL/TTI Expiration settings");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -213,10 +217,10 @@ public class LookupRegionFactoryBeanTest {
|
||||
|
||||
LookupRegionFactoryBean factoryBean = new LookupRegionFactoryBean();
|
||||
|
||||
assertTrue(factoryBean.isLookupEnabled());
|
||||
assertThat(factoryBean.isLookupEnabled()).isTrue();
|
||||
|
||||
factoryBean.setLookupEnabled(false);
|
||||
|
||||
assertTrue(factoryBean.isLookupEnabled());
|
||||
assertThat(factoryBean.isLookupEnabled()).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -13,31 +13,31 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.PartitionAttributes;
|
||||
import org.apache.geode.cache.PartitionResolver;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link PartitionAttributesFactoryBean}.
|
||||
* Unit Tests for {@link PartitionAttributesFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.PartitionAttributes
|
||||
* @see org.springframework.data.gemfire.PartitionAttributesFactoryBean
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PartitionAttributesFactoryBeanTest {
|
||||
@SuppressWarnings({ "rawtypes", "unused" })
|
||||
public class PartitionAttributesFactoryBeanUnitTests {
|
||||
|
||||
private PartitionResolver createMockPartitionResolver( String name) {
|
||||
|
||||
protected PartitionResolver createMockPartitionResolver(final String name) {
|
||||
PartitionResolver partitionResolver = mock(PartitionResolver.class);
|
||||
|
||||
when(partitionResolver.getName()).thenReturn(name);
|
||||
@@ -46,7 +46,9 @@ public class PartitionAttributesFactoryBeanTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSetBasicProperties() throws Exception {
|
||||
|
||||
PartitionAttributesFactoryBean partitionAttributesFactoryBean = new PartitionAttributesFactoryBean();
|
||||
|
||||
partitionAttributesFactoryBean.setColocatedWith("mockColocatedRegion");
|
||||
@@ -61,28 +63,32 @@ public class PartitionAttributesFactoryBeanTest {
|
||||
|
||||
PartitionAttributes partitionAttributes = partitionAttributesFactoryBean.getObject();
|
||||
|
||||
assertNotNull(partitionAttributes);
|
||||
assertEquals("mockColocatedRegion", partitionAttributes.getColocatedWith());
|
||||
assertEquals(1024, partitionAttributes.getLocalMaxMemory());
|
||||
assertNotNull(partitionAttributes.getPartitionResolver());
|
||||
assertEquals("mockPartitionResolver", partitionAttributes.getPartitionResolver().getName());
|
||||
assertEquals(1000L, partitionAttributes.getRecoveryDelay());
|
||||
assertEquals(1, partitionAttributes.getRedundantCopies());
|
||||
assertEquals(60000L, partitionAttributes.getStartupRecoveryDelay());
|
||||
assertEquals(8192L, partitionAttributes.getTotalMaxMemory());
|
||||
assertEquals(42, partitionAttributes.getTotalNumBuckets());
|
||||
assertThat(partitionAttributes).isNotNull();
|
||||
assertThat(partitionAttributes.getColocatedWith()).isEqualTo("mockColocatedRegion");
|
||||
assertThat(partitionAttributes.getLocalMaxMemory()).isEqualTo(1024);
|
||||
assertThat(partitionAttributes.getPartitionResolver()).isNotNull();
|
||||
assertThat(partitionAttributes.getPartitionResolver().getName()).isEqualTo("mockPartitionResolver");
|
||||
assertThat(partitionAttributes.getRecoveryDelay()).isEqualTo(1000L);
|
||||
assertThat(partitionAttributes.getRedundantCopies()).isEqualTo(1);
|
||||
assertThat(partitionAttributes.getStartupRecoveryDelay()).isEqualTo(60000L);
|
||||
assertThat(partitionAttributes.getTotalMaxMemory()).isEqualTo(8192L);
|
||||
assertThat(partitionAttributes.getTotalNumBuckets()).isEqualTo(42);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testValidationOnRedundantCopiesWhenExceedsBound() throws Exception {
|
||||
|
||||
PartitionAttributesFactoryBean partitionAttributesFactoryBean = new PartitionAttributesFactoryBean();
|
||||
|
||||
partitionAttributesFactoryBean.setRedundantCopies(4);
|
||||
partitionAttributesFactoryBean.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testValidationOnRedundantCopiesWhenPrecedesBound() throws Exception {
|
||||
|
||||
PartitionAttributesFactoryBean partitionAttributesFactoryBean = new PartitionAttributesFactoryBean();
|
||||
|
||||
partitionAttributesFactoryBean.setRedundantCopies(-1);
|
||||
partitionAttributesFactoryBean.afterPropertiesSet();
|
||||
}
|
||||
@@ -15,29 +15,29 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.RegionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link PartitionedRegionFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.apache.geode.cache.DataPolicy
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.RegionFactory
|
||||
* @see org.springframework.data.gemfire.PartitionedRegionFactoryBean
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
private final PartitionedRegionFactoryBean factoryBean = new PartitionedRegionFactoryBean();
|
||||
@@ -48,36 +48,46 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWithPersistentUnspecifiedAndDataPolicyUnspecified() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, (String) null);
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PARTITION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenNotPersistentAndDataPolicyUnspecified() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, (String) null);
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PARTITION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentAndDataPolicyUnspecified() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, (String) null);
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PERSISTENT_PARTITION));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWithBlankDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, " ");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [ ] is invalid.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [ ] is invalid.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -90,13 +100,14 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWithEmptyDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [] is invalid.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [] is invalid.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -109,13 +120,14 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWithInvalidDataPolicyName() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "INVALID_DATA_POLICY_NAME");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [INVALID_DATA_POLICY_NAME] is invalid.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [INVALID_DATA_POLICY_NAME] is invalid.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -127,13 +139,14 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWithInvalidDataPolicyType() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "REPLICATE");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [REPLICATE] is not supported in Partitioned Regions.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [REPLICATE] is not supported in Partitioned Regions.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -146,21 +159,28 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentUnspecifiedAndPartitionDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "PARTITION");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PARTITION));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenNotPersistentAndPartitionDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, "PARTITION");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PARTITION));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWhenPersistentAndPartitionDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
@@ -168,7 +188,7 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "PARTITION");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [PARTITION] is not valid when persistent is true", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [PARTITION] is not valid when persistent is true");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -180,13 +200,17 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentUnspecifiedAndPersistentPartitionDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "PERSISTENT_PARTITION");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PERSISTENT_PARTITION));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWhenNotPersistentAndPersistentPartitionedDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
@@ -194,7 +218,8 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, "PERSISTENT_PARTITION");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [PERSISTENT_PARTITION] is not valid when persistent is false", e.getMessage());
|
||||
assertThat(e.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_PARTITION] is not valid when persistent is false");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -206,9 +231,12 @@ public class PartitionedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentAndPersistentPartitionedDataPolicy() {
|
||||
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "PERSISTENT_PARTITION");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PERSISTENT_PARTITION));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,70 +13,76 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.DiskStore;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
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 PdxDiskStoreTest class is a test suite containing tests to reproduce the issue in JIRA SGF-197.
|
||||
* Integration Tests for PDX {@link DiskStore}
|
||||
* and to reproduce the issue in JIRA SGF-197.
|
||||
*
|
||||
* @author John Blum
|
||||
* @link https://jira.springsource.org/browse/SGF-197
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.apache.geode.cache.DiskStore
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.DiskStoreFactoryBean
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.annotation.DirtiesContext
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("/org/springframework/data/gemfire/pdxdiskstore-config.xml")
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class PdxDiskStoreIntegrationTest {
|
||||
@SuppressWarnings("unused")
|
||||
public class PdxDiskStoreIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
protected static final int NUMBER_OF_REGION_ENTRIES = 1000;
|
||||
|
||||
@Resource(name = "pdxDataRegion")
|
||||
private Region<KeyHolder<String>, ValueHolder<Integer>> pdxDataRegion;
|
||||
|
||||
protected static void assertRegionExists(final String expectedRegionName, final String expectedRegionPath, final Region region) {
|
||||
assertNotNull(region);
|
||||
assertEquals(String.format("Expected Region with name %1$s; but was %2$s!",
|
||||
expectedRegionName, region.getName()), expectedRegionName, region.getName());
|
||||
assertEquals(String.format("Expected Region with path %1$s; but was %2$s!",
|
||||
expectedRegionPath, region.getFullPath()), expectedRegionPath, region.getFullPath());
|
||||
protected static void assertRegionExists(String expectedRegionName, String expectedRegionPath, Region<?, ?> region) {
|
||||
|
||||
assertThat(region).isNotNull();
|
||||
|
||||
assertThat(region.getName())
|
||||
.describedAs("Expected Region with name %1$s; but was %2$s!", expectedRegionName, region.getName())
|
||||
.isEqualTo(expectedRegionName);
|
||||
|
||||
assertThat(region.getFullPath())
|
||||
.describedAs("Expected Region with path %1$s; but was %2$s!", expectedRegionPath, region.getFullPath())
|
||||
.isEqualTo(expectedRegionPath);
|
||||
}
|
||||
|
||||
protected static boolean createDirectory(final File path) {
|
||||
return (path != null && (path.isDirectory() || path.mkdirs()));
|
||||
}
|
||||
|
||||
protected static File createFile(final String pathname) {
|
||||
private static File createFile(final String pathname) {
|
||||
return new File(pathname);
|
||||
}
|
||||
|
||||
protected static void deleteRecursive(final File path) {
|
||||
private static void deleteRecursive(final File path) {
|
||||
|
||||
if (path.isDirectory()) {
|
||||
for (File file : path.listFiles()) {
|
||||
deleteRecursive(file);
|
||||
@@ -88,8 +94,9 @@ public class PdxDiskStoreIntegrationTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() {
|
||||
assertTrue(createDirectory(createFile("./gemfire/data-store")));
|
||||
assertTrue(createDirectory(createFile("./gemfire/pdx-store")));
|
||||
|
||||
assertThat(createDirectory(createFile("./gemfire/data-store")).isDirectory()).isTrue();
|
||||
assertThat(createDirectory(createFile("./gemfire/pdx-store")).isDirectory()).isTrue();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -100,25 +107,27 @@ public class PdxDiskStoreIntegrationTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
assertNotNull("The PdxData GemFire Region was not created successfully!", pdxDataRegion);
|
||||
assertThat(pdxDataRegion).as("The PdxData GemFire Region was not created successfully!").isNotNull();
|
||||
|
||||
if (pdxDataRegion.size() == 0) {
|
||||
for (int index = 1; index <= NUMBER_OF_REGION_ENTRIES; index++) {
|
||||
pdxDataRegion.put(new KeyHolder<String>("key" + index), new ValueHolder<Integer>(index));
|
||||
pdxDataRegion.put(new KeyHolder<>("key" + index), new ValueHolder<>(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersistentRegionWithDataCreation() {
|
||||
|
||||
assertRegionExists("PdxData", "/PdxData", pdxDataRegion);
|
||||
assertEquals(NUMBER_OF_REGION_ENTRIES, pdxDataRegion.size());
|
||||
assertThat(pdxDataRegion.size()).isEqualTo(NUMBER_OF_REGION_ENTRIES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersistentRegionWithDataRecovery() {
|
||||
|
||||
assertRegionExists("PdxData", "/PdxData", pdxDataRegion);
|
||||
assertEquals(NUMBER_OF_REGION_ENTRIES, pdxDataRegion.size());
|
||||
assertThat(pdxDataRegion.size()).isEqualTo(NUMBER_OF_REGION_ENTRIES);
|
||||
}
|
||||
|
||||
protected static class AbstractHolderSupport {
|
||||
@@ -137,10 +146,9 @@ public class PdxDiskStoreIntegrationTest {
|
||||
|
||||
private T key;
|
||||
|
||||
public KeyHolder() {
|
||||
}
|
||||
public KeyHolder() { }
|
||||
|
||||
public KeyHolder(final T key) {
|
||||
public KeyHolder(T key) {
|
||||
Assert.notNull(key, "The key cannot be null!");
|
||||
this.key = key;
|
||||
}
|
||||
@@ -149,13 +157,14 @@ public class PdxDiskStoreIntegrationTest {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(final T key) {
|
||||
public void setKey(T key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -163,15 +172,18 @@ public class PdxDiskStoreIntegrationTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
final KeyHolder that = (KeyHolder) obj;
|
||||
KeyHolder<?> that = (KeyHolder<?>) obj;
|
||||
|
||||
return equals(this.getKey(), that.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
int hashValue = 17;
|
||||
|
||||
hashValue = 37 * hashValue + hashCode(this.getKey());
|
||||
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
@@ -189,7 +201,7 @@ public class PdxDiskStoreIntegrationTest {
|
||||
public ValueHolder() {
|
||||
}
|
||||
|
||||
public ValueHolder(final T value) {
|
||||
public ValueHolder(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -197,13 +209,14 @@ public class PdxDiskStoreIntegrationTest {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(final T value) {
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -211,15 +224,18 @@ public class PdxDiskStoreIntegrationTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ValueHolder that = (ValueHolder) obj;
|
||||
ValueHolder<?> that = (ValueHolder<?>) obj;
|
||||
|
||||
return equals(this.getValue(), that.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
int hashValue = 17;
|
||||
hashValue = 17 * hashValue + hashCode(this.getValue());
|
||||
|
||||
hashValue = 37 * hashValue + hashCode(this.getValue());
|
||||
|
||||
return hashValue;
|
||||
}
|
||||
|
||||
@@ -228,5 +244,4 @@ public class PdxDiskStoreIntegrationTest {
|
||||
return String.valueOf(getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,13 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyFloat;
|
||||
@@ -93,7 +88,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
@Override
|
||||
public void verify() {
|
||||
Region region = regionFactoryBean.getRegion();
|
||||
assertEquals(DataPolicy.DEFAULT, region.getAttributes().getDataPolicy());
|
||||
assertThat(region.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.DEFAULT);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -110,7 +105,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
@Override
|
||||
public void verify() {
|
||||
Region region = regionFactoryBean.getRegion();
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, region.getAttributes().getDataPolicy());
|
||||
assertThat(region.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -127,9 +122,9 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
@Override
|
||||
public void verify() {
|
||||
assertNotNull(this.exception);
|
||||
assertEquals("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false",
|
||||
exception.getMessage());
|
||||
assertThat(this.exception).isNotNull();
|
||||
assertThat(exception.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false");
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -178,15 +173,15 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
PeerRegionFactoryBean<?, ?> factoryBean = new TestRegionFactoryBean<>();
|
||||
|
||||
assertFalse(factoryBean.isPersistent());
|
||||
assertThat(factoryBean.isPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
|
||||
assertFalse(factoryBean.isPersistent());
|
||||
assertThat(factoryBean.isPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
|
||||
assertTrue(factoryBean.isPersistent());
|
||||
assertThat(factoryBean.isPersistent()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -194,15 +189,15 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
PeerRegionFactoryBean<?, ?> factoryBean = new TestRegionFactoryBean<>();
|
||||
|
||||
assertFalse(factoryBean.isNotPersistent());
|
||||
assertThat(factoryBean.isNotPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
|
||||
assertFalse(factoryBean.isNotPersistent());
|
||||
assertThat(factoryBean.isNotPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
|
||||
assertTrue(factoryBean.isNotPersistent());
|
||||
assertThat(factoryBean.isNotPersistent()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -228,7 +223,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
@Override
|
||||
public void setDataPolicy(final DataPolicy dataPolicy) {
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, dataPolicy);
|
||||
assertThat(dataPolicy).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
super.setDataPolicy(dataPolicy);
|
||||
setDataPolicyCalled.set(true);
|
||||
}
|
||||
@@ -242,8 +237,8 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.setAttributes(mockRegionAttributes);
|
||||
factoryBean.setShortcut(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW);
|
||||
|
||||
assertSame(mockRegionFactory, factoryBean.createRegionFactory(mockCache));
|
||||
assertTrue(setDataPolicyCalled.get());
|
||||
assertThat(factoryBean.createRegionFactory(mockCache)).isSameAs(mockRegionFactory);
|
||||
assertThat(setDataPolicyCalled.get()).isTrue();
|
||||
|
||||
verify(mockCache, times(1)).createRegionFactory(eq(RegionShortcut.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW));
|
||||
}
|
||||
@@ -263,7 +258,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.setAttributes(mockRegionAttributes);
|
||||
factoryBean.setShortcut(null);
|
||||
|
||||
assertSame(mockRegionFactory, factoryBean.createRegionFactory(mockCache));
|
||||
assertThat(factoryBean.createRegionFactory(mockCache)).isSameAs(mockRegionFactory);
|
||||
|
||||
verify(mockCache, times(1)).createRegionFactory(eq(mockRegionAttributes));
|
||||
}
|
||||
@@ -282,7 +277,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.setAttributes(null);
|
||||
factoryBean.setShortcut(null);
|
||||
|
||||
assertSame(mockRegionFactory, factoryBean.createRegionFactory(mockCache));
|
||||
assertThat(factoryBean.createRegionFactory(mockCache)).isSameAs(mockRegionFactory);
|
||||
|
||||
verify(mockCache).createRegionFactory();
|
||||
}
|
||||
@@ -329,11 +324,14 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
when(mockRegionAttributes.getSubscriptionAttributes()).thenReturn(testSubscriptionAttributes);
|
||||
|
||||
PeerRegionFactoryBean factoryBean = new PeerRegionFactoryBean() {
|
||||
@Override boolean isUserSpecifiedEvictionAttributes(final RegionAttributes regionAttributes) {
|
||||
|
||||
@Override
|
||||
boolean isUserSpecifiedEvictionAttributes(RegionAttributes regionAttributes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override void validateRegionAttributes(final RegionAttributes regionAttributes) {
|
||||
@Override
|
||||
void validateRegionAttributes(RegionAttributes regionAttributes) {
|
||||
// no-op!
|
||||
}
|
||||
};
|
||||
@@ -440,11 +438,14 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
when(mockRegionAttributes.getSubscriptionAttributes()).thenReturn(null);
|
||||
|
||||
PeerRegionFactoryBean factoryBean = new PeerRegionFactoryBean() {
|
||||
@Override boolean isUserSpecifiedEvictionAttributes(final RegionAttributes regionAttributes) {
|
||||
|
||||
@Override
|
||||
boolean isUserSpecifiedEvictionAttributes(RegionAttributes regionAttributes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override void validateRegionAttributes(final RegionAttributes regionAttributes) {
|
||||
@Override
|
||||
void validateRegionAttributes(RegionAttributes regionAttributes) {
|
||||
// no-op!
|
||||
}
|
||||
};
|
||||
@@ -496,17 +497,18 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
RegionAttributes regionAttributes = TestUtils.readField("regionAttributes",
|
||||
TestUtils.readField("attrsFactory", mockRegionFactory));
|
||||
|
||||
PartitionAttributes actualPartitionAttributes = regionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(actualPartitionAttributes);
|
||||
assertNotSame(testPartitionAttributes, actualPartitionAttributes);
|
||||
assertEquals("TestRegion", actualPartitionAttributes.getColocatedWith());
|
||||
assertEquals(0, actualPartitionAttributes.getLocalMaxMemory());
|
||||
assertEquals(15000L, actualPartitionAttributes.getRecoveryDelay());
|
||||
assertEquals(1, actualPartitionAttributes.getRedundantCopies());
|
||||
assertEquals(30000L, actualPartitionAttributes.getStartupRecoveryDelay());
|
||||
assertEquals(1024000L, actualPartitionAttributes.getTotalMaxMemory());
|
||||
assertEquals(51, actualPartitionAttributes.getTotalNumBuckets());
|
||||
assertThat(actualPartitionAttributes).isNotNull();
|
||||
assertThat(actualPartitionAttributes).isNotSameAs(testPartitionAttributes);
|
||||
assertThat(actualPartitionAttributes.getColocatedWith()).isEqualTo("TestRegion");
|
||||
assertThat(actualPartitionAttributes.getLocalMaxMemory()).isEqualTo(0);
|
||||
assertThat(actualPartitionAttributes.getRecoveryDelay()).isEqualTo(15000L);
|
||||
assertThat(actualPartitionAttributes.getRedundantCopies()).isEqualTo(1);
|
||||
assertThat(actualPartitionAttributes.getStartupRecoveryDelay()).isEqualTo(30000L);
|
||||
assertThat(actualPartitionAttributes.getTotalMaxMemory()).isEqualTo(1024000L);
|
||||
assertThat(actualPartitionAttributes.getTotalNumBuckets()).isEqualTo(51);
|
||||
|
||||
verify(mockRegionAttributes, times(2)).getPartitionAttributes();
|
||||
}
|
||||
@@ -530,15 +532,15 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
TestUtils.readField("attrsFactory", mockRegionFactory));
|
||||
PartitionAttributes actualPartitionAttributes = regionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(actualPartitionAttributes);
|
||||
assertNotSame(testPartitionAttributes, actualPartitionAttributes);
|
||||
assertEquals("TestRegion", actualPartitionAttributes.getColocatedWith());
|
||||
assertEquals(512000, actualPartitionAttributes.getLocalMaxMemory());
|
||||
assertEquals(15000L, actualPartitionAttributes.getRecoveryDelay());
|
||||
assertEquals(1, actualPartitionAttributes.getRedundantCopies());
|
||||
assertEquals(30000L, actualPartitionAttributes.getStartupRecoveryDelay());
|
||||
assertEquals(1024000L, actualPartitionAttributes.getTotalMaxMemory());
|
||||
assertEquals(51, actualPartitionAttributes.getTotalNumBuckets());
|
||||
assertThat(actualPartitionAttributes).isNotNull();
|
||||
assertThat(actualPartitionAttributes).isNotSameAs(testPartitionAttributes);
|
||||
assertThat(actualPartitionAttributes.getColocatedWith()).isEqualTo("TestRegion");
|
||||
assertThat(actualPartitionAttributes.getLocalMaxMemory()).isEqualTo(512000);
|
||||
assertThat(actualPartitionAttributes.getRecoveryDelay()).isEqualTo(15000L);
|
||||
assertThat(actualPartitionAttributes.getRedundantCopies()).isEqualTo(1);
|
||||
assertThat(actualPartitionAttributes.getStartupRecoveryDelay()).isEqualTo(30000L);
|
||||
assertThat(actualPartitionAttributes.getTotalMaxMemory()).isEqualTo(1024000L);
|
||||
assertThat(actualPartitionAttributes.getTotalNumBuckets()).isEqualTo(51);
|
||||
|
||||
verify(mockRegionAttributes, times(2)).getPartitionAttributes();
|
||||
}
|
||||
@@ -560,17 +562,18 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
RegionAttributes regionAttributes = TestUtils.readField("regionAttributes",
|
||||
TestUtils.readField("attrsFactory", mockRegionFactory));
|
||||
|
||||
PartitionAttributes actualPartitionAttributes = regionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(actualPartitionAttributes);
|
||||
assertNotSame(testPartitionAttributes, actualPartitionAttributes);
|
||||
assertEquals("TestRegion", actualPartitionAttributes.getColocatedWith());
|
||||
assertEquals(512000, actualPartitionAttributes.getLocalMaxMemory());
|
||||
assertEquals(15000L, actualPartitionAttributes.getRecoveryDelay());
|
||||
assertEquals(3, actualPartitionAttributes.getRedundantCopies());
|
||||
assertEquals(30000L, actualPartitionAttributes.getStartupRecoveryDelay());
|
||||
assertEquals(1024000L, actualPartitionAttributes.getTotalMaxMemory());
|
||||
assertEquals(51, actualPartitionAttributes.getTotalNumBuckets());
|
||||
assertThat(actualPartitionAttributes).isNotNull();
|
||||
assertThat(actualPartitionAttributes).isNotSameAs(testPartitionAttributes);
|
||||
assertThat(actualPartitionAttributes.getColocatedWith()).isEqualTo("TestRegion");
|
||||
assertThat(actualPartitionAttributes.getLocalMaxMemory()).isEqualTo(512000);
|
||||
assertThat(actualPartitionAttributes.getRecoveryDelay()).isEqualTo(15000L);
|
||||
assertThat(actualPartitionAttributes.getRedundantCopies()).isEqualTo(3);
|
||||
assertThat(actualPartitionAttributes.getStartupRecoveryDelay()).isEqualTo(30000L);
|
||||
assertThat(actualPartitionAttributes.getTotalMaxMemory()).isEqualTo(1024000L);
|
||||
assertThat(actualPartitionAttributes.getTotalNumBuckets()).isEqualTo(51);
|
||||
|
||||
verify(mockRegionAttributes, times(2)).getPartitionAttributes();
|
||||
}
|
||||
@@ -592,17 +595,18 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
RegionAttributes regionAttributes = TestUtils.readField("regionAttributes",
|
||||
TestUtils.readField("attrsFactory", mockRegionFactory));
|
||||
|
||||
PartitionAttributes actualPartitionAttributes = regionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(actualPartitionAttributes);
|
||||
assertNotSame(testPartitionAttributes, actualPartitionAttributes);
|
||||
assertEquals("TestRegion", actualPartitionAttributes.getColocatedWith());
|
||||
assertEquals(0, actualPartitionAttributes.getLocalMaxMemory());
|
||||
assertEquals(15000L, actualPartitionAttributes.getRecoveryDelay());
|
||||
assertEquals(0, actualPartitionAttributes.getRedundantCopies());
|
||||
assertEquals(30000L, actualPartitionAttributes.getStartupRecoveryDelay());
|
||||
assertEquals(1024000L, actualPartitionAttributes.getTotalMaxMemory());
|
||||
assertEquals(51, actualPartitionAttributes.getTotalNumBuckets());
|
||||
assertThat(actualPartitionAttributes).isNotNull();
|
||||
assertThat(actualPartitionAttributes).isNotSameAs(testPartitionAttributes);
|
||||
assertThat(actualPartitionAttributes.getColocatedWith()).isEqualTo("TestRegion");
|
||||
assertThat(actualPartitionAttributes.getLocalMaxMemory()).isEqualTo(0);
|
||||
assertThat(actualPartitionAttributes.getRecoveryDelay()).isEqualTo(15000L);
|
||||
assertThat(actualPartitionAttributes.getRedundantCopies()).isEqualTo(0);
|
||||
assertThat(actualPartitionAttributes.getStartupRecoveryDelay()).isEqualTo(30000L);
|
||||
assertThat(actualPartitionAttributes.getTotalMaxMemory()).isEqualTo(1024000L);
|
||||
assertThat(actualPartitionAttributes.getTotalNumBuckets()).isEqualTo(51);
|
||||
|
||||
verify(mockRegionAttributes, times(2)).getPartitionAttributes();
|
||||
}
|
||||
@@ -624,17 +628,18 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
|
||||
RegionAttributes regionAttributes = TestUtils.readField("regionAttributes",
|
||||
TestUtils.readField("attrsFactory", mockRegionFactory));
|
||||
|
||||
PartitionAttributes actualPartitionAttributes = regionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(actualPartitionAttributes);
|
||||
assertNotSame(testPartitionAttributes, actualPartitionAttributes);
|
||||
assertEquals("TestRegion", actualPartitionAttributes.getColocatedWith());
|
||||
assertEquals(512000, actualPartitionAttributes.getLocalMaxMemory());
|
||||
assertEquals(15000L, actualPartitionAttributes.getRecoveryDelay());
|
||||
assertEquals(0, actualPartitionAttributes.getRedundantCopies());
|
||||
assertEquals(30000L, actualPartitionAttributes.getStartupRecoveryDelay());
|
||||
assertEquals(1024000L, actualPartitionAttributes.getTotalMaxMemory());
|
||||
assertEquals(51, actualPartitionAttributes.getTotalNumBuckets());
|
||||
assertThat(actualPartitionAttributes).isNotNull();
|
||||
assertThat(actualPartitionAttributes).isNotSameAs(testPartitionAttributes);
|
||||
assertThat(actualPartitionAttributes.getColocatedWith()).isEqualTo("TestRegion");
|
||||
assertThat(actualPartitionAttributes.getLocalMaxMemory()).isEqualTo(512000);
|
||||
assertThat(actualPartitionAttributes.getRecoveryDelay()).isEqualTo(15000L);
|
||||
assertThat(actualPartitionAttributes.getRedundantCopies()).isEqualTo(0);
|
||||
assertThat(actualPartitionAttributes.getStartupRecoveryDelay()).isEqualTo(30000L);
|
||||
assertThat(actualPartitionAttributes.getTotalMaxMemory()).isEqualTo(1024000L);
|
||||
assertThat(actualPartitionAttributes.getTotalNumBuckets()).isEqualTo(51);
|
||||
|
||||
verify(mockRegionAttributes, times(2)).getPartitionAttributes();
|
||||
}
|
||||
@@ -697,7 +702,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, " ");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [ ] is invalid", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [ ] is invalid");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -717,7 +722,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [] is invalid", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [] is invalid");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -737,7 +742,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "CSV");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [CSV] is invalid", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [CSV] is invalid");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -778,7 +783,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "EMPTY");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [EMPTY] is not valid when persistent is true", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [EMPTY] is not valid when persistent is true");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -819,7 +824,8 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, "PERSISTENT_PARTITION");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PERSISTENT_PARTITION] is not valid when persistent is false", expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_PARTITION] is not valid when persistent is false");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -842,7 +848,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
"Setting the 'persistent' attribute to TRUE and 'Data Policy' to PARTITION should have thrown an IllegalArgumentException!");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PARTITION] is not valid when persistent is true", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [PARTITION] is not valid when persistent is true");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -886,7 +892,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, (String) null);
|
||||
|
||||
verify(mockRegionFactory, times(1)).setDataPolicy(eq(DataPolicy.PRELOADED));
|
||||
assertEquals(DataPolicy.PRELOADED, factoryBean.getDataPolicy());
|
||||
assertThat(factoryBean.getDataPolicy()).isEqualTo(DataPolicy.PRELOADED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -900,7 +906,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, (String) null);
|
||||
|
||||
verify(mockRegionFactory, times(1)).setDataPolicy(eq(DataPolicy.PARTITION));
|
||||
assertEquals(DataPolicy.PARTITION, factoryBean.getDataPolicy());
|
||||
assertThat(factoryBean.getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -914,7 +920,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, (String) null);
|
||||
|
||||
verify(mockRegionFactory, times(1)).setDataPolicy(eq(DataPolicy.PERSISTENT_PARTITION));
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, factoryBean.getDataPolicy());
|
||||
assertThat(factoryBean.getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -928,7 +934,8 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, (String) null);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PERSISTENT_PARTITION] is not valid when persistent is false", expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_PARTITION] is not valid when persistent is false");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -950,7 +957,7 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, (String) null);
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PARTITION] is not valid when persistent is true", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [PARTITION] is not valid when persistent is true");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -1025,10 +1032,12 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
try {
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, DataPolicy.PERSISTENT_REPLICATE);
|
||||
fail("Setting the 'persistent' attribute to FALSE and 'Data Policy' to PERSISTENT_REPLICATE should have thrown an IllegalArgumentException!");
|
||||
fail(
|
||||
"Setting the 'persistent' attribute to FALSE and 'Data Policy' to PERSISTENT_REPLICATE should have thrown an IllegalArgumentException!");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false", expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
@@ -1047,10 +1056,11 @@ public class PeerRegionFactoryBeanTest extends AbstractRegionFactoryBeanTests {
|
||||
try {
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "REPLICATE");
|
||||
fail("Setting the 'persistent' attribute to TRUE and 'Data Policy' to REPLICATE should have thrown an IllegalArgumentException!");
|
||||
fail(
|
||||
"Setting the 'persistent' attribute to TRUE and 'Data Policy' to REPLICATE should have thrown an IllegalArgumentException!");
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [REPLICATE] is not valid when persistent is true", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [REPLICATE] is not valid when persistent is true");
|
||||
throw expected;
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.EvictionAction;
|
||||
import org.apache.geode.cache.EvictionAlgorithm;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* The RegionShortcutsIntegrationTest class is a test suite of test cases testing the use of RegionShortcuts in the
|
||||
* Spring Data GemFire XML Namespace!
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ContextConfiguration("region-datapolicy-shortcuts.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class RegionDataPolicyShortcutsIntegrationTest {
|
||||
|
||||
@Resource(name = "LocalWithDataPolicy")
|
||||
private Region localWithDataPolicy;
|
||||
|
||||
@Resource(name = "LocalWithShortcut")
|
||||
private Region localWithShortcut;
|
||||
|
||||
@Resource(name = "PartitionWithDataPolicy")
|
||||
private Region partitionWithDataPolicy;
|
||||
|
||||
@Resource(name = "PartitionWithShortcut")
|
||||
private Region partitionWithShortcut;
|
||||
|
||||
@Resource(name = "ReplicateWithDataPolicy")
|
||||
private Region replicateWithDataPolicy;
|
||||
|
||||
@Resource(name = "ReplicateWithShortcut")
|
||||
private Region replicateWithShortcut;
|
||||
|
||||
@Resource(name = "ShortcutDefaults")
|
||||
private Region shortcutDefaults;
|
||||
|
||||
@Resource(name = "ShortcutOverrides")
|
||||
private Region shortcutOverrides;
|
||||
|
||||
@Test
|
||||
public void testLocalRegionWithDataPolicy() {
|
||||
assertNotNull("A reference to the 'LocalWithDataPolicy' Region was not property configured!", localWithDataPolicy);
|
||||
assertEquals("LocalWithDataPolicy", localWithDataPolicy.getName());
|
||||
assertEquals("/LocalWithDataPolicy", localWithDataPolicy.getFullPath());
|
||||
assertNotNull(localWithDataPolicy.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, localWithDataPolicy.getAttributes().getDataPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalRegionWithShortcut() {
|
||||
assertNotNull("A reference to the 'LocalWithShortcut' Region was not property configured!", localWithShortcut);
|
||||
assertEquals("LocalWithShortcut", localWithShortcut.getName());
|
||||
assertEquals("/LocalWithShortcut", localWithShortcut.getFullPath());
|
||||
assertNotNull(localWithShortcut.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, localWithShortcut.getAttributes().getDataPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionRegionWithDataPolicy() {
|
||||
assertNotNull("A reference to the 'PartitionWithDataPolicy' Region was not property configured!", partitionWithDataPolicy);
|
||||
assertEquals("PartitionWithDataPolicy", partitionWithDataPolicy.getName());
|
||||
assertEquals("/PartitionWithDataPolicy", partitionWithDataPolicy.getFullPath());
|
||||
assertNotNull(partitionWithDataPolicy.getAttributes());
|
||||
assertEquals(DataPolicy.PARTITION, partitionWithDataPolicy.getAttributes().getDataPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionRegionWithShortcut() {
|
||||
assertNotNull("A reference to the 'PartitionWithShortcut' Region was not property configured!", partitionWithShortcut);
|
||||
assertEquals("PartitionWithShortcut", partitionWithShortcut.getName());
|
||||
assertEquals("/PartitionWithShortcut", partitionWithShortcut.getFullPath());
|
||||
assertNotNull(partitionWithShortcut.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, partitionWithShortcut.getAttributes().getDataPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicateRegionWithDataPolicy() {
|
||||
assertNotNull("A reference to the 'ReplicateWithDataPolicy' Region was not property configured!", replicateWithDataPolicy);
|
||||
assertEquals("ReplicateWithDataPolicy", replicateWithDataPolicy.getName());
|
||||
assertEquals("/ReplicateWithDataPolicy", replicateWithDataPolicy.getFullPath());
|
||||
assertNotNull(replicateWithDataPolicy.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, replicateWithDataPolicy.getAttributes().getDataPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicateRegionWithShortcut() {
|
||||
assertNotNull("A reference to the 'ReplicateWithShortcut' Region was not property configured!", replicateWithShortcut);
|
||||
assertEquals("ReplicateWithShortcut", replicateWithShortcut.getName());
|
||||
assertEquals("/ReplicateWithShortcut", replicateWithShortcut.getFullPath());
|
||||
assertNotNull(replicateWithShortcut.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, replicateWithShortcut.getAttributes().getDataPolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutDefaultsRegion() {
|
||||
assertNotNull("A reference to the 'ShortcutDefaults' Region was not properly configured!", shortcutDefaults);
|
||||
assertEquals("ShortcutDefaults", shortcutDefaults.getName());
|
||||
assertEquals("/ShortcutDefaults", shortcutDefaults.getFullPath());
|
||||
|
||||
assertNotNull(shortcutDefaults.getAttributes());
|
||||
assertFalse(shortcutDefaults.getAttributes().getCloningEnabled());
|
||||
assertTrue(shortcutDefaults.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, shortcutDefaults.getAttributes().getDataPolicy());
|
||||
assertFalse(shortcutDefaults.getAttributes().isDiskSynchronous());
|
||||
assertTrue(shortcutDefaults.getAttributes().getIgnoreJTA());
|
||||
assertEquals(101, shortcutDefaults.getAttributes().getInitialCapacity());
|
||||
assertEquals(new Float(0.85f), new Float(shortcutDefaults.getAttributes().getLoadFactor()));
|
||||
assertEquals(Long.class, shortcutDefaults.getAttributes().getKeyConstraint());
|
||||
assertEquals(String.class, shortcutDefaults.getAttributes().getValueConstraint());
|
||||
|
||||
assertNotNull(shortcutDefaults.getAttributes().getEvictionAttributes());
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, shortcutDefaults.getAttributes().getEvictionAttributes().getAction());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, shortcutDefaults.getAttributes().getEvictionAttributes().getAlgorithm());
|
||||
|
||||
assertNotNull(shortcutDefaults.getAttributes().getPartitionAttributes());
|
||||
assertEquals(1, shortcutDefaults.getAttributes().getPartitionAttributes().getRedundantCopies());
|
||||
assertEquals(177, shortcutDefaults.getAttributes().getPartitionAttributes().getTotalNumBuckets());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutOverridesRegion() {
|
||||
assertNotNull("A reference to the 'ShortcutOverrides' Region was not properly configured!", shortcutOverrides);
|
||||
assertEquals("ShortcutOverrides", shortcutOverrides.getName());
|
||||
assertEquals("/ShortcutOverrides", shortcutOverrides.getFullPath());
|
||||
|
||||
assertNotNull(shortcutOverrides.getAttributes());
|
||||
assertTrue(shortcutOverrides.getAttributes().getCloningEnabled());
|
||||
assertFalse(shortcutOverrides.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(DataPolicy.PARTITION, shortcutOverrides.getAttributes().getDataPolicy());
|
||||
assertTrue(shortcutOverrides.getAttributes().isDiskSynchronous());
|
||||
assertFalse(shortcutOverrides.getAttributes().getIgnoreJTA());
|
||||
assertEquals(51, shortcutOverrides.getAttributes().getInitialCapacity());
|
||||
assertEquals(new Float(0.72f), new Float(shortcutOverrides.getAttributes().getLoadFactor()));
|
||||
assertEquals(String.class, shortcutOverrides.getAttributes().getKeyConstraint());
|
||||
assertEquals(Object.class, shortcutOverrides.getAttributes().getValueConstraint());
|
||||
|
||||
assertNotNull(shortcutOverrides.getAttributes().getEvictionAttributes());
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, shortcutOverrides.getAttributes().getEvictionAttributes().getAction());
|
||||
assertEquals(8192, shortcutOverrides.getAttributes().getEvictionAttributes().getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, shortcutOverrides.getAttributes().getEvictionAttributes().getAlgorithm());
|
||||
|
||||
assertNotNull(shortcutOverrides.getAttributes().getPartitionAttributes());
|
||||
assertEquals(3, shortcutOverrides.getAttributes().getPartitionAttributes().getRedundantCopies());
|
||||
assertEquals(111, shortcutOverrides.getAttributes().getPartitionAttributes().getTotalNumBuckets());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.EvictionAction;
|
||||
import org.apache.geode.cache.EvictionAlgorithm;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests testing the use of {@link RegionShortcut} in SDG XML namespace configuration metadata.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.DataPolicy
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "region-datapolicy-shortcuts.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class RegionDataPolicyShortcutsIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Resource(name = "LocalWithDataPolicy")
|
||||
private Region<?, ?> localWithDataPolicy;
|
||||
|
||||
@Resource(name = "LocalWithShortcut")
|
||||
private Region<?, ?> localWithShortcut;
|
||||
|
||||
@Resource(name = "PartitionWithDataPolicy")
|
||||
private Region<?, ?> partitionWithDataPolicy;
|
||||
|
||||
@Resource(name = "PartitionWithShortcut")
|
||||
private Region<?, ?> partitionWithShortcut;
|
||||
|
||||
@Resource(name = "ReplicateWithDataPolicy")
|
||||
private Region<?, ?> replicateWithDataPolicy;
|
||||
|
||||
@Resource(name = "ReplicateWithShortcut")
|
||||
private Region<?, ?> replicateWithShortcut;
|
||||
|
||||
@Resource(name = "ShortcutDefaults")
|
||||
private Region<?, ?> shortcutDefaults;
|
||||
|
||||
@Resource(name = "ShortcutOverrides")
|
||||
private Region<?, ?> shortcutOverrides;
|
||||
|
||||
@Test
|
||||
public void testLocalRegionWithDataPolicy() {
|
||||
|
||||
assertThat(localWithDataPolicy)
|
||||
.describedAs("A reference to the 'LocalWithDataPolicy' Region was not property configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(localWithDataPolicy.getName()).isEqualTo("LocalWithDataPolicy");
|
||||
assertThat(localWithDataPolicy.getFullPath()).isEqualTo("/LocalWithDataPolicy");
|
||||
assertThat(localWithDataPolicy.getAttributes()).isNotNull();
|
||||
assertThat(localWithDataPolicy.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalRegionWithShortcut() {
|
||||
|
||||
assertThat(localWithShortcut)
|
||||
.describedAs("A reference to the 'LocalWithShortcut' Region was not property configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(localWithShortcut.getName()).isEqualTo("LocalWithShortcut");
|
||||
assertThat(localWithShortcut.getFullPath()).isEqualTo("/LocalWithShortcut");
|
||||
assertThat(localWithShortcut.getAttributes()).isNotNull();
|
||||
assertThat(localWithShortcut.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionRegionWithDataPolicy() {
|
||||
|
||||
assertThat(partitionWithDataPolicy)
|
||||
.describedAs("A reference to the 'PartitionWithDataPolicy' Region was not property configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(partitionWithDataPolicy.getName()).isEqualTo("PartitionWithDataPolicy");
|
||||
assertThat(partitionWithDataPolicy.getFullPath()).isEqualTo("/PartitionWithDataPolicy");
|
||||
assertThat(partitionWithDataPolicy.getAttributes()).isNotNull();
|
||||
assertThat(partitionWithDataPolicy.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionRegionWithShortcut() {
|
||||
|
||||
assertThat(partitionWithShortcut)
|
||||
.describedAs("A reference to the 'PartitionWithShortcut' Region was not property configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(partitionWithShortcut.getName()).isEqualTo("PartitionWithShortcut");
|
||||
assertThat(partitionWithShortcut.getFullPath()).isEqualTo("/PartitionWithShortcut");
|
||||
assertThat(partitionWithShortcut.getAttributes()).isNotNull();
|
||||
assertThat(partitionWithShortcut.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicateRegionWithDataPolicy() {
|
||||
|
||||
assertThat(replicateWithDataPolicy)
|
||||
.describedAs("A reference to the 'ReplicateWithDataPolicy' Region was not property configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(replicateWithDataPolicy.getName()).isEqualTo("ReplicateWithDataPolicy");
|
||||
assertThat(replicateWithDataPolicy.getFullPath()).isEqualTo("/ReplicateWithDataPolicy");
|
||||
assertThat(replicateWithDataPolicy.getAttributes()).isNotNull();
|
||||
assertThat(replicateWithDataPolicy.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicateRegionWithShortcut() {
|
||||
|
||||
assertThat(replicateWithShortcut)
|
||||
.describedAs("A reference to the 'ReplicateWithShortcut' Region was not property configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(replicateWithShortcut.getName()).isEqualTo("ReplicateWithShortcut");
|
||||
assertThat(replicateWithShortcut.getFullPath()).isEqualTo("/ReplicateWithShortcut");
|
||||
assertThat(replicateWithShortcut.getAttributes()).isNotNull();
|
||||
assertThat(replicateWithShortcut.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutDefaultsRegion() {
|
||||
|
||||
assertThat(shortcutDefaults)
|
||||
.describedAs("A reference to the 'ShortcutDefaults' Region was not properly configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(shortcutDefaults.getName()).isEqualTo("ShortcutDefaults");
|
||||
assertThat(shortcutDefaults.getFullPath()).isEqualTo("/ShortcutDefaults");
|
||||
assertThat(shortcutDefaults.getAttributes()).isNotNull();
|
||||
assertThat(shortcutDefaults.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(shortcutDefaults.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(shortcutDefaults.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
assertThat(shortcutDefaults.getAttributes().isDiskSynchronous()).isFalse();
|
||||
assertThat(shortcutDefaults.getAttributes().getIgnoreJTA()).isTrue();
|
||||
assertThat(shortcutDefaults.getAttributes().getInitialCapacity()).isEqualTo(101);
|
||||
assertThat(new Float(shortcutDefaults.getAttributes().getLoadFactor())).isEqualTo(new Float(0.85f));
|
||||
assertThat(shortcutDefaults.getAttributes().getKeyConstraint()).isEqualTo(Long.class);
|
||||
assertThat(shortcutDefaults.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
assertThat(shortcutDefaults.getAttributes().getEvictionAttributes()).isNotNull();
|
||||
assertThat(shortcutDefaults.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(shortcutDefaults.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP);
|
||||
assertThat(shortcutDefaults.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(shortcutDefaults.getAttributes().getPartitionAttributes().getRedundantCopies()).isEqualTo(1);
|
||||
assertThat(shortcutDefaults.getAttributes().getPartitionAttributes().getTotalNumBuckets()).isEqualTo(177);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShortcutOverridesRegion() {
|
||||
|
||||
assertThat(shortcutOverrides)
|
||||
.describedAs("A reference to the 'ShortcutOverrides' Region was not properly configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(shortcutOverrides.getName()).isEqualTo("ShortcutOverrides");
|
||||
assertThat(shortcutOverrides.getFullPath()).isEqualTo("/ShortcutOverrides");
|
||||
assertThat(shortcutOverrides.getAttributes()).isNotNull();
|
||||
assertThat(shortcutOverrides.getAttributes().getCloningEnabled()).isTrue();
|
||||
assertThat(shortcutOverrides.getAttributes().getConcurrencyChecksEnabled()).isFalse();
|
||||
assertThat(shortcutOverrides.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
assertThat(shortcutOverrides.getAttributes().isDiskSynchronous()).isTrue();
|
||||
assertThat(shortcutOverrides.getAttributes().getIgnoreJTA()).isFalse();
|
||||
assertThat(shortcutOverrides.getAttributes().getInitialCapacity()).isEqualTo(51);
|
||||
assertThat(new Float(shortcutOverrides.getAttributes().getLoadFactor())).isEqualTo(new Float(0.72f));
|
||||
assertThat(shortcutOverrides.getAttributes().getKeyConstraint()).isEqualTo(String.class);
|
||||
assertThat(shortcutOverrides.getAttributes().getValueConstraint()).isEqualTo(Object.class);
|
||||
assertThat(shortcutOverrides.getAttributes().getEvictionAttributes()).isNotNull();
|
||||
assertThat(shortcutOverrides.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
assertThat(shortcutOverrides.getAttributes().getEvictionAttributes().getMaximum()).isEqualTo(8192);
|
||||
assertThat(shortcutOverrides.getAttributes().getEvictionAttributes().getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY);
|
||||
assertThat(shortcutOverrides.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(shortcutOverrides.getAttributes().getPartitionAttributes().getRedundantCopies()).isEqualTo(3);
|
||||
assertThat(shortcutOverrides.getAttributes().getPartitionAttributes().getTotalNumBuckets()).isEqualTo(111);
|
||||
}
|
||||
}
|
||||
@@ -13,43 +13,39 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionExistsException;
|
||||
import org.apache.geode.cache.Scope;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.gemfire.fork.SpringContainerProcess;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
|
||||
/**
|
||||
* The RegionLookupIntegrationTests class is a test suite of test cases testing the lookup functionality for various
|
||||
* peer Region types.
|
||||
* Integration Tests testing SDG lookup functionality for various peer {@link Region} types.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.context.ConfigurableApplicationContext
|
||||
* @see SpringContainerProcess
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.context.ConfigurableApplicationContext
|
||||
* @see org.springframework.context.support.ClassPathXmlApplicationContext
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @since 1.4.0
|
||||
* @link https://jira.spring.io/browse/SGF-204
|
||||
*/
|
||||
// TODO: slow test; can this test use mocks?
|
||||
public class RegionLookupIntegrationTests {
|
||||
public class RegionLookupIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
private void assertNoRegionLookup(String configLocation) {
|
||||
|
||||
@@ -61,7 +57,7 @@ public class RegionLookupIntegrationTests {
|
||||
}
|
||||
catch (BeanCreationException expected) {
|
||||
|
||||
assertTrue(expected.getMessage(), expected.getCause() instanceof RegionExistsException);
|
||||
assertThat(expected.getCause() instanceof RegionExistsException).as(expected.getMessage()).isTrue();
|
||||
|
||||
throw (RegionExistsException) expected.getCause();
|
||||
}
|
||||
@@ -87,24 +83,24 @@ public class RegionLookupIntegrationTests {
|
||||
applicationContext = createApplicationContext(
|
||||
"/org/springframework/data/gemfire/allowRegionBeanDefinitionOverridesTest.xml");
|
||||
|
||||
assertNotNull(applicationContext);
|
||||
assertTrue(applicationContext.containsBean("regionOne"));
|
||||
assertThat(applicationContext).isNotNull();
|
||||
assertThat(applicationContext.containsBean("regionOne")).isTrue();
|
||||
|
||||
Region appDataRegion = applicationContext.getBean("regionOne", Region.class);
|
||||
Region<?, ?> appDataRegion = applicationContext.getBean("regionOne", Region.class);
|
||||
|
||||
assertNotNull(appDataRegion);
|
||||
assertEquals("AppDataRegion", appDataRegion.getName());
|
||||
assertEquals("/AppDataRegion", appDataRegion.getFullPath());
|
||||
assertNotNull(appDataRegion.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, appDataRegion.getAttributes().getDataPolicy());
|
||||
assertFalse(appDataRegion.getAttributes().getMulticastEnabled());
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, appDataRegion.getAttributes().getScope());
|
||||
assertEquals(101, appDataRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(new Float(0.85f), new Float(appDataRegion.getAttributes().getLoadFactor()));
|
||||
assertTrue(appDataRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(appDataRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(Integer.class, appDataRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals(String.class, appDataRegion.getAttributes().getValueConstraint());
|
||||
assertThat(appDataRegion).isNotNull();
|
||||
assertThat(appDataRegion.getName()).isEqualTo("AppDataRegion");
|
||||
assertThat(appDataRegion.getFullPath()).isEqualTo("/AppDataRegion");
|
||||
assertThat(appDataRegion.getAttributes()).isNotNull();
|
||||
assertThat(appDataRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
assertThat(appDataRegion.getAttributes().getMulticastEnabled()).isFalse();
|
||||
assertThat(appDataRegion.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_ACK);
|
||||
assertThat(appDataRegion.getAttributes().getInitialCapacity()).isEqualTo(101);
|
||||
assertThat(new Float(appDataRegion.getAttributes().getLoadFactor())).isEqualTo(new Float(0.85f));
|
||||
assertThat(appDataRegion.getAttributes().getCloningEnabled()).isTrue();
|
||||
assertThat(appDataRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(appDataRegion.getAttributes().getKeyConstraint()).isEqualTo(Integer.class);
|
||||
assertThat(appDataRegion.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
}
|
||||
finally {
|
||||
closeApplicationContext(applicationContext);
|
||||
@@ -154,76 +150,79 @@ public class RegionLookupIntegrationTests {
|
||||
try {
|
||||
applicationContext = createApplicationContext("/org/springframework/data/gemfire/enableRegionLookupsTest.xml");
|
||||
|
||||
assertNotNull(applicationContext);
|
||||
assertTrue(applicationContext.containsBean("NativeLocalRegion"));
|
||||
assertTrue(applicationContext.containsBean("NativePartitionRegion"));
|
||||
assertTrue(applicationContext.containsBean("NativeReplicateRegion"));
|
||||
assertTrue(applicationContext.containsBean("NativeParentRegion"));
|
||||
assertTrue(applicationContext.containsBean("/NativeParentRegion/NativeChildRegion"));
|
||||
assertTrue(applicationContext.containsBean("SpringReplicateRegion"));
|
||||
assertThat(applicationContext).isNotNull();
|
||||
assertThat(applicationContext.containsBean("NativeLocalRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("NativePartitionRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("NativeReplicateRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("NativeParentRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("/NativeParentRegion/NativeChildRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("SpringReplicateRegion")).isTrue();
|
||||
|
||||
Region nativeLocalRegion = applicationContext.getBean("NativeLocalRegion", Region.class);
|
||||
Region<?, ?> nativeLocalRegion = applicationContext.getBean("NativeLocalRegion", Region.class);
|
||||
|
||||
assertNotNull(nativeLocalRegion);
|
||||
assertEquals("NativeLocalRegion", nativeLocalRegion.getName());
|
||||
assertEquals("/NativeLocalRegion", nativeLocalRegion.getFullPath());
|
||||
assertNotNull(nativeLocalRegion.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, nativeLocalRegion.getAttributes().getDataPolicy());
|
||||
assertFalse(nativeLocalRegion.getAttributes().getCloningEnabled());
|
||||
assertFalse(nativeLocalRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(80, nativeLocalRegion.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(101, nativeLocalRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(Integer.class, nativeLocalRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals(new Float(0.95f), new Float(nativeLocalRegion.getAttributes().getLoadFactor()));
|
||||
assertEquals(String.class, nativeLocalRegion.getAttributes().getValueConstraint());
|
||||
assertThat(nativeLocalRegion).isNotNull();
|
||||
assertThat(nativeLocalRegion.getName()).isEqualTo("NativeLocalRegion");
|
||||
assertThat(nativeLocalRegion.getFullPath()).isEqualTo("/NativeLocalRegion");
|
||||
assertThat(nativeLocalRegion.getAttributes()).isNotNull();
|
||||
assertThat(nativeLocalRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(nativeLocalRegion.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(nativeLocalRegion.getAttributes().getConcurrencyChecksEnabled()).isFalse();
|
||||
assertThat(nativeLocalRegion.getAttributes().getConcurrencyLevel()).isEqualTo(80);
|
||||
assertThat(nativeLocalRegion.getAttributes().getInitialCapacity()).isEqualTo(101);
|
||||
assertThat(nativeLocalRegion.getAttributes().getKeyConstraint()).isEqualTo(Integer.class);
|
||||
assertThat(new Float(nativeLocalRegion.getAttributes().getLoadFactor())).isEqualTo(new Float(0.95f));
|
||||
assertThat(nativeLocalRegion.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
|
||||
Region nativePartitionRegion = applicationContext.getBean("NativePartitionRegion", Region.class);
|
||||
Region<?, ?> nativePartitionRegion = applicationContext.getBean("NativePartitionRegion", Region.class);
|
||||
|
||||
assertNotNull(nativePartitionRegion);
|
||||
assertEquals("NativePartitionRegion", nativePartitionRegion.getName());
|
||||
assertEquals("/NativePartitionRegion", nativePartitionRegion.getFullPath());
|
||||
assertNotNull(nativePartitionRegion.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, nativePartitionRegion.getAttributes().getDataPolicy());
|
||||
assertTrue(nativePartitionRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(nativePartitionRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(40, nativePartitionRegion.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(51, nativePartitionRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(Integer.class, nativePartitionRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals(new Float(0.85f), new Float(nativePartitionRegion.getAttributes().getLoadFactor()));
|
||||
assertFalse(nativePartitionRegion.getAttributes().getMulticastEnabled());
|
||||
assertEquals(String.class, nativePartitionRegion.getAttributes().getValueConstraint());
|
||||
assertThat(nativePartitionRegion).isNotNull();
|
||||
assertThat(nativePartitionRegion.getName()).isEqualTo("NativePartitionRegion");
|
||||
assertThat(nativePartitionRegion.getFullPath()).isEqualTo("/NativePartitionRegion");
|
||||
assertThat(nativePartitionRegion.getAttributes()).isNotNull();
|
||||
assertThat(nativePartitionRegion.getAttributes().getDataPolicy())
|
||||
.isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
assertThat(nativePartitionRegion.getAttributes().getCloningEnabled()).isTrue();
|
||||
assertThat(nativePartitionRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(nativePartitionRegion.getAttributes().getConcurrencyLevel()).isEqualTo(40);
|
||||
assertThat(nativePartitionRegion.getAttributes().getInitialCapacity()).isEqualTo(51);
|
||||
assertThat(nativePartitionRegion.getAttributes().getKeyConstraint()).isEqualTo(Integer.class);
|
||||
assertThat(new Float(nativePartitionRegion.getAttributes().getLoadFactor())).isEqualTo(new Float(0.85f));
|
||||
assertThat(nativePartitionRegion.getAttributes().getMulticastEnabled()).isFalse();
|
||||
assertThat(nativePartitionRegion.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
|
||||
Region nativeReplicateRegion = applicationContext.getBean("NativeReplicateRegion", Region.class);
|
||||
Region<?, ?> nativeReplicateRegion = applicationContext.getBean("NativeReplicateRegion", Region.class);
|
||||
|
||||
assertNotNull(nativeReplicateRegion);
|
||||
assertEquals("NativeReplicateRegion", nativeReplicateRegion.getName());
|
||||
assertEquals("/NativeReplicateRegion", nativeReplicateRegion.getFullPath());
|
||||
assertNotNull(nativeReplicateRegion.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, nativeReplicateRegion.getAttributes().getDataPolicy());
|
||||
assertFalse(nativeReplicateRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(nativeReplicateRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(23, nativeReplicateRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(new Float(0.75f), new Float(nativeReplicateRegion.getAttributes().getLoadFactor()));
|
||||
assertEquals(Integer.class, nativeReplicateRegion.getAttributes().getKeyConstraint());
|
||||
assertFalse(nativeReplicateRegion.getAttributes().getMulticastEnabled());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, nativeReplicateRegion.getAttributes().getScope());
|
||||
assertEquals(String.class, nativeReplicateRegion.getAttributes().getValueConstraint());
|
||||
assertThat(nativeReplicateRegion).isNotNull();
|
||||
assertThat(nativeReplicateRegion.getName()).isEqualTo("NativeReplicateRegion");
|
||||
assertThat(nativeReplicateRegion.getFullPath()).isEqualTo("/NativeReplicateRegion");
|
||||
assertThat(nativeReplicateRegion.getAttributes()).isNotNull();
|
||||
assertThat(nativeReplicateRegion.getAttributes().getDataPolicy())
|
||||
.isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
assertThat(nativeReplicateRegion.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(nativeReplicateRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(nativeReplicateRegion.getAttributes().getInitialCapacity()).isEqualTo(23);
|
||||
assertThat(new Float(nativeReplicateRegion.getAttributes().getLoadFactor())).isEqualTo(new Float(0.75f));
|
||||
assertThat(nativeReplicateRegion.getAttributes().getKeyConstraint()).isEqualTo(Integer.class);
|
||||
assertThat(nativeReplicateRegion.getAttributes().getMulticastEnabled()).isFalse();
|
||||
assertThat(nativeReplicateRegion.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
assertThat(nativeReplicateRegion.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
|
||||
Region nativeChildRegion = applicationContext.getBean("/NativeParentRegion/NativeChildRegion", Region.class);
|
||||
Region<?, ?> nativeChildRegion =
|
||||
applicationContext.getBean("/NativeParentRegion/NativeChildRegion", Region.class);
|
||||
|
||||
assertNotNull(nativeChildRegion);
|
||||
assertEquals("NativeChildRegion", nativeChildRegion.getName());
|
||||
assertEquals("/NativeParentRegion/NativeChildRegion", nativeChildRegion.getFullPath());
|
||||
assertNotNull(nativeChildRegion.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, nativeChildRegion.getAttributes().getDataPolicy());
|
||||
assertThat(nativeChildRegion).isNotNull();
|
||||
assertThat(nativeChildRegion.getName()).isEqualTo("NativeChildRegion");
|
||||
assertThat(nativeChildRegion.getFullPath()).isEqualTo("/NativeParentRegion/NativeChildRegion");
|
||||
assertThat(nativeChildRegion.getAttributes()).isNotNull();
|
||||
assertThat(nativeChildRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
|
||||
Region springReplicateRegion = applicationContext.getBean("SpringReplicateRegion", Region.class);
|
||||
Region<?, ?> springReplicateRegion = applicationContext.getBean("SpringReplicateRegion", Region.class);
|
||||
|
||||
assertNotNull(springReplicateRegion);
|
||||
assertEquals("SpringReplicateRegion", springReplicateRegion.getName());
|
||||
assertEquals("/SpringReplicateRegion", springReplicateRegion.getFullPath());
|
||||
assertNotNull(springReplicateRegion.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, springReplicateRegion.getAttributes().getDataPolicy());
|
||||
assertThat(springReplicateRegion).isNotNull();
|
||||
assertThat(springReplicateRegion.getName()).isEqualTo("SpringReplicateRegion");
|
||||
assertThat(springReplicateRegion.getFullPath()).isEqualTo("/SpringReplicateRegion");
|
||||
assertThat(springReplicateRegion.getAttributes()).isNotNull();
|
||||
assertThat(springReplicateRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
}
|
||||
finally {
|
||||
closeApplicationContext(applicationContext);
|
||||
@@ -236,30 +235,32 @@ public class RegionLookupIntegrationTests {
|
||||
ConfigurableApplicationContext applicationContext = null;
|
||||
|
||||
try {
|
||||
|
||||
applicationContext = createApplicationContext("/org/springframework/data/gemfire/enableClientRegionLookupsTest.xml");
|
||||
|
||||
assertNotNull(applicationContext);
|
||||
assertTrue(applicationContext.containsBean("NativeClientRegion"));
|
||||
assertTrue(applicationContext.containsBean("NativeClientParentRegion"));
|
||||
assertTrue(applicationContext.containsBean("/NativeClientParentRegion/NativeClientChildRegion"));
|
||||
assertThat(applicationContext).isNotNull();
|
||||
assertThat(applicationContext.containsBean("NativeClientRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("NativeClientParentRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("/NativeClientParentRegion/NativeClientChildRegion")).isTrue();
|
||||
|
||||
Region nativeClientRegion = applicationContext.getBean("NativeClientRegion", Region.class);
|
||||
Region<?, ?> nativeClientRegion = applicationContext.getBean("NativeClientRegion", Region.class);
|
||||
|
||||
assertNotNull(nativeClientRegion);
|
||||
assertEquals("NativeClientRegion", nativeClientRegion.getName());
|
||||
assertEquals("/NativeClientRegion", nativeClientRegion.getFullPath());
|
||||
assertNotNull(nativeClientRegion.getAttributes());
|
||||
assertFalse(nativeClientRegion.getAttributes().getCloningEnabled());
|
||||
assertEquals(DataPolicy.NORMAL, nativeClientRegion.getAttributes().getDataPolicy());
|
||||
assertThat(nativeClientRegion).isNotNull();
|
||||
assertThat(nativeClientRegion.getName()).isEqualTo("NativeClientRegion");
|
||||
assertThat(nativeClientRegion.getFullPath()).isEqualTo("/NativeClientRegion");
|
||||
assertThat(nativeClientRegion.getAttributes()).isNotNull();
|
||||
assertThat(nativeClientRegion.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(nativeClientRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
|
||||
Region nativeClientChildRegion = applicationContext.getBean("/NativeClientParentRegion/NativeClientChildRegion",
|
||||
Region.class);
|
||||
Region<?, ?> nativeClientChildRegion =
|
||||
applicationContext.getBean("/NativeClientParentRegion/NativeClientChildRegion", Region.class);
|
||||
|
||||
assertNotNull(nativeClientChildRegion);
|
||||
assertEquals("NativeClientChildRegion", nativeClientChildRegion.getName());
|
||||
assertEquals("/NativeClientParentRegion/NativeClientChildRegion", nativeClientChildRegion.getFullPath());
|
||||
assertNotNull(nativeClientChildRegion.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, nativeClientChildRegion.getAttributes().getDataPolicy());
|
||||
assertThat(nativeClientChildRegion).isNotNull();
|
||||
assertThat(nativeClientChildRegion.getName()).isEqualTo("NativeClientChildRegion");
|
||||
assertThat(nativeClientChildRegion.getFullPath())
|
||||
.isEqualTo("/NativeClientParentRegion/NativeClientChildRegion");
|
||||
assertThat(nativeClientChildRegion.getAttributes()).isNotNull();
|
||||
assertThat(nativeClientChildRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
}
|
||||
finally {
|
||||
closeApplicationContext(applicationContext);
|
||||
|
||||
@@ -13,53 +13,52 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
|
||||
/**
|
||||
* The RegionShortcutConverterTest class is a test suite of test cases testing the contract and functionality of the
|
||||
* RegionShortcutConverter class
|
||||
* Unit Tests for {@link RegionShortcutConverter}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.RegionShortcutConverter
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
* @see org.springframework.data.gemfire.RegionShortcutConverter
|
||||
* @since 1.3.4
|
||||
*/
|
||||
public class RegionShortcutConverterTest {
|
||||
public class RegionShortcutConverterUnitTests {
|
||||
|
||||
private final RegionShortcutConverter converter = new RegionShortcutConverter();
|
||||
|
||||
@Test
|
||||
public void testToUpperCase() {
|
||||
assertEquals("TEST", RegionShortcutConverter.toUpperCase("test"));
|
||||
assertEquals("TEST", RegionShortcutConverter.toUpperCase(" Test "));
|
||||
assertEquals("", RegionShortcutConverter.toUpperCase(""));
|
||||
assertEquals("", RegionShortcutConverter.toUpperCase(" "));
|
||||
assertEquals("NULL", RegionShortcutConverter.toUpperCase("null"));
|
||||
assertEquals("null", RegionShortcutConverter.toUpperCase(null));
|
||||
|
||||
assertThat(RegionShortcutConverter.toUpperCase("test")).isEqualTo("TEST");
|
||||
assertThat(RegionShortcutConverter.toUpperCase(" Test ")).isEqualTo("TEST");
|
||||
assertThat(RegionShortcutConverter.toUpperCase("")).isEqualTo("");
|
||||
assertThat(RegionShortcutConverter.toUpperCase(" ")).isEqualTo("");
|
||||
assertThat(RegionShortcutConverter.toUpperCase("null")).isEqualTo("NULL");
|
||||
assertThat(RegionShortcutConverter.toUpperCase(null)).isEqualTo("null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
|
||||
for (RegionShortcut shortcut : RegionShortcut.values()) {
|
||||
assertEquals(shortcut, converter.convert(shortcut.name()));
|
||||
assertThat(converter.convert(shortcut.name())).isEqualTo(shortcut);
|
||||
}
|
||||
|
||||
assertEquals(RegionShortcut.PARTITION_PROXY, converter.convert("Partition_Proxy"));
|
||||
assertEquals(RegionShortcut.REPLICATE_OVERFLOW, converter.convert("replicate_overflow"));
|
||||
assertEquals(RegionShortcut.LOCAL_HEAP_LRU, converter.convert("local_Heap_LRU"));
|
||||
assertThat(converter.convert("Partition_Proxy")).isEqualTo(RegionShortcut.PARTITION_PROXY);
|
||||
assertThat(converter.convert("replicate_overflow")).isEqualTo(RegionShortcut.REPLICATE_OVERFLOW);
|
||||
assertThat(converter.convert("local_Heap_LRU")).isEqualTo(RegionShortcut.LOCAL_HEAP_LRU);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConvertWithIllegalEnumeratedValue() {
|
||||
converter.convert("localPersistentOverflow");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,305 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The RegionShortcutWrapperTest class is a test suite of test cases testing the contract and functionality of the
|
||||
* RegionShortcutWrapper enum class type.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see RegionShortcutWrapper
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class RegionShortcutWrapperTest {
|
||||
|
||||
@Test
|
||||
public void oneForOneMapping() {
|
||||
for (RegionShortcut shortcut : RegionShortcut.values()) {
|
||||
RegionShortcutWrapper wrapper = RegionShortcutWrapper.valueOf(shortcut.name());
|
||||
|
||||
assertNotNull(wrapper);
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.equals(wrapper));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unspecifiedRegionShortcut() {
|
||||
assertEquals(RegionShortcutWrapper.UNSPECIFIED, RegionShortcutWrapper.valueOf((RegionShortcut) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isHeapLru() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isHeapLru());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_HEAP_LRU.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isHeapLru());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_HEAP_LRU.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT.isHeapLru());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isHeapLru());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PROXY.isHeapLru());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isHeapLru());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isLocal() {
|
||||
assertTrue(RegionShortcutWrapper.LOCAL.isLocal());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_HEAP_LRU.isLocal());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_OVERFLOW.isLocal());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_PERSISTENT.isLocal());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_HEAP_LRU.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_OVERFLOW.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_OVERFLOW.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PROXY.isLocal());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isLocal());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isOverflow() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_HEAP_LRU.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_HEAP_LRU.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT.isOverflow());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PROXY.isOverflow());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isOverflow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPartition() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_HEAP_LRU.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_OVERFLOW.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_HEAP_LRU.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_OVERFLOW.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PERSISTENT.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PROXY.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isPartition());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_OVERFLOW.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PROXY.isPartition());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isPartition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPersistent() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_OVERFLOW.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_PERSISTENT.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_HEAP_LRU.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_OVERFLOW.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PERSISTENT.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_OVERFLOW.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PERSISTENT.isPersistent());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PROXY.isPersistent());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isPersistent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPersistentOverflow() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT.isPersistentOverflow());
|
||||
assertTrue(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_HEAP_LRU.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT.isPersistentOverflow());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isPersistentOverflow());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT.isPersistentOverflow());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PROXY.isPersistentOverflow());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isPersistentOverflow());
|
||||
}
|
||||
@Test
|
||||
public void isProxy() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_HEAP_LRU.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_OVERFLOW.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_HEAP_LRU.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_OVERFLOW.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isProxy());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PROXY.isProxy());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_OVERFLOW.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isProxy());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PROXY.isProxy());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isProxy());
|
||||
}
|
||||
@Test
|
||||
public void isRedundant() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_HEAP_LRU.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_OVERFLOW.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_HEAP_LRU.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_OVERFLOW.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY.isRedundant());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isRedundant());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT.isRedundant());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isRedundant());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isRedundant());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isRedundant());
|
||||
assertTrue(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_OVERFLOW.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.REPLICATE_PROXY.isRedundant());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isRedundant());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isReplicate() {
|
||||
assertFalse(RegionShortcutWrapper.LOCAL.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_HEAP_LRU.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_OVERFLOW.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_HEAP_LRU.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_OVERFLOW.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isReplicate());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE.isReplicate());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isReplicate());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_OVERFLOW.isReplicate());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PERSISTENT.isReplicate());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isReplicate());
|
||||
assertTrue(RegionShortcutWrapper.REPLICATE_PROXY.isReplicate());
|
||||
assertFalse(RegionShortcutWrapper.UNSPECIFIED.isReplicate());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.RegionShortcut;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link RegionShortcutWrapper} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.RegionShortcut
|
||||
* @see org.springframework.data.gemfire.RegionShortcutWrapper
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class RegionShortcutWrapperUnitTests {
|
||||
|
||||
@Test
|
||||
public void oneForOneMapping() {
|
||||
|
||||
for (RegionShortcut shortcut : RegionShortcut.values()) {
|
||||
|
||||
RegionShortcutWrapper wrapper = RegionShortcutWrapper.valueOf(shortcut.name());
|
||||
|
||||
assertThat(wrapper).isNotNull();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.equals(wrapper)).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unspecifiedRegionShortcut() {
|
||||
assertThat(RegionShortcutWrapper.valueOf((RegionShortcut) null)).isEqualTo(RegionShortcutWrapper.UNSPECIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isHeapLru() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isHeapLru()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isHeapLru()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isHeapLru()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isHeapLru()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isHeapLru()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isHeapLru()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isLocal() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isLocal()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isLocal()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isLocal()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isLocal()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isLocal()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isLocal()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isLocal()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isOverflow() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isOverflow()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPartition() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isPartition()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isPartition()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isPartition()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPersistent() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isPersistent()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isPersistent()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isPersistent()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPersistentOverflow() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistentOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isPersistentOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isPersistentOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isPersistentOverflow()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isPersistentOverflow()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isPersistentOverflow()).isFalse();
|
||||
}
|
||||
@Test
|
||||
public void isProxy() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isProxy()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isProxy()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isProxy()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isProxy()).isFalse();
|
||||
}
|
||||
@Test
|
||||
public void isRedundant() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isRedundant()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isRedundant()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isRedundant()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isRedundant()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isRedundant()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isRedundant()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isRedundant()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isRedundant()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isReplicate() {
|
||||
|
||||
assertThat(RegionShortcutWrapper.LOCAL.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_HEAP_LRU.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_OVERFLOW.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_HEAP_LRU.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_OVERFLOW.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PERSISTENT_OVERFLOW.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_PROXY_REDUNDANT.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_HEAP_LRU.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_OVERFLOW.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.PARTITION_REDUNDANT_PERSISTENT_OVERFLOW.isReplicate()).isFalse();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE.isReplicate()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_HEAP_LRU.isReplicate()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_OVERFLOW.isReplicate()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT.isReplicate()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PERSISTENT_OVERFLOW.isReplicate()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.REPLICATE_PROXY.isReplicate()).isTrue();
|
||||
assertThat(RegionShortcutWrapper.UNSPECIFIED.isReplicate()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -15,17 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.RegionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link ReplicatedRegionFactoryBean}.
|
||||
*
|
||||
@@ -37,47 +37,57 @@ import org.junit.Test;
|
||||
* @see org.springframework.data.gemfire.ReplicatedRegionFactoryBean
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ReplicatedRegionFactoryBeanTest {
|
||||
public class ReplicatedRegionFactoryBeanUnitTests {
|
||||
|
||||
private final ReplicatedRegionFactoryBean factoryBean = new ReplicatedRegionFactoryBean();
|
||||
private final ReplicatedRegionFactoryBean<Object, Object> factoryBean = new ReplicatedRegionFactoryBean<>();
|
||||
|
||||
protected RegionFactory<?, ?> createMockRegionFactory() {
|
||||
@SuppressWarnings("unchecked")
|
||||
private RegionFactory<Object, Object> createMockRegionFactory() {
|
||||
return mock(RegionFactory.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWithPersistentUnspecifiedAndDataPolicyUnspecified() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, (String) null);
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.REPLICATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenNotPersistentAndDataPolicyUnspecified() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, (String) null);
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.REPLICATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentAndDataPolicyUnspecified() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, (String) null);
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PERSISTENT_REPLICATE));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWithBlankDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, " ");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [ ] is invalid.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [ ] is invalid.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -90,13 +100,14 @@ public class ReplicatedRegionFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWithEmptyDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [] is invalid.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [] is invalid.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -109,13 +120,14 @@ public class ReplicatedRegionFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWhenPersistentUnspecifiedAndInvalidDataPolicyName() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "INVALID_DATA_POLICY_NAME");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [INVALID_DATA_POLICY_NAME] is invalid.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [INVALID_DATA_POLICY_NAME] is invalid.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -128,13 +140,14 @@ public class ReplicatedRegionFactoryBeanTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWhenPersistentUnspecifiedAndInvalidDataPolicyType() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "PARTITION");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [PARTITION] is not supported in Replicated Regions.", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [PARTITION] is not supported in Replicated Regions.");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -145,29 +158,36 @@ public class ReplicatedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentUnspecifiedAndEmptyDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "EMPTY");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.EMPTY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenNotPersistentAndEmptyDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, "empty");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.EMPTY));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWhenPersistentAndEmptyDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "empty");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [EMPTY] is not valid when persistent is true", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [EMPTY] is not valid when persistent is true");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -179,29 +199,36 @@ public class ReplicatedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentUnspecifiedAndReplicateDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "REPLICATE");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.REPLICATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenNotPersistentAndReplicateDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, "REPLICATE");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.REPLICATE));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWhenPersistentAndReplicateDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "REPLICATE");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [REPLICATE] is not valid when persistent is true", e.getMessage());
|
||||
assertThat(e.getMessage()).isEqualTo("Data Policy [REPLICATE] is not valid when persistent is true");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -213,21 +240,26 @@ public class ReplicatedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentUnspecifiedAndPersistentReplicateDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, null, "PERSISTENT_REPLICATE");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PERSISTENT_REPLICATE));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testResolveDataPolicyWhenNotPersistentAndPersistentReplicateDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
try {
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, false, "PERSISTENT_REPLICATE");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertEquals("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false", e.getMessage());
|
||||
assertThat(e.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false");
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
@@ -239,9 +271,12 @@ public class ReplicatedRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testResolveDataPolicyWhenPersistentAndPersistentReplicateDataPolicy() {
|
||||
RegionFactory mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
RegionFactory<Object, Object> mockRegionFactory = createMockRegionFactory();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.resolveDataPolicy(mockRegionFactory, true, "PERSISTENT_REPLICATE");
|
||||
|
||||
verify(mockRegionFactory).setDataPolicy(eq(DataPolicy.PERSISTENT_REPLICATE));
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
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 org.apache.geode.cache.Scope;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The ScopeTypeTest class is a test suite of test cases testing the contract and functionality of the ScopeType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.ScopeType
|
||||
* @see org.apache.geode.cache.Scope
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class ScopeTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetScope() {
|
||||
assertEquals(Scope.GLOBAL, ScopeType.getScope(ScopeType.GLOBAL));
|
||||
assertEquals(Scope.LOCAL, ScopeType.getScope(ScopeType.LOCAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetScopeWithNull() {
|
||||
assertNull(ScopeType.getScope(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetScope() {
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, ScopeType.DISTRIBUTED_ACK.getScope());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, ScopeType.DISTRIBUTED_NO_ACK.getScope());
|
||||
assertEquals(Scope.LOCAL, ScopeType.LOCAL.getScope());
|
||||
assertEquals(Scope.GLOBAL, ScopeType.GLOBAL.getScope());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
try {
|
||||
for (int ordinal = 0; ordinal < Integer.MAX_VALUE; ordinal++) {
|
||||
Scope expectedScope = Scope.fromOrdinal(ordinal);
|
||||
ScopeType scopeType = ScopeType.valueOf(expectedScope);
|
||||
|
||||
assertNotNull(scopeType);
|
||||
assertSame(expectedScope, scopeType.getScope());
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(ScopeType.valueOf((Scope) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(ScopeType.DISTRIBUTED_ACK, ScopeType.valueOfIgnoreCase("distributed_ack"));
|
||||
assertEquals(ScopeType.DISTRIBUTED_NO_ACK, ScopeType.valueOfIgnoreCase("Distributed_No_Ack"));
|
||||
assertEquals(ScopeType.LOCAL, ScopeType.valueOfIgnoreCase("LOCal "));
|
||||
assertEquals(ScopeType.GLOBAL, ScopeType.valueOfIgnoreCase("GLOBAL"));
|
||||
assertEquals(ScopeType.GLOBAL, ScopeType.valueOfIgnoreCase(" global "));
|
||||
assertEquals(ScopeType.DISTRIBUTED_ACK, ScopeType.valueOfIgnoreCase("DisTRIBUTEd-acK"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(ScopeType.valueOfIgnoreCase(" distributed ack "));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("D!str!but3d_N0_@ck"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("DISTRIBUTED_CANT_ACK"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("Dist_ACK"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("NOT-Distributed-ACK"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("LOCALE"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase("GLO-BAL"));
|
||||
assertNull(ScopeType.valueOfIgnoreCase(" "));
|
||||
assertNull(ScopeType.valueOfIgnoreCase(""));
|
||||
assertNull(ScopeType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.Scope;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link ScopeType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.Scope
|
||||
* @see org.springframework.data.gemfire.ScopeType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class ScopeTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testStaticGetScope() {
|
||||
|
||||
assertThat(ScopeType.getScope(ScopeType.GLOBAL)).isEqualTo(Scope.GLOBAL);
|
||||
assertThat(ScopeType.getScope(ScopeType.LOCAL)).isEqualTo(Scope.LOCAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetScopeWithNull() {
|
||||
assertThat(ScopeType.getScope(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetScope() {
|
||||
|
||||
assertThat(ScopeType.DISTRIBUTED_ACK.getScope()).isEqualTo(Scope.DISTRIBUTED_ACK);
|
||||
assertThat(ScopeType.DISTRIBUTED_NO_ACK.getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
assertThat(ScopeType.LOCAL.getScope()).isEqualTo(Scope.LOCAL);
|
||||
assertThat(ScopeType.GLOBAL.getScope()).isEqualTo(Scope.GLOBAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
|
||||
try {
|
||||
for (int ordinal = 0; ordinal < Integer.MAX_VALUE; ordinal++) {
|
||||
|
||||
Scope expectedScope = Scope.fromOrdinal(ordinal);
|
||||
ScopeType scopeType = ScopeType.valueOf(expectedScope);
|
||||
|
||||
assertThat(scopeType).isNotNull();
|
||||
assertThat(scopeType.getScope()).isSameAs(expectedScope);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertThat(ScopeType.valueOf((Scope) null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(ScopeType.valueOfIgnoreCase("distributed_ack")).isEqualTo(ScopeType.DISTRIBUTED_ACK);
|
||||
assertThat(ScopeType.valueOfIgnoreCase("Distributed_No_Ack")).isEqualTo(ScopeType.DISTRIBUTED_NO_ACK);
|
||||
assertThat(ScopeType.valueOfIgnoreCase("LOCal ")).isEqualTo(ScopeType.LOCAL);
|
||||
assertThat(ScopeType.valueOfIgnoreCase("GLOBAL")).isEqualTo(ScopeType.GLOBAL);
|
||||
assertThat(ScopeType.valueOfIgnoreCase(" global ")).isEqualTo(ScopeType.GLOBAL);
|
||||
assertThat(ScopeType.valueOfIgnoreCase("DisTRIBUTEd-acK")).isEqualTo(ScopeType.DISTRIBUTED_ACK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
|
||||
assertThat(ScopeType.valueOfIgnoreCase(" distributed ack ")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase("D!str!but3d_N0_@ck")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase("DISTRIBUTED_CANT_ACK")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase("Dist_ACK")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase("NOT-Distributed-ACK")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase("LOCALE")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase("GLO-BAL")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(ScopeType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -43,11 +39,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests for Apache Geode sub-Regions defined in Spring configuration metadata,
|
||||
* i.e. Spring Data Geode's XML namespace configuration metadata.
|
||||
* Integration Tests for Apache Geode {@link Region sub-Regions} defined in SDG XML namespace configuration metadata.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -56,10 +51,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(value = "complex-subregion.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings({ "rawtypes", "unused" })
|
||||
@@ -75,71 +70,74 @@ public class SubRegionIntegrationTests extends IntegrationTestsSupport {
|
||||
private Region accounts;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGemFireAccountsSubRegionCreation() {
|
||||
|
||||
assertNotNull("The GemFire Cache was not properly initialized!", cache);
|
||||
assertThat(cache).as("The GemFire Cache was not properly initialized!").isNotNull();
|
||||
|
||||
Region customers = cache.getRegion("Customers");
|
||||
|
||||
assertNotNull(customers);
|
||||
assertEquals("Customers", customers.getName());
|
||||
assertEquals("/Customers", customers.getFullPath());
|
||||
assertThat(customers).isNotNull();
|
||||
assertThat(customers.getName()).isEqualTo("Customers");
|
||||
assertThat(customers.getFullPath()).isEqualTo("/Customers");
|
||||
|
||||
Region accounts = customers.getSubregion("Accounts");
|
||||
|
||||
assertNotNull(accounts);
|
||||
assertEquals("Accounts", accounts.getName());
|
||||
assertEquals("/Customers/Accounts", accounts.getFullPath());
|
||||
assertThat(accounts).isNotNull();
|
||||
assertThat(accounts.getName()).isEqualTo("Accounts");
|
||||
assertThat(accounts.getFullPath()).isEqualTo("/Customers/Accounts");
|
||||
|
||||
Region cacheAccounts = cache.getRegion("/Customers/Accounts");
|
||||
|
||||
assertSame(accounts, cacheAccounts);
|
||||
assertThat(cacheAccounts).isSameAs(accounts);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSpringSubRegionConfiguration() {
|
||||
|
||||
assertNotNull("The /Customers/Accounts SubRegion was not properly initialized!", accounts);
|
||||
assertEquals("Accounts", accounts.getName());
|
||||
assertEquals("/Customers/Accounts", accounts.getFullPath());
|
||||
assertThat(accounts).as("The /Customers/Accounts SubRegion was not properly initialized!").isNotNull();
|
||||
assertThat(accounts.getName()).isEqualTo("Accounts");
|
||||
assertThat(accounts.getFullPath()).isEqualTo("/Customers/Accounts");
|
||||
|
||||
RegionAttributes regionAttributes = accounts.getAttributes();
|
||||
|
||||
assertNotNull(regionAttributes);
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, regionAttributes.getDataPolicy());
|
||||
assertEquals(20, regionAttributes.getConcurrencyLevel());
|
||||
assertTrue(regionAttributes.isDiskSynchronous());
|
||||
assertTrue(regionAttributes.getIgnoreJTA());
|
||||
assertFalse(regionAttributes.getIndexMaintenanceSynchronous());
|
||||
assertEquals(1000, regionAttributes.getInitialCapacity());
|
||||
assertEquals(Long.class, regionAttributes.getKeyConstraint());
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, regionAttributes.getScope());
|
||||
assertTrue(regionAttributes.getStatisticsEnabled());
|
||||
assertEquals(String.class, regionAttributes.getValueConstraint());
|
||||
assertNotNull(regionAttributes.getCacheListeners());
|
||||
assertEquals(1, regionAttributes.getCacheListeners().length);
|
||||
assertTrue(regionAttributes.getCacheListeners()[0] instanceof SimpleCacheListener);
|
||||
assertTrue(regionAttributes.getCacheLoader() instanceof SimpleCacheLoader);
|
||||
assertTrue(regionAttributes.getCacheWriter() instanceof SimpleCacheWriter);
|
||||
assertThat(regionAttributes).isNotNull();
|
||||
assertThat(regionAttributes.getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
assertThat(regionAttributes.getConcurrencyLevel()).isEqualTo(20);
|
||||
assertThat(regionAttributes.isDiskSynchronous()).isTrue();
|
||||
assertThat(regionAttributes.getIgnoreJTA()).isTrue();
|
||||
assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isFalse();
|
||||
assertThat(regionAttributes.getInitialCapacity()).isEqualTo(1000);
|
||||
assertThat(regionAttributes.getKeyConstraint()).isEqualTo(Long.class);
|
||||
assertThat(regionAttributes.getScope()).isEqualTo(Scope.DISTRIBUTED_ACK);
|
||||
assertThat(regionAttributes.getStatisticsEnabled()).isTrue();
|
||||
assertThat(regionAttributes.getValueConstraint()).isEqualTo(String.class);
|
||||
assertThat(regionAttributes.getCacheListeners()).isNotNull();
|
||||
assertThat(regionAttributes.getCacheListeners().length).isEqualTo(1);
|
||||
assertThat(regionAttributes.getCacheListeners()[0] instanceof SimpleCacheListener).isTrue();
|
||||
assertThat(regionAttributes.getCacheLoader() instanceof SimpleCacheLoader).isTrue();
|
||||
assertThat(regionAttributes.getCacheWriter() instanceof SimpleCacheWriter).isTrue();
|
||||
|
||||
EvictionAttributes evictionAttributes = regionAttributes.getEvictionAttributes();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, evictionAttributes.getAction());
|
||||
assertEquals(10000, evictionAttributes.getMaximum());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(evictionAttributes.getMaximum()).isEqualTo(10000);
|
||||
|
||||
MembershipAttributes membershipAttributes = regionAttributes.getMembershipAttributes();
|
||||
|
||||
assertNotNull(membershipAttributes);
|
||||
assertNotNull(membershipAttributes.getRequiredRoles());
|
||||
assertEquals(1, membershipAttributes.getRequiredRoles().size());
|
||||
assertTrue(membershipAttributes.getRequiredRoles().iterator().next().getName().equalsIgnoreCase("TEST"));
|
||||
assertEquals(LossAction.LIMITED_ACCESS, membershipAttributes.getLossAction());
|
||||
assertEquals(ResumptionAction.REINITIALIZE, membershipAttributes.getResumptionAction());
|
||||
assertThat(membershipAttributes).isNotNull();
|
||||
assertThat(membershipAttributes.getRequiredRoles()).isNotNull();
|
||||
assertThat(membershipAttributes.getRequiredRoles().size()).isEqualTo(1);
|
||||
assertThat(membershipAttributes.getRequiredRoles().iterator().next().getName().equalsIgnoreCase("TEST"))
|
||||
.isTrue();
|
||||
assertThat(membershipAttributes.getLossAction()).isEqualTo(LossAction.LIMITED_ACCESS);
|
||||
assertThat(membershipAttributes.getResumptionAction()).isEqualTo(ResumptionAction.REINITIALIZE);
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = regionAttributes.getSubscriptionAttributes();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, subscriptionAttributes.getInterestPolicy());
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.CACHE_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,110 +13,111 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.InterestPolicy;
|
||||
import org.apache.geode.cache.SubscriptionAttributes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The SubscriptionAttributesFactoryBeanTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the SubscriptionAttributesFactoryBean class.
|
||||
* Unit Tests for {@link SubscriptionAttributesFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.SubscriptionAttributes
|
||||
* @see org.springframework.data.gemfire.SubscriptionAttributesFactoryBean
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class SubscriptionAttributesFactoryBeanTest {
|
||||
public class SubscriptionAttributesFactoryBeanUnitTests {
|
||||
|
||||
@Test
|
||||
public void testIsSingleton() {
|
||||
assertTrue(new SubscriptionAttributesFactoryBean().isSingleton());
|
||||
assertThat(new SubscriptionAttributesFactoryBean().isSingleton()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetInterestPolicy() {
|
||||
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
assertThat(factoryBean.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
|
||||
factoryBean.setInterestPolicy(InterestPolicy.CACHE_CONTENT);
|
||||
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, factoryBean.getInterestPolicy());
|
||||
assertThat(factoryBean.getInterestPolicy()).isEqualTo(InterestPolicy.CACHE_CONTENT);
|
||||
|
||||
factoryBean.setInterestPolicy(null);
|
||||
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
assertThat(factoryBean.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForAllInterestPolicy() throws Exception {
|
||||
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setInterestPolicy(InterestPolicy.ALL);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(InterestPolicy.ALL, factoryBean.getInterestPolicy());
|
||||
assertThat(factoryBean.getInterestPolicy()).isEqualTo(InterestPolicy.ALL);
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.ALL, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.ALL);
|
||||
assertThat(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForCacheContentInterestPolicy() throws Exception {
|
||||
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setInterestPolicy(InterestPolicy.CACHE_CONTENT);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, factoryBean.getInterestPolicy());
|
||||
assertThat(factoryBean.getInterestPolicy()).isEqualTo(InterestPolicy.CACHE_CONTENT);
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.CACHE_CONTENT);
|
||||
assertThat(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForDefaultInterestPolicy() throws Exception {
|
||||
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
assertThat(factoryBean.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.DEFAULT, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
assertThat(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectAndObjectTypeForNullInterestPolicy() throws Exception {
|
||||
|
||||
SubscriptionAttributesFactoryBean factoryBean = new SubscriptionAttributesFactoryBean();
|
||||
|
||||
factoryBean.setInterestPolicy(null);
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertEquals(InterestPolicy.DEFAULT, factoryBean.getInterestPolicy());
|
||||
assertThat(factoryBean.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.DEFAULT, subscriptionAttributes.getInterestPolicy());
|
||||
assertTrue(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType()));
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
assertThat(SubscriptionAttributes.class.isAssignableFrom(factoryBean.getObjectType())).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,11 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -26,25 +24,34 @@ import javax.annotation.Resource;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Simple TX integration test.
|
||||
* Integration Test for Apache Geode cache transactions
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = { "basic-tx-config.xml" })
|
||||
@Transactional
|
||||
public class TxIntegrationTest {
|
||||
@SuppressWarnings("unused")
|
||||
public class TxIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Resource(name = "rollback-region")
|
||||
private Map<String, String> rollbackRegion;
|
||||
|
||||
@Resource(name = "commit-region")
|
||||
private Map<String, String> commitRegion;
|
||||
|
||||
@@ -52,6 +59,7 @@ public class TxIntegrationTest {
|
||||
|
||||
@BeforeTransaction
|
||||
public void addItemsToTheCache() {
|
||||
|
||||
rollbackRegion.put("Vlaicu", "Aurel");
|
||||
rollbackRegion.put("Coanda", "Henri");
|
||||
commitRegion.put("Coanda", "Henri");
|
||||
@@ -60,14 +68,16 @@ public class TxIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionRollback() throws Exception {
|
||||
public void testTransactionRollback() {
|
||||
|
||||
rollbackRegion.remove("Coanda");
|
||||
rollbackRegion.put("Ciurcu", "Alexandru");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Rollback(value = false)
|
||||
public void testTransactionCommit() throws Exception {
|
||||
public void testTransactionCommit() {
|
||||
|
||||
commitRegion.put("Poenaru", "Petrache");
|
||||
commitRegion.remove("Coanda");
|
||||
commitRegion.put("Vlaicu", "A");
|
||||
@@ -77,13 +87,15 @@ public class TxIntegrationTest {
|
||||
|
||||
@AfterTransaction
|
||||
public void testTxOutcome() {
|
||||
|
||||
if (txCommit) {
|
||||
assertFalse(commitRegion.containsKey("Coanda"));
|
||||
assertTrue(commitRegion.containsKey("Poenaru"));
|
||||
assertTrue(commitRegion.containsValue("A"));
|
||||
assertThat(commitRegion.containsKey("Coanda")).isFalse();
|
||||
assertThat(commitRegion.containsKey("Poenaru")).isTrue();
|
||||
assertThat(commitRegion.containsValue("A")).isTrue();
|
||||
}
|
||||
assertTrue(rollbackRegion.containsKey("Coanda"));
|
||||
assertTrue(rollbackRegion.containsKey("Vlaicu"));
|
||||
assertFalse(rollbackRegion.containsKey("Ciurcu"));
|
||||
|
||||
assertThat(rollbackRegion.containsKey("Coanda")).isTrue();
|
||||
assertThat(rollbackRegion.containsKey("Vlaicu")).isTrue();
|
||||
assertThat(rollbackRegion.containsKey("Ciurcu")).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,7 @@
|
||||
|
||||
package org.springframework.data.gemfire.cache;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -34,29 +31,31 @@ import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
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 CachingWithGemFireIntegrationTest class is a test suite of test cases testing the contract and functionality
|
||||
* of Spring Framework's Cache Abstraction using GemFire as a caching provider applied with Spring Data GemFire.
|
||||
* Integration Tests testing the contract and functionality of Spring Framework's Cache Abstraction using Apache Geode
|
||||
* as a caching provider applied with Spring Data for Apache Geode.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.cache.annotation.Cacheable
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ActiveProfiles
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.5.1
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@ActiveProfiles("replica")
|
||||
@SuppressWarnings("unused")
|
||||
public class CachingWithGemFireIntegrationTest {
|
||||
public class CachingWithGemFireIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
private NamedNumbersService namedNumbersService;
|
||||
@@ -66,41 +65,43 @@ public class CachingWithGemFireIntegrationTest {
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testRegionCacheHit() {
|
||||
assertNull(namedNumbersRegion.get("eleven"));
|
||||
assertFalse(namedNumbersRegion.containsKey("eleven"));
|
||||
|
||||
assertThat(namedNumbersRegion.get("eleven")).isNull();
|
||||
assertThat(namedNumbersRegion.containsKey("eleven")).isFalse();
|
||||
|
||||
namedNumbersRegion.put("eleven", 11);
|
||||
|
||||
assertTrue(namedNumbersRegion.containsKey("eleven"));
|
||||
assertEquals(11, namedNumbersService.get("eleven").intValue());
|
||||
assertFalse(namedNumbersService.wasCacheMiss());
|
||||
assertThat(namedNumbersRegion.containsKey("eleven")).isTrue();
|
||||
assertThat(namedNumbersService.get("eleven").intValue()).isEqualTo(11);
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isFalse();
|
||||
|
||||
try {
|
||||
namedNumbersRegion.put("eleven", null); // GemFire does not accept null values on put(key, value)
|
||||
}
|
||||
finally {
|
||||
assertTrue(namedNumbersRegion.containsKey("eleven"));
|
||||
assertEquals(11, namedNumbersRegion.get("eleven").intValue());
|
||||
assertEquals(11, namedNumbersService.get("eleven").intValue());
|
||||
assertFalse(namedNumbersService.wasCacheMiss());
|
||||
assertThat(namedNumbersRegion.containsKey("eleven")).isTrue();
|
||||
assertThat(namedNumbersRegion.get("eleven").intValue()).isEqualTo(11);
|
||||
assertThat(namedNumbersService.get("eleven").intValue()).isEqualTo(11);
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionCaching() {
|
||||
assertFalse(namedNumbersService.wasCacheMiss());
|
||||
assertEquals(1, namedNumbersService.get("one").intValue());
|
||||
assertTrue(namedNumbersService.wasCacheMiss());
|
||||
assertEquals(1, namedNumbersService.get("one").intValue());
|
||||
assertFalse(namedNumbersService.wasCacheMiss());
|
||||
assertEquals(2, namedNumbersService.get("two").intValue());
|
||||
assertTrue(namedNumbersService.wasCacheMiss());
|
||||
assertEquals(2, namedNumbersService.get("two").intValue());
|
||||
assertFalse(namedNumbersService.wasCacheMiss());
|
||||
assertNull(namedNumbersService.get("twelve"));
|
||||
assertTrue(namedNumbersService.wasCacheMiss());
|
||||
assertNull(namedNumbersService.get("twelve"));
|
||||
assertTrue(namedNumbersService.wasCacheMiss());
|
||||
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isFalse();
|
||||
assertThat(namedNumbersService.get("one").intValue()).isEqualTo(1);
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isTrue();
|
||||
assertThat(namedNumbersService.get("one").intValue()).isEqualTo(1);
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isFalse();
|
||||
assertThat(namedNumbersService.get("two").intValue()).isEqualTo(2);
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isTrue();
|
||||
assertThat(namedNumbersService.get("two").intValue()).isEqualTo(2);
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isFalse();
|
||||
assertThat(namedNumbersService.get("twelve")).isNull();
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isTrue();
|
||||
assertThat(namedNumbersService.get("twelve")).isNull();
|
||||
assertThat(namedNumbersService.wasCacheMiss()).isTrue();
|
||||
}
|
||||
|
||||
public static class NamedNumbersService {
|
||||
@@ -160,5 +161,4 @@ public class CachingWithGemFireIntegrationTest {
|
||||
return localCacheMiss;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,29 +16,38 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.cache;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests for {@link GemfireCacheManager}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.cache.GemfireCacheManager
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("/org/springframework/data/gemfire/cache/cache-manager-client-cache.xml")
|
||||
public class ClientCacheManagerTest {
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(value = "/org/springframework/data/gemfire/cache/cache-manager-client-cache.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
public class ClientCacheManagerIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
GemfireCacheManager cacheManager;
|
||||
|
||||
@Test
|
||||
public void cacheManagerUsesConfiguredGemFireRegionAsCache() {
|
||||
assertNotNull(cacheManager.getCache("Example"));
|
||||
assertThat(cacheManager.getCache("Example")).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,25 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.client;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -58,21 +52,22 @@ import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ClientRegionFactoryBean}.
|
||||
* Unit Tests for {@link ClientRegionFactoryBean}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionFactoryBean
|
||||
* @see org.apache.geode.cache.EvictionAttributes
|
||||
* @see org.apache.geode.cache.ExpirationAttributes
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.ClientRegionFactory
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionFactoryBean
|
||||
*/
|
||||
public class ClientRegionFactoryBeanTest {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ClientRegionFactoryBeanUnitTests {
|
||||
|
||||
private ClientRegionFactoryBean<Object, Object> factoryBean;
|
||||
|
||||
@@ -208,7 +203,7 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void createRegionWithSpecifiedShortcut() throws Exception {
|
||||
public void createRegionWithSpecifiedShortcut() {
|
||||
|
||||
BeanFactory mockBeanFactory = mock(BeanFactory.class);
|
||||
|
||||
@@ -229,15 +224,17 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
assertThat(actualRegion).isEqualTo(mockRegion);
|
||||
|
||||
verifyZeroInteractions(mockBeanFactory);
|
||||
verifyNoInteractions(mockBeanFactory);
|
||||
|
||||
verify(mockClientCache, times(1))
|
||||
.createClientRegionFactory(eq(ClientRegionShortcut.CACHING_PROXY));
|
||||
|
||||
verify(mockClientRegionFactory, times(1)).create(eq("TestRegion"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void createRegionAsSubRegion() throws Exception {
|
||||
public void createRegionAsSubRegion() {
|
||||
|
||||
BeanFactory mockBeanFactory = mock(BeanFactory.class);
|
||||
|
||||
@@ -260,9 +257,11 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
assertThat(actualRegion).isEqualTo(mockSubRegion);
|
||||
|
||||
verifyZeroInteractions(mockBeanFactory);
|
||||
verifyNoInteractions(mockBeanFactory);
|
||||
|
||||
verify(mockClientCache, times(1))
|
||||
.createClientRegionFactory(eq(ClientRegionShortcut.PROXY));
|
||||
|
||||
verify(mockClientRegionFactory, times(1))
|
||||
.createSubregion(eq(mockRegion), eq("TestSubRegion"));
|
||||
}
|
||||
@@ -476,29 +475,29 @@ public class ClientRegionFactoryBeanTest {
|
||||
@Test
|
||||
public void isPersistentIsCorrect() {
|
||||
|
||||
assertFalse(factoryBean.isPersistent());
|
||||
assertThat(factoryBean.isPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
|
||||
assertFalse(factoryBean.isPersistent());
|
||||
assertThat(factoryBean.isPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
|
||||
assertTrue(factoryBean.isPersistent());
|
||||
assertThat(factoryBean.isPersistent()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotPersistentIsCorrect() {
|
||||
|
||||
assertFalse(factoryBean.isNotPersistent());
|
||||
assertThat(factoryBean.isNotPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
|
||||
assertFalse(factoryBean.isNotPersistent());
|
||||
assertThat(factoryBean.isNotPersistent()).isFalse();
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
|
||||
assertTrue(factoryBean.isNotPersistent());
|
||||
assertThat(factoryBean.isNotPersistent()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -506,58 +505,58 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
ClientRegionFactoryBean<Object, Object> factory = new ClientRegionFactoryBean<>();
|
||||
|
||||
assertNotNull(factory);
|
||||
assertFalse(factory.isClose());
|
||||
assertFalse(factory.isDestroy());
|
||||
assertThat(factory).isNotNull();
|
||||
assertThat(factory.isClose()).isFalse();
|
||||
assertThat(factory.isDestroy()).isFalse();
|
||||
|
||||
factory.setClose(false);
|
||||
|
||||
assertFalse(factory.isClose());
|
||||
assertFalse(factory.isDestroy()); // when destroy is false it remains false even when setClose(false) is called
|
||||
assertThat(factory.isClose()).isFalse();
|
||||
assertThat(factory.isDestroy()).isFalse(); // when destroy is false it remains false even when setClose(false) is called
|
||||
|
||||
factory.setClose(true);
|
||||
|
||||
assertTrue(factory.isClose()); // calling setClose(true) should set close to true
|
||||
assertFalse(factory.isDestroy());
|
||||
assertThat(factory.isClose()).isTrue(); // calling setClose(true) should set close to true
|
||||
assertThat(factory.isDestroy()).isFalse();
|
||||
|
||||
factory.setDestroy(false);
|
||||
|
||||
assertTrue(factory.isClose()); // calling setDestroy(false) should have no affect on close
|
||||
assertFalse(factory.isDestroy());
|
||||
assertThat(factory.isClose()).isTrue(); // calling setDestroy(false) should have no affect on close
|
||||
assertThat(factory.isDestroy()).isFalse();
|
||||
|
||||
factory.setDestroy(true);
|
||||
|
||||
assertFalse(factory.isClose()); // setting destroy to true should set close to false
|
||||
assertTrue(factory.isDestroy()); // calling setDestroy(true) should set destroy to true
|
||||
assertThat(factory.isClose()).isFalse(); // setting destroy to true should set close to false
|
||||
assertThat(factory.isDestroy()).isTrue(); // calling setDestroy(true) should set destroy to true
|
||||
|
||||
factory.setClose(false);
|
||||
|
||||
assertFalse(factory.isClose());
|
||||
assertTrue(factory.isDestroy()); // calling setClose(false) should have no affect on destroy
|
||||
assertThat(factory.isClose()).isFalse();
|
||||
assertThat(factory.isDestroy()).isTrue(); // calling setClose(false) should have no affect on destroy
|
||||
|
||||
factory.setDestroy(false);
|
||||
|
||||
assertFalse(factory.isClose()); // setting destroy back to false should have no affect on close
|
||||
assertFalse(factory.isDestroy());
|
||||
assertThat(factory.isClose()).isFalse(); // setting destroy back to false should have no affect on close
|
||||
assertThat(factory.isDestroy()).isFalse();
|
||||
|
||||
factory.setDestroy(true);
|
||||
|
||||
assertFalse(factory.isClose());
|
||||
assertTrue(factory.isDestroy());
|
||||
assertThat(factory.isClose()).isFalse();
|
||||
assertThat(factory.isDestroy()).isTrue();
|
||||
|
||||
factory.setClose(true);
|
||||
|
||||
assertTrue(factory.isClose());
|
||||
assertFalse(factory.isDestroy()); // setting close to true should set destroy to false
|
||||
assertThat(factory.isClose()).isTrue();
|
||||
assertThat(factory.isDestroy()).isFalse(); // setting close to true should set destroy to false
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveClientRegionShortcut() throws Exception {
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertNull(TestUtils.readField("persistent", factoryBean));
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.LOCAL, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(TestUtils.<Object>readField("persistent", factoryBean)).isNull();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.LOCAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -565,10 +564,10 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
factoryBean.setPersistent(false);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertTrue(factoryBean.isNotPersistent());
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.LOCAL, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(factoryBean.isNotPersistent()).isTrue();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.LOCAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -576,10 +575,10 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
factoryBean.setPersistent(true);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertTrue(factoryBean.isPersistent());
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.LOCAL_PERSISTENT, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(factoryBean.isPersistent()).isTrue();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.LOCAL_PERSISTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -587,9 +586,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
factoryBean.setShortcut(ClientRegionShortcut.CACHING_PROXY_OVERFLOW);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertNull(TestUtils.readField("persistent", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.CACHING_PROXY_OVERFLOW, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(TestUtils.<Object>readField("persistent", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.CACHING_PROXY_OVERFLOW);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -598,9 +597,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.setShortcut(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertTrue(factoryBean.isNotPersistent());
|
||||
assertEquals(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(factoryBean.isNotPersistent()).isTrue();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -610,14 +609,14 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.setShortcut(ClientRegionShortcut.CACHING_PROXY);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertTrue(factoryBean.isPersistent());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(factoryBean.isPersistent()).isTrue();
|
||||
|
||||
factoryBean.resolveClientRegionShortcut();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Client Region Shortcut [CACHING_PROXY] is not valid when persistent is true",
|
||||
expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Client Region Shortcut [CACHING_PROXY] is not valid when persistent is true");
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -627,9 +626,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
factoryBean.setShortcut(ClientRegionShortcut.LOCAL_PERSISTENT);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertNull(TestUtils.readField("persistent", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.LOCAL_PERSISTENT, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(TestUtils.<Object>readField("persistent", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.LOCAL_PERSISTENT);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -639,14 +638,14 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setPersistent(false);
|
||||
factoryBean.setShortcut(ClientRegionShortcut.LOCAL_PERSISTENT);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertTrue(factoryBean.isNotPersistent());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(factoryBean.isNotPersistent()).isTrue();
|
||||
|
||||
factoryBean.resolveClientRegionShortcut();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Client Region Shortcut [LOCAL_PERSISTENT] is not valid when persistent is false",
|
||||
expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Client Region Shortcut [LOCAL_PERSISTENT] is not valid when persistent is false");
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -657,9 +656,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setPersistent(true);
|
||||
factoryBean.setShortcut(ClientRegionShortcut.LOCAL_PERSISTENT_OVERFLOW);
|
||||
|
||||
assertNull(TestUtils.readField("dataPolicy", factoryBean));
|
||||
assertTrue(factoryBean.isPersistent());
|
||||
assertEquals(ClientRegionShortcut.LOCAL_PERSISTENT_OVERFLOW, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", factoryBean)).isNull();
|
||||
assertThat(factoryBean.isPersistent()).isTrue();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.LOCAL_PERSISTENT_OVERFLOW);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -667,9 +666,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
factoryBean.setDataPolicy(DataPolicy.EMPTY);
|
||||
|
||||
assertNull(TestUtils.readField("persistent", factoryBean));
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.PROXY, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("persistent", factoryBean)).isNull();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.PROXY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -678,9 +677,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setDataPolicy(DataPolicy.NORMAL);
|
||||
factoryBean.setPersistent(false);
|
||||
|
||||
assertTrue(factoryBean.isNotPersistent());
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.CACHING_PROXY, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(factoryBean.isNotPersistent()).isTrue();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.CACHING_PROXY);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -690,13 +689,13 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setDataPolicy(DataPolicy.NORMAL);
|
||||
factoryBean.setPersistent(true);
|
||||
|
||||
assertTrue(factoryBean.isPersistent());
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertThat(factoryBean.isPersistent()).isTrue();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
|
||||
factoryBean.resolveClientRegionShortcut();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [NORMAL] is not valid when persistent is true", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Data Policy [NORMAL] is not valid when persistent is true");
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -706,9 +705,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
|
||||
factoryBean.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
|
||||
|
||||
assertNull(TestUtils.readField("persistent", factoryBean));
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertEquals(ClientRegionShortcut.LOCAL_PERSISTENT, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("persistent", factoryBean)).isNull();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.LOCAL_PERSISTENT);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -718,13 +717,14 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
|
||||
factoryBean.setPersistent(false);
|
||||
|
||||
assertTrue(factoryBean.isNotPersistent());
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertThat(factoryBean.isNotPersistent()).isTrue();
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
|
||||
factoryBean.resolveClientRegionShortcut();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false", expected.getMessage());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("Data Policy [PERSISTENT_REPLICATE] is not valid when persistent is false");
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -735,9 +735,9 @@ public class ClientRegionFactoryBeanTest {
|
||||
factoryBean.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
|
||||
factoryBean.setPersistent(true);
|
||||
|
||||
assertNull(TestUtils.readField("shortcut", factoryBean));
|
||||
assertTrue(factoryBean.isPersistent());
|
||||
assertEquals(ClientRegionShortcut.LOCAL_PERSISTENT, factoryBean.resolveClientRegionShortcut());
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factoryBean)).isNull();
|
||||
assertThat(factoryBean.isPersistent()).isTrue();
|
||||
assertThat(factoryBean.resolveClientRegionShortcut()).isEqualTo(ClientRegionShortcut.LOCAL_PERSISTENT);
|
||||
}
|
||||
|
||||
private <K> Interest<K> newInterest(K key) {
|
||||
@@ -14,53 +14,52 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
/**
|
||||
* The ClientRegionShortcutConverterTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the ClientRegionShortcutConverter class
|
||||
* Unit Tests for {@link ClientRegionShortcutConverter}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see ClientRegionShortcutConverter
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionShortcutConverter
|
||||
* @since 1.3.4
|
||||
*/
|
||||
public class ClientRegionShortcutConverterTest {
|
||||
public class ClientRegionShortcutConverterUnitTests {
|
||||
|
||||
private final ClientRegionShortcutConverter converter = new ClientRegionShortcutConverter();
|
||||
|
||||
@Test
|
||||
public void testToUpperCase() {
|
||||
assertEquals("TEST", ClientRegionShortcutConverter.toUpperCase("test"));
|
||||
assertEquals("TEST", ClientRegionShortcutConverter.toUpperCase(" Test "));
|
||||
assertEquals("", ClientRegionShortcutConverter.toUpperCase(""));
|
||||
assertEquals("", ClientRegionShortcutConverter.toUpperCase(" "));
|
||||
assertEquals("NULL", ClientRegionShortcutConverter.toUpperCase("null"));
|
||||
assertEquals("null", ClientRegionShortcutConverter.toUpperCase(null));
|
||||
|
||||
assertThat(ClientRegionShortcutConverter.toUpperCase("test")).isEqualTo("TEST");
|
||||
assertThat(ClientRegionShortcutConverter.toUpperCase(" Test ")).isEqualTo("TEST");
|
||||
assertThat(ClientRegionShortcutConverter.toUpperCase("")).isEqualTo("");
|
||||
assertThat(ClientRegionShortcutConverter.toUpperCase(" ")).isEqualTo("");
|
||||
assertThat(ClientRegionShortcutConverter.toUpperCase("null")).isEqualTo("NULL");
|
||||
assertThat(ClientRegionShortcutConverter.toUpperCase(null)).isEqualTo("null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvert() {
|
||||
|
||||
for (ClientRegionShortcut shortcut : ClientRegionShortcut.values()) {
|
||||
assertEquals(shortcut, converter.convert(shortcut.name()));
|
||||
assertThat(converter.convert(shortcut.name())).isEqualTo(shortcut);
|
||||
}
|
||||
|
||||
assertEquals(ClientRegionShortcut.PROXY, converter.convert("Proxy"));
|
||||
assertEquals(ClientRegionShortcut.CACHING_PROXY, converter.convert("caching_proxy"));
|
||||
assertEquals(ClientRegionShortcut.LOCAL_HEAP_LRU, converter.convert("local_Heap_LRU"));
|
||||
assertThat(converter.convert("Proxy")).isEqualTo(ClientRegionShortcut.PROXY);
|
||||
assertThat(converter.convert("caching_proxy")).isEqualTo(ClientRegionShortcut.CACHING_PROXY);
|
||||
assertThat(converter.convert("local_Heap_LRU")).isEqualTo(ClientRegionShortcut.LOCAL_HEAP_LRU);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testConvertWithIllegalEnumeratedValue() {
|
||||
converter.convert("LOCAL Persistent OverFlow");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
/**
|
||||
* The ClientRegionShortcutWrapperTest class is a test suite of test cases testing the contract and functionality of the
|
||||
* ClientRegionShortcutWrapper enum class type.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see ClientRegionShortcutWrapper
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class ClientRegionShortcutWrapperTest {
|
||||
|
||||
@Test
|
||||
public void testOneToOneMapping() {
|
||||
for (ClientRegionShortcut shortcut : ClientRegionShortcut.values()) {
|
||||
assertNotNull(ClientRegionShortcutWrapper.valueOf(shortcut.name()));
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.equals(ClientRegionShortcutWrapper.valueOf(shortcut)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientRegionShortcutUnspecified() {
|
||||
assertEquals(ClientRegionShortcutWrapper.UNSPECIFIED, ClientRegionShortcutWrapper.valueOf(
|
||||
(ClientRegionShortcut) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsCaching() {
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY.isCaching());
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isCaching());
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isCaching());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL.isCaching());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isCaching());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isCaching());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isCaching());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isCaching());
|
||||
assertFalse(ClientRegionShortcutWrapper.PROXY.isCaching());
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.isCaching());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsHeapLru() {
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY.isHeapLru());
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isHeapLru());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isHeapLru());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL.isHeapLru());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isHeapLru());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isHeapLru());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isHeapLru());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isHeapLru());
|
||||
assertFalse(ClientRegionShortcutWrapper.PROXY.isHeapLru());
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.isHeapLru());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLocal() {
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY.isLocal());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isLocal());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isLocal());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL.isLocal());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isLocal());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isLocal());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isLocal());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isLocal());
|
||||
assertFalse(ClientRegionShortcutWrapper.PROXY.isLocal());
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.isLocal());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsOverflow() {
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY.isOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isOverflow());
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL.isOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isOverflow());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isOverflow());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.PROXY.isOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.isOverflow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPersistent() {
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY.isPersistent());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isPersistent());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isPersistent());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL.isPersistent());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistent());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isPersistent());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isPersistent());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistent());
|
||||
assertFalse(ClientRegionShortcutWrapper.PROXY.isPersistent());
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.isPersistent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPersistentOverflow() {
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isPersistentOverflow());
|
||||
assertTrue(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.PROXY.isPersistentOverflow());
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.isPersistentOverflow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsProxy() {
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY.isProxy());
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isProxy());
|
||||
assertTrue(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isProxy());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL.isProxy());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isProxy());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isProxy());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isProxy());
|
||||
assertFalse(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isProxy());
|
||||
assertTrue(ClientRegionShortcutWrapper.PROXY.isProxy());
|
||||
assertFalse(ClientRegionShortcutWrapper.UNSPECIFIED.isProxy());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.client;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link ClientRegionShortcutWrapper} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionShortcutWrapper
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class ClientRegionShortcutWrapperUnitTests {
|
||||
|
||||
@Test
|
||||
public void testOneToOneMapping() {
|
||||
|
||||
for (ClientRegionShortcut shortcut : ClientRegionShortcut.values()) {
|
||||
assertThat(ClientRegionShortcutWrapper.valueOf(shortcut.name())).isNotNull();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.equals(ClientRegionShortcutWrapper.valueOf(shortcut))).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientRegionShortcutUnspecified() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.valueOf(
|
||||
(ClientRegionShortcut) null)).isEqualTo(ClientRegionShortcutWrapper.UNSPECIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsCaching() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY.isCaching()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isCaching()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isCaching()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL.isCaching()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isCaching()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isCaching()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isCaching()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isCaching()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.PROXY.isCaching()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.isCaching()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsHeapLru() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY.isHeapLru()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isHeapLru()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL.isHeapLru()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isHeapLru()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isHeapLru()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isHeapLru()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.PROXY.isHeapLru()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.isHeapLru()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsLocal() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY.isLocal()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isLocal()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isLocal()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL.isLocal()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isLocal()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isLocal()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isLocal()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isLocal()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.PROXY.isLocal()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.isLocal()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsOverflow() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY.isOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL.isOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isOverflow()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.PROXY.isOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.isOverflow()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPersistent() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY.isPersistent()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isPersistent()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isPersistent()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL.isPersistent()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistent()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isPersistent()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isPersistent()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistent()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.PROXY.isPersistent()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.isPersistent()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPersistentOverflow() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isPersistentOverflow()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.PROXY.isPersistentOverflow()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.isPersistentOverflow()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsProxy() {
|
||||
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY.isProxy()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_HEAP_LRU.isProxy()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.CACHING_PROXY_OVERFLOW.isProxy()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL.isProxy()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_HEAP_LRU.isProxy()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT.isProxy()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.LOCAL_PERSISTENT_OVERFLOW.isProxy()).isFalse();
|
||||
assertThat(ClientRegionShortcutWrapper.PROXY.isProxy()).isTrue();
|
||||
assertThat(ClientRegionShortcutWrapper.UNSPECIFIED.isProxy()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.client;
|
||||
|
||||
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 org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.InterestResultPolicy;
|
||||
|
||||
/**
|
||||
* The InterestResultPolicyTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the InterestResultPolicyType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.client.InterestResultPolicyTypeTest
|
||||
* @see org.apache.geode.cache.InterestResultPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class InterestResultPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestResultPolicy() {
|
||||
assertEquals(InterestResultPolicy.KEYS, InterestResultPolicyType.getInterestResultPolicy(
|
||||
InterestResultPolicyType.KEYS));
|
||||
assertEquals(InterestResultPolicy.KEYS_VALUES, InterestResultPolicyType.getInterestResultPolicy(
|
||||
InterestResultPolicyType.KEYS_VALUES));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestResultPolicyWithNull() {
|
||||
assertNull(InterestResultPolicyType.getInterestResultPolicy(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(InterestResultPolicyType.DEFAULT, InterestResultPolicyType.valueOf(InterestResultPolicy.DEFAULT));
|
||||
assertEquals(InterestResultPolicy.DEFAULT, InterestResultPolicyType.DEFAULT.getInterestResultPolicy());
|
||||
assertSame(InterestResultPolicyType.KEYS_VALUES, InterestResultPolicyType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
try {
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
InterestResultPolicy interestResultPolicy = InterestResultPolicy.fromOrdinal(ordinal);
|
||||
InterestResultPolicyType interestResultPolicyType = InterestResultPolicyType.valueOf(
|
||||
interestResultPolicy);
|
||||
|
||||
assertNotNull(interestResultPolicyType);
|
||||
assertEquals(interestResultPolicy, interestResultPolicyType.getInterestResultPolicy());
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(InterestResultPolicyType.valueOf((InterestResultPolicy) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(InterestResultPolicyType.KEYS, InterestResultPolicyType.valueOfIgnoreCase("KEYS"));
|
||||
assertEquals(InterestResultPolicyType.KEYS_VALUES, InterestResultPolicyType.valueOfIgnoreCase("Keys_Values"));
|
||||
assertEquals(InterestResultPolicyType.NONE, InterestResultPolicyType.valueOfIgnoreCase("none"));
|
||||
assertEquals(InterestResultPolicyType.NONE, InterestResultPolicyType.valueOfIgnoreCase("nONE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(InterestResultPolicyType.valueOfIgnoreCase("keyz"));
|
||||
assertNull(InterestResultPolicyType.valueOfIgnoreCase("KEY_VALUE"));
|
||||
assertNull(InterestResultPolicyType.valueOfIgnoreCase("all"));
|
||||
assertNull(InterestResultPolicyType.valueOfIgnoreCase(" "));
|
||||
assertNull(InterestResultPolicyType.valueOfIgnoreCase(""));
|
||||
assertNull(InterestResultPolicyType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.client;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.InterestResultPolicy;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link InterestResultPolicyType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.InterestResultPolicy
|
||||
* @see org.springframework.data.gemfire.client.InterestResultPolicyTypeUnitTests
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class InterestResultPolicyTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestResultPolicy() {
|
||||
|
||||
assertThat(InterestResultPolicyType.getInterestResultPolicy(InterestResultPolicyType.KEYS)).isEqualTo(InterestResultPolicy.KEYS);
|
||||
assertThat(InterestResultPolicyType.getInterestResultPolicy(InterestResultPolicyType.KEYS_VALUES)).isEqualTo(InterestResultPolicy.KEYS_VALUES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetInterestResultPolicyWithNull() {
|
||||
assertThat(InterestResultPolicyType.getInterestResultPolicy(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
|
||||
assertThat(InterestResultPolicyType.valueOf(InterestResultPolicy.DEFAULT)).isEqualTo(InterestResultPolicyType.DEFAULT);
|
||||
assertThat(InterestResultPolicyType.DEFAULT.getInterestResultPolicy()).isEqualTo(InterestResultPolicy.DEFAULT);
|
||||
assertThat(InterestResultPolicyType.DEFAULT).isSameAs(InterestResultPolicyType.KEYS_VALUES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
|
||||
try {
|
||||
for (byte ordinal = 0; ordinal < Byte.MAX_VALUE; ordinal++) {
|
||||
|
||||
InterestResultPolicy interestResultPolicy = InterestResultPolicy.fromOrdinal(ordinal);
|
||||
|
||||
InterestResultPolicyType interestResultPolicyType =
|
||||
InterestResultPolicyType.valueOf(interestResultPolicy);
|
||||
|
||||
assertThat(interestResultPolicyType).isNotNull();
|
||||
assertThat(interestResultPolicyType.getInterestResultPolicy()).isEqualTo(interestResultPolicy);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertThat(InterestResultPolicyType.valueOf((InterestResultPolicy) null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("KEYS")).isEqualTo(InterestResultPolicyType.KEYS);
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("Keys_Values")).isEqualTo(InterestResultPolicyType.KEYS_VALUES);
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("none")).isEqualTo(InterestResultPolicyType.NONE);
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("nONE")).isEqualTo(InterestResultPolicyType.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("keyz")).isNull();
|
||||
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("KEY_VALUE")).isNull();
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("all")).isNull();
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(InterestResultPolicyType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.client;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -28,31 +24,35 @@ import javax.annotation.Resource;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The SpringJavaConfiguredClientCacheIntegrationTest class is a test suite of test cases testing
|
||||
* the proper configuration of a GemFire ClientCache instance using Spring Java-based configuration meta-data.
|
||||
* Integration Tests for the proper configuration of a {@link ClientCache} instance
|
||||
* using Spring Java-based configuration metadata.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
* @see org.springframework.data.gemfire.client.ClientCacheFactoryBean
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @link https://jira.spring.io/browse/SGF-441
|
||||
* @since 1.8.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = SpringJavaConfiguredClientCacheIntegrationTest.GemFireConfiguration.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = SpringJavaConfiguredClientCacheIntegrationTests.TestConfiguration.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class SpringJavaConfiguredClientCacheIntegrationTest {
|
||||
public class SpringJavaConfiguredClientCacheIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Resource(name = "&clientCache")
|
||||
private ClientCacheFactoryBean clientCacheFactoryBean;
|
||||
@@ -62,28 +62,30 @@ public class SpringJavaConfiguredClientCacheIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void clientCacheFactoryBeanConfiguration() {
|
||||
assertThat(clientCacheFactoryBean, is(notNullValue()));
|
||||
assertThat(clientCacheFactoryBean.getBeanName(), is(equalTo("clientCache")));
|
||||
assertThat(clientCacheFactoryBean.getProperties(), is(equalTo(gemfireProperties)));
|
||||
|
||||
assertThat(clientCacheFactoryBean).isNotNull();
|
||||
assertThat(clientCacheFactoryBean.getBeanName()).isEqualTo("clientCache");
|
||||
assertThat(clientCacheFactoryBean.getProperties()).isEqualTo(gemfireProperties);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class GemFireConfiguration {
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
public Properties gemfireProperties() {
|
||||
Properties gemfireProperties() {
|
||||
|
||||
Properties gemfireProperties = new Properties();
|
||||
gemfireProperties.setProperty("name", SpringJavaConfiguredClientCacheIntegrationTest.class.getSimpleName());
|
||||
gemfireProperties.setProperty("log-level", "error");
|
||||
|
||||
gemfireProperties.setProperty("name", SpringJavaConfiguredClientCacheIntegrationTests.class.getSimpleName());
|
||||
|
||||
return gemfireProperties;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientCacheFactoryBean clientCache() {
|
||||
ClientCacheFactoryBean clientCache() {
|
||||
|
||||
ClientCacheFactoryBean clientCacheFactoryBean = new ClientCacheFactoryBean();
|
||||
|
||||
clientCacheFactoryBean.setUseBeanFactoryLocator(false);
|
||||
clientCacheFactoryBean.setProperties(gemfireProperties());
|
||||
|
||||
@@ -14,17 +14,14 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.client.function;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -36,8 +33,6 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.Region;
|
||||
@@ -45,34 +40,34 @@ import org.apache.geode.cache.execute.FunctionContext;
|
||||
import org.apache.geode.cache.execute.ResultSender;
|
||||
|
||||
/**
|
||||
* The ListRegionsOnServerFunctionTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the ListRegionsOnServerFunction GemFire Function class.
|
||||
* Unit Tests for {@link ListRegionsOnServerFunction}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see ListRegionsOnServerFunction
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction
|
||||
* @since 1.7.0
|
||||
*/
|
||||
public class ListRegionsOnServerFunctionTest {
|
||||
public class ListRegionsOnServerFunctionUnitTests {
|
||||
|
||||
private ListRegionsOnServerFunction function = new ListRegionsOnServerFunction();
|
||||
private final ListRegionsOnServerFunction function = spy(new ListRegionsOnServerFunction());
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void executeReturnsRootRegionNames() {
|
||||
final Cache mockCache = mock(Cache.class, "MockGemFireCache");
|
||||
|
||||
Region mockRegionOne = mock(Region.class, "MockGemFireRegionOne");
|
||||
Region mockRegionTwo = mock(Region.class, "MockGemFireRegionTwo");
|
||||
Region mockRegionThree = mock(Region.class, "MockGemFireRegionThree");
|
||||
Cache mockCache = mock(Cache.class, "MockGemFireCache");
|
||||
|
||||
FunctionContext mockFunctionContext = mock(FunctionContext.class, "MockGemFireFunctionContext");
|
||||
Region<?, ?> mockRegionOne = mock(Region.class, "MockGemFireRegionOne");
|
||||
Region<?, ?> mockRegionTwo = mock(Region.class, "MockGemFireRegionTwo");
|
||||
Region<?, ?> mockRegionThree = mock(Region.class, "MockGemFireRegionThree");
|
||||
|
||||
FunctionContext<?> mockFunctionContext = mock(FunctionContext.class, "MockGemFireFunctionContext");
|
||||
|
||||
ResultSender<Object> mockResultSender = mock(ResultSender.class, "MockGemFireResultSender");
|
||||
|
||||
when(mockCache.rootRegions()).thenReturn(new HashSet<>(
|
||||
Arrays.<Region<?, ?>>asList(mockRegionOne, mockRegionTwo, mockRegionThree)));
|
||||
when(mockCache.rootRegions()).thenReturn(new HashSet<>(Arrays.asList(mockRegionOne, mockRegionTwo, mockRegionThree)));
|
||||
when(mockRegionOne.getName()).thenReturn("One");
|
||||
when(mockRegionTwo.getName()).thenReturn("Two");
|
||||
when(mockRegionThree.getName()).thenReturn("Three");
|
||||
@@ -80,28 +75,23 @@ public class ListRegionsOnServerFunctionTest {
|
||||
|
||||
final AtomicReference<List<String>> regionNames = new AtomicReference<>(null);
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
regionNames.compareAndSet(null, invocation.getArgument(0));
|
||||
return null;
|
||||
}
|
||||
doAnswer(invocation -> {
|
||||
regionNames.compareAndSet(null, invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(mockResultSender).lastResult(any(List.class));
|
||||
|
||||
ListRegionsOnServerFunction function = new ListRegionsOnServerFunction() {
|
||||
@Override Cache getCache() {
|
||||
return mockCache;
|
||||
}
|
||||
};
|
||||
ListRegionsOnServerFunction function = spy(new ListRegionsOnServerFunction());
|
||||
|
||||
doReturn(mockCache).when(function).getCache();
|
||||
|
||||
function.execute(mockFunctionContext);
|
||||
|
||||
List<String> actualRegionNames = regionNames.get();
|
||||
|
||||
assertThat(actualRegionNames, is(not(nullValue())));
|
||||
assertThat(actualRegionNames.isEmpty(), is(false));
|
||||
assertThat(actualRegionNames.size(), is(equalTo(3)));
|
||||
assertThat(actualRegionNames.containsAll(Arrays.asList("One", "Two", "Three")), is(true));
|
||||
assertThat(actualRegionNames).isNotNull();
|
||||
assertThat(actualRegionNames.isEmpty()).isFalse();
|
||||
assertThat(actualRegionNames.size()).isEqualTo(3);
|
||||
assertThat(actualRegionNames.containsAll(Arrays.asList("One", "Two", "Three"))).isTrue();
|
||||
|
||||
verify(mockCache, times(1)).rootRegions();
|
||||
verify(mockRegionOne, times(1)).getName();
|
||||
@@ -114,9 +104,10 @@ public class ListRegionsOnServerFunctionTest {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void executeWithNoRegions() {
|
||||
final Cache mockCache = mock(Cache.class, "MockGemFireCache");
|
||||
|
||||
FunctionContext mockFunctionContext = mock(FunctionContext.class, "MockGemFireFunctionContext");
|
||||
Cache mockCache = mock(Cache.class, "MockGemFireCache");
|
||||
|
||||
FunctionContext<?> mockFunctionContext = mock(FunctionContext.class, "MockGemFireFunctionContext");
|
||||
|
||||
ResultSender<Object> mockResultSender = mock(ResultSender.class, "MockGemFireResultSender");
|
||||
|
||||
@@ -125,26 +116,21 @@ public class ListRegionsOnServerFunctionTest {
|
||||
|
||||
final AtomicReference<List<String>> regionNames = new AtomicReference<>(null);
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
regionNames.compareAndSet(null, invocation.getArgument(0));
|
||||
return null;
|
||||
}
|
||||
doAnswer(invocation -> {
|
||||
regionNames.compareAndSet(null, invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(mockResultSender).lastResult(any(List.class));
|
||||
|
||||
ListRegionsOnServerFunction function = new ListRegionsOnServerFunction() {
|
||||
@Override Cache getCache() {
|
||||
return mockCache;
|
||||
}
|
||||
};
|
||||
ListRegionsOnServerFunction function = spy(new ListRegionsOnServerFunction());
|
||||
|
||||
doReturn(mockCache).when(function).getCache();
|
||||
|
||||
function.execute(mockFunctionContext);
|
||||
|
||||
List<String> actualRegionNames = regionNames.get();
|
||||
|
||||
assertThat(actualRegionNames, is(not(nullValue())));
|
||||
assertThat(actualRegionNames.isEmpty(), is(true));
|
||||
assertThat(actualRegionNames).isNotNull();
|
||||
assertThat(actualRegionNames.isEmpty()).isTrue();
|
||||
|
||||
verify(mockCache, times(1)).rootRegions();
|
||||
verify(mockFunctionContext, times(1)).getResultSender();
|
||||
@@ -153,17 +139,17 @@ public class ListRegionsOnServerFunctionTest {
|
||||
|
||||
@Test
|
||||
public void getIdIsFullyQualifiedClassName() {
|
||||
assertThat(function.getId(), is(equalTo(ListRegionsOnServerFunction.class.getName())));
|
||||
assertThat(function.getId()).isEqualTo(ListRegionsOnServerFunction.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasResultIsTrue() {
|
||||
assertThat(function.hasResult(), is(true));
|
||||
assertThat(function.hasResult()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isHighAvailabilityAndOptimizeForWriteAreFalse() {
|
||||
assertThat(function.isHA(), is(false));
|
||||
assertThat(function.optimizeForWrite(), is(false));
|
||||
assertThat(function.isHA()).isFalse();
|
||||
assertThat(function.optimizeForWrite()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -27,9 +25,10 @@ import org.apache.geode.cache.server.ClientSubscriptionConfig;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -41,14 +40,16 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
*/
|
||||
@ContextConfiguration(locations="server-ns.xml", initializers= GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "server-ns.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class CacheServerNamespaceTest {
|
||||
public class CacheServerNamespaceIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@@ -59,25 +60,27 @@ public class CacheServerNamespaceTest {
|
||||
|
||||
CacheServer cacheServer = applicationContext.getBean("advanced-config", CacheServer.class);
|
||||
|
||||
assertNotNull(cacheServer);
|
||||
assertEquals(1, cacheServer.getGroups().length);
|
||||
assertEquals("localhost", cacheServer.getBindAddress());
|
||||
assertTrue(cacheServer.getPort() != 0);
|
||||
assertEquals("localhost", cacheServer.getHostnameForClients());
|
||||
assertEquals("test-server", cacheServer.getGroups()[0]);
|
||||
assertEquals(2000L, cacheServer.getLoadPollInterval());
|
||||
assertEquals(22, cacheServer.getMaxConnections());
|
||||
assertEquals(16, cacheServer.getMaxThreads());
|
||||
assertEquals(1000, cacheServer.getMaximumMessageCount());
|
||||
assertEquals(30000, cacheServer.getMaximumTimeBetweenPings());
|
||||
assertTrue(cacheServer.isRunning());
|
||||
assertThat(cacheServer).isNotNull();
|
||||
assertThat(cacheServer.getGroups().length).isEqualTo(1);
|
||||
assertThat(cacheServer.getBindAddress()).isEqualTo("localhost");
|
||||
assertThat(cacheServer.getPort() != 0).isTrue();
|
||||
assertThat(cacheServer.getHostnameForClients()).isEqualTo("localhost");
|
||||
assertThat(cacheServer.getGroups()[0]).isEqualTo("test-server");
|
||||
assertThat(cacheServer.getLoadPollInterval()).isEqualTo(2000L);
|
||||
assertThat(cacheServer.getMaxConnections()).isEqualTo(22);
|
||||
assertThat(cacheServer.getMaxThreads()).isEqualTo(16);
|
||||
assertThat(cacheServer.getMaximumMessageCount()).isEqualTo(1000);
|
||||
assertThat(cacheServer.getMaximumTimeBetweenPings()).isEqualTo(30000);
|
||||
assertThat(cacheServer.isRunning()).isTrue();
|
||||
|
||||
ClientSubscriptionConfig clientSubscriptionConfig = cacheServer.getClientSubscriptionConfig();
|
||||
|
||||
assertNotNull(clientSubscriptionConfig);
|
||||
assertEquals(1000, clientSubscriptionConfig.getCapacity());
|
||||
assertTrue("ENTRY".equalsIgnoreCase(clientSubscriptionConfig.getEvictionPolicy()));
|
||||
assertTrue(String.format("Expected empty DiskStoreName; but was (%1$s)", clientSubscriptionConfig.getDiskStoreName()),
|
||||
StringUtils.isEmpty(clientSubscriptionConfig.getDiskStoreName()));
|
||||
assertThat(clientSubscriptionConfig).isNotNull();
|
||||
assertThat(clientSubscriptionConfig.getCapacity()).isEqualTo(1000);
|
||||
assertThat("ENTRY".equalsIgnoreCase(clientSubscriptionConfig.getEvictionPolicy())).isTrue();
|
||||
|
||||
assertThat(StringUtils.isEmpty(clientSubscriptionConfig.getDiskStoreName()))
|
||||
.describedAs("Expected empty DiskStoreName; but was (%1$s)", clientSubscriptionConfig.getDiskStoreName())
|
||||
.isTrue();
|
||||
}
|
||||
}
|
||||
@@ -13,17 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.InterestPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
import org.apache.geode.cache.SubscriptionAttributes;
|
||||
|
||||
@@ -31,67 +29,80 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.PeerRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Test to ensure subscription policy can be applied to server regions.
|
||||
* Integration Tests ensuring subscription policy can be applied to server {@link Region Regions}.
|
||||
*
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.SubscriptionAttributes
|
||||
* @see org.springframework.data.gemfire.SubscriptionAttributesFactoryBean
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("subscription-ns.xml")
|
||||
@SuppressWarnings("unused")
|
||||
public class CacheSubscriptionTest{
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "subscription-ns.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings({ "rawtypes", "unused" })
|
||||
public class CacheSubscriptionTest extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
public void testReplicatedRegionSubscriptionAllPolicy() throws Exception {
|
||||
assertTrue(context.containsBean("replicALL"));
|
||||
|
||||
PeerRegionFactoryBean regionFactoryBean = context.getBean("&replicALL", PeerRegionFactoryBean.class);
|
||||
assertThat(applicationContext.containsBean("replicALL")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean regionFactoryBean = applicationContext.getBean("&replicALL", PeerRegionFactoryBean.class);
|
||||
RegionAttributes regionAttributes = TestUtils.readField("attributes", regionFactoryBean);
|
||||
|
||||
assertNotNull(regionAttributes);
|
||||
assertThat(regionAttributes).isNotNull();
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = regionAttributes.getSubscriptionAttributes();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.ALL, subscriptionAttributes.getInterestPolicy());
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.ALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionRegionSubscriptionCacheContentPolicy() throws Exception {
|
||||
assertTrue(context.containsBean("partCACHE_CONTENT"));
|
||||
|
||||
PeerRegionFactoryBean regionFactoryBean = context.getBean("&partCACHE_CONTENT", PeerRegionFactoryBean.class);
|
||||
assertThat(applicationContext.containsBean("partCACHE_CONTENT")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean regionFactoryBean = applicationContext.getBean("&partCACHE_CONTENT", PeerRegionFactoryBean.class);
|
||||
RegionAttributes regionAttributes = TestUtils.readField("attributes", regionFactoryBean);
|
||||
|
||||
assertNotNull(regionAttributes);
|
||||
assertThat(regionAttributes).isNotNull();
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = regionAttributes.getSubscriptionAttributes();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.CACHE_CONTENT, subscriptionAttributes.getInterestPolicy());
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.CACHE_CONTENT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartitionRegionSubscriptionDefaultPolicy() throws Exception {
|
||||
assertTrue(context.containsBean("partDEFAULT"));
|
||||
|
||||
PeerRegionFactoryBean regionFactoryBean = context.getBean("&partDEFAULT", PeerRegionFactoryBean.class);
|
||||
assertThat(applicationContext.containsBean("partDEFAULT")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean regionFactoryBean = applicationContext.getBean("&partDEFAULT", PeerRegionFactoryBean.class);
|
||||
RegionAttributes regionAttributes = TestUtils.readField("attributes", regionFactoryBean);
|
||||
|
||||
assertNotNull(regionAttributes);
|
||||
assertThat(regionAttributes).isNotNull();
|
||||
|
||||
SubscriptionAttributes subscriptionAttributes = regionAttributes.getSubscriptionAttributes();
|
||||
|
||||
assertNotNull(subscriptionAttributes);
|
||||
assertEquals(InterestPolicy.DEFAULT, subscriptionAttributes.getInterestPolicy());
|
||||
assertThat(subscriptionAttributes).isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(InterestPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static java.util.Arrays.stream;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -80,7 +76,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "client-ns.xml", initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientRegionNamespaceTests extends IntegrationTestsSupport {
|
||||
public class ClientRegionNamespaceIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@@ -94,198 +90,206 @@ public class ClientRegionNamespaceTests extends IntegrationTestsSupport {
|
||||
@Test
|
||||
public void testBeanNames() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("SimpleRegion"));
|
||||
assertTrue(applicationContext.containsBean("Publisher"));
|
||||
assertTrue(applicationContext.containsBean("ComplexRegion"));
|
||||
assertTrue(applicationContext.containsBean("PersistentRegion"));
|
||||
assertTrue(applicationContext.containsBean("OverflowRegion"));
|
||||
assertTrue(applicationContext.containsBean("Compressed"));
|
||||
assertThat(applicationContext.containsBean("SimpleRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("Publisher")).isTrue();
|
||||
assertThat(applicationContext.containsBean("ComplexRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("PersistentRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("OverflowRegion")).isTrue();
|
||||
assertThat(applicationContext.containsBean("Compressed")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleClientRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("simple"));
|
||||
assertThat(applicationContext.containsBean("simple")).isTrue();
|
||||
|
||||
Region<?, ?> simple = applicationContext.getBean("simple", Region.class);
|
||||
|
||||
assertNotNull("The 'SimpleRegion' Client Region was not properly configured and initialized!", simple);
|
||||
assertEquals("SimpleRegion", simple.getName());
|
||||
assertEquals(Region.SEPARATOR + "SimpleRegion", simple.getFullPath());
|
||||
assertNotNull(simple.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, simple.getAttributes().getDataPolicy());
|
||||
assertThat(simple).as("The 'SimpleRegion' Client Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(simple.getName()).isEqualTo("SimpleRegion");
|
||||
assertThat(simple.getFullPath()).isEqualTo(Region.SEPARATOR + "SimpleRegion");
|
||||
assertThat(simple.getAttributes()).isNotNull();
|
||||
assertThat(simple.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testPublishingClientRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("empty"));
|
||||
assertThat(applicationContext.containsBean("empty")).isTrue();
|
||||
|
||||
ClientRegionFactoryBean emptyClientRegionFactoryBean = applicationContext
|
||||
.getBean("&empty", ClientRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(emptyClientRegionFactoryBean);
|
||||
assertEquals(DataPolicy.EMPTY, TestUtils.readField("dataPolicy", emptyClientRegionFactoryBean));
|
||||
assertEquals("empty", TestUtils.readField("beanName", emptyClientRegionFactoryBean));
|
||||
assertEquals("Publisher", TestUtils.readField("name", emptyClientRegionFactoryBean));
|
||||
assertEquals("gemfire-pool", TestUtils.readField("poolName", emptyClientRegionFactoryBean));
|
||||
assertThat(emptyClientRegionFactoryBean).isNotNull();
|
||||
assertThat(TestUtils.<Object>readField("dataPolicy", emptyClientRegionFactoryBean)).isEqualTo(DataPolicy.EMPTY);
|
||||
assertThat(TestUtils.<Object>readField("beanName", emptyClientRegionFactoryBean)).isEqualTo("empty");
|
||||
assertThat(TestUtils.<Object>readField("name", emptyClientRegionFactoryBean)).isEqualTo("Publisher");
|
||||
assertThat(TestUtils.<Object>readField("poolName", emptyClientRegionFactoryBean)).isEqualTo("gemfire-pool");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testComplexClientRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("complex"));
|
||||
assertThat(applicationContext.containsBean("complex")).isTrue();
|
||||
|
||||
ClientRegionFactoryBean complexClientRegionFactoryBean = applicationContext
|
||||
.getBean("&complex", ClientRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(complexClientRegionFactoryBean);
|
||||
assertThat(complexClientRegionFactoryBean).isNotNull();
|
||||
|
||||
CacheListener[] cacheListeners = TestUtils.readField("cacheListeners", complexClientRegionFactoryBean);
|
||||
|
||||
assertFalse(ObjectUtils.isEmpty(cacheListeners));
|
||||
assertEquals(2, cacheListeners.length);
|
||||
assertSame(cacheListeners[0], applicationContext.getBean("c-listener"));
|
||||
assertTrue(cacheListeners[1] instanceof SimpleCacheListener);
|
||||
assertNotSame(cacheListeners[0], cacheListeners[1]);
|
||||
assertThat(ObjectUtils.isEmpty(cacheListeners)).isFalse();
|
||||
assertThat(cacheListeners.length).isEqualTo(2);
|
||||
assertThat(applicationContext.getBean("c-listener")).isSameAs(cacheListeners[0]);
|
||||
assertThat(cacheListeners[1] instanceof SimpleCacheListener).isTrue();
|
||||
assertThat(cacheListeners[1]).isNotSameAs(cacheListeners[0]);
|
||||
|
||||
RegionAttributes complexRegionAttributes = TestUtils.readField("attributes", complexClientRegionFactoryBean);
|
||||
RegionAttributes complexRegionAttributes =
|
||||
TestUtils.<RegionAttributes<?, ?>>readField("attributes", complexClientRegionFactoryBean);
|
||||
|
||||
assertNotNull(complexRegionAttributes);
|
||||
assertEquals(0.5f, complexRegionAttributes.getLoadFactor(), 0.001);
|
||||
assertEquals(ExpirationAction.INVALIDATE, complexRegionAttributes.getEntryTimeToLive().getAction());
|
||||
assertEquals(500, complexRegionAttributes.getEntryTimeToLive().getTimeout());
|
||||
assertEquals(5, complexRegionAttributes.getEvictionAttributes().getMaximum());
|
||||
assertThat(complexRegionAttributes).isNotNull();
|
||||
assertThat(complexRegionAttributes.getLoadFactor()).isCloseTo(0.5f, offset(0.001f));
|
||||
assertThat(complexRegionAttributes.getEntryTimeToLive().getAction()).isEqualTo(ExpirationAction.INVALIDATE);
|
||||
assertThat(complexRegionAttributes.getEntryTimeToLive().getTimeout()).isEqualTo(500);
|
||||
assertThat(complexRegionAttributes.getEvictionAttributes().getMaximum()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testPersistentClientRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("persistent"));
|
||||
assertThat(applicationContext.containsBean("persistent")).isTrue();
|
||||
|
||||
Region persistent = applicationContext.getBean("persistent", Region.class);
|
||||
Region<?, ?> persistent = applicationContext.getBean("persistent", Region.class);
|
||||
|
||||
assertNotNull("The 'PersistentRegion' Region was not properly configured and initialized!", persistent);
|
||||
assertEquals("PersistentRegion", persistent.getName());
|
||||
assertEquals(Region.SEPARATOR + "PersistentRegion", persistent.getFullPath());
|
||||
assertThat(persistent)
|
||||
.describedAs("The 'PersistentRegion' Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(persistent.getName()).isEqualTo("PersistentRegion");
|
||||
assertThat(persistent.getFullPath()).isEqualTo(Region.SEPARATOR + "PersistentRegion");
|
||||
|
||||
RegionAttributes persistentRegionAttributes = persistent.getAttributes();
|
||||
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, persistentRegionAttributes.getDataPolicy());
|
||||
assertEquals("diskStore", persistentRegionAttributes.getDiskStoreName());
|
||||
assertEquals("gemfire-pool", persistentRegionAttributes.getPoolName());
|
||||
assertThat(persistentRegionAttributes.getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
assertThat(persistentRegionAttributes.getDiskStoreName()).isEqualTo("diskStore");
|
||||
assertThat(persistentRegionAttributes.getPoolName()).isEqualTo("gemfire-pool");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testOverflowClientRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("overflow"));
|
||||
assertThat(applicationContext.containsBean("overflow")).isTrue();
|
||||
|
||||
ClientRegionFactoryBean overflowClientRegionFactoryBean = applicationContext
|
||||
.getBean("&overflow", ClientRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(overflowClientRegionFactoryBean);
|
||||
assertEquals("diskStore", TestUtils.readField("diskStoreName", overflowClientRegionFactoryBean));
|
||||
assertEquals("gemfire-pool", TestUtils.readField("poolName", overflowClientRegionFactoryBean));
|
||||
assertThat(overflowClientRegionFactoryBean).isNotNull();
|
||||
assertThat(TestUtils.<Object>readField("diskStoreName", overflowClientRegionFactoryBean)).isEqualTo("diskStore");
|
||||
assertThat(TestUtils.<Object>readField("poolName", overflowClientRegionFactoryBean)).isEqualTo("gemfire-pool");
|
||||
|
||||
RegionAttributes overflowRegionAttributes = TestUtils.readField("attributes", overflowClientRegionFactoryBean);
|
||||
RegionAttributes overflowRegionAttributes =
|
||||
TestUtils.<RegionAttributes<?, ?>>readField("attributes", overflowClientRegionFactoryBean);
|
||||
|
||||
assertNotNull(overflowRegionAttributes);
|
||||
assertEquals(DataPolicy.NORMAL, overflowRegionAttributes.getDataPolicy());
|
||||
assertThat(overflowRegionAttributes).isNotNull();
|
||||
assertThat(overflowRegionAttributes.getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
|
||||
EvictionAttributes overflowEvictionAttributes = overflowRegionAttributes.getEvictionAttributes();
|
||||
|
||||
assertNotNull(overflowEvictionAttributes);
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, overflowEvictionAttributes.getAction());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, overflowEvictionAttributes.getAlgorithm());
|
||||
assertEquals(10, overflowEvictionAttributes.getMaximum());
|
||||
assertTrue(overflowEvictionAttributes.getObjectSizer() instanceof SimpleObjectSizer);
|
||||
assertThat(overflowEvictionAttributes).isNotNull();
|
||||
assertThat(overflowEvictionAttributes.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(overflowEvictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
assertThat(overflowEvictionAttributes.getMaximum()).isEqualTo(10);
|
||||
assertThat(overflowEvictionAttributes.getObjectSizer() instanceof SimpleObjectSizer).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientRegionWithCacheLoaderAndCacheWriter() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("loadWithWrite"));
|
||||
assertThat(applicationContext.containsBean("loadWithWrite")).isTrue();
|
||||
|
||||
ClientRegionFactoryBean<?, ?> factory =
|
||||
applicationContext.getBean("&loadWithWrite", ClientRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(factory);
|
||||
assertEquals("LoadedFullOfWrites", TestUtils.readField("name", factory));
|
||||
assertEquals(ClientRegionShortcut.LOCAL, TestUtils.readField("shortcut", factory));
|
||||
assertTrue(TestUtils.readField("cacheLoader", factory) instanceof TestCacheLoader);
|
||||
assertTrue(TestUtils.readField("cacheWriter", factory) instanceof TestCacheWriter);
|
||||
assertThat(factory).isNotNull();
|
||||
assertThat(TestUtils.<Object>readField("name", factory)).isEqualTo("LoadedFullOfWrites");
|
||||
assertThat(TestUtils.<Object>readField("shortcut", factory)).isEqualTo(ClientRegionShortcut.LOCAL);
|
||||
assertThat(TestUtils.<Object>readField("cacheLoader", factory)).isInstanceOf(TestCacheLoader.class);
|
||||
assertThat(TestUtils.<Object>readField("cacheWriter", factory)).isInstanceOf(TestCacheWriter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressedReplicateRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("Compressed"));
|
||||
assertThat(applicationContext.containsBean("Compressed")).isTrue();
|
||||
|
||||
Region<?, ?> compressed = applicationContext.getBean("Compressed", Region.class);
|
||||
|
||||
assertNotNull("The 'Compressed' Client Region was not properly configured and initialized!", compressed);
|
||||
assertEquals("Compressed", compressed.getName());
|
||||
assertEquals(Region.SEPARATOR + "Compressed", compressed.getFullPath());
|
||||
assertNotNull(compressed.getAttributes());
|
||||
assertEquals(DataPolicy.EMPTY, compressed.getAttributes().getDataPolicy());
|
||||
assertEquals("gemfire-pool", compressed.getAttributes().getPoolName());
|
||||
assertTrue(String.format("Expected 'TestCompressor'; but was '%1$s'!",
|
||||
ObjectUtils.nullSafeClassName(compressed.getAttributes().getCompressor())),
|
||||
compressed.getAttributes().getCompressor() instanceof TestCompressor);
|
||||
assertEquals("STD", compressed.getAttributes().getCompressor().toString());
|
||||
assertThat(compressed).as("The 'Compressed' Client Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(compressed.getName()).isEqualTo("Compressed");
|
||||
assertThat(compressed.getFullPath()).isEqualTo(Region.SEPARATOR + "Compressed");
|
||||
assertThat(compressed.getAttributes()).isNotNull();
|
||||
assertThat(compressed.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.EMPTY);
|
||||
assertThat(compressed.getAttributes().getPoolName()).isEqualTo("gemfire-pool");
|
||||
assertThat(compressed.getAttributes().getCompressor() instanceof TestCompressor)
|
||||
.as(String.format("Expected 'TestCompressor'; but was '%1$s'!",
|
||||
ObjectUtils.nullSafeClassName(compressed.getAttributes().getCompressor()))).isTrue();
|
||||
assertThat(compressed.getAttributes().getCompressor().toString()).isEqualTo("STD");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testClientRegionWithAttributes() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("client-with-attributes"));
|
||||
assertThat(applicationContext.containsBean("client-with-attributes")).isTrue();
|
||||
|
||||
Region<Long, String> clientRegion = applicationContext.getBean("client-with-attributes", Region.class);
|
||||
|
||||
assertNotNull("The 'client-with-attributes' Client Region was not properly configured and initialized!", clientRegion);
|
||||
assertEquals("client-with-attributes", clientRegion.getName());
|
||||
assertEquals(Region.SEPARATOR + "client-with-attributes", clientRegion.getFullPath());
|
||||
assertNotNull(clientRegion.getAttributes());
|
||||
assertFalse(clientRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(clientRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(8, clientRegion.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(DataPolicy.NORMAL, clientRegion.getAttributes().getDataPolicy());
|
||||
assertFalse(clientRegion.getAttributes().getDataPolicy().withPersistence());
|
||||
assertEquals(64, clientRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(Long.class, clientRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals("0.85", String.valueOf(clientRegion.getAttributes().getLoadFactor()));
|
||||
assertEquals("gemfire-pool", clientRegion.getAttributes().getPoolName());
|
||||
assertEquals(String.class, clientRegion.getAttributes().getValueConstraint());
|
||||
assertThat(clientRegion)
|
||||
.as("The 'client-with-attributes' Client Region was not properly configured and initialized!").isNotNull();
|
||||
assertThat(clientRegion.getName()).isEqualTo("client-with-attributes");
|
||||
assertThat(clientRegion.getFullPath()).isEqualTo(Region.SEPARATOR + "client-with-attributes");
|
||||
assertThat(clientRegion.getAttributes()).isNotNull();
|
||||
assertThat(clientRegion.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(clientRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(clientRegion.getAttributes().getConcurrencyLevel()).isEqualTo(8);
|
||||
assertThat(clientRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(clientRegion.getAttributes().getDataPolicy().withPersistence()).isFalse();
|
||||
assertThat(clientRegion.getAttributes().getInitialCapacity()).isEqualTo(64);
|
||||
assertThat(clientRegion.getAttributes().getKeyConstraint()).isEqualTo(Long.class);
|
||||
assertThat(String.valueOf(clientRegion.getAttributes().getLoadFactor())).isEqualTo("0.85");
|
||||
assertThat(clientRegion.getAttributes().getPoolName()).isEqualTo("gemfire-pool");
|
||||
assertThat(clientRegion.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testClientRegionWithRegisteredInterests() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("client-with-interests"));
|
||||
assertThat(applicationContext.containsBean("client-with-interests")).isTrue();
|
||||
|
||||
ClientRegionFactoryBean<?, ?> factoryBean =
|
||||
applicationContext.getBean("&client-with-interests", ClientRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(factoryBean);
|
||||
assertThat(factoryBean).isNotNull();
|
||||
|
||||
Interest<?>[] interests = TestUtils.readField("interests", factoryBean);
|
||||
|
||||
assertNotNull(interests);
|
||||
assertEquals(2, interests.length);
|
||||
assertThat(interests).isNotNull();
|
||||
assertThat(interests.length).isEqualTo(2);
|
||||
|
||||
assertInterest(true, false, InterestResultPolicy.KEYS, getInterestWithKey(".*", interests));
|
||||
assertInterest(true, false, InterestResultPolicy.KEYS_VALUES, getInterestWithKey("keyPrefix.*", interests));
|
||||
|
||||
Region<Object, Object> mockClientRegion = applicationContext.getBean("client-with-interests", Region.class);
|
||||
|
||||
assertNotNull(mockClientRegion);
|
||||
assertThat(mockClientRegion).isNotNull();
|
||||
|
||||
verify(mockClientRegion, times(1)).registerInterest(eq(".*"),
|
||||
eq(InterestResultPolicy.KEYS), eq(true), eq(false));
|
||||
@@ -297,10 +301,10 @@ public class ClientRegionNamespaceTests extends IntegrationTestsSupport {
|
||||
private void assertInterest(boolean expectedDurable, boolean expectedReceiveValues,
|
||||
InterestResultPolicy expectedPolicy, Interest<Object> actualInterest) {
|
||||
|
||||
assertNotNull(actualInterest);
|
||||
assertEquals(expectedDurable, actualInterest.isDurable());
|
||||
assertEquals(expectedReceiveValues, actualInterest.isReceiveValues());
|
||||
assertEquals(expectedPolicy, actualInterest.getPolicy());
|
||||
assertThat(actualInterest).isNotNull();
|
||||
assertThat(actualInterest.isDurable()).isEqualTo(expectedDurable);
|
||||
assertThat(actualInterest.isReceiveValues()).isEqualTo(expectedReceiveValues);
|
||||
assertThat(actualInterest.getPolicy()).isEqualTo(expectedPolicy);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -13,36 +13,45 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* The ClientRegionUsingDataPolicyAndShortcutTest class is a test suite of test case testing a client Region
|
||||
* bean definition with both data-policy and shortcut specified.
|
||||
* Integration Tests for client {@link Region} bean definition with both {@literal data-policy}(i.e. {@link DataPolicy})
|
||||
* and {@literal shortcut} {@link ClientRegionShortcut} attributes specified.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.DataPolicy
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.ClientRegionShortcut
|
||||
* @see org.springframework.context.support.ClassPathXmlApplicationContext
|
||||
* @since 1.3.3
|
||||
*/
|
||||
public class ClientRegionUsingDataPolicyAndShortcutTest {
|
||||
public class ClientRegionUsingDataPolicyAndShortcutIntegrationTests {
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
public void testClientRegionBeanDefinitionWithDataPolicyAndShortcut() {
|
||||
|
||||
try {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"/org/springframework/data/gemfire/config/xml/client-region-using-datapolicy-and-shortcut.xml");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertTrue(e.getMessage().contains("Only one of [data-policy, shortcut] may be specified with element"));
|
||||
throw e;
|
||||
catch (BeanDefinitionParsingException expected) {
|
||||
|
||||
assertThat(expected).hasMessageContaining("Only one of [data-policy, shortcut] may be specified with element");
|
||||
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -89,20 +85,21 @@ public class ContinuousQueryListenerContainerNamespaceIntegrationTests
|
||||
@Test
|
||||
public void testContainerConfiguration() throws Exception {
|
||||
|
||||
assertNotNull("The ContinuousQueryListenerContainer was not properly configured!", container);
|
||||
assertTrue("The CQ Listener Container should be active (initialized)!", container.isActive());
|
||||
assertFalse("The CQ Listener container should not be configured to auto-start!", container.isAutoStartup());
|
||||
assertFalse("The CQ Listener Container should not be running!", container.isRunning());
|
||||
assertEquals(4, container.getPhase());
|
||||
assertNotNull(testErrorHandler);
|
||||
assertSame(testErrorHandler, TestUtils.readField("errorHandler", container));
|
||||
assertNotNull(testTaskExecutor);
|
||||
assertSame(testTaskExecutor, TestUtils.readField("taskExecutor", container));
|
||||
assertThat(container).as("The ContinuousQueryListenerContainer was not properly configured!").isNotNull();
|
||||
assertThat(container.isActive()).as("The CQ Listener Container should be active (initialized)!").isTrue();
|
||||
assertThat(container.isAutoStartup()).as("The CQ Listener container should not be configured to auto-start!")
|
||||
.isFalse();
|
||||
assertThat(container.isRunning()).as("The CQ Listener Container should not be running!").isFalse();
|
||||
assertThat(container.getPhase()).isEqualTo(4);
|
||||
assertThat(testErrorHandler).isNotNull();
|
||||
assertThat(TestUtils.<Object>readField("errorHandler", container)).isSameAs(testErrorHandler);
|
||||
assertThat(testTaskExecutor).isNotNull();
|
||||
assertThat(TestUtils.<Object>readField("taskExecutor", container)).isSameAs(testTaskExecutor);
|
||||
|
||||
CqQuery[] queries = gemfireCache.getQueryService().getCqs();
|
||||
|
||||
assertNotNull(queries);
|
||||
assertEquals(3, queries.length);
|
||||
assertThat(queries).isNotNull();
|
||||
assertThat(queries.length).isEqualTo(3);
|
||||
|
||||
List<String> actualNames = new ArrayList<>(3);
|
||||
|
||||
@@ -110,8 +107,8 @@ public class ContinuousQueryListenerContainerNamespaceIntegrationTests
|
||||
|
||||
actualNames.add(query.getName());
|
||||
|
||||
assertEquals("SELECT * FROM /test-cq", query.getQueryString());
|
||||
assertEquals("Q3".equalsIgnoreCase(query.getName()), query.isDurable());
|
||||
assertThat(query.getQueryString()).isEqualTo("SELECT * FROM /test-cq");
|
||||
assertThat(query.isDurable()).isEqualTo("Q3".equalsIgnoreCase(query.getName()));
|
||||
|
||||
CqListener cqListener = query.getCqAttributes().getCqListener();
|
||||
|
||||
@@ -119,11 +116,11 @@ public class ContinuousQueryListenerContainerNamespaceIntegrationTests
|
||||
// So, get the SDG "ContinuousQueryListener"
|
||||
ContinuousQueryListener listener = TestUtils.readField("listener", cqListener);
|
||||
|
||||
assertTrue(listener instanceof ContinuousQueryListenerAdapter);
|
||||
assertTrue(((ContinuousQueryListenerAdapter) listener).getDelegate() instanceof GemfireMDP);
|
||||
assertThat(listener instanceof ContinuousQueryListenerAdapter).isTrue();
|
||||
assertThat(((ContinuousQueryListenerAdapter) listener).getDelegate() instanceof GemfireMDP).isTrue();
|
||||
|
||||
if ("Q2".equalsIgnoreCase(query.getName())) {
|
||||
assertEquals("handleQuery", TestUtils.readField("defaultListenerMethod", listener));
|
||||
assertThat(TestUtils.<String>readField("defaultListenerMethod", listener)).isEqualTo("handleQuery");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
|
||||
|
||||
import java.io.File;
|
||||
@@ -97,7 +92,7 @@ public class DiskStoreEvictionAndExpirationRegionParsingIntegrationTests extends
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
diskStoreDirectory = new File("./tmp");
|
||||
assertTrue(diskStoreDirectory.isDirectory() || diskStoreDirectory.mkdirs());
|
||||
assertThat(diskStoreDirectory.isDirectory() || diskStoreDirectory.mkdirs()).isTrue();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -115,91 +110,96 @@ public class DiskStoreEvictionAndExpirationRegionParsingIntegrationTests extends
|
||||
@Test
|
||||
public void testDiskStore() {
|
||||
|
||||
assertNotNull(applicationContext.getBean("ds2"));
|
||||
assertThat(applicationContext.getBean("ds2")).isNotNull();
|
||||
applicationContext.getBean("diskStore1");
|
||||
assertNotNull(diskStore);
|
||||
assertEquals("diskStore1", diskStore.getName());
|
||||
assertEquals(50, diskStore.getQueueSize());
|
||||
assertTrue(diskStore.getAutoCompact());
|
||||
assertEquals(DiskStoreFactory.DEFAULT_COMPACTION_THRESHOLD, diskStore.getCompactionThreshold());
|
||||
assertEquals(9999, diskStore.getTimeInterval());
|
||||
assertEquals(1, diskStore.getMaxOplogSize());
|
||||
assertEquals(diskStoreDirectory, diskStore.getDiskDirs()[0]);
|
||||
assertThat(diskStore).isNotNull();
|
||||
assertThat(diskStore.getName()).isEqualTo("diskStore1");
|
||||
assertThat(diskStore.getQueueSize()).isEqualTo(50);
|
||||
assertThat(diskStore.getAutoCompact()).isTrue();
|
||||
assertThat(diskStore.getCompactionThreshold()).isEqualTo(DiskStoreFactory.DEFAULT_COMPACTION_THRESHOLD);
|
||||
assertThat(diskStore.getTimeInterval()).isEqualTo(9999);
|
||||
assertThat(diskStore.getMaxOplogSize()).isEqualTo(1);
|
||||
assertThat(diskStore.getDiskDirs()[0]).isEqualTo(diskStoreDirectory);
|
||||
Cache cache = applicationContext.getBean("gemfireCache", Cache.class);
|
||||
assertSame(diskStore, cache.findDiskStore("diskStore1"));
|
||||
assertThat(cache.findDiskStore("diskStore1")).isSameAs(diskStore);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testReplicatedDataRegionAttributes() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("replicated-data"));
|
||||
assertThat(applicationContext.containsBean("replicated-data")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean replicatedDataRegionFactoryBean = applicationContext.getBean("&replicated-data", PeerRegionFactoryBean.class);
|
||||
|
||||
assertTrue(replicatedDataRegionFactoryBean instanceof ReplicatedRegionFactoryBean);
|
||||
assertEquals(DataPolicy.REPLICATE, replicatedDataRegionFactoryBean.getDataPolicy());
|
||||
assertFalse(replicatedDataRegionFactoryBean.getDataPolicy().withPersistence());
|
||||
assertEquals("diskStore1", TestUtils.readField("diskStoreName", replicatedDataRegionFactoryBean));
|
||||
assertNull(TestUtils.readField("scope", replicatedDataRegionFactoryBean));
|
||||
assertThat(replicatedDataRegionFactoryBean instanceof ReplicatedRegionFactoryBean).isTrue();
|
||||
assertThat(replicatedDataRegionFactoryBean.getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(replicatedDataRegionFactoryBean.getDataPolicy().withPersistence()).isFalse();
|
||||
assertThat(TestUtils.<String>readField("diskStoreName", replicatedDataRegionFactoryBean)).isEqualTo("diskStore1");
|
||||
assertThat(TestUtils.<Object>readField("scope", replicatedDataRegionFactoryBean)).isNull();
|
||||
|
||||
Region replicatedDataRegion = applicationContext.getBean("replicated-data", Region.class);
|
||||
|
||||
RegionAttributes replicatedDataRegionAttributes = TestUtils.readField("attributes", replicatedDataRegionFactoryBean);
|
||||
|
||||
assertNotNull(replicatedDataRegionAttributes);
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, replicatedDataRegionAttributes.getScope());
|
||||
assertThat(replicatedDataRegionAttributes).isNotNull();
|
||||
assertThat(replicatedDataRegionAttributes.getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
|
||||
EvictionAttributes replicatedDataEvictionAttributes = replicatedDataRegionAttributes.getEvictionAttributes();
|
||||
|
||||
assertNotNull(replicatedDataEvictionAttributes);
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, replicatedDataEvictionAttributes.getAction());
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, replicatedDataEvictionAttributes.getAlgorithm());
|
||||
assertEquals(50, replicatedDataEvictionAttributes.getMaximum());
|
||||
assertNull(replicatedDataEvictionAttributes.getObjectSizer());
|
||||
assertThat(replicatedDataEvictionAttributes).isNotNull();
|
||||
assertThat(replicatedDataEvictionAttributes.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(replicatedDataEvictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY);
|
||||
assertThat(replicatedDataEvictionAttributes.getMaximum()).isEqualTo(50);
|
||||
assertThat(replicatedDataEvictionAttributes.getObjectSizer()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testPartitionDataOptions() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("partition-data"));
|
||||
PeerRegionFactoryBean fb = applicationContext.getBean("&partition-data", PeerRegionFactoryBean.class);
|
||||
assertTrue(fb instanceof PartitionedRegionFactoryBean);
|
||||
assertTrue(TestUtils.readField("persistent", fb));
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
assertThat(applicationContext.containsBean("partition-data")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean regionFactoryBean = applicationContext.getBean("&partition-data", PeerRegionFactoryBean.class);
|
||||
|
||||
assertThat(regionFactoryBean instanceof PartitionedRegionFactoryBean).isTrue();
|
||||
assertThat(TestUtils.<Boolean>readField("persistent", regionFactoryBean)).isTrue();
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", regionFactoryBean);
|
||||
|
||||
EvictionAttributes evicAttr = attrs.getEvictionAttributes();
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, evicAttr.getAction());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, evicAttr.getAlgorithm());
|
||||
|
||||
assertThat(evicAttr.getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
assertThat(evicAttr.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
|
||||
ObjectSizer sizer = evicAttr.getObjectSizer();
|
||||
assertEquals(SimpleObjectSizer.class, sizer.getClass());
|
||||
|
||||
assertThat(sizer.getClass()).isEqualTo(SimpleObjectSizer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testEntryTtl() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("replicated-data"));
|
||||
assertThat(applicationContext.containsBean("replicated-data")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean fb = applicationContext.getBean("&replicated-data", PeerRegionFactoryBean.class);
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
|
||||
ExpirationAttributes entryTTL = attrs.getEntryTimeToLive();
|
||||
assertEquals(100, entryTTL.getTimeout());
|
||||
assertEquals(ExpirationAction.DESTROY, entryTTL.getAction());
|
||||
assertThat(entryTTL.getTimeout()).isEqualTo(100);
|
||||
assertThat(entryTTL.getAction()).isEqualTo(ExpirationAction.DESTROY);
|
||||
|
||||
ExpirationAttributes entryTTI = attrs.getEntryIdleTimeout();
|
||||
assertEquals(200, entryTTI.getTimeout());
|
||||
assertEquals(ExpirationAction.INVALIDATE, entryTTI.getAction());
|
||||
assertThat(entryTTI.getTimeout()).isEqualTo(200);
|
||||
assertThat(entryTTI.getAction()).isEqualTo(ExpirationAction.INVALIDATE);
|
||||
|
||||
ExpirationAttributes regionTTL = attrs.getRegionTimeToLive();
|
||||
assertEquals(300, regionTTL.getTimeout());
|
||||
assertEquals(ExpirationAction.DESTROY, regionTTL.getAction());
|
||||
assertThat(regionTTL.getTimeout()).isEqualTo(300);
|
||||
assertThat(regionTTL.getAction()).isEqualTo(ExpirationAction.DESTROY);
|
||||
|
||||
ExpirationAttributes regionTTI = attrs.getRegionIdleTimeout();
|
||||
assertEquals(400, regionTTI.getTimeout());
|
||||
assertEquals(ExpirationAction.INVALIDATE, regionTTI.getAction());
|
||||
assertThat(regionTTI.getTimeout()).isEqualTo(400);
|
||||
assertThat(regionTTI.getAction()).isEqualTo(ExpirationAction.INVALIDATE);
|
||||
}
|
||||
|
||||
|
||||
@@ -207,16 +207,16 @@ public class DiskStoreEvictionAndExpirationRegionParsingIntegrationTests extends
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testCustomExpiry() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("replicated-data-custom-expiry"));
|
||||
assertThat(applicationContext.containsBean("replicated-data-custom-expiry")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean fb = applicationContext.getBean("&replicated-data-custom-expiry", PeerRegionFactoryBean.class);
|
||||
RegionAttributes attrs = TestUtils.readField("attributes", fb);
|
||||
|
||||
assertNotNull(attrs.getCustomEntryIdleTimeout());
|
||||
assertNotNull(attrs.getCustomEntryTimeToLive());
|
||||
assertThat(attrs.getCustomEntryIdleTimeout()).isNotNull();
|
||||
assertThat(attrs.getCustomEntryTimeToLive()).isNotNull();
|
||||
|
||||
assertTrue(attrs.getCustomEntryIdleTimeout() instanceof TestCustomExpiry);
|
||||
assertTrue(attrs.getCustomEntryTimeToLive() instanceof TestCustomExpiry);
|
||||
assertThat(attrs.getCustomEntryIdleTimeout() instanceof TestCustomExpiry).isTrue();
|
||||
assertThat(attrs.getCustomEntryTimeToLive() instanceof TestCustomExpiry).isTrue();
|
||||
}
|
||||
|
||||
public static class TestCustomExpiry<K,V> implements CustomExpiry<K,V> {
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -55,9 +54,9 @@ public class FunctionServiceNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
@Test
|
||||
public void testFunctionsRegistered() {
|
||||
|
||||
assertEquals(2, FunctionService.getRegisteredFunctions().size());
|
||||
assertNotNull(FunctionService.getFunction("function1"));
|
||||
assertNotNull(FunctionService.getFunction("function2"));
|
||||
assertThat(FunctionService.getRegisteredFunctions().size()).isEqualTo(2);
|
||||
assertThat(FunctionService.getFunction("function1")).isNotNull();
|
||||
assertThat(FunctionService.getFunction("function2")).isNotNull();
|
||||
}
|
||||
|
||||
public static class Function1 implements Function<Object> {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -34,22 +33,6 @@ import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApp
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests with test cases testing the functionality of GemFire Index creation using
|
||||
* the Spring Data for Apache Geode XML namespace (XSD) configuration metadata and the {@link IndexParser}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.IndexFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.xml.IndexParser
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "index-ns.xml", initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
@@ -69,11 +52,11 @@ public class IndexNamespaceIntegrationTests extends IntegrationTestsSupport {
|
||||
@Test
|
||||
public void basicIndexIsCorrect() {
|
||||
|
||||
assertEquals("basic", basic.getName());
|
||||
assertEquals("status", basic.getIndexedExpression());
|
||||
assertEquals(Region.SEPARATOR + TEST_REGION_NAME, basic.getFromClause());
|
||||
assertEquals(TEST_REGION_NAME, basic.getRegion().getName());
|
||||
assertEquals(org.apache.geode.cache.query.IndexType.FUNCTIONAL, basic.getType());
|
||||
assertThat(basic.getName()).isEqualTo("basic");
|
||||
assertThat(basic.getIndexedExpression()).isEqualTo("status");
|
||||
assertThat(basic.getFromClause()).isEqualTo(Region.SEPARATOR + TEST_REGION_NAME);
|
||||
assertThat(basic.getRegion().getName()).isEqualTo(TEST_REGION_NAME);
|
||||
assertThat(basic.getType()).isEqualTo(org.apache.geode.cache.query.IndexType.FUNCTIONAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,11 +71,11 @@ public class IndexNamespaceIntegrationTests extends IntegrationTestsSupport {
|
||||
@Test
|
||||
public void complexIndexIsCorrect() {
|
||||
|
||||
assertEquals("complex-index", complex.getName());
|
||||
assertEquals("tsi.name", complex.getIndexedExpression());
|
||||
assertEquals(Region.SEPARATOR + TEST_REGION_NAME + " tsi", complex.getFromClause());
|
||||
assertEquals(TEST_REGION_NAME, complex.getRegion().getName());
|
||||
assertEquals(org.apache.geode.cache.query.IndexType.HASH, complex.getType());
|
||||
assertThat(complex.getName()).isEqualTo("complex-index");
|
||||
assertThat(complex.getIndexedExpression()).isEqualTo("tsi.name");
|
||||
assertThat(complex.getFromClause()).isEqualTo(Region.SEPARATOR + TEST_REGION_NAME + " tsi");
|
||||
assertThat(complex.getRegion().getName()).isEqualTo(TEST_REGION_NAME);
|
||||
assertThat(complex.getType()).isEqualTo(org.apache.geode.cache.query.IndexType.HASH);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -13,30 +13,37 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.gemfire.PeerRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.RegionAttributesFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
|
||||
/**
|
||||
* The InvalidRegionDefinitionUsingBeansNamespaceTest class is a test suite of test cases testing the definition of
|
||||
* invalid Region beans in a Spring context. Specifically, this test class tests the specification of the Region's
|
||||
* DataPolicy on a nested RegionAttributesFactoryBean conflicting with the 'persistent' attribute configuration
|
||||
* on the containing RegionFactoryBean definition.
|
||||
* Integration Tests testing the definition of invalid {@link Region} beans in a Spring context.
|
||||
*
|
||||
* Specifically, this test class tests the specification of the {@link Region} {@link DataPolicy}
|
||||
* on a nested {@link RegionAttributesFactoryBean} conflicting with the {@literal persistent} attribute
|
||||
* configuration on the containing {@link ClientRegionFactoryBean} and {@link PeerRegionFactoryBean} definitions.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see PeerRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.PeerRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class InvalidRegionDefinitionUsingBeansNamespaceTest {
|
||||
public class InvalidRegionDefinitionUsingBeansNamespaceIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
private static final String CONFIG_LOCATION =
|
||||
"org/springframework/data/gemfire/config/xml/InvalidDataPolicyPersistentAttributeSettingsBeansNamespaceTest.xml";
|
||||
@@ -49,9 +56,9 @@ public class InvalidRegionDefinitionUsingBeansNamespaceTest {
|
||||
}
|
||||
catch (BeanCreationException expected) {
|
||||
|
||||
assertTrue(expected.getCause() instanceof IllegalArgumentException);
|
||||
assertEquals("Data Policy [REPLICATE] is not valid when persistent is true",
|
||||
expected.getCause().getMessage());
|
||||
assertThat(expected.getCause() instanceof IllegalArgumentException).isTrue();
|
||||
assertThat(expected.getCause().getMessage())
|
||||
.isEqualTo("Data Policy [REPLICATE] is not valid when persistent is true");
|
||||
|
||||
throw (IllegalArgumentException) expected.getCause();
|
||||
}
|
||||
@@ -13,11 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -26,33 +24,40 @@ import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.internal.datasource.GemFireBasicDataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests for Apache Geode JNDI context bindings.
|
||||
*
|
||||
* This test requires a real cache
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("jndi-binding-ns.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class JndiBindingsTest {
|
||||
public class JndiBindingsIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Test
|
||||
public void testJndiBindings() throws Exception {
|
||||
|
||||
Object dataSourceObject = cache.getJNDIContext().lookup("java:/SimpleDataSource");
|
||||
|
||||
assertTrue(dataSourceObject instanceof GemFireBasicDataSource);
|
||||
assertThat(dataSourceObject instanceof GemFireBasicDataSource).isTrue();
|
||||
|
||||
GemFireBasicDataSource dataSource = (GemFireBasicDataSource) dataSourceObject;
|
||||
|
||||
assertEquals("org.apache.derby.jdbc.EmbeddedDriver", dataSource.getJDBCDriver());
|
||||
assertEquals(60, dataSource.getLoginTimeout());
|
||||
assertThat(dataSource.getJDBCDriver()).isEqualTo("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
assertThat(dataSource.getLoginTimeout()).isEqualTo(60);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.config.xml;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.internal.datasource.ConfigProperty;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests testing the configuration of a cache JNDI DataSource using property placeholders.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "jndi-binding-with-property-placeholders-ns.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
public class JndiBindingsPropertyPlaceholderIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("unused")
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
protected void assertPropertyValueExists(String expectedPropertyName, String expectedPropertyValue,
|
||||
List<ConfigProperty> properties) {
|
||||
|
||||
for (ConfigProperty property : properties) {
|
||||
if (expectedPropertyName.equals(property.getName())) {
|
||||
assertThat(property.getValue()).isEqualTo(expectedPropertyValue);
|
||||
assertThat(property.getType()).isEqualTo(String.class.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fail("ConfigProperty with name [%1$s] was not found!", expectedPropertyName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheJndiDataSourceConfiguration() {
|
||||
|
||||
CacheFactoryBean factory = applicationContext.getBean("&gemfireCache", CacheFactoryBean.class);
|
||||
|
||||
List<CacheFactoryBean.JndiDataSource> jndiDataSources = factory.getJndiDataSources();
|
||||
|
||||
assertThat(jndiDataSources).isNotNull();
|
||||
assertThat(jndiDataSources.size()).isEqualTo(1);
|
||||
|
||||
CacheFactoryBean.JndiDataSource dataSource = jndiDataSources.get(0);
|
||||
|
||||
assertThat(dataSource).isNotNull();
|
||||
|
||||
Map<String, String> attributes = dataSource.getAttributes();
|
||||
|
||||
assertThat(attributes).isNotNull();
|
||||
assertThat(attributes.isEmpty()).isFalse();
|
||||
assertThat(attributes.get("jndi-name")).isEqualTo("testDataSource");
|
||||
assertThat(attributes.get("type")).isEqualTo("XAPooledDataSource");
|
||||
assertThat(attributes.get("blocking-timeout-seconds")).isEqualTo("60");
|
||||
assertThat(attributes.get("conn-pooled-datasource-class"))
|
||||
.isEqualTo("org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource");
|
||||
assertThat(attributes.get("connection-url")).isEqualTo("jdbc:derby:testDataStore;create=true");
|
||||
assertThat(attributes.get("idle-timeout-seconds")).isEqualTo("180");
|
||||
assertThat(attributes.get("init-pool-size")).isEqualTo("10");
|
||||
assertThat(attributes.get("jdbc-driver-class")).isEqualTo("org.apache.derby.jdbc.EmbeddedDriver");
|
||||
assertThat(attributes.get("login-timeout-seconds")).isEqualTo("30");
|
||||
assertThat(attributes.get("managed-connection-factory-class"))
|
||||
.isEqualTo("org.apache.derby.jdbc.NonExistingManagedConnectionFactoryClass");
|
||||
assertThat(attributes.get("max-pool-size")).isEqualTo("50");
|
||||
assertThat(attributes.get("password")).isEqualTo("test123");
|
||||
assertThat(attributes.get("transaction-type")).isEqualTo("XATransaction");
|
||||
assertThat(attributes.get("user-name")).isEqualTo("masterdba");
|
||||
assertThat(attributes.get("xa-datasource-class")).isEqualTo("org.apache.derby.jdbc.EmbeddedXADataSource");
|
||||
|
||||
List<ConfigProperty> props = dataSource.getProps();
|
||||
|
||||
assertThat(props).isNotNull();
|
||||
assertThat(props.isEmpty()).isFalse();
|
||||
assertPropertyValueExists("schemaName", "testSchema", props);
|
||||
assertPropertyValueExists("databaseName", "testDataStore", props);
|
||||
assertPropertyValueExists("description", "test", props);
|
||||
assertPropertyValueExists("email", "masterdba@xcompany.com", props);
|
||||
assertPropertyValueExists("phone", "501-555-1234", props);
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.internal.datasource.ConfigProperty;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* The JndiBindingsPropertyPlaceholderTest class is a test suite of test cases testing the configuration of a GemFire
|
||||
* Cache JNDI DataSource using property placeholders.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.4.0
|
||||
* @since 7.0.1 (GemFire)
|
||||
*/
|
||||
@ContextConfiguration(locations = "jndi-binding-with-property-placeholders-ns.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JndiBindingsPropertyPlaceholderTest {
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("unused")
|
||||
private ApplicationContext context;
|
||||
|
||||
protected void assertPropertyValueExists(final String expectedPropertyName, final String expectedPropertyValue,
|
||||
final List<ConfigProperty> properties) {
|
||||
for (ConfigProperty property : properties) {
|
||||
if (expectedPropertyName.equals(property.getName())) {
|
||||
assertEquals(expectedPropertyValue, property.getValue());
|
||||
assertEquals(String.class.getName(), property.getType());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fail(String.format("ConfigProperty with name [%1$s] was not found!", expectedPropertyName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheJndiDataSourceConfiguration() {
|
||||
CacheFactoryBean factory = context.getBean("&gemfireCache", CacheFactoryBean.class);
|
||||
|
||||
List<CacheFactoryBean.JndiDataSource> jndiDataSources = factory.getJndiDataSources();
|
||||
|
||||
assertNotNull(jndiDataSources);
|
||||
assertEquals(1, jndiDataSources.size());
|
||||
|
||||
CacheFactoryBean.JndiDataSource dataSource = jndiDataSources.get(0);
|
||||
|
||||
assertNotNull(dataSource);
|
||||
|
||||
Map<String, String> attributes = dataSource.getAttributes();
|
||||
|
||||
assertNotNull(attributes);
|
||||
assertFalse(attributes.isEmpty());
|
||||
assertEquals("testDataSource", attributes.get("jndi-name"));
|
||||
assertEquals("XAPooledDataSource", attributes.get("type"));
|
||||
assertEquals("60", attributes.get("blocking-timeout-seconds"));
|
||||
assertEquals("org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource", attributes.get("conn-pooled-datasource-class"));
|
||||
assertEquals("jdbc:derby:testDataStore;create=true", attributes.get("connection-url"));
|
||||
assertEquals("180", attributes.get("idle-timeout-seconds"));
|
||||
assertEquals("10", attributes.get("init-pool-size"));
|
||||
assertEquals("org.apache.derby.jdbc.EmbeddedDriver", attributes.get("jdbc-driver-class"));
|
||||
assertEquals("30", attributes.get("login-timeout-seconds"));
|
||||
assertEquals("org.apache.derby.jdbc.NonExistingManagedConnectionFactoryClass", attributes.get("managed-connection-factory-class"));
|
||||
assertEquals("50", attributes.get("max-pool-size"));
|
||||
assertEquals("test123", attributes.get("password"));
|
||||
assertEquals("XATransaction", attributes.get("transaction-type"));
|
||||
assertEquals("masterdba", attributes.get("user-name"));
|
||||
assertEquals("org.apache.derby.jdbc.EmbeddedXADataSource", attributes.get("xa-datasource-class"));
|
||||
|
||||
List<ConfigProperty> props = dataSource.getProps();
|
||||
|
||||
assertNotNull(props);
|
||||
assertFalse(props.isEmpty());
|
||||
assertPropertyValueExists("schemaName", "testSchema", props);
|
||||
assertPropertyValueExists("databaseName", "testDataStore", props);
|
||||
assertPropertyValueExists("description", "test", props);
|
||||
assertPropertyValueExists("email", "masterdba@xcompany.com", props);
|
||||
assertPropertyValueExists("phone", "501-555-1234", props);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,12 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -69,82 +64,90 @@ public class LocalRegionNamespaceIntegrationTests extends IntegrationTestsSuppor
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
public void testSimpleLocalRegion() throws Exception {
|
||||
public void testSimpleLocalRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("simple"));
|
||||
assertThat(applicationContext.containsBean("simple")).isTrue();
|
||||
|
||||
Region<?, ?> simple = applicationContext.getBean("simple", Region.class);
|
||||
|
||||
assertNotNull("The 'simple' Region was not properly configured or initialized!", simple);
|
||||
assertEquals("simple", simple.getName());
|
||||
assertEquals(Region.SEPARATOR + "simple", simple.getFullPath());
|
||||
assertNotNull(simple.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, simple.getAttributes().getDataPolicy());
|
||||
assertThat(simple)
|
||||
.describedAs("The 'simple' Region was not properly configured or initialized!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(simple.getName()).isEqualTo("simple");
|
||||
assertThat(simple.getFullPath()).isEqualTo(Region.SEPARATOR + "simple");
|
||||
assertThat(simple.getAttributes()).isNotNull();
|
||||
assertThat(simple.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
public void testPublisherLocalRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("pub"));
|
||||
assertThat(applicationContext.containsBean("pub")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean publisherRegionFactoryBean = applicationContext.getBean("&pub", PeerRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(publisherRegionFactoryBean);
|
||||
assertEquals(DataPolicy.NORMAL, TestUtils.readField("dataPolicy", publisherRegionFactoryBean));
|
||||
assertEquals("publisher", TestUtils.readField("name", publisherRegionFactoryBean));
|
||||
assertEquals(Scope.LOCAL, TestUtils.readField("scope", publisherRegionFactoryBean));
|
||||
assertThat(publisherRegionFactoryBean).isNotNull();
|
||||
assertThat(TestUtils.<DataPolicy>readField("dataPolicy", publisherRegionFactoryBean)).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(TestUtils.<String>readField("name", publisherRegionFactoryBean)).isEqualTo("publisher");
|
||||
assertThat(TestUtils.<Scope>readField("scope", publisherRegionFactoryBean)).isEqualTo(Scope.LOCAL);
|
||||
|
||||
RegionAttributes publisherRegionAttributes = TestUtils.readField("attributes", publisherRegionFactoryBean);
|
||||
|
||||
assertNotNull(publisherRegionAttributes);
|
||||
assertFalse(publisherRegionAttributes.getPublisher());
|
||||
assertThat(publisherRegionAttributes).isNotNull();
|
||||
assertThat(publisherRegionAttributes.getPublisher()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testComplexLocal() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("complex"));
|
||||
assertThat(applicationContext.containsBean("complex")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean complexRegionFactoryBean = applicationContext.getBean("&complex", PeerRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(complexRegionFactoryBean);
|
||||
assertThat(complexRegionFactoryBean).isNotNull();
|
||||
|
||||
CacheListener[] cacheListeners = TestUtils.readField("cacheListeners", complexRegionFactoryBean);
|
||||
|
||||
assertFalse(ObjectUtils.isEmpty(cacheListeners));
|
||||
assertEquals(2, cacheListeners.length);
|
||||
assertSame(applicationContext.getBean("c-listener"), cacheListeners[0]);
|
||||
assertTrue(cacheListeners[1] instanceof SimpleCacheListener);
|
||||
assertNotSame(cacheListeners[0], cacheListeners[1]);
|
||||
assertSame(applicationContext.getBean("c-loader"), TestUtils.readField("cacheLoader", complexRegionFactoryBean));
|
||||
assertSame(applicationContext.getBean("c-writer"), TestUtils.readField("cacheWriter", complexRegionFactoryBean));
|
||||
assertThat(ObjectUtils.isEmpty(cacheListeners)).isFalse();
|
||||
assertThat(cacheListeners.length).isEqualTo(2);
|
||||
assertThat(cacheListeners[0]).isSameAs(applicationContext.getBean("c-listener"));
|
||||
assertThat(cacheListeners[1] instanceof SimpleCacheListener).isTrue();
|
||||
assertThat(cacheListeners[1]).isNotSameAs(cacheListeners[0]);
|
||||
assertThat(TestUtils.<String>readField("cacheLoader", complexRegionFactoryBean))
|
||||
.isSameAs(applicationContext.getBean("c-loader"));
|
||||
assertThat(TestUtils.<String>readField("cacheWriter", complexRegionFactoryBean))
|
||||
.isSameAs(applicationContext.getBean("c-writer"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testLocalWithAttributes() throws Exception {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void testLocalWithAttributes() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("local-with-attributes"));
|
||||
assertThat(applicationContext.containsBean("local-with-attributes")).isTrue();
|
||||
|
||||
Region region = applicationContext.getBean("local-with-attributes", Region.class);
|
||||
|
||||
assertNotNull("The 'local-with-attributes' Region was not properly configured and initialized!", region);
|
||||
assertEquals("local-with-attributes", region.getName());
|
||||
assertEquals(Region.SEPARATOR + "local-with-attributes", region.getFullPath());
|
||||
assertThat(region)
|
||||
.describedAs("The 'local-with-attributes' Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(region.getName()).isEqualTo("local-with-attributes");
|
||||
assertThat(region.getFullPath()).isEqualTo(Region.SEPARATOR + "local-with-attributes");
|
||||
|
||||
RegionAttributes localRegionAttributes = region.getAttributes();
|
||||
|
||||
assertEquals(DataPolicy.PRELOADED, localRegionAttributes.getDataPolicy());
|
||||
assertTrue(localRegionAttributes.isDiskSynchronous());
|
||||
assertTrue(localRegionAttributes.getIgnoreJTA());
|
||||
assertFalse(localRegionAttributes.getIndexMaintenanceSynchronous());
|
||||
assertEquals(10, localRegionAttributes.getInitialCapacity());
|
||||
assertEquals(String.class, localRegionAttributes.getKeyConstraint());
|
||||
assertEquals("0.9", String.valueOf(localRegionAttributes.getLoadFactor()));
|
||||
assertTrue(localRegionAttributes.getOffHeap());
|
||||
assertEquals(String.class, localRegionAttributes.getValueConstraint());
|
||||
assertThat(localRegionAttributes.getDataPolicy()).isEqualTo(DataPolicy.PRELOADED);
|
||||
assertThat(localRegionAttributes.isDiskSynchronous()).isTrue();
|
||||
assertThat(localRegionAttributes.getIgnoreJTA()).isTrue();
|
||||
assertThat(localRegionAttributes.getIndexMaintenanceSynchronous()).isFalse();
|
||||
assertThat(localRegionAttributes.getInitialCapacity()).isEqualTo(10);
|
||||
assertThat(localRegionAttributes.getKeyConstraint()).isEqualTo(String.class);
|
||||
assertThat(String.valueOf(localRegionAttributes.getLoadFactor())).isEqualTo("0.9");
|
||||
assertThat(localRegionAttributes.getOffHeap()).isTrue();
|
||||
assertThat(localRegionAttributes.getValueConstraint()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,45 +158,49 @@ public class LocalRegionNamespaceIntegrationTests extends IntegrationTestsSuppor
|
||||
|
||||
Region existing = cache.createRegionFactory().create("existing");
|
||||
|
||||
assertTrue(applicationContext.containsBean("lookup"));
|
||||
assertThat(applicationContext.containsBean("lookup")).isTrue();
|
||||
|
||||
ResolvableRegionFactoryBean localRegionFactoryBean = applicationContext.getBean("&lookup", ResolvableRegionFactoryBean.class);
|
||||
|
||||
assertEquals("existing", TestUtils.readField("name", localRegionFactoryBean));
|
||||
assertSame(existing, applicationContext.getBean("lookup"));
|
||||
assertThat(TestUtils.<String>readField("name", localRegionFactoryBean)).isEqualTo("existing");
|
||||
assertThat(applicationContext.getBean("lookup")).isSameAs(existing);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void testLocalPersistent() {
|
||||
|
||||
Region persistentLocalRegion = applicationContext.getBean("persistent", Region.class);
|
||||
|
||||
assertNotNull("The 'persistent' Local Region was not properly configured and initialized!", persistentLocalRegion);
|
||||
assertEquals("persistent", persistentLocalRegion.getName());
|
||||
assertEquals(Region.SEPARATOR + "persistent", persistentLocalRegion.getFullPath());
|
||||
assertThat(persistentLocalRegion)
|
||||
.describedAs("The 'persistent' Local Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(persistentLocalRegion.getName()).isEqualTo("persistent");
|
||||
assertThat(persistentLocalRegion.getFullPath()).isEqualTo(Region.SEPARATOR + "persistent");
|
||||
|
||||
RegionAttributes persistentRegionAttributes = persistentLocalRegion.getAttributes();
|
||||
|
||||
assertNotNull(persistentRegionAttributes);
|
||||
assertTrue(persistentRegionAttributes.getDataPolicy().withPersistence());
|
||||
assertThat(persistentRegionAttributes).isNotNull();
|
||||
assertThat(persistentRegionAttributes.getDataPolicy().withPersistence()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressedLocalRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("Compressed"));
|
||||
assertThat(applicationContext.containsBean("Compressed")).isTrue();
|
||||
|
||||
Region<?, ?> compressed = applicationContext.getBean("Compressed", Region.class);
|
||||
|
||||
assertNotNull("The 'Compressed' Local Region was not properly configured and initialized!", compressed);
|
||||
assertEquals("Compressed", compressed.getName());
|
||||
assertEquals(Region.SEPARATOR + "Compressed", compressed.getFullPath());
|
||||
assertNotNull(compressed.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, compressed.getAttributes().getDataPolicy());
|
||||
assertEquals(Scope.LOCAL, compressed.getAttributes().getScope());
|
||||
assertTrue(compressed.getAttributes().getCompressor() instanceof TestCompressor);
|
||||
assertEquals("ABC", compressed.getAttributes().getCompressor().toString());
|
||||
assertThat(compressed).as("The 'Compressed' Local Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(compressed.getName()).isEqualTo("Compressed");
|
||||
assertThat(compressed.getFullPath()).isEqualTo(Region.SEPARATOR + "Compressed");
|
||||
assertThat(compressed.getAttributes()).isNotNull();
|
||||
assertThat(compressed.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(compressed.getAttributes().getScope()).isEqualTo(Scope.LOCAL);
|
||||
assertThat(compressed.getAttributes().getCompressor() instanceof TestCompressor).isTrue();
|
||||
assertThat(compressed.getAttributes().getCompressor().toString()).isEqualTo("ABC");
|
||||
}
|
||||
|
||||
public static class TestCompressor implements Compressor {
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -64,39 +63,41 @@ public class LocalRegionWithEvictionPolicyActionNamespaceIntegrationTests extend
|
||||
@Test
|
||||
public void testLocalRegionConfigurationWithEvictionPolicyActionSetToLocalDestroy() {
|
||||
|
||||
assertNotNull("The 'LocalDestroy' Region was not properly configured and initialized!", localDestroyRegion);
|
||||
assertEquals("LocalDestroy", localDestroyRegion.getName());
|
||||
assertEquals("/LocalDestroy", localDestroyRegion.getFullPath());
|
||||
assertNotNull(localDestroyRegion.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, localDestroyRegion.getAttributes().getDataPolicy());
|
||||
assertEquals(Scope.LOCAL, localDestroyRegion.getAttributes().getScope());
|
||||
assertNotNull(localDestroyRegion.getAttributes().getEvictionAttributes());
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, localDestroyRegion.getAttributes().getEvictionAttributes().getAction());
|
||||
assertThat(localDestroyRegion).as("The 'LocalDestroy' Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(localDestroyRegion.getName()).isEqualTo("LocalDestroy");
|
||||
assertThat(localDestroyRegion.getFullPath()).isEqualTo("/LocalDestroy");
|
||||
assertThat(localDestroyRegion.getAttributes()).isNotNull();
|
||||
assertThat(localDestroyRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(localDestroyRegion.getAttributes().getScope()).isEqualTo(Scope.LOCAL);
|
||||
assertThat(localDestroyRegion.getAttributes().getEvictionAttributes()).isNotNull();
|
||||
assertThat(localDestroyRegion.getAttributes().getEvictionAttributes().getAction())
|
||||
.isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalRegionConfigurationWithEvictionPolicyActionSetToNone() {
|
||||
|
||||
assertNotNull("The 'None' Region was not properly configured and initialized!", noneRegion);
|
||||
assertEquals("None", noneRegion.getName());
|
||||
assertEquals("/None", noneRegion.getFullPath());
|
||||
assertNotNull(noneRegion.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, noneRegion.getAttributes().getDataPolicy());
|
||||
assertEquals(Scope.LOCAL, noneRegion.getAttributes().getScope());
|
||||
assertNotNull(noneRegion.getAttributes().getEvictionAttributes());
|
||||
assertEquals(EvictionAction.NONE, noneRegion.getAttributes().getEvictionAttributes().getAction());
|
||||
assertThat(noneRegion).as("The 'None' Region was not properly configured and initialized!").isNotNull();
|
||||
assertThat(noneRegion.getName()).isEqualTo("None");
|
||||
assertThat(noneRegion.getFullPath()).isEqualTo("/None");
|
||||
assertThat(noneRegion.getAttributes()).isNotNull();
|
||||
assertThat(noneRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(noneRegion.getAttributes().getScope()).isEqualTo(Scope.LOCAL);
|
||||
assertThat(noneRegion.getAttributes().getEvictionAttributes()).isNotNull();
|
||||
assertThat(noneRegion.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalRegionConfigurationWithEvictionPolicyActionSetToOverflowToDisk() {
|
||||
|
||||
assertNotNull("The 'Overflow' Region was not properly configured and initialized!", overflowRegion);
|
||||
assertEquals("Overflow", overflowRegion.getName());
|
||||
assertEquals("/Overflow", overflowRegion.getFullPath());
|
||||
assertNotNull(overflowRegion.getAttributes());
|
||||
assertEquals(DataPolicy.NORMAL, overflowRegion.getAttributes().getDataPolicy());
|
||||
assertEquals(Scope.LOCAL, overflowRegion.getAttributes().getScope());
|
||||
assertNotNull(overflowRegion.getAttributes().getEvictionAttributes());
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, overflowRegion.getAttributes().getEvictionAttributes().getAction());
|
||||
assertThat(overflowRegion).as("The 'Overflow' Region was not properly configured and initialized!").isNotNull();
|
||||
assertThat(overflowRegion.getName()).isEqualTo("Overflow");
|
||||
assertThat(overflowRegion.getFullPath()).isEqualTo("/Overflow");
|
||||
assertThat(overflowRegion.getAttributes()).isNotNull();
|
||||
assertThat(overflowRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(overflowRegion.getAttributes().getScope()).isEqualTo(Scope.LOCAL);
|
||||
assertThat(overflowRegion.getAttributes().getEvictionAttributes()).isNotNull();
|
||||
assertThat(overflowRegion.getAttributes().getEvictionAttributes().getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,26 +12,37 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
|
||||
/**
|
||||
* Integration Tests for multiple Apache Geode {@link GemFireCache caches}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.context.ConfigurableApplicationContext
|
||||
* @see org.springframework.context.support.ClassPathXmlApplicationContext
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
*/
|
||||
public class MultipleCacheTest {
|
||||
|
||||
public class MultipleCacheIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Test
|
||||
public void testMultipleCaches() {
|
||||
|
||||
String configLocation = "/org/springframework/data/gemfire/config/xml/MultipleCacheTest-context.xml";
|
||||
|
||||
ConfigurableApplicationContext context1 = new ClassPathXmlApplicationContext(configLocation);
|
||||
@@ -40,21 +51,20 @@ public class MultipleCacheTest {
|
||||
Cache cache1 = context1.getBean(Cache.class);
|
||||
Cache cache2 = context2.getBean(Cache.class);
|
||||
|
||||
assertNotNull(cache1);
|
||||
assertSame(cache1, cache2);
|
||||
assertThat(cache1).isNotNull();
|
||||
assertThat(cache2).isSameAs(cache1);
|
||||
|
||||
Region region1 = context1.getBean(Region.class);
|
||||
Region region2 = context2.getBean(Region.class);
|
||||
Region<?, ?> region1 = context1.getBean(Region.class);
|
||||
Region<?, ?> region2 = context2.getBean(Region.class);
|
||||
|
||||
assertNotNull(region1);
|
||||
assertSame(region1, region2);
|
||||
assertFalse(cache1.isClosed());
|
||||
assertFalse(region1.isDestroyed());
|
||||
assertThat(region1).isNotNull();
|
||||
assertThat(region2).isSameAs(region1);
|
||||
assertThat(cache1.isClosed()).isFalse();
|
||||
assertThat(region1.isDestroyed()).isFalse();
|
||||
|
||||
context1.close();
|
||||
|
||||
assertFalse(cache1.isClosed());
|
||||
assertFalse("region was destroyed", region1.isDestroyed());
|
||||
assertThat(cache1.isClosed()).isFalse();
|
||||
assertThat(region1.isDestroyed()).as("region was destroyed").isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,12 +16,6 @@
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -79,23 +73,23 @@ public class PartitionedRegionNamespaceIntegrationTests extends IntegrationTests
|
||||
@Test
|
||||
public void testSimplePartitionRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("simple"));
|
||||
assertThat(applicationContext.containsBean("simple")).isTrue();
|
||||
|
||||
Region<?, ?> simple = applicationContext.getBean("simple", Region.class);
|
||||
|
||||
assertNotNull(simple);
|
||||
assertEquals("simple", simple.getName());
|
||||
assertEquals(Region.SEPARATOR + "simple", simple.getFullPath());
|
||||
assertNotNull(simple.getAttributes());
|
||||
assertEquals(DataPolicy.PARTITION, simple.getAttributes().getDataPolicy());
|
||||
assertThat(simple).isNotNull();
|
||||
assertThat(simple.getName()).isEqualTo("simple");
|
||||
assertThat(simple.getFullPath()).isEqualTo(Region.SEPARATOR + "simple");
|
||||
assertThat(simple.getAttributes()).isNotNull();
|
||||
assertThat(simple.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testOptionsPartitionRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("options"));
|
||||
assertTrue(applicationContext.containsBean("redundant"));
|
||||
assertThat(applicationContext.containsBean("options")).isTrue();
|
||||
assertThat(applicationContext.containsBean("redundant")).isTrue();
|
||||
|
||||
Region<?, ?> options = applicationContext.getBean("options", Region.class);
|
||||
|
||||
@@ -106,70 +100,74 @@ public class PartitionedRegionNamespaceIntegrationTests extends IntegrationTests
|
||||
|
||||
PeerRegionFactoryBean optionsRegionFactoryBean = applicationContext.getBean("&options", PeerRegionFactoryBean.class);
|
||||
|
||||
assertTrue(optionsRegionFactoryBean instanceof PartitionedRegionFactoryBean);
|
||||
assertNull(TestUtils.readField("scope", optionsRegionFactoryBean));
|
||||
assertEquals("redundant", TestUtils.readField("name", optionsRegionFactoryBean));
|
||||
assertNull(TestUtils.readField("scope", optionsRegionFactoryBean));
|
||||
assertThat(optionsRegionFactoryBean instanceof PartitionedRegionFactoryBean).isTrue();
|
||||
assertThat(TestUtils.<Object>readField("scope", optionsRegionFactoryBean)).isNull();
|
||||
assertThat(TestUtils.<Object>readField("name", optionsRegionFactoryBean)).isEqualTo("redundant");
|
||||
assertThat(TestUtils.<Object>readField("scope", optionsRegionFactoryBean)).isNull();
|
||||
|
||||
RegionAttributes optionsRegionAttributes = optionsRegionFactoryBean.getAttributes();
|
||||
|
||||
assertNotNull(optionsRegionAttributes);
|
||||
assertTrue(optionsRegionAttributes.getOffHeap());
|
||||
assertTrue(optionsRegionAttributes.getStatisticsEnabled());
|
||||
assertThat(optionsRegionAttributes).isNotNull();
|
||||
assertThat(optionsRegionAttributes.getOffHeap()).isTrue();
|
||||
assertThat(optionsRegionAttributes.getStatisticsEnabled()).isTrue();
|
||||
|
||||
PartitionAttributes optionsRegionPartitionAttributes = optionsRegionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(optionsRegionPartitionAttributes);
|
||||
assertEquals(1, optionsRegionPartitionAttributes.getRedundantCopies());
|
||||
assertEquals(4, optionsRegionPartitionAttributes.getTotalNumBuckets());
|
||||
assertTrue(optionsRegionPartitionAttributes.getPartitionResolver() instanceof SimplePartitionResolver);
|
||||
assertThat(optionsRegionPartitionAttributes).isNotNull();
|
||||
assertThat(optionsRegionPartitionAttributes.getRedundantCopies()).isEqualTo(1);
|
||||
assertThat(optionsRegionPartitionAttributes.getTotalNumBuckets()).isEqualTo(4);
|
||||
assertThat(optionsRegionPartitionAttributes.getPartitionResolver() instanceof SimplePartitionResolver).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testComplexPartitionRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("complex"));
|
||||
assertThat(applicationContext.containsBean("complex")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean complexRegionFactoryBean = applicationContext.getBean("&complex", PeerRegionFactoryBean.class);
|
||||
|
||||
CacheListener[] cacheListeners = TestUtils.readField("cacheListeners", complexRegionFactoryBean);
|
||||
|
||||
assertFalse(ObjectUtils.isEmpty(cacheListeners));
|
||||
assertEquals(2, cacheListeners.length);
|
||||
assertSame(cacheListeners[0], applicationContext.getBean("c-listener"));
|
||||
assertTrue(cacheListeners[1] instanceof SimpleCacheListener);
|
||||
assertThat(ObjectUtils.isEmpty(cacheListeners)).isFalse();
|
||||
assertThat(cacheListeners.length).isEqualTo(2);
|
||||
assertThat(applicationContext.getBean("c-listener")).isSameAs(cacheListeners[0]);
|
||||
assertThat(cacheListeners[1] instanceof SimpleCacheListener).isTrue();
|
||||
|
||||
assertSame(applicationContext.getBean("c-loader"), TestUtils.readField("cacheLoader", complexRegionFactoryBean));
|
||||
assertSame(applicationContext.getBean("c-writer"), TestUtils.readField("cacheWriter", complexRegionFactoryBean));
|
||||
assertThat(TestUtils.<Object>readField("cacheLoader", complexRegionFactoryBean))
|
||||
.isSameAs(applicationContext.getBean("c-loader"));
|
||||
assertThat(TestUtils.<Object>readField("cacheWriter", complexRegionFactoryBean))
|
||||
.isSameAs(applicationContext.getBean("c-writer"));
|
||||
|
||||
RegionAttributes complexRegionAttributes = TestUtils.readField("attributes", complexRegionFactoryBean);
|
||||
|
||||
assertNotNull(complexRegionAttributes);
|
||||
assertThat(complexRegionAttributes).isNotNull();
|
||||
|
||||
PartitionAttributes complexRegionPartitionAttributes = complexRegionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(complexRegionPartitionAttributes);
|
||||
assertEquals(20, complexRegionPartitionAttributes.getLocalMaxMemory());
|
||||
assertNotNull(complexRegionPartitionAttributes.getPartitionListeners());
|
||||
assertEquals(1, complexRegionPartitionAttributes.getPartitionListeners().length);
|
||||
assertTrue(complexRegionPartitionAttributes.getPartitionListeners()[0] instanceof TestPartitionListener);
|
||||
assertThat(complexRegionPartitionAttributes).isNotNull();
|
||||
assertThat(complexRegionPartitionAttributes.getLocalMaxMemory()).isEqualTo(20);
|
||||
assertThat(complexRegionPartitionAttributes.getPartitionListeners()).isNotNull();
|
||||
assertThat(complexRegionPartitionAttributes.getPartitionListeners().length).isEqualTo(1);
|
||||
assertThat(complexRegionPartitionAttributes.getPartitionListeners()[0] instanceof TestPartitionListener)
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressedPartitionRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("compressed"));
|
||||
assertThat(applicationContext.containsBean("compressed")).isTrue();
|
||||
|
||||
Region<?, ?> compressed = applicationContext.getBean("compressed", Region.class);
|
||||
|
||||
assertNotNull("The 'compressed' PARTITION Region was not properly configured and initialized!", compressed);
|
||||
assertEquals("compressed", compressed.getName());
|
||||
assertEquals(Region.SEPARATOR + "compressed", compressed.getFullPath());
|
||||
assertNotNull(compressed.getAttributes());
|
||||
assertEquals(DataPolicy.PARTITION, compressed.getAttributes().getDataPolicy());
|
||||
assertTrue(compressed.getAttributes().getCompressor() instanceof TestCompressor);
|
||||
assertEquals("testCompressor", compressed.getAttributes().getCompressor().toString());
|
||||
assertThat(compressed).as("The 'compressed' PARTITION Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(compressed.getName()).isEqualTo("compressed");
|
||||
assertThat(compressed.getFullPath()).isEqualTo(Region.SEPARATOR + "compressed");
|
||||
assertThat(compressed.getAttributes()).isNotNull();
|
||||
assertThat(compressed.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
assertThat(compressed.getAttributes().getCompressor() instanceof TestCompressor).isTrue();
|
||||
assertThat(compressed.getAttributes().getCompressor().toString()).isEqualTo("testCompressor");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -178,73 +176,75 @@ public class PartitionedRegionNamespaceIntegrationTests extends IntegrationTests
|
||||
|
||||
PeerRegionFactoryBean fixedRegionFactoryBean = applicationContext.getBean("&fixed", PeerRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(fixedRegionFactoryBean);
|
||||
assertThat(fixedRegionFactoryBean).isNotNull();
|
||||
|
||||
RegionAttributes fixedRegionAttributes = TestUtils.readField("attributes", fixedRegionFactoryBean);
|
||||
|
||||
assertNotNull(fixedRegionAttributes);
|
||||
assertThat(fixedRegionAttributes).isNotNull();
|
||||
|
||||
PartitionAttributes fixedRegionPartitionAttributes = fixedRegionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(fixedRegionPartitionAttributes);
|
||||
assertThat(fixedRegionPartitionAttributes).isNotNull();
|
||||
|
||||
assertNotNull(fixedRegionPartitionAttributes.getFixedPartitionAttributes());
|
||||
assertEquals(3, fixedRegionPartitionAttributes.getFixedPartitionAttributes().size());
|
||||
assertThat(fixedRegionPartitionAttributes.getFixedPartitionAttributes()).isNotNull();
|
||||
assertThat(fixedRegionPartitionAttributes.getFixedPartitionAttributes().size()).isEqualTo(3);
|
||||
|
||||
FixedPartitionAttributes fixedPartitionAttributes =
|
||||
(FixedPartitionAttributes) fixedRegionPartitionAttributes.getFixedPartitionAttributes().get(0);
|
||||
|
||||
assertEquals(3, fixedPartitionAttributes.getNumBuckets());
|
||||
assertTrue(fixedPartitionAttributes.isPrimary());
|
||||
assertThat(fixedPartitionAttributes.getNumBuckets()).isEqualTo(3);
|
||||
assertThat(fixedPartitionAttributes.isPrimary()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiplePartitionListeners() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("listeners"));
|
||||
assertThat(applicationContext.containsBean("listeners")).isTrue();
|
||||
|
||||
Region<?, ?> listeners = applicationContext.getBean("listeners", Region.class);
|
||||
|
||||
assertNotNull("The 'listeners' PARTITION Region was not properly configured and initialized!", listeners);
|
||||
assertEquals("listeners", listeners.getName());
|
||||
assertEquals(Region.SEPARATOR + "listeners", listeners.getFullPath());
|
||||
assertNotNull(listeners.getAttributes());
|
||||
assertEquals(DataPolicy.PARTITION, listeners.getAttributes().getDataPolicy());
|
||||
assertThat(listeners).as("The 'listeners' PARTITION Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(listeners.getName()).isEqualTo("listeners");
|
||||
assertThat(listeners.getFullPath()).isEqualTo(Region.SEPARATOR + "listeners");
|
||||
assertThat(listeners.getAttributes()).isNotNull();
|
||||
assertThat(listeners.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
|
||||
PartitionAttributes<?, ?> listenersPartitionAttributes = listeners.getAttributes().getPartitionAttributes();
|
||||
|
||||
assertNotNull(listenersPartitionAttributes);
|
||||
assertNotNull(listenersPartitionAttributes.getPartitionListeners());
|
||||
assertEquals(4, listenersPartitionAttributes.getPartitionListeners().length);
|
||||
assertThat(listenersPartitionAttributes).isNotNull();
|
||||
assertThat(listenersPartitionAttributes.getPartitionListeners()).isNotNull();
|
||||
assertThat(listenersPartitionAttributes.getPartitionListeners().length).isEqualTo(4);
|
||||
|
||||
List<String> expectedNames = Arrays.asList("X", "Y", "Z", "ABC");
|
||||
|
||||
for (PartitionListener listener : listenersPartitionAttributes.getPartitionListeners()) {
|
||||
assertTrue(listener instanceof TestPartitionListener);
|
||||
assertTrue(expectedNames.contains(listener.toString()));
|
||||
assertThat(listener instanceof TestPartitionListener).isTrue();
|
||||
assertThat(expectedNames.contains(listener.toString())).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSinglePartitionListeners() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("listenerRef"));
|
||||
assertThat(applicationContext.containsBean("listenerRef")).isTrue();
|
||||
|
||||
Region<?, ?> listeners = applicationContext.getBean("listenerRef", Region.class);
|
||||
|
||||
assertNotNull("The 'listenerRef' PARTITION Region was not properly configured and initialized!", listeners);
|
||||
assertEquals("listenerRef", listeners.getName());
|
||||
assertEquals(Region.SEPARATOR + "listenerRef", listeners.getFullPath());
|
||||
assertNotNull(listeners.getAttributes());
|
||||
assertEquals(DataPolicy.PARTITION, listeners.getAttributes().getDataPolicy());
|
||||
assertThat(listeners).as("The 'listenerRef' PARTITION Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(listeners.getName()).isEqualTo("listenerRef");
|
||||
assertThat(listeners.getFullPath()).isEqualTo(Region.SEPARATOR + "listenerRef");
|
||||
assertThat(listeners.getAttributes()).isNotNull();
|
||||
assertThat(listeners.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
|
||||
PartitionAttributes<?, ?> listenersPartitionAttributes = listeners.getAttributes().getPartitionAttributes();
|
||||
|
||||
assertNotNull(listenersPartitionAttributes);
|
||||
assertNotNull(listenersPartitionAttributes.getPartitionListeners());
|
||||
assertEquals(1, listenersPartitionAttributes.getPartitionListeners().length);
|
||||
assertTrue(listenersPartitionAttributes.getPartitionListeners()[0] instanceof TestPartitionListener);
|
||||
assertEquals("ABC", listenersPartitionAttributes.getPartitionListeners()[0].toString());
|
||||
assertThat(listenersPartitionAttributes).isNotNull();
|
||||
assertThat(listenersPartitionAttributes.getPartitionListeners()).isNotNull();
|
||||
assertThat(listenersPartitionAttributes.getPartitionListeners().length).isEqualTo(1);
|
||||
assertThat(listenersPartitionAttributes.getPartitionListeners()[0] instanceof TestPartitionListener).isTrue();
|
||||
assertThat(listenersPartitionAttributes.getPartitionListeners()[0].toString()).isEqualTo("ABC");
|
||||
}
|
||||
|
||||
public static class TestCompressor implements Compressor {
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -73,15 +71,15 @@ public class RegionDefinitionUsingBeansNamespaceIntegrationTests extends Integra
|
||||
@Test
|
||||
public void testExampleRegionBeanDefinitionConfiguration() {
|
||||
|
||||
assertNotNull("The '/Example' Region was not properly configured and initialized!", example);
|
||||
assertEquals("Example", example.getName());
|
||||
assertEquals("/Example", example.getFullPath());
|
||||
assertNotNull(example.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, example.getAttributes().getDataPolicy());
|
||||
assertTrue(example.getAttributes().getStatisticsEnabled());
|
||||
assertNotNull(example.getAttributes().getPartitionAttributes());
|
||||
assertEquals(1, example.getAttributes().getPartitionAttributes().getRedundantCopies());
|
||||
assertEquals(0, example.getAttributes().getPartitionAttributes().getRecoveryDelay());
|
||||
assertThat(example).as("The '/Example' Region was not properly configured and initialized!").isNotNull();
|
||||
assertThat(example.getName()).isEqualTo("Example");
|
||||
assertThat(example.getFullPath()).isEqualTo("/Example");
|
||||
assertThat(example.getAttributes()).isNotNull();
|
||||
assertThat(example.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
assertThat(example.getAttributes().getStatisticsEnabled()).isTrue();
|
||||
assertThat(example.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(example.getAttributes().getPartitionAttributes().getRedundantCopies()).isEqualTo(1);
|
||||
assertThat(example.getAttributes().getPartitionAttributes().getRecoveryDelay()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,32 +88,33 @@ public class RegionDefinitionUsingBeansNamespaceIntegrationTests extends Integra
|
||||
PeerRegionFactoryBean<?, ?> anotherExampleRegionFactoryBean =
|
||||
applicationContext.getBean("&AnotherExample", PeerRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(anotherExampleRegionFactoryBean);
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, anotherExampleRegionFactoryBean.getDataPolicy());
|
||||
assertTrue(Boolean.TRUE.equals(TestUtils.readField("persistent", anotherExampleRegionFactoryBean)));
|
||||
assertThat(anotherExampleRegionFactoryBean).isNotNull();
|
||||
assertThat(anotherExampleRegionFactoryBean.getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
assertThat(Boolean.TRUE.equals(TestUtils.readField("persistent", anotherExampleRegionFactoryBean))).isTrue();
|
||||
|
||||
RegionAttributes<?, ?> anotherExampleRegionAttributes =
|
||||
TestUtils.readField("attributes", anotherExampleRegionFactoryBean);
|
||||
|
||||
assertNotNull(anotherExampleRegionAttributes);
|
||||
assertEquals(DataPolicy.PARTITION, anotherExampleRegionAttributes.getDataPolicy());
|
||||
assertThat(anotherExampleRegionAttributes).isNotNull();
|
||||
assertThat(anotherExampleRegionAttributes.getDataPolicy()).isEqualTo(DataPolicy.PARTITION);
|
||||
|
||||
PartitionAttributes<?, ?> anotherExamplePartitionAttributes = anotherExampleRegionAttributes.getPartitionAttributes();
|
||||
|
||||
assertNotNull(anotherExamplePartitionAttributes);
|
||||
assertEquals(2, anotherExamplePartitionAttributes.getRedundantCopies());
|
||||
assertThat(anotherExamplePartitionAttributes).isNotNull();
|
||||
assertThat(anotherExamplePartitionAttributes.getRedundantCopies()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnotherExampleRegionDefinitionConfiguration() {
|
||||
|
||||
assertNotNull("The '/AnotherExample' Region was not properly configured and initialized!", anotherExample);
|
||||
assertEquals("AnotherExample", anotherExample.getName());
|
||||
assertEquals("/AnotherExample", anotherExample.getFullPath());
|
||||
assertNotNull(anotherExample.getAttributes());
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, anotherExample.getAttributes().getDataPolicy());
|
||||
assertNotNull(anotherExample.getAttributes().getPartitionAttributes());
|
||||
assertEquals(2, anotherExample.getAttributes().getPartitionAttributes().getRedundantCopies());
|
||||
assertThat(anotherExample).as("The '/AnotherExample' Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(anotherExample.getName()).isEqualTo("AnotherExample");
|
||||
assertThat(anotherExample.getFullPath()).isEqualTo("/AnotherExample");
|
||||
assertThat(anotherExample.getAttributes()).isNotNull();
|
||||
assertThat(anotherExample.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
assertThat(anotherExample.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(anotherExample.getAttributes().getPartitionAttributes().getRedundantCopies()).isEqualTo(2);
|
||||
}
|
||||
|
||||
public static final class TestRegionFactoryBean<K, V> extends PeerRegionFactoryBean<K, V> { }
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -43,6 +41,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.apache.geode.cache.ExpirationAttributes
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
@@ -75,35 +74,37 @@ public class RegionExpirationAttributesNamespaceIntegrationTests extends Integra
|
||||
private void assertRegionMetaData(Region<?, ?> region, String regionName, String regionFullPath,
|
||||
DataPolicy dataPolicy) {
|
||||
|
||||
assertNotNull(String.format("The '%1$s' Region was not properly configured and initialized!", regionName), region);
|
||||
assertEquals(regionName, region.getName());
|
||||
assertEquals(regionFullPath, region.getFullPath());
|
||||
assertNotNull(region.getAttributes());
|
||||
assertEquals(dataPolicy, region.getAttributes().getDataPolicy());
|
||||
assertThat(region)
|
||||
.as(String.format("The '%1$s' Region was not properly configured and initialized!", regionName))
|
||||
.isNotNull();
|
||||
assertThat(region.getName()).isEqualTo(regionName);
|
||||
assertThat(region.getFullPath()).isEqualTo(regionFullPath);
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getDataPolicy()).isEqualTo(dataPolicy);
|
||||
}
|
||||
|
||||
private void assertNoExpiration(final ExpirationAttributes expirationAttributes) {
|
||||
|
||||
if (expirationAttributes != null) {
|
||||
//assertEquals(ExpirationAction.INVALIDATE, expirationAttributes.getAction());
|
||||
assertEquals(0, expirationAttributes.getTimeout());
|
||||
assertThat(expirationAttributes.getTimeout()).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertExpirationAttributes(ExpirationAttributes expirationAttributes,
|
||||
int timeout, ExpirationAction action) {
|
||||
|
||||
assertNotNull(expirationAttributes);
|
||||
assertEquals(timeout, expirationAttributes.getTimeout());
|
||||
assertEquals(action, expirationAttributes.getAction());
|
||||
assertThat(expirationAttributes).isNotNull();
|
||||
assertThat(expirationAttributes.getTimeout()).isEqualTo(timeout);
|
||||
assertThat(expirationAttributes.getAction()).isEqualTo(action);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void assertCustomExpiry(CustomExpiry<?, ?> customExpiry, String name, int timeout,
|
||||
ExpirationAction action) {
|
||||
|
||||
assertNotNull(customExpiry);
|
||||
assertEquals(name, customExpiry.toString());
|
||||
assertThat(customExpiry).isNotNull();
|
||||
assertThat(customExpiry.toString()).isEqualTo(name);
|
||||
assertExpirationAttributes(customExpiry.getExpiry(mock(Region.Entry.class)), timeout, action);
|
||||
}
|
||||
|
||||
@@ -115,8 +116,8 @@ public class RegionExpirationAttributesNamespaceIntegrationTests extends Integra
|
||||
600, ExpirationAction.DESTROY);
|
||||
assertExpirationAttributes(replicateExample.getAttributes().getEntryIdleTimeout(),
|
||||
300, ExpirationAction.INVALIDATE);
|
||||
assertNull(replicateExample.getAttributes().getCustomEntryTimeToLive());
|
||||
assertNull(replicateExample.getAttributes().getCustomEntryIdleTimeout());
|
||||
assertThat(replicateExample.getAttributes().getCustomEntryTimeToLive()).isNull();
|
||||
assertThat(replicateExample.getAttributes().getCustomEntryIdleTimeout()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,8 +127,8 @@ public class RegionExpirationAttributesNamespaceIntegrationTests extends Integra
|
||||
assertExpirationAttributes(preloadedExample.getAttributes().getEntryTimeToLive(),
|
||||
120, ExpirationAction.LOCAL_DESTROY);
|
||||
assertNoExpiration(preloadedExample.getAttributes().getEntryIdleTimeout());
|
||||
assertNull(preloadedExample.getAttributes().getCustomEntryTimeToLive());
|
||||
assertNull(preloadedExample.getAttributes().getCustomEntryIdleTimeout());
|
||||
assertThat(preloadedExample.getAttributes().getCustomEntryTimeToLive()).isNull();
|
||||
assertThat(preloadedExample.getAttributes().getCustomEntryIdleTimeout()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,7 +138,7 @@ public class RegionExpirationAttributesNamespaceIntegrationTests extends Integra
|
||||
assertExpirationAttributes(partitionExample.getAttributes().getEntryTimeToLive(),
|
||||
300, ExpirationAction.DESTROY);
|
||||
assertNoExpiration(partitionExample.getAttributes().getEntryIdleTimeout());
|
||||
assertNull(partitionExample.getAttributes().getCustomEntryTimeToLive());
|
||||
assertThat(partitionExample.getAttributes().getCustomEntryTimeToLive()).isNull();
|
||||
assertCustomExpiry(partitionExample.getAttributes().getCustomEntryIdleTimeout(), "PartitionCustomExpiry",
|
||||
120, ExpirationAction.INVALIDATE);
|
||||
}
|
||||
|
||||
@@ -15,19 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.CacheListener;
|
||||
import org.apache.geode.cache.CacheLoader;
|
||||
import org.apache.geode.cache.CacheWriter;
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
@@ -74,109 +71,113 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
|
||||
@Test
|
||||
public void testSimpleReplicateRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("simple"));
|
||||
assertThat(applicationContext.containsBean("simple")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean<?, ?> simpleRegionFactoryBean =
|
||||
applicationContext.getBean("&simple", PeerRegionFactoryBean.class);
|
||||
|
||||
assertEquals("simple", TestUtils.readField("beanName", simpleRegionFactoryBean));
|
||||
assertEquals(false, TestUtils.readField("close", simpleRegionFactoryBean));
|
||||
assertNull(TestUtils.readField("scope", simpleRegionFactoryBean));
|
||||
assertThat(TestUtils.<String>readField("beanName", simpleRegionFactoryBean)).isEqualTo("simple");
|
||||
assertThat(TestUtils.<Boolean>readField("close", simpleRegionFactoryBean)).isEqualTo(false);
|
||||
assertThat(TestUtils.<Scope>readField("scope", simpleRegionFactoryBean)).isNull();
|
||||
|
||||
RegionAttributes<?, ?> simpleRegionAttributes = TestUtils.readField("attributes", simpleRegionFactoryBean);
|
||||
|
||||
assertNotNull(simpleRegionAttributes);
|
||||
assertFalse(simpleRegionAttributes.getConcurrencyChecksEnabled());
|
||||
assertEquals(13, simpleRegionAttributes.getConcurrencyLevel());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, simpleRegionAttributes.getScope());
|
||||
assertThat(simpleRegionAttributes).isNotNull();
|
||||
assertThat(simpleRegionAttributes.getConcurrencyChecksEnabled()).isFalse();
|
||||
assertThat(simpleRegionAttributes.getConcurrencyLevel()).isEqualTo(13);
|
||||
assertThat(simpleRegionAttributes.getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
public void testPublishReplicateRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("pub"));
|
||||
assertThat(applicationContext.containsBean("pub")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean publisherRegionFactoryBean =
|
||||
applicationContext.getBean("&pub", PeerRegionFactoryBean.class);
|
||||
|
||||
assertTrue(publisherRegionFactoryBean instanceof ReplicatedRegionFactoryBean);
|
||||
assertEquals("publisher", TestUtils.readField("name", publisherRegionFactoryBean));
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, TestUtils.readField("scope", publisherRegionFactoryBean));
|
||||
assertThat(publisherRegionFactoryBean instanceof ReplicatedRegionFactoryBean).isTrue();
|
||||
assertThat(TestUtils.<String>readField("name", publisherRegionFactoryBean)).isEqualTo("publisher");
|
||||
assertThat(TestUtils.<Scope>readField("scope", publisherRegionFactoryBean)).isEqualTo(Scope.DISTRIBUTED_ACK);
|
||||
|
||||
RegionAttributes publisherRegionAttributes = TestUtils.readField("attributes", publisherRegionFactoryBean);
|
||||
|
||||
assertTrue(publisherRegionAttributes.getConcurrencyChecksEnabled());
|
||||
assertFalse(publisherRegionAttributes.getPublisher());
|
||||
assertThat(publisherRegionAttributes.getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(publisherRegionAttributes.getPublisher()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testComplexReplicateRegion() throws Exception {
|
||||
|
||||
assertTrue(applicationContext.containsBean("complex"));
|
||||
assertThat(applicationContext.containsBean("complex")).isTrue();
|
||||
|
||||
PeerRegionFactoryBean complexRegionFactoryBean =
|
||||
applicationContext.getBean("&complex", PeerRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(complexRegionFactoryBean);
|
||||
assertEquals("complex", TestUtils.readField("beanName", complexRegionFactoryBean));
|
||||
assertThat(complexRegionFactoryBean).isNotNull();
|
||||
assertThat(TestUtils.<String>readField("beanName", complexRegionFactoryBean)).isEqualTo("complex");
|
||||
|
||||
CacheListener[] cacheListeners = TestUtils.readField("cacheListeners", complexRegionFactoryBean);
|
||||
|
||||
assertFalse(ObjectUtils.isEmpty(cacheListeners));
|
||||
assertEquals(2, cacheListeners.length);
|
||||
assertSame(applicationContext.getBean("c-listener"), cacheListeners[0]);
|
||||
assertTrue(cacheListeners[1] instanceof SimpleCacheListener);
|
||||
assertNotSame(cacheListeners[0], cacheListeners[1]);
|
||||
assertSame(applicationContext.getBean("c-loader"), TestUtils.readField("cacheLoader", complexRegionFactoryBean));
|
||||
assertSame(applicationContext.getBean("c-writer"), TestUtils.readField("cacheWriter", complexRegionFactoryBean));
|
||||
assertThat(ObjectUtils.isEmpty(cacheListeners)).isFalse();
|
||||
assertThat(cacheListeners.length).isEqualTo(2);
|
||||
assertThat(cacheListeners[0]).isSameAs(applicationContext.getBean("c-listener"));
|
||||
assertThat(cacheListeners[1] instanceof SimpleCacheListener).isTrue();
|
||||
assertThat(cacheListeners[1]).isNotSameAs(cacheListeners[0]);
|
||||
assertThat(TestUtils.<CacheLoader>readField("cacheLoader", complexRegionFactoryBean))
|
||||
.isSameAs(applicationContext.getBean("c-loader"));
|
||||
assertThat(TestUtils.<CacheWriter>readField("cacheWriter", complexRegionFactoryBean))
|
||||
.isSameAs(applicationContext.getBean("c-writer"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void testReplicatedRegionWithAttributes() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("replicated-with-attributes"));
|
||||
assertThat(applicationContext.containsBean("replicated-with-attributes")).isTrue();
|
||||
|
||||
Region region = applicationContext.getBean("replicated-with-attributes", Region.class);
|
||||
Region<?, ?> region = applicationContext.getBean("replicated-with-attributes", Region.class);
|
||||
|
||||
assertNotNull("The 'replicated-with-attributes' Region was not properly configured and initialized!", region);
|
||||
assertThat(region)
|
||||
.describedAs("The 'replicated-with-attributes' Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
|
||||
RegionAttributes regionAttributes = region.getAttributes();
|
||||
|
||||
assertNotNull(regionAttributes);
|
||||
assertFalse(regionAttributes.getCloningEnabled());
|
||||
assertEquals(10, regionAttributes.getConcurrencyLevel());
|
||||
assertTrue(regionAttributes.isDiskSynchronous());
|
||||
assertTrue(regionAttributes.getEnableAsyncConflation());
|
||||
assertTrue(regionAttributes.getEnableSubscriptionConflation());
|
||||
assertTrue(regionAttributes.getIgnoreJTA());
|
||||
assertEquals(10, regionAttributes.getInitialCapacity());
|
||||
assertFalse(regionAttributes.getIndexMaintenanceSynchronous());
|
||||
assertEquals(String.class, regionAttributes.getKeyConstraint());
|
||||
assertEquals(0.50, regionAttributes.getLoadFactor(), 0.001);
|
||||
assertTrue(regionAttributes.isLockGrantor());
|
||||
assertTrue(regionAttributes.getMulticastEnabled());
|
||||
assertTrue(regionAttributes.getOffHeap());
|
||||
assertEquals(Scope.GLOBAL, regionAttributes.getScope());
|
||||
assertEquals(String.class, regionAttributes.getValueConstraint());
|
||||
assertThat(regionAttributes).isNotNull();
|
||||
assertThat(regionAttributes.getCloningEnabled()).isFalse();
|
||||
assertThat(regionAttributes.getConcurrencyLevel()).isEqualTo(10);
|
||||
assertThat(regionAttributes.isDiskSynchronous()).isTrue();
|
||||
assertThat(regionAttributes.getEnableAsyncConflation()).isTrue();
|
||||
assertThat(regionAttributes.getEnableSubscriptionConflation()).isTrue();
|
||||
assertThat(regionAttributes.getIgnoreJTA()).isTrue();
|
||||
assertThat(regionAttributes.getInitialCapacity()).isEqualTo(10);
|
||||
assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isFalse();
|
||||
assertThat(regionAttributes.getKeyConstraint()).isEqualTo(String.class);
|
||||
assertThat(regionAttributes.getLoadFactor()).isCloseTo(0.50f, offset(0.001f));
|
||||
assertThat(regionAttributes.isLockGrantor()).isTrue();
|
||||
assertThat(regionAttributes.getMulticastEnabled()).isTrue();
|
||||
assertThat(regionAttributes.getOffHeap()).isTrue();
|
||||
assertThat(regionAttributes.getScope()).isEqualTo(Scope.GLOBAL);
|
||||
assertThat(regionAttributes.getValueConstraint()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplicatedWithSynchronousIndexUpdates() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("replicated-with-synchronous-index-updates"));
|
||||
assertThat(applicationContext.containsBean("replicated-with-synchronous-index-updates")).isTrue();
|
||||
|
||||
Region<?, ?> region = applicationContext.getBean("replicated-with-synchronous-index-updates", Region.class);
|
||||
|
||||
assertNotNull(String.format("The '%1$s' Region was not properly configured and initialized!",
|
||||
"replicated-with-synchronous-index-updates"), region);
|
||||
assertThat(region).as(String.format("The '%1$s' Region was not properly configured and initialized!",
|
||||
"replicated-with-synchronous-index-updates")).isNotNull();
|
||||
|
||||
RegionAttributes<?, ?> regionAttributes = region.getAttributes();
|
||||
|
||||
assertNotNull(regionAttributes);
|
||||
assertTrue(regionAttributes.getIndexMaintenanceSynchronous());
|
||||
assertThat(regionAttributes).isNotNull();
|
||||
assertThat(regionAttributes.getIndexMaintenanceSynchronous()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -187,31 +188,32 @@ public class ReplicatedRegionNamespaceIntegrationTests extends IntegrationTestsS
|
||||
|
||||
Region existing = cache.createRegionFactory().create("existing");
|
||||
|
||||
assertTrue(applicationContext.containsBean("lookup"));
|
||||
assertThat(applicationContext.containsBean("lookup")).isTrue();
|
||||
|
||||
ResolvableRegionFactoryBean regionFactoryBean =
|
||||
applicationContext.getBean("&lookup", ResolvableRegionFactoryBean.class);
|
||||
|
||||
assertNotNull(regionFactoryBean);
|
||||
assertEquals("existing", TestUtils.readField("name", regionFactoryBean));
|
||||
assertSame(existing, applicationContext.getBean("lookup"));
|
||||
assertThat(regionFactoryBean).isNotNull();
|
||||
assertThat(TestUtils.<String>readField("name", regionFactoryBean)).isEqualTo("existing");
|
||||
assertThat(applicationContext.getBean("lookup")).isSameAs(existing);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompressedReplicateRegion() {
|
||||
|
||||
assertTrue(applicationContext.containsBean("Compressed"));
|
||||
assertThat(applicationContext.containsBean("Compressed")).isTrue();
|
||||
|
||||
Region<?, ?> compressed = applicationContext.getBean("Compressed", Region.class);
|
||||
|
||||
assertNotNull("The 'Compressed' REPLICATE Region was not properly configured and initialized!", compressed);
|
||||
assertEquals("Compressed", compressed.getName());
|
||||
assertEquals(Region.SEPARATOR + "Compressed", compressed.getFullPath());
|
||||
assertNotNull(compressed.getAttributes());
|
||||
assertEquals(DataPolicy.REPLICATE, compressed.getAttributes().getDataPolicy());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, compressed.getAttributes().getScope());
|
||||
assertTrue(compressed.getAttributes().getCompressor() instanceof TestCompressor);
|
||||
assertEquals("XYZ", compressed.getAttributes().getCompressor().toString());
|
||||
assertThat(compressed).as("The 'Compressed' REPLICATE Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(compressed.getName()).isEqualTo("Compressed");
|
||||
assertThat(compressed.getFullPath()).isEqualTo(Region.SEPARATOR + "Compressed");
|
||||
assertThat(compressed.getAttributes()).isNotNull();
|
||||
assertThat(compressed.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(compressed.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
assertThat(compressed.getAttributes().getCompressor() instanceof TestCompressor).isTrue();
|
||||
assertThat(compressed.getAttributes().getCompressor().toString()).isEqualTo("XYZ");
|
||||
}
|
||||
|
||||
public static class TestCompressor implements Compressor {
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,7 +35,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.mock.context.GemFireMockObjectsApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests for {@link Region sub-Region}, sub-element SDG XML namespace configuration metadata.
|
||||
@@ -53,7 +52,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(locations = "subregionsubelement-ns.xml",
|
||||
initializers = GemFireMockObjectsApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
@@ -71,9 +70,9 @@ public class SubRegionSubElementNamespaceIntegrationTests extends IntegrationTes
|
||||
@Test
|
||||
public void testCustomersAccountsSubRegionCacheListener() {
|
||||
|
||||
assertNotNull(customersAccountsRegion);
|
||||
assertNotNull(customersAccountsRegion.getAttributes());
|
||||
assertNotNull(customersAccountsRegion.getAttributes().getCacheListeners());
|
||||
assertThat(customersAccountsRegion).isNotNull();
|
||||
assertThat(customersAccountsRegion.getAttributes()).isNotNull();
|
||||
assertThat(customersAccountsRegion.getAttributes().getCacheListeners()).isNotNull();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
@@ -81,8 +80,9 @@ public class SubRegionSubElementNamespaceIntegrationTests extends IntegrationTes
|
||||
found |= (listener instanceof TestNoOpCacheListener);
|
||||
}
|
||||
|
||||
assertTrue(String.format("Expected a GemFire CacheListener of type (%1$s) to be registered on Region (%2$s)!",
|
||||
TestNoOpCacheListener.class.getName(), customersAccountsRegion.getName()), found);
|
||||
assertThat(found)
|
||||
.as(String.format("Expected a GemFire CacheListener of type (%1$s) to be registered on Region (%2$s)!",
|
||||
TestNoOpCacheListener.class.getName(), customersAccountsRegion.getName())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,19 +90,19 @@ public class SubRegionSubElementNamespaceIntegrationTests extends IntegrationTes
|
||||
|
||||
Region<?, ?> orderItemsRegion = applicationContext.getBean("/Orders/Items", Region.class);
|
||||
|
||||
assertNotNull(orderItemsRegion);
|
||||
assertNotNull(orderItemsRegion.getAttributes());
|
||||
assertNotNull(orderItemsRegion.getAttributes().getGatewaySenderIds());
|
||||
assertTrue(orderItemsRegion.getAttributes().getGatewaySenderIds().contains("testSender"));
|
||||
assertThat(orderItemsRegion).isNotNull();
|
||||
assertThat(orderItemsRegion.getAttributes()).isNotNull();
|
||||
assertThat(orderItemsRegion.getAttributes().getGatewaySenderIds()).isNotNull();
|
||||
assertThat(orderItemsRegion.getAttributes().getGatewaySenderIds().contains("testSender")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentChildSubRegionAsyncEventQueue() {
|
||||
|
||||
assertNotNull(parentChildRegion);
|
||||
assertNotNull(parentChildRegion.getAttributes());
|
||||
assertNotNull(parentChildRegion.getAttributes().getAsyncEventQueueIds());
|
||||
assertTrue(parentChildRegion.getAttributes().getAsyncEventQueueIds().contains("testQueue"));
|
||||
assertThat(parentChildRegion).isNotNull();
|
||||
assertThat(parentChildRegion.getAttributes()).isNotNull();
|
||||
assertThat(parentChildRegion.getAttributes().getAsyncEventQueueIds()).isNotNull();
|
||||
assertThat(parentChildRegion.getAttributes().getAsyncEventQueueIds().contains("testQueue")).isTrue();
|
||||
}
|
||||
|
||||
public static final class TestNoOpCacheListener extends CacheListenerAdapter<Object, Object> { }
|
||||
|
||||
@@ -13,31 +13,35 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.DataPolicy;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
/**
|
||||
* The SubRegionWithInvalidDataPolicyTest class is a test suite of test cases testing the data-policy and persistent
|
||||
* attributes settings are consistent for GemFire SubRegion bean definitions.
|
||||
* Unit Tests testing the {@link DataPolicy} and {@literal persistent} attributes settings are consistent for
|
||||
* {@link Region sub-Region} bean definitions.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since GemFire 7.0.1
|
||||
* @since Spring Data GemFire 1.4.0
|
||||
* @see org.apache.geode.cache.DataPolicy
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.context.support.ClassPathXmlApplicationContext
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class SubRegionWithInvalidDataPolicyTest {
|
||||
public class SubRegionWithInvalidDataPolicyTest extends IntegrationTestsSupport {
|
||||
|
||||
@Test(expected = XmlBeanDefinitionStoreException.class)
|
||||
public void testSubRegionBeanDefinitionWithInconsistentDataPolicy() {
|
||||
@@ -48,8 +52,8 @@ public class SubRegionWithInvalidDataPolicyTest {
|
||||
}
|
||||
catch (XmlBeanDefinitionStoreException expected) {
|
||||
|
||||
assertTrue(expected.getCause() instanceof SAXParseException);
|
||||
assertTrue(expected.getCause().getMessage().contains("PERSISTENT_PARTITION"));
|
||||
assertThat(expected.getCause() instanceof SAXParseException).isTrue();
|
||||
assertThat(expected.getCause().getMessage().contains("PERSISTENT_PARTITION")).isTrue();
|
||||
|
||||
throw expected;
|
||||
}
|
||||
@@ -64,10 +68,10 @@ public class SubRegionWithInvalidDataPolicyTest {
|
||||
}
|
||||
catch (BeanCreationException expected) {
|
||||
|
||||
assertTrue(expected.getMessage().contains("Error creating bean with name '/Parent/Child'"));
|
||||
assertTrue(expected.getCause() instanceof IllegalArgumentException);
|
||||
assertEquals("Data Policy [REPLICATE] is not valid when persistent is true",
|
||||
expected.getCause().getMessage());
|
||||
assertThat(expected.getMessage().contains("Error creating bean with name '/Parent/Child'")).isTrue();
|
||||
assertThat(expected.getCause() instanceof IllegalArgumentException).isTrue();
|
||||
assertThat(expected.getCause().getMessage())
|
||||
.isEqualTo("Data Policy [REPLICATE] is not valid when persistent is true");
|
||||
|
||||
throw expected;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
import static org.junit.Assume.assumeNotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -112,43 +109,43 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
|
||||
private void assertAsyncEventQueues(Region<?, ?> region, String... expectedNames) {
|
||||
|
||||
assertNotNull(region);
|
||||
assertNotNull(region.getAttributes());
|
||||
assertNotNull(region.getAttributes().getAsyncEventQueueIds());
|
||||
assertEquals(expectedNames.length, region.getAttributes().getAsyncEventQueueIds().size());
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getAsyncEventQueueIds()).isNotNull();
|
||||
assertThat(region.getAttributes().getAsyncEventQueueIds().size()).isEqualTo(expectedNames.length);
|
||||
|
||||
for (String asyncEventQueueId : region.getAttributes().getAsyncEventQueueIds()) {
|
||||
assertTrue(Arrays.asList(expectedNames).contains(asyncEventQueueId));
|
||||
assertThat(Arrays.asList(expectedNames).contains(asyncEventQueueId)).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertCacheListeners(Region<?, ?> region, String... expectedNames) {
|
||||
|
||||
assertNotNull(region);
|
||||
assertNotNull(region.getAttributes());
|
||||
assertNotNull(region.getAttributes().getCacheListeners());
|
||||
assertEquals(expectedNames.length, region.getAttributes().getCacheListeners().length);
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getCacheListeners()).isNotNull();
|
||||
assertThat(region.getAttributes().getCacheListeners().length).isEqualTo(expectedNames.length);
|
||||
|
||||
for (CacheListener cacheListener : region.getAttributes().getCacheListeners()) {
|
||||
assertTrue(cacheListener instanceof TestCacheListener);
|
||||
assertTrue(Arrays.asList(expectedNames).contains(cacheListener.toString()));
|
||||
assertThat(cacheListener instanceof TestCacheListener).isTrue();
|
||||
assertThat(Arrays.asList(expectedNames).contains(cacheListener.toString())).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertCacheLoader(Region<?, ?> region, String expectedName) {
|
||||
|
||||
assertNotNull(region);
|
||||
assertNotNull(region.getAttributes());
|
||||
assertTrue(region.getAttributes().getCacheLoader() instanceof TestCacheLoader);
|
||||
assertEquals(expectedName, region.getAttributes().getCacheLoader().toString());
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getCacheLoader() instanceof TestCacheLoader).isTrue();
|
||||
assertThat(region.getAttributes().getCacheLoader().toString()).isEqualTo(expectedName);
|
||||
}
|
||||
|
||||
private void assertCacheWriter(Region<?, ?> region, String expectedName) {
|
||||
|
||||
assertNotNull(region);
|
||||
assertNotNull(region.getAttributes());
|
||||
assertTrue(region.getAttributes().getCacheWriter() instanceof TestCacheWriter);
|
||||
assertEquals(expectedName, region.getAttributes().getCacheWriter().toString());
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getCacheWriter() instanceof TestCacheWriter).isTrue();
|
||||
assertThat(region.getAttributes().getCacheWriter().toString()).isEqualTo(expectedName);
|
||||
}
|
||||
|
||||
private void assertDefaultEvictionAttributes(EvictionAttributes evictionAttributes) {
|
||||
@@ -159,35 +156,35 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
private void assertEvictionAttributes(EvictionAttributes evictionAttributes, EvictionAction expectedAction,
|
||||
EvictionAlgorithm expectedAlgorithm, int expectedMaximum, ObjectSizer expectedObjectSizer) {
|
||||
|
||||
assertNotNull("The 'EvictionAttributes' must not be null!", evictionAttributes);
|
||||
assertEquals(expectedAction, evictionAttributes.getAction());
|
||||
assertEquals(expectedAlgorithm, evictionAttributes.getAlgorithm());
|
||||
assertEquals(expectedMaximum, evictionAttributes.getMaximum());
|
||||
assertEquals(expectedObjectSizer, evictionAttributes.getObjectSizer());
|
||||
assertThat(evictionAttributes).as("The 'EvictionAttributes' must not be null!").isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(expectedAction);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(expectedAlgorithm);
|
||||
assertThat(evictionAttributes.getMaximum()).isEqualTo(expectedMaximum);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isEqualTo(expectedObjectSizer);
|
||||
}
|
||||
|
||||
private void assertDefaultExpirationAttributes(ExpirationAttributes expirationAttributes) {
|
||||
|
||||
assumeNotNull(expirationAttributes);
|
||||
assertEquals(ExpirationAction.INVALIDATE, expirationAttributes.getAction());
|
||||
assertEquals(0, expirationAttributes.getTimeout());
|
||||
assertThat(expirationAttributes.getAction()).isEqualTo(ExpirationAction.INVALIDATE);
|
||||
assertThat(expirationAttributes.getTimeout()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private void assertExpirationAttributes(ExpirationAttributes expirationAttributes, ExpirationAction expectedAction,
|
||||
int expectedTimeout) {
|
||||
|
||||
assertNotNull("The 'ExpirationAttributes' must not be null!", expirationAttributes);
|
||||
assertEquals(expectedAction, expirationAttributes.getAction());
|
||||
assertEquals(expectedTimeout, expirationAttributes.getTimeout());
|
||||
assertThat(expirationAttributes).as("The 'ExpirationAttributes' must not be null!").isNotNull();
|
||||
assertThat(expirationAttributes.getAction()).isEqualTo(expectedAction);
|
||||
assertThat(expirationAttributes.getTimeout()).isEqualTo(expectedTimeout);
|
||||
}
|
||||
|
||||
private void assertGatewaySenders(Region<?, ?> region, String... gatewaySenderIds) {
|
||||
|
||||
assertNotNull(region);
|
||||
assertNotNull(region.getAttributes());
|
||||
assertNotNull(region.getAttributes().getGatewaySenderIds());
|
||||
assertEquals(gatewaySenderIds.length, region.getAttributes().getGatewaySenderIds().size());
|
||||
assertTrue(Arrays.asList(gatewaySenderIds).containsAll(region.getAttributes().getGatewaySenderIds()));
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getGatewaySenderIds()).isNotNull();
|
||||
assertThat(region.getAttributes().getGatewaySenderIds().size()).isEqualTo(gatewaySenderIds.length);
|
||||
assertThat(Arrays.asList(gatewaySenderIds).containsAll(region.getAttributes().getGatewaySenderIds())).isTrue();
|
||||
}
|
||||
|
||||
private void assertDefaultMembershipAttributes(MembershipAttributes membershipAttributes) {
|
||||
@@ -199,51 +196,58 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
private void assertMembershipAttributes(MembershipAttributes membershipAttributes, LossAction expectedLossAction,
|
||||
ResumptionAction expectedResumptionAction, String... expectedRequiredRoles) {
|
||||
|
||||
assertNotNull("The 'MembershipAttributes' must not be null!", membershipAttributes);
|
||||
assertEquals(expectedLossAction, membershipAttributes.getLossAction());
|
||||
assertEquals(expectedResumptionAction, membershipAttributes.getResumptionAction());
|
||||
assertThat(membershipAttributes).as("The 'MembershipAttributes' must not be null!").isNotNull();
|
||||
assertThat(membershipAttributes.getLossAction()).isEqualTo(expectedLossAction);
|
||||
assertThat(membershipAttributes.getResumptionAction()).isEqualTo(expectedResumptionAction);
|
||||
|
||||
if (!ObjectUtils.isEmpty(expectedRequiredRoles)) {
|
||||
for (Role membershipRole : membershipAttributes.getRequiredRoles()) {
|
||||
assertTrue(String.format("Role '%1$s' was not found!", membershipRole),
|
||||
Arrays.asList(expectedRequiredRoles).contains(membershipRole.getName()));
|
||||
assertThat(Arrays.asList(expectedRequiredRoles).contains(membershipRole.getName()))
|
||||
.as(String.format("Role '%1$s' was not found!", membershipRole)).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void assertPartitionListener(Region<?, ?> region, String... expectedNames) {
|
||||
|
||||
assertNotNull(region);
|
||||
assertNotNull(region.getAttributes());
|
||||
assertNotNull(region.getAttributes().getPartitionAttributes());
|
||||
assertNotNull(region.getAttributes().getPartitionAttributes().getPartitionListeners());
|
||||
assertEquals(expectedNames.length, region.getAttributes().getPartitionAttributes().getPartitionListeners().length);
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getPartitionAttributes().getPartitionListeners()).isNotNull();
|
||||
assertThat(region.getAttributes().getPartitionAttributes().getPartitionListeners().length)
|
||||
.isEqualTo(expectedNames.length);
|
||||
|
||||
for (PartitionListener partitionListener : region.getAttributes().getPartitionAttributes().getPartitionListeners()) {
|
||||
assertTrue(partitionListener instanceof TestPartitionListener);
|
||||
assertTrue(Arrays.asList(expectedNames).contains(partitionListener.toString()));
|
||||
assertThat(partitionListener instanceof TestPartitionListener).isTrue();
|
||||
assertThat(Arrays.asList(expectedNames).contains(partitionListener.toString())).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertPartitionResolver(Region<?, ?> region, String expectedName) {
|
||||
|
||||
assertNotNull(region);
|
||||
assertNotNull(region.getAttributes());
|
||||
assertNotNull(region.getAttributes().getPartitionAttributes());
|
||||
assertTrue(region.getAttributes().getPartitionAttributes().getPartitionResolver() instanceof TestPartitionResolver);
|
||||
assertEquals(expectedName, region.getAttributes().getPartitionAttributes().getPartitionResolver().toString());
|
||||
assertThat(region).isNotNull();
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(
|
||||
region.getAttributes().getPartitionAttributes().getPartitionResolver() instanceof TestPartitionResolver)
|
||||
.isTrue();
|
||||
assertThat(region.getAttributes().getPartitionAttributes().getPartitionResolver().toString())
|
||||
.isEqualTo(expectedName);
|
||||
}
|
||||
|
||||
private void assertDefaultRegionAttributes(Region region) {
|
||||
|
||||
assertNotNull("The Region must not be null!", region);
|
||||
assertNotNull(String.format("Region (%1$s) must have 'RegionAttributes' defined!",
|
||||
region.getFullPath()), region.getAttributes());
|
||||
assertNull(region.getAttributes().getCompressor());
|
||||
assertNull(region.getAttributes().getCustomEntryIdleTimeout());
|
||||
assertNull(region.getAttributes().getCustomEntryTimeToLive());
|
||||
assertNull(region.getAttributes().getDiskStoreName());
|
||||
assertFalse(region.getAttributes().getMulticastEnabled());
|
||||
assertThat(region).describedAs("The Region must not be null!").isNotNull();
|
||||
|
||||
assertThat(region.getAttributes())
|
||||
.describedAs(String.format("Region (%1$s) must have 'RegionAttributes' defined!",region.getFullPath()))
|
||||
.isNotNull();
|
||||
|
||||
assertThat(region.getAttributes().getCompressor()).isNull();
|
||||
assertThat(region.getAttributes().getCustomEntryIdleTimeout()).isNull();
|
||||
assertThat(region.getAttributes().getCustomEntryTimeToLive()).isNull();
|
||||
assertThat(region.getAttributes().getDiskStoreName()).isNull();
|
||||
assertThat(region.getAttributes().getMulticastEnabled()).isFalse();
|
||||
assertNullEmpty(region.getAttributes().getPoolName());
|
||||
assertDefaultExpirationAttributes(region.getAttributes().getRegionTimeToLive());
|
||||
assertDefaultExpirationAttributes(region.getAttributes().getRegionIdleTimeout());
|
||||
@@ -258,20 +262,20 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
private void assertSubscriptionAttributes(SubscriptionAttributes subscriptionAttributes,
|
||||
InterestPolicy expectedInterestPolicy) {
|
||||
|
||||
assertNotNull("The 'SubscriptionAttributes' must not be null!", subscriptionAttributes);
|
||||
assertEquals(expectedInterestPolicy, subscriptionAttributes.getInterestPolicy());
|
||||
assertThat(subscriptionAttributes).as("The 'SubscriptionAttributes' must not be null!").isNotNull();
|
||||
assertThat(subscriptionAttributes.getInterestPolicy()).isEqualTo(expectedInterestPolicy);
|
||||
}
|
||||
|
||||
private static void assertEmpty(Object[] array) {
|
||||
assertTrue((array == null || array.length == 0));
|
||||
assertThat((array == null || array.length == 0)).isTrue();
|
||||
}
|
||||
|
||||
private static void assertEmpty(Iterable<?> collection) {
|
||||
assertTrue(collection == null || !collection.iterator().hasNext());
|
||||
assertThat(collection == null || !collection.iterator().hasNext()).isTrue();
|
||||
}
|
||||
|
||||
private static void assertNullEmpty(String value) {
|
||||
assertFalse(StringUtils.hasText(value));
|
||||
assertThat(StringUtils.hasText(value)).isFalse();
|
||||
}
|
||||
|
||||
private static void assertRegionMetaData(Region<?, ?> region, String expectedRegionName) {
|
||||
@@ -280,12 +284,12 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
|
||||
private static void assertRegionMetaData(Region<?, ?> region, String expectedRegionName, String expectedRegionPath) {
|
||||
|
||||
assertNotNull(String.format("The '%1$s' Region was not properly configured and initialized!",
|
||||
expectedRegionName), region);
|
||||
assertEquals(expectedRegionName, region.getName());
|
||||
assertEquals(expectedRegionPath, region.getFullPath());
|
||||
assertNotNull(String.format("The '%1$s' Region must have RegionAttributes defined!",
|
||||
expectedRegionName), region.getAttributes());
|
||||
assertThat(region).as(String.format("The '%1$s' Region was not properly configured and initialized!",
|
||||
expectedRegionName)).isNotNull();
|
||||
assertThat(region.getName()).isEqualTo(expectedRegionName);
|
||||
assertThat(region.getFullPath()).isEqualTo(expectedRegionPath);
|
||||
assertThat(region.getAttributes()).as(String.format("The '%1$s' Region must have RegionAttributes defined!",
|
||||
expectedRegionName)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -300,17 +304,18 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
};
|
||||
|
||||
for (String beanName : beanNames) {
|
||||
assertTrue(applicationContext.containsBean(beanName));
|
||||
assertTrue(applicationContext.containsBeanDefinition(beanName));
|
||||
assertThat(applicationContext.containsBean(beanName)).isTrue();
|
||||
assertThat(applicationContext.containsBeanDefinition(beanName)).isTrue();
|
||||
|
||||
try {
|
||||
applicationContext.getBean(beanName);
|
||||
fail(String.format("The abstract bean definition '%1$s' should not exist as a bean in the Spring context!",
|
||||
beanName));
|
||||
fail(String
|
||||
.format("The abstract bean definition '%1$s' should not exist as a bean in the Spring context!",
|
||||
beanName));
|
||||
}
|
||||
catch (BeansException expected) {
|
||||
assertTrue(expected instanceof BeanIsAbstractException);
|
||||
assertTrue(expected.getMessage().contains(beanName));
|
||||
assertThat(expected instanceof BeanIsAbstractException).isTrue();
|
||||
assertThat(expected.getMessage().contains(beanName)).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,29 +329,29 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertEmpty(nonTemplateBasedReplicateRegion.getAttributes().getCacheListeners());
|
||||
assertCacheLoader(nonTemplateBasedReplicateRegion, "ABC");
|
||||
assertCacheWriter(nonTemplateBasedReplicateRegion, "DEF");
|
||||
assertFalse(nonTemplateBasedReplicateRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(nonTemplateBasedReplicateRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(12, nonTemplateBasedReplicateRegion.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(DataPolicy.REPLICATE, nonTemplateBasedReplicateRegion.getAttributes().getDataPolicy());
|
||||
assertTrue(nonTemplateBasedReplicateRegion.getAttributes().isDiskSynchronous());
|
||||
assertFalse(nonTemplateBasedReplicateRegion.getAttributes().getEnableAsyncConflation());
|
||||
assertFalse(nonTemplateBasedReplicateRegion.getAttributes().getEnableSubscriptionConflation());
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getConcurrencyLevel()).isEqualTo(12);
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().isDiskSynchronous()).isTrue();
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getEnableAsyncConflation()).isFalse();
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getEnableSubscriptionConflation()).isFalse();
|
||||
assertDefaultEvictionAttributes(nonTemplateBasedReplicateRegion.getAttributes().getEvictionAttributes());
|
||||
assertDefaultExpirationAttributes(nonTemplateBasedReplicateRegion.getAttributes().getEntryIdleTimeout());
|
||||
assertDefaultExpirationAttributes(nonTemplateBasedReplicateRegion.getAttributes().getEntryTimeToLive());
|
||||
assertEmpty(nonTemplateBasedReplicateRegion.getAttributes().getGatewaySenderIds());
|
||||
assertFalse(nonTemplateBasedReplicateRegion.getAttributes().getIgnoreJTA());
|
||||
assertTrue(nonTemplateBasedReplicateRegion.getAttributes().getIndexMaintenanceSynchronous());
|
||||
assertEquals(97, nonTemplateBasedReplicateRegion.getAttributes().getInitialCapacity());
|
||||
assertNull(nonTemplateBasedReplicateRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals("0.65", String.valueOf(nonTemplateBasedReplicateRegion.getAttributes().getLoadFactor()));
|
||||
assertFalse(nonTemplateBasedReplicateRegion.getAttributes().isLockGrantor());
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getIgnoreJTA()).isFalse();
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getIndexMaintenanceSynchronous()).isTrue();
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getInitialCapacity()).isEqualTo(97);
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getKeyConstraint()).isNull();
|
||||
assertThat(String.valueOf(nonTemplateBasedReplicateRegion.getAttributes().getLoadFactor())).isEqualTo("0.65");
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().isLockGrantor()).isFalse();
|
||||
assertDefaultMembershipAttributes(nonTemplateBasedReplicateRegion.getAttributes().getMembershipAttributes());
|
||||
assertNull(nonTemplateBasedReplicateRegion.getAttributes().getPartitionAttributes());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, nonTemplateBasedReplicateRegion.getAttributes().getScope());
|
||||
assertFalse(nonTemplateBasedReplicateRegion.getAttributes().getStatisticsEnabled());
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getPartitionAttributes()).isNull();
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getStatisticsEnabled()).isFalse();
|
||||
assertDefaultSubscriptionAttributes(nonTemplateBasedReplicateRegion.getAttributes().getSubscriptionAttributes());
|
||||
assertNull(nonTemplateBasedReplicateRegion.getAttributes().getValueConstraint());
|
||||
assertThat(nonTemplateBasedReplicateRegion.getAttributes().getValueConstraint()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -358,13 +363,13 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertCacheListeners(templateBasedReplicateRegion, "XYZ");
|
||||
assertCacheLoader(templateBasedReplicateRegion, "dbLoader");
|
||||
assertCacheWriter(templateBasedReplicateRegion, "dbWriter");
|
||||
assertTrue(templateBasedReplicateRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(templateBasedReplicateRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(24, templateBasedReplicateRegion.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(DataPolicy.REPLICATE, templateBasedReplicateRegion.getAttributes().getDataPolicy());
|
||||
assertFalse(templateBasedReplicateRegion.getAttributes().isDiskSynchronous());
|
||||
assertFalse(templateBasedReplicateRegion.getAttributes().getEnableAsyncConflation());
|
||||
assertTrue(templateBasedReplicateRegion.getAttributes().getEnableSubscriptionConflation());
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getCloningEnabled()).isTrue();
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getConcurrencyLevel()).isEqualTo(24);
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().isDiskSynchronous()).isFalse();
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getEnableAsyncConflation()).isFalse();
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getEnableSubscriptionConflation()).isTrue();
|
||||
assertEvictionAttributes(templateBasedReplicateRegion.getAttributes().getEvictionAttributes(),
|
||||
EvictionAction.OVERFLOW_TO_DISK, EvictionAlgorithm.LRU_ENTRY, 2024, null);
|
||||
assertExpirationAttributes(templateBasedReplicateRegion.getAttributes().getEntryIdleTimeout(),
|
||||
@@ -372,19 +377,19 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertExpirationAttributes(templateBasedReplicateRegion.getAttributes().getEntryTimeToLive(),
|
||||
ExpirationAction.INVALIDATE, 300);
|
||||
assertEmpty(templateBasedReplicateRegion.getAttributes().getGatewaySenderIds());
|
||||
assertTrue(templateBasedReplicateRegion.getAttributes().getIgnoreJTA());
|
||||
assertTrue(templateBasedReplicateRegion.getAttributes().getIndexMaintenanceSynchronous());
|
||||
assertEquals(51, templateBasedReplicateRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(String.class, templateBasedReplicateRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals("0.85", String.valueOf(templateBasedReplicateRegion.getAttributes().getLoadFactor()));
|
||||
assertTrue(templateBasedReplicateRegion.getAttributes().isLockGrantor());
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getIgnoreJTA()).isTrue();
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getIndexMaintenanceSynchronous()).isTrue();
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getInitialCapacity()).isEqualTo(51);
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getKeyConstraint()).isEqualTo(String.class);
|
||||
assertThat(String.valueOf(templateBasedReplicateRegion.getAttributes().getLoadFactor())).isEqualTo("0.85");
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().isLockGrantor()).isTrue();
|
||||
assertDefaultMembershipAttributes(templateBasedReplicateRegion.getAttributes().getMembershipAttributes());
|
||||
assertNull(templateBasedReplicateRegion.getAttributes().getPartitionAttributes());
|
||||
assertEquals(Scope.GLOBAL, templateBasedReplicateRegion.getAttributes().getScope());
|
||||
assertTrue(templateBasedReplicateRegion.getAttributes().getStatisticsEnabled());
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getPartitionAttributes()).isNull();
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getScope()).isEqualTo(Scope.GLOBAL);
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getStatisticsEnabled()).isTrue();
|
||||
assertSubscriptionAttributes(templateBasedReplicateRegion.getAttributes().getSubscriptionAttributes(),
|
||||
InterestPolicy.CACHE_CONTENT);
|
||||
assertEquals(Object.class, templateBasedReplicateRegion.getAttributes().getValueConstraint());
|
||||
assertThat(templateBasedReplicateRegion.getAttributes().getValueConstraint()).isEqualTo(Object.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -397,32 +402,32 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertCacheListeners(templateBasedReplicateSubRegion, "testListener");
|
||||
assertCacheLoader(templateBasedReplicateSubRegion, "A");
|
||||
assertCacheWriter(templateBasedReplicateSubRegion, "B");
|
||||
assertFalse(templateBasedReplicateSubRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(templateBasedReplicateSubRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(16, templateBasedReplicateSubRegion.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(DataPolicy.REPLICATE, templateBasedReplicateSubRegion.getAttributes().getDataPolicy());
|
||||
assertFalse(templateBasedReplicateSubRegion.getAttributes().isDiskSynchronous());
|
||||
assertTrue(templateBasedReplicateSubRegion.getAttributes().getEnableAsyncConflation());
|
||||
assertFalse(templateBasedReplicateSubRegion.getAttributes().getEnableSubscriptionConflation());
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getConcurrencyLevel()).isEqualTo(16);
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().isDiskSynchronous()).isFalse();
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getEnableAsyncConflation()).isTrue();
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getEnableSubscriptionConflation()).isFalse();
|
||||
assertDefaultEvictionAttributes(templateBasedReplicateSubRegion.getAttributes().getEvictionAttributes());
|
||||
assertExpirationAttributes(templateBasedReplicateSubRegion.getAttributes().getEntryIdleTimeout(),
|
||||
ExpirationAction.DESTROY, 600);
|
||||
assertExpirationAttributes(templateBasedReplicateSubRegion.getAttributes().getEntryTimeToLive(),
|
||||
ExpirationAction.DESTROY, 600);
|
||||
assertEmpty(templateBasedReplicateSubRegion.getAttributes().getGatewaySenderIds());
|
||||
assertTrue(templateBasedReplicateSubRegion.getAttributes().getIgnoreJTA());
|
||||
assertFalse(templateBasedReplicateSubRegion.getAttributes().getIndexMaintenanceSynchronous());
|
||||
assertEquals(51, templateBasedReplicateSubRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(Integer.class, templateBasedReplicateSubRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals("0.95", String.valueOf(templateBasedReplicateSubRegion.getAttributes().getLoadFactor()));
|
||||
assertFalse(templateBasedReplicateSubRegion.getAttributes().isLockGrantor());
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getIgnoreJTA()).isTrue();
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getIndexMaintenanceSynchronous()).isFalse();
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getInitialCapacity()).isEqualTo(51);
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getKeyConstraint()).isEqualTo(Integer.class);
|
||||
assertThat(String.valueOf(templateBasedReplicateSubRegion.getAttributes().getLoadFactor())).isEqualTo("0.95");
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().isLockGrantor()).isFalse();
|
||||
assertMembershipAttributes(templateBasedReplicateSubRegion.getAttributes().getMembershipAttributes(),
|
||||
LossAction.LIMITED_ACCESS, ResumptionAction.NONE, "readWriteNode");
|
||||
assertNull(templateBasedReplicateSubRegion.getAttributes().getPartitionAttributes());
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, templateBasedReplicateSubRegion.getAttributes().getScope());
|
||||
assertTrue(templateBasedReplicateSubRegion.getAttributes().getStatisticsEnabled());
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getPartitionAttributes()).isNull();
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getStatisticsEnabled()).isTrue();
|
||||
assertDefaultSubscriptionAttributes(templateBasedReplicateSubRegion.getAttributes().getSubscriptionAttributes());
|
||||
assertEquals(String.class, templateBasedReplicateSubRegion.getAttributes().getValueConstraint());
|
||||
assertThat(templateBasedReplicateSubRegion.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -432,15 +437,16 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertDefaultRegionAttributes(templateBasedReplicateRegionNoOverrides);
|
||||
assertEmpty(templateBasedReplicateRegionNoOverrides.getAttributes().getAsyncEventQueueIds());
|
||||
assertCacheListeners(templateBasedReplicateRegionNoOverrides, "XYZ");
|
||||
assertNull(templateBasedReplicateRegionNoOverrides.getAttributes().getCacheLoader());
|
||||
assertNull(templateBasedReplicateRegionNoOverrides.getAttributes().getCacheWriter());
|
||||
assertTrue(templateBasedReplicateRegionNoOverrides.getAttributes().getCloningEnabled());
|
||||
assertTrue(templateBasedReplicateRegionNoOverrides.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(24, templateBasedReplicateRegionNoOverrides.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(DataPolicy.PERSISTENT_REPLICATE, templateBasedReplicateRegionNoOverrides.getAttributes().getDataPolicy());
|
||||
assertFalse(templateBasedReplicateRegionNoOverrides.getAttributes().isDiskSynchronous());
|
||||
assertFalse(templateBasedReplicateRegionNoOverrides.getAttributes().getEnableAsyncConflation());
|
||||
assertTrue(templateBasedReplicateRegionNoOverrides.getAttributes().getEnableSubscriptionConflation());
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getCacheLoader()).isNull();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getCacheWriter()).isNull();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getCloningEnabled()).isTrue();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getConcurrencyLevel()).isEqualTo(24);
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getDataPolicy())
|
||||
.isEqualTo(DataPolicy.PERSISTENT_REPLICATE);
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().isDiskSynchronous()).isFalse();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getEnableAsyncConflation()).isFalse();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getEnableSubscriptionConflation()).isTrue();
|
||||
assertEvictionAttributes(templateBasedReplicateRegionNoOverrides.getAttributes().getEvictionAttributes(),
|
||||
EvictionAction.OVERFLOW_TO_DISK, EvictionAlgorithm.LRU_ENTRY, 2024, null);
|
||||
assertExpirationAttributes(templateBasedReplicateRegionNoOverrides.getAttributes().getEntryIdleTimeout(),
|
||||
@@ -448,21 +454,23 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertExpirationAttributes(templateBasedReplicateRegionNoOverrides.getAttributes().getEntryTimeToLive(),
|
||||
ExpirationAction.INVALIDATE, 300);
|
||||
assertEmpty(templateBasedReplicateRegionNoOverrides.getAttributes().getGatewaySenderIds());
|
||||
assertTrue(templateBasedReplicateRegionNoOverrides.getAttributes().getIgnoreJTA());
|
||||
assertTrue(templateBasedReplicateRegionNoOverrides.getAttributes().getIndexMaintenanceSynchronous());
|
||||
assertEquals(51, templateBasedReplicateRegionNoOverrides.getAttributes().getInitialCapacity());
|
||||
assertEquals(String.class, templateBasedReplicateRegionNoOverrides.getAttributes().getKeyConstraint());
|
||||
assertEquals(0.85f, templateBasedReplicateRegionNoOverrides.getAttributes().getLoadFactor(), 0.0f);
|
||||
assertFalse(templateBasedReplicateRegionNoOverrides.getAttributes().isLockGrantor());
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getIgnoreJTA()).isTrue();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getIndexMaintenanceSynchronous()).isTrue();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getInitialCapacity()).isEqualTo(51);
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getKeyConstraint()).isEqualTo(String.class);
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getLoadFactor())
|
||||
.isCloseTo(0.85f, offset(0.0f));
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().isLockGrantor()).isFalse();
|
||||
assertDefaultMembershipAttributes(
|
||||
templateBasedReplicateRegionNoOverrides.getAttributes().getMembershipAttributes());
|
||||
assertNull(templateBasedReplicateRegionNoOverrides.getAttributes().getPartitionAttributes());
|
||||
assertEquals(Scope.DISTRIBUTED_ACK, templateBasedReplicateRegionNoOverrides.getAttributes().getScope());
|
||||
assertTrue(templateBasedReplicateRegionNoOverrides.getAttributes().getStatisticsEnabled());
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getPartitionAttributes()).isNull();
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_ACK);
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getStatisticsEnabled()).isTrue();
|
||||
assertSubscriptionAttributes(
|
||||
templateBasedReplicateRegionNoOverrides.getAttributes().getSubscriptionAttributes(),
|
||||
InterestPolicy.CACHE_CONTENT);
|
||||
assertEquals(Object.class, templateBasedReplicateRegionNoOverrides.getAttributes().getValueConstraint());
|
||||
assertThat(templateBasedReplicateRegionNoOverrides.getAttributes().getValueConstraint())
|
||||
.isEqualTo(Object.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -474,12 +482,13 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertCacheListeners(templateBasedPartitionRegion, "X", "Y", "Z");
|
||||
assertCacheLoader(templateBasedPartitionRegion, "A");
|
||||
assertCacheWriter(templateBasedPartitionRegion, "dbWriter");
|
||||
assertFalse(templateBasedPartitionRegion.getAttributes().getCloningEnabled());
|
||||
assertTrue(templateBasedPartitionRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(DataPolicy.PERSISTENT_PARTITION, templateBasedPartitionRegion.getAttributes().getDataPolicy());
|
||||
assertTrue(templateBasedPartitionRegion.getAttributes().isDiskSynchronous());
|
||||
assertTrue(templateBasedPartitionRegion.getAttributes().getEnableAsyncConflation());
|
||||
assertTrue(templateBasedPartitionRegion.getAttributes().getEnableSubscriptionConflation());
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getCloningEnabled()).isFalse();
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getConcurrencyChecksEnabled()).isTrue();
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getDataPolicy())
|
||||
.isEqualTo(DataPolicy.PERSISTENT_PARTITION);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().isDiskSynchronous()).isTrue();
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getEnableAsyncConflation()).isTrue();
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getEnableSubscriptionConflation()).isTrue();
|
||||
assertEvictionAttributes(templateBasedPartitionRegion.getAttributes().getEvictionAttributes(),
|
||||
EvictionAction.OVERFLOW_TO_DISK, EvictionAlgorithm.LRU_ENTRY, 8192000, null);
|
||||
assertExpirationAttributes(templateBasedPartitionRegion.getAttributes().getEntryIdleTimeout(),
|
||||
@@ -487,30 +496,36 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertExpirationAttributes(templateBasedPartitionRegion.getAttributes().getEntryTimeToLive(),
|
||||
ExpirationAction.INVALIDATE, 300);
|
||||
assertGatewaySenders(templateBasedPartitionRegion, "TestGatewaySender");
|
||||
assertFalse(templateBasedPartitionRegion.getAttributes().getIgnoreJTA());
|
||||
assertFalse(templateBasedPartitionRegion.getAttributes().getIndexMaintenanceSynchronous());
|
||||
assertEquals(51, templateBasedPartitionRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(Date.class, templateBasedPartitionRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals("0.7", String.valueOf(templateBasedPartitionRegion.getAttributes().getLoadFactor()));
|
||||
assertFalse(templateBasedPartitionRegion.getAttributes().isLockGrantor());
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getIgnoreJTA()).isFalse();
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getIndexMaintenanceSynchronous()).isFalse();
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getInitialCapacity()).isEqualTo(51);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getKeyConstraint()).isEqualTo(Date.class);
|
||||
assertThat(String.valueOf(templateBasedPartitionRegion.getAttributes().getLoadFactor())).isEqualTo("0.7");
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().isLockGrantor()).isFalse();
|
||||
assertMembershipAttributes(templateBasedPartitionRegion.getAttributes().getMembershipAttributes(),
|
||||
LossAction.NO_ACCESS, ResumptionAction.REINITIALIZE, "admin", "root", "supertool");
|
||||
assertNotNull(templateBasedPartitionRegion.getAttributes().getPartitionAttributes());
|
||||
assertEquals("Neighbor",
|
||||
templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getColocatedWith());
|
||||
assertEquals(8192, templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getLocalMaxMemory());
|
||||
assertEquals(2, templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getRedundantCopies());
|
||||
assertEquals(60000L, templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getRecoveryDelay());
|
||||
assertEquals(15000L, templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
|
||||
assertEquals(16384, templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getTotalMaxMemory());
|
||||
assertEquals(91, templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getTotalNumBuckets());
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes()).isNotNull();
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getColocatedWith())
|
||||
.isEqualTo("Neighbor");
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getLocalMaxMemory())
|
||||
.isEqualTo(8192);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getRedundantCopies())
|
||||
.isEqualTo(2);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getRecoveryDelay())
|
||||
.isEqualTo(60000L);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getStartupRecoveryDelay())
|
||||
.isEqualTo(15000L);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getTotalMaxMemory())
|
||||
.isEqualTo(16384);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getPartitionAttributes().getTotalNumBuckets())
|
||||
.isEqualTo(91);
|
||||
assertPartitionListener(templateBasedPartitionRegion, "testListener");
|
||||
assertPartitionResolver(templateBasedPartitionRegion, "testResolver");
|
||||
assertEquals(Scope.DISTRIBUTED_NO_ACK, templateBasedPartitionRegion.getAttributes().getScope());
|
||||
assertTrue(templateBasedPartitionRegion.getAttributes().getStatisticsEnabled());
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getScope()).isEqualTo(Scope.DISTRIBUTED_NO_ACK);
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getStatisticsEnabled()).isTrue();
|
||||
assertSubscriptionAttributes(templateBasedPartitionRegion.getAttributes().getSubscriptionAttributes(),
|
||||
InterestPolicy.ALL);
|
||||
assertEquals(Object.class, templateBasedPartitionRegion.getAttributes().getValueConstraint());
|
||||
assertThat(templateBasedPartitionRegion.getAttributes().getValueConstraint()).isEqualTo(Object.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -520,15 +535,15 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertDefaultRegionAttributes(templateBasedLocalRegion);
|
||||
assertEmpty(templateBasedLocalRegion.getAttributes().getAsyncEventQueueIds());
|
||||
assertCacheListeners(templateBasedLocalRegion, "X", "Y", "Z");
|
||||
assertNull(templateBasedLocalRegion.getAttributes().getCacheLoader());
|
||||
assertNull(templateBasedLocalRegion.getAttributes().getCacheWriter());
|
||||
assertTrue(templateBasedLocalRegion.getAttributes().getCloningEnabled());
|
||||
assertFalse(templateBasedLocalRegion.getAttributes().getConcurrencyChecksEnabled());
|
||||
assertEquals(8, templateBasedLocalRegion.getAttributes().getConcurrencyLevel());
|
||||
assertEquals(DataPolicy.NORMAL, templateBasedLocalRegion.getAttributes().getDataPolicy());
|
||||
assertFalse(templateBasedLocalRegion.getAttributes().isDiskSynchronous());
|
||||
assertFalse(templateBasedLocalRegion.getAttributes().getEnableAsyncConflation());
|
||||
assertFalse(templateBasedLocalRegion.getAttributes().getEnableSubscriptionConflation());
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getCacheLoader()).isNull();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getCacheWriter()).isNull();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getCloningEnabled()).isTrue();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getConcurrencyChecksEnabled()).isFalse();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getConcurrencyLevel()).isEqualTo(8);
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.NORMAL);
|
||||
assertThat(templateBasedLocalRegion.getAttributes().isDiskSynchronous()).isFalse();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getEnableAsyncConflation()).isFalse();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getEnableSubscriptionConflation()).isFalse();
|
||||
assertEvictionAttributes(templateBasedLocalRegion.getAttributes().getEvictionAttributes(),
|
||||
EvictionAction.LOCAL_DESTROY, EvictionAlgorithm.LRU_ENTRY, 4096, null);
|
||||
assertExpirationAttributes(templateBasedLocalRegion.getAttributes().getEntryIdleTimeout(),
|
||||
@@ -536,18 +551,18 @@ public class TemplateRegionsNamespaceIntegrationTests extends IntegrationTestsSu
|
||||
assertExpirationAttributes(templateBasedLocalRegion.getAttributes().getEntryTimeToLive(),
|
||||
ExpirationAction.INVALIDATE, 300);
|
||||
assertEmpty(templateBasedLocalRegion.getAttributes().getGatewaySenderIds());
|
||||
assertTrue(templateBasedLocalRegion.getAttributes().getIgnoreJTA());
|
||||
assertTrue(templateBasedLocalRegion.getAttributes().getIndexMaintenanceSynchronous());
|
||||
assertEquals(51, templateBasedLocalRegion.getAttributes().getInitialCapacity());
|
||||
assertEquals(Long.class, templateBasedLocalRegion.getAttributes().getKeyConstraint());
|
||||
assertEquals("0.85", String.valueOf(templateBasedLocalRegion.getAttributes().getLoadFactor()));
|
||||
assertFalse(templateBasedLocalRegion.getAttributes().isLockGrantor());
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getIgnoreJTA()).isTrue();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getIndexMaintenanceSynchronous()).isTrue();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getInitialCapacity()).isEqualTo(51);
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getKeyConstraint()).isEqualTo(Long.class);
|
||||
assertThat(String.valueOf(templateBasedLocalRegion.getAttributes().getLoadFactor())).isEqualTo("0.85");
|
||||
assertThat(templateBasedLocalRegion.getAttributes().isLockGrantor()).isFalse();
|
||||
assertDefaultMembershipAttributes(templateBasedLocalRegion.getAttributes().getMembershipAttributes());
|
||||
assertNull(templateBasedLocalRegion.getAttributes().getPartitionAttributes());
|
||||
assertEquals(Scope.LOCAL, templateBasedLocalRegion.getAttributes().getScope());
|
||||
assertTrue(templateBasedLocalRegion.getAttributes().getStatisticsEnabled());
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getPartitionAttributes()).isNull();
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getScope()).isEqualTo(Scope.LOCAL);
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getStatisticsEnabled()).isTrue();
|
||||
assertDefaultSubscriptionAttributes(templateBasedLocalRegion.getAttributes().getSubscriptionAttributes());
|
||||
assertEquals(String.class, templateBasedLocalRegion.getAttributes().getValueConstraint());
|
||||
assertThat(templateBasedLocalRegion.getAttributes().getValueConstraint()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
public static final class TestAsyncEventListener implements AsyncEventListener {
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -74,10 +73,10 @@ public class TxEventHandlersIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
TransactionListener[] listeners = cache.getCacheTransactionManager().getListeners();
|
||||
|
||||
assertEquals(2, listeners.length);
|
||||
assertSame(txListener1, listeners[0]);
|
||||
assertSame(txListener2, listeners[1]);
|
||||
assertSame(txWriter, cache.getCacheTransactionManager().getWriter());
|
||||
assertThat(listeners.length).isEqualTo(2);
|
||||
assertThat(listeners[0]).isSameAs(txListener1);
|
||||
assertThat(listeners[1]).isSameAs(txListener2);
|
||||
assertThat(cache.getCacheTransactionManager().getWriter()).isSameAs(txWriter);
|
||||
}
|
||||
|
||||
public static class TestTransactionListener implements TransactionListener, BeanNameAware {
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.eviction;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import org.apache.geode.cache.EvictionAction;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The EvictionActionTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the EvictionActionType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see EvictionActionType
|
||||
* @see org.apache.geode.cache.EvictionAction
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionActionTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAction() {
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, EvictionActionType.getEvictionAction(
|
||||
EvictionActionType.LOCAL_DESTROY));
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, EvictionActionType.getEvictionAction(
|
||||
EvictionActionType.OVERFLOW_TO_DISK));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionActionWithNull() {
|
||||
assertNull(EvictionActionType.getEvictionAction(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEvictionAction() {
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, EvictionActionType.LOCAL_DESTROY.getEvictionAction());
|
||||
assertEquals(EvictionAction.NONE, EvictionActionType.NONE.getEvictionAction());
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, EvictionActionType.OVERFLOW_TO_DISK.getEvictionAction());
|
||||
assertEquals(EvictionAction.DEFAULT_EVICTION_ACTION, EvictionActionType.DEFAULT.getEvictionAction());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(EvictionAction.DEFAULT_EVICTION_ACTION, EvictionActionType.DEFAULT.getEvictionAction());
|
||||
assertSame(EvictionActionType.LOCAL_DESTROY, EvictionActionType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
assertEquals(EvictionActionType.LOCAL_DESTROY, EvictionActionType.valueOf(EvictionAction.LOCAL_DESTROY));
|
||||
assertEquals(EvictionActionType.NONE, EvictionActionType.valueOf(EvictionAction.NONE));
|
||||
assertEquals(EvictionActionType.OVERFLOW_TO_DISK, EvictionActionType.valueOf(EvictionAction.OVERFLOW_TO_DISK));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(EvictionActionType.valueOf((EvictionAction) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(EvictionActionType.LOCAL_DESTROY, EvictionActionType.valueOfIgnoreCase("Local_Destroy"));
|
||||
assertEquals(EvictionActionType.NONE, EvictionActionType.valueOfIgnoreCase("none"));
|
||||
assertEquals(EvictionActionType.NONE, EvictionActionType.valueOfIgnoreCase("NONE"));
|
||||
assertEquals(EvictionActionType.OVERFLOW_TO_DISK, EvictionActionType.valueOfIgnoreCase("OverFlow_TO_DiSk"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase("REMOTE_DESTROY"));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase("All"));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase(" none "));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase("underflow_from_disk"));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase(" "));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase(""));
|
||||
assertNull(EvictionActionType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.eviction;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.EvictionAction;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link EvictionActionType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.EvictionAction
|
||||
* @see org.springframework.data.gemfire.eviction.EvictionActionType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionActionTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAction() {
|
||||
|
||||
assertThat(EvictionActionType.getEvictionAction(
|
||||
EvictionActionType.LOCAL_DESTROY)).isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
|
||||
assertThat(EvictionActionType.getEvictionAction(
|
||||
EvictionActionType.OVERFLOW_TO_DISK)).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionActionWithNull() {
|
||||
assertThat(EvictionActionType.getEvictionAction(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEvictionAction() {
|
||||
|
||||
assertThat(EvictionActionType.LOCAL_DESTROY.getEvictionAction()).isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
assertThat(EvictionActionType.NONE.getEvictionAction()).isEqualTo(EvictionAction.NONE);
|
||||
assertThat(EvictionActionType.OVERFLOW_TO_DISK.getEvictionAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(EvictionActionType.DEFAULT.getEvictionAction()).isEqualTo(EvictionAction.DEFAULT_EVICTION_ACTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
|
||||
assertThat(EvictionActionType.DEFAULT.getEvictionAction()).isEqualTo(EvictionAction.DEFAULT_EVICTION_ACTION);
|
||||
assertThat(EvictionActionType.DEFAULT).isSameAs(EvictionActionType.LOCAL_DESTROY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
|
||||
assertThat(EvictionActionType.valueOf(EvictionAction.LOCAL_DESTROY)).isEqualTo(EvictionActionType.LOCAL_DESTROY);
|
||||
assertThat(EvictionActionType.valueOf(EvictionAction.NONE)).isEqualTo(EvictionActionType.NONE);
|
||||
assertThat(EvictionActionType.valueOf(EvictionAction.OVERFLOW_TO_DISK)).isEqualTo(EvictionActionType.OVERFLOW_TO_DISK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertThat(EvictionActionType.valueOf((EvictionAction) null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("Local_Destroy")).isEqualTo(EvictionActionType.LOCAL_DESTROY);
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("none")).isEqualTo(EvictionActionType.NONE);
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("NONE")).isEqualTo(EvictionActionType.NONE);
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("OverFlow_TO_DiSk")).isEqualTo(EvictionActionType.OVERFLOW_TO_DISK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("REMOTE_DESTROY")).isNull();
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("All")).isNull();
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase(" none ")).isNull();
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("underflow_from_disk")).isNull();
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(EvictionActionType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,9 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.eviction;
|
||||
|
||||
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;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.apache.geode.cache.EvictionAction;
|
||||
@@ -34,13 +29,12 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The EvictionAttributesFactoryBeanTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the EvictionAttributesFactoryBean class used to create Region Eviction configuration settings.
|
||||
* Unit Tests for {@link EvictionAttributesFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see EvictionAttributesFactoryBean
|
||||
* @see org.apache.geode.cache.EvictionAttributes
|
||||
* @see org.springframework.data.gemfire.eviction.EvictionAttributesFactoryBean
|
||||
* @since 1.3.4
|
||||
*/
|
||||
public class EvictionAttributesFactoryBeanTest {
|
||||
@@ -63,11 +57,12 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
@Test
|
||||
public void testIsSingleton() {
|
||||
assertTrue(new EvictionAttributesFactoryBean().isSingleton());
|
||||
assertThat(new EvictionAttributesFactoryBean().isSingleton()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateEntryCountEvictionAttributesWithNullAction() {
|
||||
|
||||
factoryBean.setAction(null);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(1024);
|
||||
@@ -76,15 +71,16 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.DEFAULT_EVICTION_ACTION, evictionAttributes.getAction());
|
||||
assertNull(evictionAttributes.getObjectSizer());
|
||||
assertEquals(1024, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.DEFAULT_EVICTION_ACTION);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isNull();
|
||||
assertThat(evictionAttributes.getMaximum()).isEqualTo(1024);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateEntryCountEvictionAttributesWithLocalDestroy() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.LOCAL_DESTROY);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(128);
|
||||
@@ -93,15 +89,16 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, evictionAttributes.getAction());
|
||||
assertNull(evictionAttributes.getObjectSizer());
|
||||
assertEquals(128, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isNull();
|
||||
assertThat(evictionAttributes.getMaximum()).isEqualTo(128);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateEntryCountEvictionAttributesWithNone() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.NONE);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
@@ -110,15 +107,17 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.NONE, evictionAttributes.getAction());
|
||||
assertNull(evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAttributesFactoryBean.DEFAULT_LRU_MAXIMUM_ENTRIES, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.NONE);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isNull();
|
||||
assertThat(evictionAttributes.getMaximum())
|
||||
.isEqualTo(EvictionAttributesFactoryBean.DEFAULT_LRU_MAXIMUM_ENTRIES);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateEntryCountEvictionAttributesWithOverflowToDisk() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.OVERFLOW_TO_DISK);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
@@ -127,15 +126,17 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, evictionAttributes.getAction());
|
||||
assertNull(evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAttributesFactoryBean.DEFAULT_LRU_MAXIMUM_ENTRIES, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isNull();
|
||||
assertThat(evictionAttributes.getMaximum())
|
||||
.isEqualTo(EvictionAttributesFactoryBean.DEFAULT_LRU_MAXIMUM_ENTRIES);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateHeapPercentageEvictionAttributesWithNullAction() {
|
||||
|
||||
factoryBean.setAction(null);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setType(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
@@ -143,14 +144,15 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.DEFAULT_EVICTION_ACTION, evictionAttributes.getAction());
|
||||
assertSame(mockObjectSizer, evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.DEFAULT_EVICTION_ACTION);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isSameAs(mockObjectSizer);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateHeapPercentageEvictionAttributesWithLocalDestroy() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.LOCAL_DESTROY);
|
||||
factoryBean.setObjectSizer(null);
|
||||
factoryBean.setThreshold(null);
|
||||
@@ -159,14 +161,15 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, evictionAttributes.getAction());
|
||||
assertNull(evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isNull();
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateHeapPercentageEvictionAttributesWithNone() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.NONE);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
@@ -175,14 +178,15 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.NONE, evictionAttributes.getAction());
|
||||
assertSame(mockObjectSizer, evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.NONE);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isSameAs(mockObjectSizer);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateHeapPercentageEvictionAttributesWithOverflowToDisk() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.OVERFLOW_TO_DISK);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
@@ -191,14 +195,15 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, evictionAttributes.getAction());
|
||||
assertSame(mockObjectSizer, evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isSameAs(mockObjectSizer);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testCreateHeapPercentageEvictionAttributesSettingThreshold() {
|
||||
|
||||
EvictionAttributesFactoryBean factoryBean = new EvictionAttributesFactoryBean();
|
||||
|
||||
try {
|
||||
@@ -207,16 +212,17 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
factoryBean.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("HEAP_PERCENTAGE (LRU_HEAP algorithm) does not support threshold (a.k.a. maximum)!",
|
||||
expected.getMessage());
|
||||
assertEquals(85, factoryBean.getThreshold().intValue());
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, factoryBean.getType());
|
||||
assertThat(expected.getMessage())
|
||||
.isEqualTo("HEAP_PERCENTAGE (LRU_HEAP algorithm) does not support threshold (a.k.a. maximum)!");
|
||||
assertThat(factoryBean.getThreshold().intValue()).isEqualTo(85);
|
||||
assertThat(factoryBean.getType()).isEqualTo(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateMemorySizeEvictionAttributesWithNullAction() {
|
||||
|
||||
factoryBean.setAction(null);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(null);
|
||||
@@ -225,15 +231,17 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.DEFAULT_EVICTION_ACTION, evictionAttributes.getAction());
|
||||
assertSame(mockObjectSizer, evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAttributesFactoryBean.DEFAULT_MEMORY_MAXIMUM_SIZE, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.DEFAULT_EVICTION_ACTION);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isSameAs(mockObjectSizer);
|
||||
assertThat(evictionAttributes.getMaximum())
|
||||
.isEqualTo(EvictionAttributesFactoryBean.DEFAULT_MEMORY_MAXIMUM_SIZE);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateMemorySizeEvictionAttributesWithLocalDestroy() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.LOCAL_DESTROY);
|
||||
factoryBean.setObjectSizer(mockObjectSizer);
|
||||
factoryBean.setThreshold(1024);
|
||||
@@ -242,15 +250,16 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.LOCAL_DESTROY, evictionAttributes.getAction());
|
||||
assertSame(mockObjectSizer, evictionAttributes.getObjectSizer());
|
||||
assertEquals(1024, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.LOCAL_DESTROY);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isSameAs(mockObjectSizer);
|
||||
assertThat(evictionAttributes.getMaximum()).isEqualTo(1024);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateMemorySizeEvictionAttributesWithNone() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.NONE);
|
||||
factoryBean.setObjectSizer(null);
|
||||
factoryBean.setThreshold(256);
|
||||
@@ -259,15 +268,16 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.NONE, evictionAttributes.getAction());
|
||||
assertNull(evictionAttributes.getObjectSizer());
|
||||
assertEquals(256, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.NONE);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isNull();
|
||||
assertThat(evictionAttributes.getMaximum()).isEqualTo(256);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateMemorySizeEvictionAttributesWithOverflowToDisk() {
|
||||
|
||||
factoryBean.setAction(EvictionAction.OVERFLOW_TO_DISK);
|
||||
factoryBean.setObjectSizer(null);
|
||||
factoryBean.setThreshold(null);
|
||||
@@ -276,11 +286,11 @@ public class EvictionAttributesFactoryBeanTest {
|
||||
|
||||
EvictionAttributes evictionAttributes = factoryBean.getObject();
|
||||
|
||||
assertNotNull(evictionAttributes);
|
||||
assertEquals(EvictionAction.OVERFLOW_TO_DISK, evictionAttributes.getAction());
|
||||
assertNull(evictionAttributes.getObjectSizer());
|
||||
assertEquals(EvictionAttributesFactoryBean.DEFAULT_MEMORY_MAXIMUM_SIZE, evictionAttributes.getMaximum());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, evictionAttributes.getAlgorithm());
|
||||
assertThat(evictionAttributes).isNotNull();
|
||||
assertThat(evictionAttributes.getAction()).isEqualTo(EvictionAction.OVERFLOW_TO_DISK);
|
||||
assertThat(evictionAttributes.getObjectSizer()).isNull();
|
||||
assertThat(evictionAttributes.getMaximum())
|
||||
.isEqualTo(EvictionAttributesFactoryBean.DEFAULT_MEMORY_MAXIMUM_SIZE);
|
||||
assertThat(evictionAttributes.getAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.eviction;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.apache.geode.cache.EvictionAlgorithm;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The EvictionTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the EvictionType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see EvictionPolicyType
|
||||
* @see org.apache.geode.cache.EvictionAlgorithm
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionPolicyTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithm() {
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, EvictionPolicyType.getEvictionAlgorithm(
|
||||
EvictionPolicyType.HEAP_PERCENTAGE));
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, EvictionPolicyType.getEvictionAlgorithm(
|
||||
EvictionPolicyType.MEMORY_SIZE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithmWithNull() {
|
||||
assertNull(EvictionPolicyType.getEvictionAlgorithm(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEvictionAlgorithm() {
|
||||
assertEquals(EvictionAlgorithm.LRU_ENTRY, EvictionPolicyType.ENTRY_COUNT.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.LRU_HEAP, EvictionPolicyType.HEAP_PERCENTAGE.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.LRU_MEMORY, EvictionPolicyType.MEMORY_SIZE.getEvictionAlgorithm());
|
||||
assertEquals(EvictionAlgorithm.NONE, EvictionPolicyType.NONE.getEvictionAlgorithm());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
assertEquals(EvictionPolicyType.ENTRY_COUNT, EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_ENTRY));
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_HEAP));
|
||||
assertEquals(EvictionPolicyType.MEMORY_SIZE, EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_MEMORY));
|
||||
assertEquals(EvictionPolicyType.NONE, EvictionPolicyType.valueOf(EvictionAlgorithm.NONE));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testValueOfInvalidEvictionAlgorithms() {
|
||||
assertNull(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_ENTRY));
|
||||
assertNull(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_MEMORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(EvictionPolicyType.valueOf((EvictionAlgorithm) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(EvictionPolicyType.ENTRY_COUNT, EvictionPolicyType.valueOfIgnoreCase("entry_count"));
|
||||
assertEquals(EvictionPolicyType.HEAP_PERCENTAGE, EvictionPolicyType.valueOfIgnoreCase("Heap_Percentage"));
|
||||
assertEquals(EvictionPolicyType.MEMORY_SIZE, EvictionPolicyType.valueOfIgnoreCase("MEMorY_SiZe"));
|
||||
assertEquals(EvictionPolicyType.NONE, EvictionPolicyType.valueOfIgnoreCase("NONE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("number_of_entries"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("heap_%"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("mem_size"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase("memory_space"));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase(" "));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase(""));
|
||||
assertNull(EvictionPolicyType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.eviction;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.EvictionAlgorithm;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link EvictionPolicyType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.EvictionAlgorithm
|
||||
* @see org.springframework.data.gemfire.eviction.EvictionPolicyType
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class EvictionPolicyTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithm() {
|
||||
|
||||
assertThat(EvictionPolicyType.getEvictionAlgorithm(EvictionPolicyType.HEAP_PERCENTAGE)).isEqualTo(EvictionAlgorithm.LRU_HEAP);
|
||||
assertThat(EvictionPolicyType.getEvictionAlgorithm(EvictionPolicyType.MEMORY_SIZE)).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetEvictionAlgorithmWithNull() {
|
||||
assertThat(EvictionPolicyType.getEvictionAlgorithm(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEvictionAlgorithm() {
|
||||
|
||||
assertThat(EvictionPolicyType.ENTRY_COUNT.getEvictionAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_ENTRY);
|
||||
assertThat(EvictionPolicyType.HEAP_PERCENTAGE.getEvictionAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_HEAP);
|
||||
assertThat(EvictionPolicyType.MEMORY_SIZE.getEvictionAlgorithm()).isEqualTo(EvictionAlgorithm.LRU_MEMORY);
|
||||
assertThat(EvictionPolicyType.NONE.getEvictionAlgorithm()).isEqualTo(EvictionAlgorithm.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
|
||||
assertThat(EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_ENTRY)).isEqualTo(EvictionPolicyType.ENTRY_COUNT);
|
||||
assertThat(EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_HEAP)).isEqualTo(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
assertThat(EvictionPolicyType.valueOf(EvictionAlgorithm.LRU_MEMORY)).isEqualTo(EvictionPolicyType.MEMORY_SIZE);
|
||||
assertThat(EvictionPolicyType.valueOf(EvictionAlgorithm.NONE)).isEqualTo(EvictionPolicyType.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testValueOfInvalidEvictionAlgorithms() {
|
||||
|
||||
assertThat(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_ENTRY)).isNull();
|
||||
assertThat(EvictionPolicyType.valueOf(EvictionAlgorithm.LIFO_MEMORY)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertThat(EvictionPolicyType.valueOf((EvictionAlgorithm) null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("entry_count")).isEqualTo(EvictionPolicyType.ENTRY_COUNT);
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("Heap_Percentage")).isEqualTo(EvictionPolicyType.HEAP_PERCENTAGE);
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("MEMorY_SiZe")).isEqualTo(EvictionPolicyType.MEMORY_SIZE);
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("NONE")).isEqualTo(EvictionPolicyType.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("number_of_entries")).isNull();
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("heap_%")).isNull();
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("mem_size")).isNull();
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("memory_space")).isNull();
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(EvictionPolicyType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -14,18 +14,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.expiration;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.isA;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -34,15 +26,13 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.data.gemfire.expiration.AnnotationBasedExpiration.ExpirationMetaData;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.ExpirationAttributes;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
@@ -54,52 +44,54 @@ import org.springframework.expression.TypeLocator;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
|
||||
/**
|
||||
* The AnnotationBasedExpirationTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the AnnotationBasedExpirationTest.
|
||||
* Unit Tests for {@link AnnotationBasedExpiration}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see AnnotationBasedExpiration
|
||||
* @see org.springframework.data.gemfire.expiration.AnnotationBasedExpiration
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
public class AnnotationBasedExpirationTest {
|
||||
public class AnnotationBasedExpirationUnitTests {
|
||||
|
||||
private AnnotationBasedExpiration noDefaultExpiration = new AnnotationBasedExpiration();
|
||||
private final AnnotationBasedExpiration noDefaultExpiration = new AnnotationBasedExpiration();
|
||||
|
||||
protected void assertExpiration(ExpirationAttributes expirationAttributes, int expectedTimeout,
|
||||
ExpirationAction expectedAction) {
|
||||
|
||||
assertThat(expirationAttributes, is(not(nullValue())));
|
||||
assertThat(expirationAttributes.getTimeout(), is(equalTo(expectedTimeout)));
|
||||
assertThat(expirationAttributes.getAction(), is(equalTo(expectedAction)));
|
||||
assertThat(expirationAttributes).isNotNull();
|
||||
assertThat(expirationAttributes.getTimeout()).isEqualTo(expectedTimeout);
|
||||
assertThat(expirationAttributes.getAction()).isEqualTo(expectedAction);
|
||||
}
|
||||
|
||||
protected void assertExpiration(ExpirationMetaData expirationMetaData, int expectedTimeout,
|
||||
ExpirationActionType expectedExpirationAction) {
|
||||
|
||||
assertThat(expirationMetaData, is(not(nullValue())));
|
||||
assertThat(expirationMetaData.timeout(), is(equalTo(expectedTimeout)));
|
||||
assertThat(expirationMetaData.action(), is(equalTo(expectedExpirationAction)));
|
||||
assertThat(expirationMetaData).isNotNull();
|
||||
assertThat(expirationMetaData.timeout()).isEqualTo(expectedTimeout);
|
||||
assertThat(expirationMetaData.action()).isEqualTo(expectedExpirationAction);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructUninitializedAnnotationBasedExpirationInstance() {
|
||||
|
||||
AnnotationBasedExpiration expiration = new AnnotationBasedExpiration();
|
||||
|
||||
assertThat(expiration.getDefaultExpirationAttributes(), is(nullValue()));
|
||||
assertThat(expiration.getDefaultExpirationAttributes()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructInitializedAnnotationBasedExpirationInstance() {
|
||||
|
||||
AnnotationBasedExpiration expiration = new AnnotationBasedExpiration(ExpirationAttributes.DEFAULT);
|
||||
|
||||
assertThat(expiration.getDefaultExpirationAttributes(), is(equalTo(ExpirationAttributes.DEFAULT)));
|
||||
assertThat(expiration.getDefaultExpirationAttributes()).isEqualTo(ExpirationAttributes.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forIdleTimeoutNoDefaultExpiration() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
AnnotationBasedExpiration expiration = AnnotationBasedExpiration.forIdleTimeout();
|
||||
@@ -109,12 +101,13 @@ public class AnnotationBasedExpirationTest {
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveGenericExpiration());
|
||||
assertExpiration(expiration.getExpiry(mockRegionEntry), 60, ExpirationAction.INVALIDATE);
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(expiration.getExpiry(mockRegionEntry), is(nullValue()));
|
||||
assertThat(expiration.getExpiry(mockRegionEntry)).isNull();
|
||||
verify(mockRegionEntry, atLeast(3)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forIdleTimeoutWithDefaultExpiration() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
ExpirationAttributes defaultExpiration = new ExpirationAttributes(300, ExpirationAction.DESTROY);
|
||||
@@ -126,12 +119,13 @@ public class AnnotationBasedExpirationTest {
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveGenericExpiration());
|
||||
assertExpiration(expiration.getExpiry(mockRegionEntry), 60, ExpirationAction.INVALIDATE);
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(expiration.getExpiry(mockRegionEntry), is(equalTo(defaultExpiration)));
|
||||
assertThat(expiration.getExpiry(mockRegionEntry)).isEqualTo(defaultExpiration);
|
||||
verify(mockRegionEntry, atLeast(3)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forTimeToLiveNoDefaultExpiration() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
AnnotationBasedExpiration expiration = AnnotationBasedExpiration.forTimeToLive();
|
||||
@@ -141,12 +135,13 @@ public class AnnotationBasedExpirationTest {
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithIdleTimeoutGenericExpiration());
|
||||
assertExpiration(expiration.getExpiry(mockRegionEntry), 60, ExpirationAction.INVALIDATE);
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(expiration.getExpiry(mockRegionEntry), is(nullValue()));
|
||||
assertThat(expiration.getExpiry(mockRegionEntry)).isNull();
|
||||
verify(mockRegionEntry, atLeast(3)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forTimeToLiveWithDefaultExpiration() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
ExpirationAttributes defaultExpiration = new ExpirationAttributes(300, ExpirationAction.DESTROY);
|
||||
@@ -158,253 +153,278 @@ public class AnnotationBasedExpirationTest {
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithIdleTimeoutGenericExpiration());
|
||||
assertExpiration(expiration.getExpiry(mockRegionEntry), 60, ExpirationAction.INVALIDATE);
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(expiration.getExpiry(mockRegionEntry), is(equalTo(defaultExpiration)));
|
||||
assertThat(expiration.getExpiry(mockRegionEntry)).isEqualTo(defaultExpiration);
|
||||
verify(mockRegionEntry, atLeast(3)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAndGetBeanFactory() {
|
||||
final StandardEvaluationContext mockEvaluationContext = mock(StandardEvaluationContext.class,
|
||||
"MockStandardEvaluationContext");
|
||||
|
||||
StandardEvaluationContext mockEvaluationContext =
|
||||
mock(StandardEvaluationContext.class, "MockStandardEvaluationContext");
|
||||
|
||||
ConversionService mockConversionService = mock(ConversionService.class, "MockConversionService");
|
||||
|
||||
final ConfigurableBeanFactory mockBeanFactory = mock(ConfigurableBeanFactory.class, "MockBeanFactory");
|
||||
ConfigurableBeanFactory mockBeanFactory = mock(ConfigurableBeanFactory.class, "MockBeanFactory");
|
||||
|
||||
when(mockBeanFactory.getConversionService()).thenReturn(mockConversionService);
|
||||
when(mockBeanFactory.getBeanClassLoader()).thenReturn(Thread.currentThread().getContextClassLoader());
|
||||
|
||||
doAnswer(new Answer<Void>() {
|
||||
@Override public Void answer(final InvocationOnMock invocation) throws Throwable {
|
||||
BeanResolver beanResolver = invocation.getArgument(0);
|
||||
assertThat(beanResolver, is(instanceOf(BeanFactoryResolver.class)));
|
||||
assertThat(TestUtils.<ConfigurableBeanFactory>readField("beanFactory", beanResolver),
|
||||
is(equalTo(mockBeanFactory)));
|
||||
return null;
|
||||
}
|
||||
}).when(mockEvaluationContext).setBeanResolver(Matchers.any(BeanResolver.class));
|
||||
doAnswer((Answer<Void>) invocation -> {
|
||||
|
||||
BeanResolver beanResolver = invocation.getArgument(0);
|
||||
|
||||
assertThat(beanResolver).isInstanceOf(BeanFactoryResolver.class);
|
||||
assertThat(TestUtils.<ConfigurableBeanFactory>readField("beanFactory", beanResolver)).isEqualTo(mockBeanFactory);
|
||||
|
||||
return null;
|
||||
}).when(mockEvaluationContext).setBeanResolver(any(BeanResolver.class));
|
||||
|
||||
AnnotationBasedExpiration<Object, Object> annotationBasedExpiration = new AnnotationBasedExpiration<Object, Object>() {
|
||||
@Override StandardEvaluationContext newEvaluationContext() {
|
||||
|
||||
@Override
|
||||
StandardEvaluationContext newEvaluationContext() {
|
||||
return mockEvaluationContext;
|
||||
}
|
||||
};
|
||||
|
||||
annotationBasedExpiration.setBeanFactory(mockBeanFactory);
|
||||
|
||||
assertSame(mockBeanFactory, annotationBasedExpiration.getBeanFactory());
|
||||
assertThat(annotationBasedExpiration.getBeanFactory()).isSameAs(mockBeanFactory);
|
||||
|
||||
verify(mockEvaluationContext, times(3)).addPropertyAccessor(Matchers.any(PropertyAccessor.class));
|
||||
verify(mockEvaluationContext, times(1)).setTypeConverter(Matchers.any(TypeConverter.class));
|
||||
verify(mockEvaluationContext, times(1)).setTypeLocator(Matchers.any(TypeLocator.class));
|
||||
verify(mockEvaluationContext, times(1)).setBeanResolver(Matchers.any(BeanResolver.class));
|
||||
verify(mockEvaluationContext, times(3)).addPropertyAccessor(any(PropertyAccessor.class));
|
||||
verify(mockEvaluationContext, times(1)).setTypeConverter(any(TypeConverter.class));
|
||||
verify(mockEvaluationContext, times(1)).setTypeLocator(any(TypeLocator.class));
|
||||
verify(mockEvaluationContext, times(1)).setBeanResolver(any(BeanResolver.class));
|
||||
verify(mockBeanFactory, times(1)).getConversionService();
|
||||
verify(mockBeanFactory, times(1)).getBeanClassLoader();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void getUninitializedBeanFactory() {
|
||||
new AnnotationBasedExpiration<Object, Object>().getBeanFactory();
|
||||
new AnnotationBasedExpiration<>().getBeanFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAndGetDefaultExpirationAttributes() {
|
||||
|
||||
ExpirationAttributes expectedExpirationAttributes = new ExpirationAttributes(120, ExpirationAction.INVALIDATE);
|
||||
|
||||
AnnotationBasedExpiration expiration = new AnnotationBasedExpiration();
|
||||
|
||||
expiration.setDefaultExpirationAttributes(expectedExpirationAttributes);
|
||||
|
||||
assertThat(expiration.getDefaultExpirationAttributes(), is(equalTo(expectedExpirationAttributes)));
|
||||
assertThat(expiration.getDefaultExpirationAttributes()).isEqualTo(expectedExpirationAttributes);
|
||||
|
||||
expiration.setDefaultExpirationAttributes(null);
|
||||
|
||||
assertThat(expiration.getDefaultExpirationAttributes(), is(nullValue()));
|
||||
assertThat(expiration.getDefaultExpirationAttributes()).isNull();
|
||||
|
||||
expiration.setDefaultExpirationAttributes(ExpirationAttributes.DEFAULT);
|
||||
|
||||
assertThat(expiration.getDefaultExpirationAttributes(), is(equalTo(ExpirationAttributes.DEFAULT)));
|
||||
assertThat(expiration.getDefaultExpirationAttributes()).isEqualTo(ExpirationAttributes.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getExpiryCallsGetExpirationMetaDataOnRegionEntryFollowedByNewExpirationAttributes() {
|
||||
final ExpirationAttributes expectedExpirationAttributes = new ExpirationAttributes(60,
|
||||
ExpirationAction.LOCAL_DESTROY);
|
||||
|
||||
ExpirationAttributes expectedExpirationAttributes =
|
||||
new ExpirationAttributes(60, ExpirationAction.LOCAL_DESTROY);
|
||||
|
||||
final Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
AnnotationBasedExpiration expiration = new AnnotationBasedExpiration() {
|
||||
@Override protected ExpirationMetaData getExpirationMetaData(Region.Entry entry) {
|
||||
assertThat(entry, is(sameInstance(mockRegionEntry)));
|
||||
|
||||
@Override
|
||||
protected ExpirationMetaData getExpirationMetaData(Region.Entry entry) {
|
||||
assertThat(entry).isSameAs(mockRegionEntry);
|
||||
return ExpirationMetaData.from(expectedExpirationAttributes);
|
||||
}
|
||||
|
||||
@Override protected ExpirationAttributes newExpirationAttributes(ExpirationMetaData expirationMetaData) {
|
||||
assertThat(expirationMetaData.timeout(), is(equalTo(expectedExpirationAttributes.getTimeout())));
|
||||
assertThat(expirationMetaData.expirationAction(), is(equalTo(expectedExpirationAttributes.getAction())));
|
||||
@Override
|
||||
protected ExpirationAttributes newExpirationAttributes(ExpirationMetaData expirationMetaData) {
|
||||
assertThat(expirationMetaData.timeout()).isEqualTo(expectedExpirationAttributes.getTimeout());
|
||||
assertThat(expirationMetaData.expirationAction()).isEqualTo(expectedExpirationAttributes.getAction());
|
||||
return expectedExpirationAttributes;
|
||||
}
|
||||
};
|
||||
|
||||
assertThat(expiration.getExpiry(mockRegionEntry), is(equalTo(expectedExpirationAttributes)));
|
||||
assertThat(expiration.getExpiry(mockRegionEntry)).isEqualTo(expectedExpirationAttributes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isExpirationConfiguredWithGenericExpirationBasedRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithGenericExpiration());
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry), is(true));
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry)).isTrue();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry), is(true));
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry)).isTrue();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isExpirationConfiguredWithNoGenericExpirationRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutExpiration());
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry), is(false));
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry)).isFalse();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry), is(false));
|
||||
assertThat(noDefaultExpiration.isExpirationConfigured(mockRegionEntry)).isFalse();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isIdleTimeoutConfiguredWithIdleTimeoutExpirationBasedRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithIdleTimeoutExpiration());
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry), is(true));
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry)).isTrue();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry), is(true));
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry)).isTrue();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isIdleTimeoutConfiguredWithNoIdleTimeoutExpirationRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveGenericExpiration());
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry), is(false));
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry)).isFalse();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry), is(false));
|
||||
assertThat(noDefaultExpiration.isIdleTimeoutConfigured(mockRegionEntry)).isFalse();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isTimeToLiveConfiguredWithTimeToLiveExpirationBasedRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveExpiration());
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry), is(true));
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry)).isTrue();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry), is(true));
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry)).isTrue();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
public void isTimeToLiveConfiguredWithNoTimeToLiveExpirationRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry), is(false));
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry)).isFalse();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry), is(false));
|
||||
assertThat(noDefaultExpiration.isTimeToLiveConfigured(mockRegionEntry)).isFalse();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getExpirationWithGenericExpirationBasedRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithGenericExpiration());
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry), isA(Expiration.class));
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry)).isInstanceOf(Expiration.class);
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry), isA(Expiration.class));
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry)).isInstanceOf(Expiration.class);
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getExpirationWithNoGenericExpirationRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutExpiration());
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry), is(nullValue()));
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry)).isNull();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry), is(nullValue()));
|
||||
assertThat(noDefaultExpiration.getExpiration(mockRegionEntry)).isNull();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdleTimeoutWithIdleTimeoutExpirationBasedRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithIdleTimeoutExpiration());
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry), isA(IdleTimeoutExpiration.class));
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry)).isInstanceOf(IdleTimeoutExpiration.class);
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry), isA(IdleTimeoutExpiration.class));
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry)).isInstanceOf(IdleTimeoutExpiration.class);
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIdleTimeoutWithNoIdleTimeoutExpirationRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveGenericExpiration());
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry), is(nullValue()));
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry)).isNull();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry), is(nullValue()));
|
||||
assertThat(noDefaultExpiration.getIdleTimeout(mockRegionEntry)).isNull();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTimeToLiveWithTimeToLiveExpirationBasedRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveExpiration());
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry), isA(TimeToLiveExpiration.class));
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry)).isInstanceOf(TimeToLiveExpiration.class);
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry), isA(TimeToLiveExpiration.class));
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry)).isInstanceOf(TimeToLiveExpiration.class);
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTimeToLiveWithNoTimeToLiveExpirationRegionEntry() {
|
||||
|
||||
Region.Entry mockRegionEntry = mock(Region.Entry.class, "MockRegionEntry");
|
||||
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithIdleTimeoutGenericExpiration());
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry), is(nullValue()));
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry)).isNull();
|
||||
when(mockRegionEntry.getValue()).thenReturn(new RegionEntryValueWithNoExpiration());
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry), is(nullValue()));
|
||||
assertThat(noDefaultExpiration.getTimeToLive(mockRegionEntry)).isNull();
|
||||
verify(mockRegionEntry, times(2)).getValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromExpiration() {
|
||||
ExpirationMetaData expirationMetaData = ExpirationMetaData.from(
|
||||
RegionEntryValueWithGenericExpiration.class.getAnnotation(Expiration.class));
|
||||
|
||||
ExpirationMetaData expirationMetaData =
|
||||
ExpirationMetaData.from(RegionEntryValueWithGenericExpiration.class.getAnnotation(Expiration.class));
|
||||
|
||||
assertExpiration(expirationMetaData, 60, ExpirationActionType.INVALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromExpirationIdleTimeout() {
|
||||
ExpirationMetaData expirationMetaData = ExpirationMetaData.from(
|
||||
RegionEntryValueWithIdleTimeoutExpiration.class.getAnnotation(IdleTimeoutExpiration.class));
|
||||
|
||||
ExpirationMetaData expirationMetaData =
|
||||
ExpirationMetaData.from(RegionEntryValueWithIdleTimeoutExpiration.class.getAnnotation(IdleTimeoutExpiration.class));
|
||||
|
||||
assertExpiration(expirationMetaData, 120, ExpirationActionType.LOCAL_INVALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromExpirationTimeToLive() {
|
||||
ExpirationMetaData expirationMetaData = ExpirationMetaData.from(
|
||||
RegionEntryValueWithTimeToLiveExpiration.class.getAnnotation(TimeToLiveExpiration.class));
|
||||
|
||||
ExpirationMetaData expirationMetaData =
|
||||
ExpirationMetaData.from(RegionEntryValueWithTimeToLiveExpiration.class.getAnnotation(TimeToLiveExpiration.class));
|
||||
|
||||
assertExpiration(expirationMetaData, 300, ExpirationActionType.LOCAL_DESTROY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toExpirationAttributes() {
|
||||
|
||||
ExpirationMetaData expirationMetaData = new ExpirationMetaData(90, ExpirationActionType.DESTROY);
|
||||
|
||||
assertExpiration(expirationMetaData.toExpirationAttributes(), expirationMetaData.timeout(),
|
||||
@@ -414,37 +434,29 @@ public class AnnotationBasedExpirationTest {
|
||||
@Expiration(timeout = "60", action = "INVALIDATE")
|
||||
@IdleTimeoutExpiration(timeout = "120", action = "LOCAL_INVALIDATE")
|
||||
@TimeToLiveExpiration(timeout = "300", action = "LOCAL_DESTROY")
|
||||
public static class RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithTimeToLiveIdleTimeoutGenericExpiration { }
|
||||
|
||||
@IdleTimeoutExpiration(timeout = "120", action = "LOCAL_INVALIDATE")
|
||||
@TimeToLiveExpiration(timeout = "300", action = "LOCAL_DESTROY")
|
||||
public static class RegionEntryValueWithTimeToLiveIdleTimeoutExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithTimeToLiveIdleTimeoutExpiration { }
|
||||
|
||||
@Expiration(timeout = "60", action = "INVALIDATE")
|
||||
@TimeToLiveExpiration(timeout = "300", action = "LOCAL_DESTROY")
|
||||
public static class RegionEntryValueWithTimeToLiveGenericExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithTimeToLiveGenericExpiration { }
|
||||
|
||||
@TimeToLiveExpiration(timeout = "300", action = "LOCAL_DESTROY")
|
||||
public static class RegionEntryValueWithTimeToLiveExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithTimeToLiveExpiration { }
|
||||
|
||||
@Expiration(timeout = "60", action = "INVALIDATE")
|
||||
@IdleTimeoutExpiration(timeout = "120", action = "LOCAL_INVALIDATE")
|
||||
public static class RegionEntryValueWithIdleTimeoutGenericExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithIdleTimeoutGenericExpiration { }
|
||||
|
||||
@IdleTimeoutExpiration(timeout = "120", action = "LOCAL_INVALIDATE")
|
||||
public static class RegionEntryValueWithIdleTimeoutExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithIdleTimeoutExpiration { }
|
||||
|
||||
@Expiration(timeout = "60", action = "INVALIDATE")
|
||||
public static class RegionEntryValueWithGenericExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithGenericExpiration { }
|
||||
|
||||
public static class RegionEntryValueWithNoExpiration {
|
||||
}
|
||||
public static class RegionEntryValueWithNoExpiration { }
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.expiration;
|
||||
|
||||
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 org.apache.geode.cache.ExpirationAction;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The ExpirationActionTypeTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the ExpirationActionType enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see ExpirationActionType
|
||||
* @see org.apache.geode.cache.ExpirationAction
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class ExpirationActionTypeTest {
|
||||
|
||||
@Test
|
||||
public void testStaticGetExpirationAction() {
|
||||
assertEquals(ExpirationAction.DESTROY, ExpirationActionType.getExpirationAction(ExpirationActionType.DESTROY));
|
||||
assertEquals(ExpirationAction.LOCAL_DESTROY, ExpirationActionType.getExpirationAction(
|
||||
ExpirationActionType.LOCAL_DESTROY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetExpirationActionWithNull() {
|
||||
assertNull(ExpirationActionType.getExpirationAction(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetExpirationAction() {
|
||||
assertEquals(ExpirationAction.DESTROY, ExpirationActionType.DESTROY.getExpirationAction());
|
||||
assertEquals(ExpirationAction.INVALIDATE, ExpirationActionType.INVALIDATE.getExpirationAction());
|
||||
assertEquals(ExpirationAction.LOCAL_DESTROY, ExpirationActionType.LOCAL_DESTROY.getExpirationAction());
|
||||
assertEquals(ExpirationAction.LOCAL_INVALIDATE, ExpirationActionType.LOCAL_INVALIDATE.getExpirationAction());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(ExpirationAction.INVALIDATE, ExpirationActionType.DEFAULT.getExpirationAction());
|
||||
assertSame(ExpirationActionType.INVALIDATE, ExpirationActionType.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
assertEquals(ExpirationActionType.DESTROY, ExpirationActionType.valueOf(ExpirationAction.DESTROY));
|
||||
assertEquals(ExpirationActionType.INVALIDATE, ExpirationActionType.valueOf(ExpirationAction.INVALIDATE));
|
||||
assertEquals(ExpirationActionType.LOCAL_DESTROY, ExpirationActionType.valueOf(ExpirationAction.LOCAL_DESTROY));
|
||||
assertEquals(ExpirationActionType.LOCAL_INVALIDATE, ExpirationActionType.valueOf(ExpirationAction.LOCAL_INVALIDATE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfExpirationActionOrdinalValues() {
|
||||
try {
|
||||
for (int ordinal = 0; ordinal < Integer.MAX_VALUE; ordinal++) {
|
||||
ExpirationAction expirationAction = ExpirationAction.fromOrdinal(ordinal);
|
||||
ExpirationActionType expirationActionType = ExpirationActionType.valueOf(expirationAction);
|
||||
|
||||
assertNotNull(expirationActionType);
|
||||
assertEquals(expirationAction, expirationActionType.getExpirationAction());
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertNull(ExpirationActionType.valueOf((ExpirationAction) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(ExpirationActionType.DESTROY, ExpirationActionType.valueOfIgnoreCase("destroy"));
|
||||
assertEquals(ExpirationActionType.INVALIDATE, ExpirationActionType.valueOfIgnoreCase("Invalidate"));
|
||||
assertEquals(ExpirationActionType.LOCAL_DESTROY, ExpirationActionType.valueOfIgnoreCase("LOCAL_DESTROY"));
|
||||
assertEquals(ExpirationActionType.LOCAL_INVALIDATE, ExpirationActionType.valueOfIgnoreCase("LocaL_InValidAte"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
assertNull(ExpirationActionType.valueOfIgnoreCase("Invalid"));
|
||||
assertNull(ExpirationActionType.valueOfIgnoreCase("local destroy"));
|
||||
assertNull(ExpirationActionType.valueOfIgnoreCase(" "));
|
||||
assertNull(ExpirationActionType.valueOfIgnoreCase(""));
|
||||
assertNull(ExpirationActionType.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.expiration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link ExpirationActionType} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see ExpirationActionType
|
||||
* @see org.apache.geode.cache.ExpirationAction
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class ExpirationActionTypeUnitTests {
|
||||
|
||||
@Test
|
||||
public void testStaticGetExpirationAction() {
|
||||
|
||||
assertThat(ExpirationActionType.getExpirationAction(ExpirationActionType.DESTROY))
|
||||
.isEqualTo(ExpirationAction.DESTROY);
|
||||
|
||||
assertThat(ExpirationActionType.getExpirationAction(
|
||||
ExpirationActionType.LOCAL_DESTROY)).isEqualTo(ExpirationAction.LOCAL_DESTROY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticGetExpirationActionWithNull() {
|
||||
assertThat(ExpirationActionType.getExpirationAction(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetExpirationAction() {
|
||||
|
||||
assertThat(ExpirationActionType.DESTROY.getExpirationAction()).isEqualTo(ExpirationAction.DESTROY);
|
||||
assertThat(ExpirationActionType.INVALIDATE.getExpirationAction()).isEqualTo(ExpirationAction.INVALIDATE);
|
||||
assertThat(ExpirationActionType.LOCAL_DESTROY.getExpirationAction()).isEqualTo(ExpirationAction.LOCAL_DESTROY);
|
||||
assertThat(ExpirationActionType.LOCAL_INVALIDATE.getExpirationAction()).isEqualTo(ExpirationAction.LOCAL_INVALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertThat(ExpirationActionType.DEFAULT.getExpirationAction()).isEqualTo(ExpirationAction.INVALIDATE);
|
||||
|
||||
assertThat(ExpirationActionType.DEFAULT).isSameAs(ExpirationActionType.INVALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOf() {
|
||||
|
||||
assertThat(ExpirationActionType.valueOf(ExpirationAction.DESTROY)).isEqualTo(ExpirationActionType.DESTROY);
|
||||
assertThat(ExpirationActionType.valueOf(ExpirationAction.INVALIDATE)).isEqualTo(ExpirationActionType.INVALIDATE);
|
||||
assertThat(ExpirationActionType.valueOf(ExpirationAction.LOCAL_DESTROY)).isEqualTo(ExpirationActionType.LOCAL_DESTROY);
|
||||
assertThat(ExpirationActionType.valueOf(ExpirationAction.LOCAL_INVALIDATE)).isEqualTo(ExpirationActionType.LOCAL_INVALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfExpirationActionOrdinalValues() {
|
||||
|
||||
try {
|
||||
for (int ordinal = 0; ordinal < Integer.MAX_VALUE; ordinal++) {
|
||||
|
||||
ExpirationAction expirationAction = ExpirationAction.fromOrdinal(ordinal);
|
||||
ExpirationActionType expirationActionType = ExpirationActionType.valueOf(expirationAction);
|
||||
|
||||
assertThat(expirationActionType).isNotNull();
|
||||
assertThat(expirationActionType.getExpirationAction()).isEqualTo(expirationAction);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfWithNull() {
|
||||
assertThat(ExpirationActionType.valueOf((ExpirationAction) null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase("destroy")).isEqualTo(ExpirationActionType.DESTROY);
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase("Invalidate")).isEqualTo(ExpirationActionType.INVALIDATE);
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase("LOCAL_DESTROY")).isEqualTo(ExpirationActionType.LOCAL_DESTROY);
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase("LocaL_InValidAte")).isEqualTo(ExpirationActionType.LOCAL_INVALIDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithInvalidValues() {
|
||||
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase("Invalid")).isNull();
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase("local destroy")).isNull();
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(ExpirationActionType.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
}
|
||||
@@ -14,73 +14,72 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.expiration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.ExpirationAction;
|
||||
import org.apache.geode.cache.ExpirationAttributes;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The ExpirationAttributesFactoryBeanTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the ExpirationAttributesFactoryBean class.
|
||||
* Unit Tests for {@link ExpirationAttributesFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see ExpirationAttributesFactoryBean
|
||||
* @see org.apache.geode.cache.ExpirationAttributes
|
||||
* @see org.springframework.data.gemfire.expiration.ExpirationAttributesFactoryBean
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class ExpirationAttributesFactoryBeanTest {
|
||||
public class ExpirationAttributesFactoryBeanUnitTests {
|
||||
|
||||
@Test
|
||||
public void testIsSingleton() {
|
||||
assertTrue(new ExpirationAttributesFactoryBean().isSingleton());
|
||||
assertThat(new ExpirationAttributesFactoryBean().isSingleton()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetAction() {
|
||||
|
||||
ExpirationAttributesFactoryBean expirationAttributesFactoryBean = new ExpirationAttributesFactoryBean();
|
||||
|
||||
assertEquals(ExpirationAttributesFactoryBean.DEFAULT_EXPIRATION_ACTION,
|
||||
expirationAttributesFactoryBean.getAction());
|
||||
assertThat(expirationAttributesFactoryBean.getAction())
|
||||
.isEqualTo(ExpirationAttributesFactoryBean.DEFAULT_EXPIRATION_ACTION);
|
||||
|
||||
expirationAttributesFactoryBean.setAction(ExpirationAction.LOCAL_DESTROY);
|
||||
|
||||
assertEquals(ExpirationAction.LOCAL_DESTROY, expirationAttributesFactoryBean.getAction());
|
||||
assertThat(expirationAttributesFactoryBean.getAction()).isEqualTo(ExpirationAction.LOCAL_DESTROY);
|
||||
|
||||
expirationAttributesFactoryBean.setAction(null);
|
||||
|
||||
assertEquals(ExpirationAttributesFactoryBean.DEFAULT_EXPIRATION_ACTION,
|
||||
expirationAttributesFactoryBean.getAction());
|
||||
assertThat(expirationAttributesFactoryBean.getAction())
|
||||
.isEqualTo(ExpirationAttributesFactoryBean.DEFAULT_EXPIRATION_ACTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetTimeout() {
|
||||
|
||||
ExpirationAttributesFactoryBean expirationAttributesFactoryBean = new ExpirationAttributesFactoryBean();
|
||||
|
||||
assertEquals(0, expirationAttributesFactoryBean.getTimeout());
|
||||
assertThat(expirationAttributesFactoryBean.getTimeout()).isEqualTo(0);
|
||||
|
||||
expirationAttributesFactoryBean.setTimeout(60000);
|
||||
|
||||
assertEquals(60000, expirationAttributesFactoryBean.getTimeout());
|
||||
assertThat(expirationAttributesFactoryBean.getTimeout()).isEqualTo(60000);
|
||||
|
||||
expirationAttributesFactoryBean.setTimeout(null);
|
||||
|
||||
assertEquals(0, expirationAttributesFactoryBean.getTimeout());
|
||||
assertThat(expirationAttributesFactoryBean.getTimeout()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterPropertiesSet() throws Exception {
|
||||
|
||||
ExpirationAttributesFactoryBean expirationAttributesFactoryBean = new ExpirationAttributesFactoryBean();
|
||||
|
||||
assertNull(expirationAttributesFactoryBean.getObject());
|
||||
assertEquals(ExpirationAttributes.class, expirationAttributesFactoryBean.getObjectType());
|
||||
assertThat(expirationAttributesFactoryBean.getObject()).isNull();
|
||||
assertThat(expirationAttributesFactoryBean.getObjectType()).isEqualTo(ExpirationAttributes.class);
|
||||
|
||||
expirationAttributesFactoryBean.setAction(ExpirationAction.DESTROY);
|
||||
expirationAttributesFactoryBean.setTimeout(8192);
|
||||
@@ -88,10 +87,9 @@ public class ExpirationAttributesFactoryBeanTest {
|
||||
|
||||
ExpirationAttributes expirationAttributes = expirationAttributesFactoryBean.getObject();
|
||||
|
||||
assertNotNull(expirationAttributes);
|
||||
assertEquals(ExpirationAction.DESTROY, expirationAttributes.getAction());
|
||||
assertEquals(8192, expirationAttributes.getTimeout());
|
||||
assertEquals(expirationAttributes.getClass(), expirationAttributesFactoryBean.getObjectType());
|
||||
assertThat(expirationAttributes).isNotNull();
|
||||
assertThat(expirationAttributes.getAction()).isEqualTo(ExpirationAction.DESTROY);
|
||||
assertThat(expirationAttributes.getTimeout()).isEqualTo(8192);
|
||||
assertThat(expirationAttributesFactoryBean.getObjectType()).isEqualTo(expirationAttributes.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,10 +12,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -35,13 +32,18 @@ import org.springframework.data.gemfire.function.annotation.Filter;
|
||||
import org.springframework.data.gemfire.function.annotation.RegionData;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link FunctionArgumentResolver}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
*/
|
||||
public class FunctionArgumentResolverTest {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class FunctionArgumentResolverUnitTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultFunctionArgumentResolverWithNoArguments() {
|
||||
|
||||
FunctionArgumentResolver functionArgumentResolver = new DefaultFunctionArgumentResolver();
|
||||
FunctionContext mockFunctionContext = mock(FunctionContext.class);
|
||||
|
||||
@@ -49,12 +51,13 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = functionArgumentResolver.resolveFunctionArguments(mockFunctionContext);
|
||||
|
||||
assertNotNull(args);
|
||||
assertEquals(0, args.length);
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultFunctionArgumentResolverWithArgumentArray() {
|
||||
|
||||
FunctionArgumentResolver functionArgumentResolver = new DefaultFunctionArgumentResolver();
|
||||
FunctionContext functionContext = mock(FunctionContext.class);
|
||||
|
||||
@@ -62,16 +65,17 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = functionArgumentResolver.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertNotNull(args);
|
||||
assertFalse(args instanceof String[]);
|
||||
assertEquals(3, args.length);
|
||||
assertEquals("one", args[0]);
|
||||
assertEquals("two", args[1]);
|
||||
assertEquals("three", args[2]);
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args instanceof String[]).isFalse();
|
||||
assertThat(args.length).isEqualTo(3);
|
||||
assertThat(args[0]).isEqualTo("one");
|
||||
assertThat(args[1]).isEqualTo("two");
|
||||
assertThat(args[2]).isEqualTo("three");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultFunctionArgumentResolverWithSingleArgument() {
|
||||
|
||||
FunctionArgumentResolver functionArgumentResolver = new DefaultFunctionArgumentResolver();
|
||||
FunctionContext functionContext = mock(FunctionContext.class);
|
||||
|
||||
@@ -79,13 +83,14 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = functionArgumentResolver.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertNotNull(args);
|
||||
assertEquals(1, args.length);
|
||||
assertEquals("test", args[0]);
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(1);
|
||||
assertThat(args[0]).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodWithNoSpecialArgs() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithNoSpecialArgs", String.class, int.class,
|
||||
@@ -97,18 +102,20 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(originalArgs.length, args.length);
|
||||
assertThat(args.length).isEqualTo(originalArgs.length);
|
||||
|
||||
int index = 0;
|
||||
|
||||
int i = 0;
|
||||
for (Object arg : args) {
|
||||
assertSame(originalArgs[i++], arg);
|
||||
assertThat(arg).isSameAs(originalArgs[index++]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMethodWithRegionType() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Region<Object, Object> region = mock(Region.class);
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithRegionType", String.class, Region.class);
|
||||
@@ -120,22 +127,23 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(originalArgs.length + 1, args.length);
|
||||
assertThat(args.length).isEqualTo(originalArgs.length + 1);
|
||||
|
||||
int i = 0;
|
||||
for (Object arg : args) {
|
||||
if (i != 1) {
|
||||
assertSame(originalArgs[i++], arg);
|
||||
assertThat(arg).isSameAs(originalArgs[i++]);
|
||||
} else {
|
||||
assertSame(region, arg);
|
||||
assertThat(arg).isSameAs(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMethodWithOneArgRegionType() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Region<Object, Object> region = mock(Region.class);
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithOneArgRegionType", Region.class);
|
||||
@@ -147,14 +155,15 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(1, args.length);
|
||||
assertSame(region, args[0]);
|
||||
assertThat(args.length).isEqualTo(1);
|
||||
assertThat(args[0]).isSameAs(region);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMethodWithAnnotatedRegion() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Region<Object, Object> region = mock(Region.class);
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithAnnotatedRegion", Region.class, String.class);
|
||||
@@ -166,15 +175,16 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(2, args.length);
|
||||
assertSame(region, args[0]);
|
||||
assertSame(originalArgs[0], args[1]);
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isSameAs(region);
|
||||
assertThat(args[1]).isSameAs(originalArgs[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMethodWithFunctionContext() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
Region<Object, Object> region = mock(Region.class);
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithFunctionContext", Map.class, String.class,
|
||||
@@ -187,15 +197,16 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(3, args.length);
|
||||
assertSame(region, args[0]);
|
||||
assertSame(originalArgs[0], args[1]);
|
||||
assertSame(functionContext, args[2]);
|
||||
assertThat(args.length).isEqualTo(3);
|
||||
assertThat(args[0]).isSameAs(region);
|
||||
assertThat(args[1]).isSameAs(originalArgs[0]);
|
||||
assertThat(args[2]).isSameAs(functionContext);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Test
|
||||
public void testMethodWithResultSender() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
|
||||
ResultSender resultSender = mock(ResultSender.class);
|
||||
Region<Object, Object> region = mock(Region.class);
|
||||
@@ -210,15 +221,16 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(2, args.length);
|
||||
assertSame(region, args[0]);
|
||||
assertSame(resultSender, args[1]);
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isSameAs(region);
|
||||
assertThat(args[1]).isSameAs(resultSender);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testMethodWithFilterAndRegion() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
|
||||
Region<Object, Object> region = mock(Region.class);
|
||||
|
||||
@@ -235,40 +247,48 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(3, args.length);
|
||||
assertSame(region, args[0]);
|
||||
assertSame(originalArgs[0], args[2]);
|
||||
assertSame(keys, args[1]);
|
||||
assertThat(args.length).isEqualTo(3);
|
||||
assertThat(args[0]).isSameAs(region);
|
||||
assertThat(args[2]).isSameAs(originalArgs[0]);
|
||||
assertThat(args[1]).isSameAs(keys);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testMethodWithMultipleRegionData() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithMultipleRegionData", Map.class, Map.class);
|
||||
|
||||
new FunctionContextInjectingArgumentResolver(method);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testMethodWithMultipleRegions() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithMultipleRegions", Region.class, Map.class);
|
||||
|
||||
new FunctionContextInjectingArgumentResolver(method);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testMethodWithInvalidTypeForAnnotation() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithInvalidTypeForAnnotation", Region.class);
|
||||
|
||||
new FunctionContextInjectingArgumentResolver(method);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testMethodWithMultipleFunctionContext() throws SecurityException, NoSuchMethodException {
|
||||
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithMultipleFunctionContext",
|
||||
FunctionContext.class, FunctionContext.class);
|
||||
|
||||
new FunctionContextInjectingArgumentResolver(method);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMethodWithFunctionContextAndResultSender() throws NoSuchMethodException {
|
||||
|
||||
FunctionContext functionContext = mock(FunctionContext.class);
|
||||
ResultSender resultSender = mock(ResultSender.class);
|
||||
Method method = TestFunction.class.getDeclaredMethod("methodWithFunctionContextAndResultSender",
|
||||
@@ -282,51 +302,37 @@ public class FunctionArgumentResolverTest {
|
||||
|
||||
Object[] args = far.resolveFunctionArguments(functionContext);
|
||||
|
||||
assertEquals(2, args.length);
|
||||
assertSame(functionContext, args[0]);
|
||||
assertSame(resultSender, args[1]);
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isSameAs(functionContext);
|
||||
assertThat(args[1]).isSameAs(resultSender);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
static class TestFunction {
|
||||
|
||||
public void methodWithNoSpecialArgs(String s1, int i1, boolean b1) {
|
||||
}
|
||||
public void methodWithNoSpecialArgs(String s1, int i1, boolean b1) { }
|
||||
|
||||
public void methodWithRegionType(String s1, Region<?, ?> region) {
|
||||
}
|
||||
public void methodWithRegionType(String s1, Region<?, ?> region) { }
|
||||
|
||||
public void methodWithOneArgRegionType(Region<?, ?> region) {
|
||||
}
|
||||
public void methodWithOneArgRegionType(Region<?, ?> region) { }
|
||||
|
||||
public void methodWithAnnotatedRegion(@RegionData Region<?, ?> data, String s1) {
|
||||
}
|
||||
public void methodWithAnnotatedRegion(@RegionData Region<?, ?> data, String s1) { }
|
||||
|
||||
public void methodWithFunctionContext(@RegionData Map<?, ?> data, String s1, FunctionContext fc) {
|
||||
}
|
||||
public void methodWithFunctionContext(@RegionData Map<?, ?> data, String s1, FunctionContext fc) { }
|
||||
|
||||
public void methodWithResultSender(@RegionData Map<?, ?> data, ResultSender<?> resultSender) {
|
||||
}
|
||||
public void methodWithResultSender(@RegionData Map<?, ?> data, ResultSender<?> resultSender) { }
|
||||
|
||||
public void methodWithFilterAndRegion(@RegionData Map<String, Object> region, @Filter Set<String> keys, Object arg) {
|
||||
}
|
||||
public void methodWithFilterAndRegion(@RegionData Map<String, Object> region, @Filter Set<String> keys, Object arg) { }
|
||||
|
||||
//Invalid Method Signatures
|
||||
public void methodWithMultipleRegionData(@RegionData Map<?, ?> r1, @RegionData Map<?, ?> r2) {
|
||||
}
|
||||
public void methodWithMultipleRegionData(@RegionData Map<?, ?> r1, @RegionData Map<?, ?> r2) { }
|
||||
|
||||
public void methodWithMultipleRegions(Region<?, ?> r1, @RegionData Map<?, ?> r2) {
|
||||
}
|
||||
public void methodWithMultipleRegions(Region<?, ?> r1, @RegionData Map<?, ?> r2) { }
|
||||
|
||||
public void methodWithInvalidTypeForAnnotation(@Filter Region<?, ?> r1) {
|
||||
}
|
||||
public void methodWithInvalidTypeForAnnotation(@Filter Region<?, ?> r1) { }
|
||||
|
||||
public void methodWithMultipleFunctionContext(FunctionContext fc1, FunctionContext fc2) {
|
||||
}
|
||||
public void methodWithMultipleFunctionContext(FunctionContext fc1, FunctionContext fc2) { }
|
||||
|
||||
public void methodWithFunctionContextAndResultSender(FunctionContext fc1, ResultSender<?> rs) {
|
||||
|
||||
}
|
||||
public void methodWithFunctionContextAndResultSender(FunctionContext fc1, ResultSender<?> rs) { }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newRuntimeException;
|
||||
@@ -46,22 +44,21 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* The PdxFunctionArgumentResolverTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the PdxFunctionArgumentResolver class.
|
||||
* Unit Tests for {@link PdxFunctionArgumentResolver}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.function.PdxFunctionArgumentResolver
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.execute.FunctionContext
|
||||
* @see org.apache.geode.pdx.PdxInstance
|
||||
* @see org.apache.geode.pdx.PdxSerializer
|
||||
* @see org.apache.geode.pdx.internal.PdxInstanceEnum
|
||||
* @see org.springframework.data.gemfire.function.PdxFunctionArgumentResolver
|
||||
* @since 1.5.2
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class PdxFunctionArgumentResolverTest {
|
||||
public class PdxFunctionArgumentResolverUnitTests {
|
||||
|
||||
private static Cache gemfireCache;
|
||||
|
||||
@@ -73,7 +70,7 @@ public class PdxFunctionArgumentResolverTest {
|
||||
gemfireCache = new CacheFactory()
|
||||
.setPdxSerializer(new PersonPdxSerializer())
|
||||
.setPdxReadSerialized(true)
|
||||
.set("name", PdxFunctionArgumentResolverTest.class.getSimpleName())
|
||||
.set("name", PdxFunctionArgumentResolverUnitTests.class.getSimpleName())
|
||||
.set("log-level", "error")
|
||||
.create();
|
||||
}
|
||||
@@ -84,7 +81,7 @@ public class PdxFunctionArgumentResolverTest {
|
||||
gemfireCache = null;
|
||||
}
|
||||
|
||||
protected Method getMethod(Class<?> type, String methodName, Class<?>... parameterTypes) {
|
||||
private Method getMethod(Class<?> type, String methodName, Class<?>... parameterTypes) {
|
||||
|
||||
try {
|
||||
return type.getDeclaredMethod(methodName, parameterTypes);
|
||||
@@ -95,7 +92,7 @@ public class PdxFunctionArgumentResolverTest {
|
||||
}
|
||||
}
|
||||
|
||||
protected Object getMethodSignature(final String methodName, final Class<?>... parameterTypes) {
|
||||
private Object getMethodSignature(final String methodName, final Class<?>... parameterTypes) {
|
||||
|
||||
StringBuilder methodSignature = new StringBuilder(methodName);
|
||||
|
||||
@@ -112,22 +109,22 @@ public class PdxFunctionArgumentResolverTest {
|
||||
return methodSignature.toString();
|
||||
}
|
||||
|
||||
protected void assertArguments(final Object[] expectedArguments, final Object[] actualArguments) {
|
||||
private void assertArguments(final Object[] expectedArguments, final Object[] actualArguments) {
|
||||
|
||||
assertNotNull(actualArguments);
|
||||
assertNotSame(expectedArguments, actualArguments);
|
||||
assertEquals(expectedArguments.length, actualArguments.length);
|
||||
assertThat(actualArguments).isNotNull();
|
||||
assertThat(actualArguments).isNotSameAs(expectedArguments);
|
||||
assertThat(actualArguments.length).isEqualTo(expectedArguments.length);
|
||||
|
||||
for (int index = 0; index < expectedArguments.length; index++) {
|
||||
assertEquals(expectedArguments[index], actualArguments[index]);
|
||||
assertThat(actualArguments[index]).isEqualTo(expectedArguments[index]);
|
||||
}
|
||||
}
|
||||
|
||||
protected Person createPerson(final String firstName, final String lastName, final Gender gender) {
|
||||
private Person createPerson(final String firstName, final String lastName, final Gender gender) {
|
||||
return new Person(firstName, lastName, gender);
|
||||
}
|
||||
|
||||
protected PdxInstance toPdxInstance(final Person person) {
|
||||
private PdxInstance toPdxInstance(final Person person) {
|
||||
|
||||
PdxInstanceFactory pdxInstanceFactory = gemfireCache.createPdxInstanceFactory(person.getClass().getName());
|
||||
|
||||
@@ -138,7 +135,7 @@ public class PdxFunctionArgumentResolverTest {
|
||||
return pdxInstanceFactory.create();
|
||||
}
|
||||
|
||||
protected PdxInstance toPdxInstance(final Map<String, Object> objectData) {
|
||||
private PdxInstance toPdxInstance(final Map<String, Object> objectData) {
|
||||
|
||||
PdxInstanceFactory pdxInstanceFactory = gemfireCache.createPdxInstanceFactory(objectData.get("@type").toString());
|
||||
|
||||
@@ -151,7 +148,7 @@ public class PdxFunctionArgumentResolverTest {
|
||||
return pdxInstanceFactory.create();
|
||||
}
|
||||
|
||||
protected PdxInstance toPdxInstance(Enum<?> enumeratedType) {
|
||||
private PdxInstance toPdxInstance(Enum<?> enumeratedType) {
|
||||
|
||||
return PdxInstanceFactoryImpl.createPdxEnum(enumeratedType.getClass().getName(), enumeratedType.name(),
|
||||
enumeratedType.ordinal(), (GemFireCacheImpl) gemfireCache);
|
||||
@@ -161,7 +158,9 @@ public class PdxFunctionArgumentResolverTest {
|
||||
public void testResolveSimpleFunctionArguments() {
|
||||
|
||||
functionArgumentResolver = new PdxFunctionArgumentResolver() {
|
||||
@Override public Method getFunctionAnnotatedMethod() {
|
||||
|
||||
@Override
|
||||
public Method getFunctionAnnotatedMethod() {
|
||||
return getMethod(FunctionExecutions.class, "simpleMethod", Boolean.class, Character.class,
|
||||
Integer.class, Double.class, String.class);
|
||||
}
|
||||
@@ -180,8 +179,11 @@ public class PdxFunctionArgumentResolverTest {
|
||||
|
||||
@Test
|
||||
public void testResolveNonSerializedApplicationDomainTypeFunctionArguments() {
|
||||
|
||||
functionArgumentResolver = new PdxFunctionArgumentResolver() {
|
||||
@Override public Method getFunctionAnnotatedMethod() {
|
||||
|
||||
@Override
|
||||
public Method getFunctionAnnotatedMethod() {
|
||||
return getMethod(FunctionExecutions.class, "nonSerializedMethod", Boolean.class, Person.class,
|
||||
Character.class, Person.class, Integer.class, Double.class, Gender.class, String.class);
|
||||
}
|
||||
@@ -201,8 +203,11 @@ public class PdxFunctionArgumentResolverTest {
|
||||
|
||||
@Test
|
||||
public void testResolveSerializedApplicationDomainTypeFunctionArguments() {
|
||||
|
||||
functionArgumentResolver = new PdxFunctionArgumentResolver() {
|
||||
@Override public Method getFunctionAnnotatedMethod() {
|
||||
|
||||
@Override
|
||||
public Method getFunctionAnnotatedMethod() {
|
||||
return getMethod(FunctionExecutions.class, "serializedMethod", Boolean.class, Person.class,
|
||||
String.class, Gender.class);
|
||||
}
|
||||
@@ -224,8 +229,11 @@ public class PdxFunctionArgumentResolverTest {
|
||||
|
||||
@Test
|
||||
public void testResolveUnnecessaryDeserializationFunctionArguments() {
|
||||
|
||||
functionArgumentResolver = new PdxFunctionArgumentResolver() {
|
||||
@Override public Method getFunctionAnnotatedMethod() {
|
||||
|
||||
@Override
|
||||
public Method getFunctionAnnotatedMethod() {
|
||||
return getMethod(FunctionExecutions.class, "unnecessaryDeserializationMethod", Boolean.class,
|
||||
Object.class, String.class, PdxInstanceEnum.class);
|
||||
}
|
||||
@@ -246,8 +254,11 @@ public class PdxFunctionArgumentResolverTest {
|
||||
|
||||
@Test
|
||||
public void testResolveUnresolvableApplicationDomainTypeFunctionArguments() {
|
||||
|
||||
functionArgumentResolver = new PdxFunctionArgumentResolver() {
|
||||
@Override public Method getFunctionAnnotatedMethod() {
|
||||
|
||||
@Override
|
||||
public Method getFunctionAnnotatedMethod() {
|
||||
return getMethod(FunctionExecutions.class, "unresolvableMethod", String.class, Object.class);
|
||||
}
|
||||
};
|
||||
@@ -299,9 +310,11 @@ public class PdxFunctionArgumentResolverTest {
|
||||
private final String lastName;
|
||||
|
||||
public Person(final String firstName, final String lastName, final Gender gender) {
|
||||
|
||||
Assert.hasText(firstName, "The person's first name must be specified!");
|
||||
Assert.hasText(lastName, "The person's last name must be specified!");
|
||||
Assert.notNull(gender, "The person's gender must be specified!");
|
||||
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.gender = gender;
|
||||
@@ -12,72 +12,80 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function.config;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
import org.apache.geode.cache.execute.FunctionService;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
import org.apache.geode.cache.execute.FunctionService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.function.annotation.Filter;
|
||||
import org.springframework.data.gemfire.function.annotation.GemfireFunction;
|
||||
import org.springframework.data.gemfire.function.annotation.RegionData;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
public class AnnotationDrivenFunctionsTest {
|
||||
@SuppressWarnings("unused")
|
||||
public class AnnotationDrivenFunctionsIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext applicationContext;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
public void testAnnotatedFunctions() {
|
||||
|
||||
assertTrue(FunctionService.isRegistered("foo"));
|
||||
assertThat(FunctionService.isRegistered("foo")).isTrue();
|
||||
|
||||
Function function = FunctionService.getFunction("foo");
|
||||
assertFalse(function.isHA());
|
||||
assertFalse(function.optimizeForWrite());
|
||||
assertFalse(function.hasResult());
|
||||
Function<?> function = FunctionService.getFunction("foo");
|
||||
|
||||
assertThat(function.isHA()).isFalse();
|
||||
assertThat(function.optimizeForWrite()).isFalse();
|
||||
assertThat(function.hasResult()).isFalse();
|
||||
assertThat(FunctionService.isRegistered("bar")).isTrue();
|
||||
|
||||
assertTrue(FunctionService.isRegistered("bar"));
|
||||
function = FunctionService.getFunction("bar");
|
||||
assertTrue(function.isHA());
|
||||
assertFalse(function.optimizeForWrite());
|
||||
assertTrue(function.hasResult());
|
||||
|
||||
assertTrue(FunctionService.isRegistered("foo2"));
|
||||
assertThat(function.isHA()).isTrue();
|
||||
assertThat(function.optimizeForWrite()).isFalse();
|
||||
assertThat(function.hasResult()).isTrue();
|
||||
assertThat(FunctionService.isRegistered("foo2")).isTrue();
|
||||
|
||||
function = FunctionService.getFunction("foo2");
|
||||
assertTrue(function.isHA());
|
||||
assertTrue(function.optimizeForWrite());
|
||||
assertTrue(function.hasResult());
|
||||
|
||||
assertTrue(FunctionService.isRegistered("injectFilter"));
|
||||
assertThat(function.isHA()).isTrue();
|
||||
assertThat(function.optimizeForWrite()).isTrue();
|
||||
assertThat(function.hasResult()).isTrue();
|
||||
assertThat(FunctionService.isRegistered("injectFilter")).isTrue();
|
||||
|
||||
function = FunctionService.getFunction("injectFilter");
|
||||
assertTrue(function.isHA());
|
||||
assertTrue(function.optimizeForWrite());
|
||||
assertTrue(function.hasResult());
|
||||
|
||||
assertThat(function.isHA()).isTrue();
|
||||
assertThat(function.optimizeForWrite()).isTrue();
|
||||
assertThat(function.hasResult()).isTrue();
|
||||
}
|
||||
|
||||
@Component
|
||||
public static class FooFunction {
|
||||
|
||||
@GemfireFunction
|
||||
public void foo() {
|
||||
}
|
||||
public void foo() { }
|
||||
|
||||
@GemfireFunction(HA = true, optimizeForWrite = false)
|
||||
public String bar() {
|
||||
@@ -87,6 +95,7 @@ public class AnnotationDrivenFunctionsTest {
|
||||
|
||||
@Component
|
||||
public static class Foo2Function {
|
||||
|
||||
@GemfireFunction(id = "foo2", HA = true, optimizeForWrite = true)
|
||||
public List<String> foo(Object someVal, @RegionData Map<?, ?> region, Object someOtherValue) {
|
||||
return null;
|
||||
@@ -97,5 +106,4 @@ public class AnnotationDrivenFunctionsTest {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,23 +12,22 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
import org.apache.geode.cache.execute.Execution;
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
import org.apache.geode.cache.execute.FunctionException;
|
||||
import org.apache.geode.cache.execute.ResultCollector;
|
||||
import org.apache.geode.distributed.DistributedMember;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -40,12 +39,21 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests for {@link Function} {@link Execution} on {@link ClientCache}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.execute.Execution
|
||||
* @see org.apache.geode.cache.execute.Function
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = ClientCacheTestConfiguration.class)
|
||||
public class FunctionExecutionClientCacheTests extends IntegrationTestsSupport {
|
||||
public class FunctionExecutionClientCacheIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext applicationContext;
|
||||
@@ -57,22 +65,22 @@ public class FunctionExecutionClientCacheTests extends IntegrationTestsSupport {
|
||||
|
||||
Pool pool = this.applicationContext.getBean("gemfirePool", Pool.class);
|
||||
|
||||
assertEquals("gemfirePool", pool.getName());
|
||||
assertTrue(cache.getDefaultPool().getLocators().isEmpty());
|
||||
assertEquals(1, cache.getDefaultPool().getServers().size());
|
||||
assertTrue(pool.getLocators().isEmpty());
|
||||
assertEquals(1, pool.getServers().size());
|
||||
assertEquals(pool.getServers().get(0), cache.getDefaultPool().getServers().get(0));
|
||||
assertThat(pool.getName()).isEqualTo("gemfirePool");
|
||||
assertThat(cache.getDefaultPool().getLocators().isEmpty()).isTrue();
|
||||
assertThat(cache.getDefaultPool().getServers().size()).isEqualTo(1);
|
||||
assertThat(pool.getLocators().isEmpty()).isTrue();
|
||||
assertThat(pool.getServers().size()).isEqualTo(1);
|
||||
assertThat(cache.getDefaultPool().getServers().get(0)).isEqualTo(pool.getServers().get(0));
|
||||
|
||||
Region region = this.applicationContext.getBean("r1", Region.class);
|
||||
Region<?, ?> region = this.applicationContext.getBean("r1", Region.class);
|
||||
|
||||
assertEquals("r1", region.getName());
|
||||
assertNotNull(region.getAttributes());
|
||||
assertNull(region.getAttributes().getPoolName());
|
||||
assertThat(region.getName()).isEqualTo("r1");
|
||||
assertThat(region.getAttributes()).isNotNull();
|
||||
assertThat(region.getAttributes().getPoolName()).isNull();
|
||||
|
||||
GemfireOnServerFunctionTemplate template = this.applicationContext.getBean(GemfireOnServerFunctionTemplate.class);
|
||||
|
||||
assertTrue(template.getResultCollector() instanceof MyResultCollector);
|
||||
assertThat(template.getResultCollector() instanceof MyResultCollector).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +114,7 @@ class MyResultCollector implements ResultCollector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult(long arg0, TimeUnit arg1) throws FunctionException, InterruptedException {
|
||||
public Object getResult(long arg0, TimeUnit arg1) throws FunctionException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function.config;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -28,41 +28,50 @@ import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.data.gemfire.function.config.one.TestFunctionExecution;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
* Unit Tests for {@link FunctionExecutionComponentProvider}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.function.config.FunctionExecutionComponentProvider
|
||||
*/
|
||||
public class FunctionExecutionComponentProviderTest {
|
||||
public class FunctionExecutionComponentProviderUnitTests {
|
||||
|
||||
@Test
|
||||
public void testDiscovery() throws ClassNotFoundException {
|
||||
List<TypeFilter> includeFilters = new ArrayList<TypeFilter>();
|
||||
public void testDiscovery() {
|
||||
|
||||
List<TypeFilter> includeFilters = new ArrayList<>();
|
||||
|
||||
FunctionExecutionComponentProvider provider = new FunctionExecutionComponentProvider(includeFilters,
|
||||
AnnotationFunctionExecutionConfigurationSource.getFunctionExecutionAnnotationTypes());
|
||||
Set<BeanDefinition> candidates = provider.findCandidateComponents(this.getClass().getPackage().getName()
|
||||
+ ".one");
|
||||
|
||||
ScannedGenericBeanDefinition bd = null;
|
||||
Set<BeanDefinition> candidates =
|
||||
provider.findCandidateComponents(this.getClass().getPackage().getName() + ".one");
|
||||
|
||||
ScannedGenericBeanDefinition beanDefinition = null;
|
||||
|
||||
for (BeanDefinition candidate : candidates) {
|
||||
if (candidate.getBeanClassName().equals(TestFunctionExecution.class.getName())) {
|
||||
bd = (ScannedGenericBeanDefinition) candidate;
|
||||
beanDefinition = (ScannedGenericBeanDefinition) candidate;
|
||||
}
|
||||
}
|
||||
|
||||
assertNotNull(bd);
|
||||
|
||||
assertThat(beanDefinition).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExcludeFilter() throws ClassNotFoundException {
|
||||
List<TypeFilter> includeFilters = new ArrayList<TypeFilter>();
|
||||
FunctionExecutionComponentProvider provider = new FunctionExecutionComponentProvider(includeFilters,
|
||||
public void testExcludeFilter() {
|
||||
|
||||
List<TypeFilter> includeFilters = new ArrayList<>();
|
||||
|
||||
FunctionExecutionComponentProvider provider =
|
||||
new FunctionExecutionComponentProvider(includeFilters,
|
||||
AnnotationFunctionExecutionConfigurationSource.getFunctionExecutionAnnotationTypes());
|
||||
|
||||
provider.addExcludeFilter(new AssignableTypeFilter(TestFunctionExecution.class));
|
||||
|
||||
Set<BeanDefinition> candidates = provider.findCandidateComponents(this.getClass().getPackage().getName()
|
||||
+ ".one");
|
||||
Set<BeanDefinition> candidates =
|
||||
provider.findCandidateComponents(this.getClass().getPackage().getName() + ".one");
|
||||
|
||||
for (BeanDefinition candidate : candidates) {
|
||||
if (candidate.getBeanClassName().equals(TestFunctionExecution.class.getName())) {
|
||||
@@ -70,5 +79,4 @@ public class FunctionExecutionComponentProviderTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function.execution;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -50,13 +47,13 @@ import org.apache.geode.cache.execute.ResultCollector;
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class AbstractFunctionTemplateTest {
|
||||
public class AbstractFunctionTemplateUnitTests {
|
||||
|
||||
@Mock
|
||||
private AbstractFunctionExecution mockFunctionExecution;
|
||||
|
||||
@Mock
|
||||
Function mockFunction;
|
||||
private Function mockFunction;
|
||||
|
||||
@Mock
|
||||
private ResultCollector mockResultCollector;
|
||||
@@ -65,6 +62,7 @@ public class AbstractFunctionTemplateTest {
|
||||
public void executeWithFunctionAndArgs() {
|
||||
|
||||
Object[] args = { "test", "testing", "tested" };
|
||||
|
||||
List<Object> results = Arrays.asList(args);
|
||||
|
||||
when(mockFunctionExecution.setArguments(args)).thenReturn(mockFunctionExecution);
|
||||
@@ -86,9 +84,9 @@ public class AbstractFunctionTemplateTest {
|
||||
|
||||
Iterable<Object> actualResults = functionTemplate.execute(mockFunction, args);
|
||||
|
||||
assertThat(functionTemplate.getResultCollector(), is(equalTo(mockResultCollector)));
|
||||
assertThat(actualResults, is(notNullValue()));
|
||||
assertThat(actualResults, is(equalTo((results))));
|
||||
assertThat(functionTemplate.getResultCollector()).isEqualTo(mockResultCollector);
|
||||
assertThat(actualResults).isNotNull();
|
||||
assertThat(actualResults).isEqualTo((results));
|
||||
|
||||
verify(mockFunctionExecution, times(1)).setArguments(args);
|
||||
verify(mockFunctionExecution, times(1)).setFunction(mockFunction);
|
||||
@@ -121,9 +119,9 @@ public class AbstractFunctionTemplateTest {
|
||||
|
||||
String result = functionTemplate.executeAndExtract(mockFunction, args);
|
||||
|
||||
assertThat(functionTemplate.getResultCollector(), is(equalTo(mockResultCollector)));
|
||||
assertThat(result, is(notNullValue()));
|
||||
assertThat(result, is(equalTo("test")));
|
||||
assertThat(functionTemplate.getResultCollector()).isEqualTo(mockResultCollector);
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result).isEqualTo("test");
|
||||
|
||||
verify(mockFunctionExecution, times(1)).setArguments(args);
|
||||
verify(mockFunctionExecution, times(1)).setFunction(mockFunction);
|
||||
@@ -157,9 +155,9 @@ public class AbstractFunctionTemplateTest {
|
||||
|
||||
Iterable<Object> actualResults = functionTemplate.execute("TestFunction", args);
|
||||
|
||||
assertThat(functionTemplate.getResultCollector(), is(equalTo(mockResultCollector)));
|
||||
assertThat(actualResults, is(notNullValue()));
|
||||
assertThat(actualResults, is(equalTo(results)));
|
||||
assertThat(functionTemplate.getResultCollector()).isEqualTo(mockResultCollector);
|
||||
assertThat(actualResults).isNotNull();
|
||||
assertThat(actualResults).isEqualTo(results);
|
||||
|
||||
verify(mockFunctionExecution, times(1)).setArguments(args);
|
||||
verify(mockFunctionExecution, times(1)).setFunctionId("TestFunction");
|
||||
@@ -192,9 +190,9 @@ public class AbstractFunctionTemplateTest {
|
||||
|
||||
String result = functionTemplate.executeAndExtract("TestFunction", args);
|
||||
|
||||
assertThat(functionTemplate.getResultCollector(), is(equalTo(mockResultCollector)));
|
||||
assertThat(result, is(notNullValue()));
|
||||
assertThat(result, is(equalTo("test")));
|
||||
assertThat(functionTemplate.getResultCollector()).isEqualTo(mockResultCollector);
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result).isEqualTo("test");
|
||||
|
||||
verify(mockFunctionExecution, times(1)).setArguments(args);
|
||||
verify(mockFunctionExecution, times(1)).setFunctionId("TestFunction");
|
||||
@@ -227,7 +225,7 @@ public class AbstractFunctionTemplateTest {
|
||||
|
||||
functionTemplate.executeWithNoResult("TestFunction", args);
|
||||
|
||||
assertThat(functionTemplate.getResultCollector(), is(equalTo(mockResultCollector)));
|
||||
assertThat(functionTemplate.getResultCollector()).isEqualTo(mockResultCollector);
|
||||
|
||||
verify(mockFunctionExecution, times(1)).setArguments(args);
|
||||
verify(mockFunctionExecution, times(1)).setFunctionId("TestFunction");
|
||||
@@ -12,9 +12,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function.execution;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -92,27 +90,27 @@ public class FunctionIntegrationTests extends ForkingClientServerIntegrationTest
|
||||
|
||||
Object result = template.executeAndExtract("getMapWithNoArgs");
|
||||
|
||||
assertTrue(result.getClass().getName(), result instanceof Map);
|
||||
assertThat(result instanceof Map).as(result.getClass().getName()).isTrue();
|
||||
|
||||
Map<String, Integer> map = (Map<String, Integer>) result;
|
||||
|
||||
assertEquals(1, map.get("one").intValue());
|
||||
assertEquals(2, map.get("two").intValue());
|
||||
assertEquals(3, map.get("three").intValue());
|
||||
assertThat(map.get("one").intValue()).isEqualTo(1);
|
||||
assertThat(map.get("two").intValue()).isEqualTo(2);
|
||||
assertThat(map.get("three").intValue()).isEqualTo(3);
|
||||
|
||||
result = template.executeAndExtract("collections", Arrays.asList(1, 2, 3, 4, 5));
|
||||
|
||||
assertTrue(result.getClass().getName(), result instanceof List);
|
||||
assertThat(result instanceof List).as(result.getClass().getName()).isTrue();
|
||||
|
||||
List<?> list = (List<?>) result;
|
||||
|
||||
assertFalse(list.isEmpty());
|
||||
assertEquals(5, list.size());
|
||||
assertThat(list.isEmpty()).isFalse();
|
||||
assertThat(list.size()).isEqualTo(5);
|
||||
|
||||
int expectedNumber = 1;
|
||||
|
||||
for (Object actualNumber : list) {
|
||||
assertEquals(expectedNumber++, actualNumber);
|
||||
assertThat(actualNumber).isEqualTo(expectedNumber++);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +121,8 @@ public class FunctionIntegrationTests extends ForkingClientServerIntegrationTest
|
||||
Object result = new GemfireOnRegionFunctionTemplate(this.region)
|
||||
.executeAndExtract("arrays", new int[] { 1, 2, 3, 4, 5 });
|
||||
|
||||
assertTrue(result.getClass().getName(), result instanceof int[]);
|
||||
assertEquals(5, ((int[]) result).length);
|
||||
assertThat(result instanceof int[]).as(result.getClass().getName()).isTrue();
|
||||
assertThat(((int[]) result).length).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,10 +131,11 @@ public class FunctionIntegrationTests extends ForkingClientServerIntegrationTest
|
||||
|
||||
GemfireOnRegionOperations template = new GemfireOnRegionFunctionTemplate(this.region);
|
||||
|
||||
assertEquals(2, template.<Integer>execute("oneArg", "two").iterator().next().intValue());
|
||||
assertFalse(template.<Integer>execute("oneArg", Collections.singleton("one"), "two").iterator().hasNext());
|
||||
assertEquals(5, template.<Integer>execute("twoArg", "two", "three").iterator().next().intValue());
|
||||
assertEquals(5, template.<Integer>executeAndExtract("twoArg", "two", "three").intValue());
|
||||
assertThat(template.<Integer>execute("oneArg", "two").iterator().next().intValue()).isEqualTo(2);
|
||||
assertThat(template.<Integer>execute("oneArg", Collections.singleton("one"), "two").iterator().hasNext())
|
||||
.isFalse();
|
||||
assertThat(template.<Integer>execute("twoArg", "two", "three").iterator().next().intValue()).isEqualTo(5);
|
||||
assertThat(template.<Integer>executeAndExtract("twoArg", "two", "three").intValue()).isEqualTo(5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,33 +13,34 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.listener.adapter;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.same;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.Operation;
|
||||
import org.apache.geode.cache.query.CqEvent;
|
||||
import org.apache.geode.cache.query.CqQuery;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryListener;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link ContinuousQueryListenerAdapter}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Oliver Gierke
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter
|
||||
*/
|
||||
public class QueryListenerAdapterTest {
|
||||
public class QueryListenerAdapterUnitTests {
|
||||
|
||||
private ContinuousQueryListenerAdapter adapter;
|
||||
|
||||
@@ -88,6 +89,7 @@ public class QueryListenerAdapterTest {
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
interface Delegate {
|
||||
|
||||
void handleEvent(CqEvent event);
|
||||
@@ -114,12 +116,13 @@ public class QueryListenerAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheListenerAdapterItself() {
|
||||
assertSame(adapter, adapter.getDelegate());
|
||||
assertThat(adapter.getDelegate()).isSameAs(adapter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatTheDefaultHandlingMethodNameIsTheConstantDefault() {
|
||||
assertEquals(ContinuousQueryListenerAdapter.DEFAULT_LISTENER_METHOD_NAME, adapter.getDefaultListenerMethod());
|
||||
assertThat(adapter.getDefaultListenerMethod())
|
||||
.isEqualTo(ContinuousQueryListenerAdapter.DEFAULT_LISTENER_METHOD_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -270,10 +273,10 @@ public class QueryListenerAdapterTest {
|
||||
};
|
||||
|
||||
listenerAdapter.onEvent(event());
|
||||
assertThat(listener.count, is(1));
|
||||
assertThat(listener.count).isEqualTo(1);
|
||||
}
|
||||
|
||||
class SampleListener implements ContinuousQueryListener {
|
||||
static class SampleListener implements ContinuousQueryListener {
|
||||
|
||||
int count;
|
||||
|
||||
@@ -13,13 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -33,14 +29,14 @@ import org.springframework.data.gemfire.repository.sample.Algorithm;
|
||||
import org.springframework.data.gemfire.repository.sample.Animal;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DefaultGemfireEntityInformation}.
|
||||
* Unit Tests for {@link DefaultGemfireEntityInformation}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.repository.query.DefaultGemfireEntityInformation
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class DefaultGemfireEntityInformationTest {
|
||||
public class DefaultGemfireEntityInformationUnitTests {
|
||||
|
||||
private GemfireMappingContext mappingContext;
|
||||
|
||||
@@ -78,10 +74,10 @@ public class DefaultGemfireEntityInformationTest {
|
||||
GemfireEntityInformation<Algorithm, String> entityInfo =
|
||||
newEntityInformation(newPersistentEntity(Algorithm.class));
|
||||
|
||||
assertNotNull(entityInfo);
|
||||
assertEquals("Algorithms", entityInfo.getRegionName());
|
||||
assertTrue(Algorithm.class.isAssignableFrom(entityInfo.getJavaType()));
|
||||
assertEquals(String.class, entityInfo.getIdType());
|
||||
assertThat(entityInfo).isNotNull();
|
||||
assertThat(entityInfo.getRegionName()).isEqualTo("Algorithms");
|
||||
assertThat(Algorithm.class.isAssignableFrom(entityInfo.getJavaType())).isTrue();
|
||||
assertThat(entityInfo.getIdType()).isEqualTo(String.class);
|
||||
assertThat(entityInfo.getId(new QuickSort())).isEqualTo("QuickSort");
|
||||
assertThat(entityInfo.getId(newAlgorithm("Quick Sort"))).isEqualTo("Quick Sort");
|
||||
}
|
||||
@@ -92,10 +88,10 @@ public class DefaultGemfireEntityInformationTest {
|
||||
GemfireEntityInformation<Animal, Long> entityInfo =
|
||||
newEntityInformation(newPersistentEntity(Animal.class));
|
||||
|
||||
assertNotNull(entityInfo);
|
||||
assertEquals("Animal", entityInfo.getRegionName());
|
||||
assertEquals(Animal.class, entityInfo.getJavaType());
|
||||
assertEquals(Long.class, entityInfo.getIdType());
|
||||
assertThat(entityInfo).isNotNull();
|
||||
assertThat(entityInfo.getRegionName()).isEqualTo("Animal");
|
||||
assertThat(entityInfo.getJavaType()).isEqualTo(Animal.class);
|
||||
assertThat(entityInfo.getIdType()).isEqualTo(Long.class);
|
||||
assertThat(entityInfo.getId(newAnimal(1L, "Tyger"))).isEqualTo(1L);
|
||||
}
|
||||
|
||||
@@ -105,25 +101,24 @@ public class DefaultGemfireEntityInformationTest {
|
||||
GemfireEntityInformation<ConfusedDomainEntity, Long> entityInfo =
|
||||
newEntityInformation(newPersistentEntity(ConfusedDomainEntity.class));
|
||||
|
||||
assertNotNull(entityInfo);
|
||||
assertEquals("ConfusedDomainEntity", entityInfo.getRegionName());
|
||||
assertEquals(ConfusedDomainEntity.class, entityInfo.getJavaType());
|
||||
assertEquals(Long.class, entityInfo.getIdType());
|
||||
assertThat(entityInfo).isNotNull();
|
||||
assertThat(entityInfo.getRegionName()).isEqualTo("ConfusedDomainEntity");
|
||||
assertThat(entityInfo.getJavaType()).isEqualTo(ConfusedDomainEntity.class);
|
||||
assertThat(entityInfo.getIdType()).isEqualTo(Long.class);
|
||||
assertThat(entityInfo.getId(new ConfusedDomainEntity(123L))).isEqualTo(123L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
public void confusedDomainEntityTypedStringId() {
|
||||
|
||||
GemfireEntityInformation<ConfusedDomainEntity, ?> entityInfo =
|
||||
newEntityInformation(newPersistentEntity(ConfusedDomainEntity.class));
|
||||
|
||||
assertNotNull(entityInfo);
|
||||
assertEquals("ConfusedDomainEntity", entityInfo.getRegionName());
|
||||
assertEquals(ConfusedDomainEntity.class, entityInfo.getJavaType());
|
||||
assertThat(entityInfo).isNotNull();
|
||||
assertThat(entityInfo.getRegionName()).isEqualTo("ConfusedDomainEntity");
|
||||
assertThat(entityInfo.getJavaType()).isEqualTo(ConfusedDomainEntity.class);
|
||||
//assertEquals(String.class, entityInfo.getIdType());
|
||||
assertTrue(Long.class.equals(entityInfo.getIdType()));
|
||||
assertThat(Long.class.equals(entityInfo.getIdType())).isTrue();
|
||||
assertThat(entityInfo.getId(new ConfusedDomainEntity(123L))).isEqualTo(123L);
|
||||
assertThat(entityInfo.getId(new ConfusedDomainEntity("248"))).isEqualTo(248L);
|
||||
}
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.query;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -28,10 +26,12 @@ import org.springframework.data.gemfire.repository.sample.Person;
|
||||
import org.springframework.data.repository.query.parser.PartTree;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link GemfireQueryCreator}.
|
||||
* Unit Tests for {@link GemfireQueryCreator}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.repository.query.GemfireQueryCreator
|
||||
*/
|
||||
public class GemfireQueryCreatorUnitTests {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class GemfireQueryCreatorUnitTests {
|
||||
|
||||
QueryString query = queryCreator.createQuery();
|
||||
|
||||
assertThat(query.toString(), is(equalTo("SELECT * FROM /simple x WHERE x.lastname = $1")));
|
||||
assertThat(query.toString()).isEqualTo("SELECT * FROM /simple x WHERE x.lastname = $1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,6 +64,6 @@ public class GemfireQueryCreatorUnitTests {
|
||||
|
||||
QueryString query = queryCreator.createQuery();
|
||||
|
||||
assertThat(query.toString(), is(equalTo("SELECT * FROM /simple x WHERE x.address.city = $1")));
|
||||
assertThat(query.toString()).isEqualTo("SELECT * FROM /simple x WHERE x.address.city = $1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,16 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.query;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -49,7 +40,7 @@ import org.apache.geode.cache.query.SelectResults;
|
||||
* @see org.springframework.data.gemfire.repository.query.StringBasedGemfireRepositoryQuery
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class StringBasedGemfireRepositoryQueryTest {
|
||||
public class StringBasedGemfireRepositoryQueryUnitTests {
|
||||
|
||||
private final StringBasedGemfireRepositoryQuery repositoryQuery = new StringBasedGemfireRepositoryQuery();
|
||||
|
||||
@@ -65,7 +56,7 @@ public class StringBasedGemfireRepositoryQueryTest {
|
||||
|
||||
Collection<?> actualList = this.repositoryQuery.toCollection(mockSelectResults);
|
||||
|
||||
assertSame(expectedList, actualList);
|
||||
assertThat(actualList).isSameAs(expectedList);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,21 +66,22 @@ public class StringBasedGemfireRepositoryQueryTest {
|
||||
|
||||
Collection<?> actualList = this.repositoryQuery.toCollection(expectedList);
|
||||
|
||||
assertSame(expectedList, actualList);
|
||||
assertThat(actualList).isSameAs(expectedList);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
public void testToCollectionWithArray() {
|
||||
|
||||
Object[] array = { 1, 2, 3 };
|
||||
|
||||
Collection<?> list = repositoryQuery.toCollection(array);
|
||||
|
||||
assertNotNull(list);
|
||||
assertNotSame(array, list);
|
||||
assertTrue(list instanceof List);
|
||||
assertEquals(array.length, list.size());
|
||||
assertTrue(list.containsAll(Arrays.asList(array)));
|
||||
assertThat(list).isNotNull();
|
||||
assertThat(list).isNotSameAs(array);
|
||||
assertThat(list).isInstanceOf(List.class);
|
||||
assertThat(list.size()).isEqualTo(array.length);
|
||||
assertThat(list.containsAll(Arrays.asList(array))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,10 +89,10 @@ public class StringBasedGemfireRepositoryQueryTest {
|
||||
|
||||
Collection<?> list = repositoryQuery.toCollection("test");
|
||||
|
||||
assertTrue(list instanceof List);
|
||||
assertFalse(list.isEmpty());
|
||||
assertEquals(1, list.size());
|
||||
assertEquals("test", ((List<?>) list).get(0));
|
||||
assertThat(list instanceof List).isTrue();
|
||||
assertThat(list.isEmpty()).isFalse();
|
||||
assertThat(list.size()).isEqualTo(1);
|
||||
assertThat(((List<?>) list).get(0)).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,8 +100,8 @@ public class StringBasedGemfireRepositoryQueryTest {
|
||||
|
||||
Collection<?> list = repositoryQuery.toCollection(null);
|
||||
|
||||
assertNotNull(list);
|
||||
assertTrue(list.isEmpty());
|
||||
assertThat(list).isNotNull();
|
||||
assertThat(list.isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,16 +119,16 @@ public class StringBasedGemfireRepositoryQueryTest {
|
||||
|
||||
QueryString queryString = QueryString.of("SELECT * FROM /Example");
|
||||
|
||||
assertThat(queryString.toString(), is(equalTo("SELECT * FROM /Example")));
|
||||
assertThat(queryString.toString()).isEqualTo("SELECT * FROM /Example");
|
||||
|
||||
StringBasedGemfireRepositoryQuery repositoryQuery = new StringBasedGemfireRepositoryQuery();
|
||||
|
||||
String postProcessedQueryString = repositoryQuery.getQueryPostProcessor()
|
||||
.postProcess(mockQueryMethod, queryString.toString());
|
||||
|
||||
assertThat(postProcessedQueryString, is(notNullValue()));
|
||||
assertThat(postProcessedQueryString,
|
||||
is(equalTo("<TRACE> <HINT 'IdIdx', 'NameIdx'> IMPORT org.example.domain.Type; SELECT * FROM /Example LIMIT 10")));
|
||||
assertThat(postProcessedQueryString).isNotNull();
|
||||
assertThat(postProcessedQueryString).isEqualTo(
|
||||
"<TRACE> <HINT 'IdIdx', 'NameIdx'> IMPORT org.example.domain.Type; SELECT * FROM /Example LIMIT 10");
|
||||
|
||||
verify(mockQueryMethod, times(1)).hasHint();
|
||||
verify(mockQueryMethod, times(1)).getHints();
|
||||
@@ -161,15 +153,14 @@ public class StringBasedGemfireRepositoryQueryTest {
|
||||
|
||||
QueryString queryString = new QueryString("<HINT 'LastNameIdx'> SELECT * FROM /Example LIMIT 25");
|
||||
|
||||
assertThat(queryString.toString(), is(equalTo("<HINT 'LastNameIdx'> SELECT * FROM /Example LIMIT 25")));
|
||||
assertThat(queryString.toString()).isEqualTo("<HINT 'LastNameIdx'> SELECT * FROM /Example LIMIT 25");
|
||||
|
||||
StringBasedGemfireRepositoryQuery repositoryQuery = new StringBasedGemfireRepositoryQuery();
|
||||
|
||||
String postProcessedQueryString = repositoryQuery.getQueryPostProcessor().postProcess(mockQueryMethod, queryString.toString());
|
||||
|
||||
assertThat(postProcessedQueryString, is(notNullValue()));
|
||||
assertThat(postProcessedQueryString,
|
||||
is(equalTo("<TRACE> <HINT 'LastNameIdx'> SELECT * FROM /Example LIMIT 25")));
|
||||
assertThat(postProcessedQueryString).isNotNull();
|
||||
assertThat(postProcessedQueryString).isEqualTo("<TRACE> <HINT 'LastNameIdx'> SELECT * FROM /Example LIMIT 25");
|
||||
|
||||
verify(mockQueryMethod, times(1)).hasHint();
|
||||
verify(mockQueryMethod, never()).getHints();
|
||||
@@ -193,15 +184,14 @@ public class StringBasedGemfireRepositoryQueryTest {
|
||||
|
||||
QueryString queryString = new QueryString("<TRACE> SELECT * FROM /Example");
|
||||
|
||||
assertThat(queryString.toString(), is(equalTo("<TRACE> SELECT * FROM /Example")));
|
||||
assertThat(queryString.toString()).isEqualTo("<TRACE> SELECT * FROM /Example");
|
||||
|
||||
StringBasedGemfireRepositoryQuery repositoryQuery = new StringBasedGemfireRepositoryQuery();
|
||||
|
||||
String postProcessedQueryString = repositoryQuery.getQueryPostProcessor().postProcess(mockQueryMethod, queryString.toString());
|
||||
|
||||
assertThat(postProcessedQueryString, is(notNullValue()));
|
||||
assertThat(postProcessedQueryString,
|
||||
is(equalTo("IMPORT org.example.domain.Type; <TRACE> SELECT * FROM /Example")));
|
||||
assertThat(postProcessedQueryString).isNotNull();
|
||||
assertThat(postProcessedQueryString).isEqualTo("IMPORT org.example.domain.Type; <TRACE> SELECT * FROM /Example");
|
||||
|
||||
verify(mockQueryMethod, times(1)).hasHint();
|
||||
verify(mockQueryMethod, never()).getHints();
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.sample;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -33,9 +30,9 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The AlgorithmRepositoryIntegrationTests class is a test suite of test cases testing the contract and functionality of
|
||||
* GemFire's Repository extension when using a plain old Java interface for defining the application domain object
|
||||
* /entity type, rather than a Java class, that is the subject of the persistence operations.
|
||||
* Integration Tests testing the contract and functionality of GemFire's Repository extension when using a plain old
|
||||
* Java interface for defining the application domain object/entity type, rather than a Java class, that is the subject
|
||||
* of the persistence operations.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -60,31 +57,36 @@ public class AlgorithmRepositoryIntegrationTests extends IntegrationTestsSupport
|
||||
@Test
|
||||
public void algorithmsRepositoryFunctionsCorrectly() {
|
||||
|
||||
assertNotNull("A reference to the AlgorithmRepository was not properly configured!", algorithmRepo);
|
||||
assertNotNull("A reference to the 'Algorithms' GemFire Cache Region was not properly configured!",
|
||||
algorithmsRegion);
|
||||
assertEquals("Algorithms", algorithmsRegion.getName());
|
||||
assertEquals("/Algorithms", algorithmsRegion.getFullPath());
|
||||
assertTrue(algorithmsRegion.isEmpty());
|
||||
assertThat(algorithmRepo)
|
||||
.describedAs("A reference to the AlgorithmRepository was not properly configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(algorithmsRegion)
|
||||
.describedAs("A reference to the 'Algorithms' GemFire Cache Region was not properly configured!")
|
||||
.isNotNull();
|
||||
|
||||
assertThat(algorithmsRegion.getName()).isEqualTo("Algorithms");
|
||||
assertThat(algorithmsRegion.getFullPath()).isEqualTo("/Algorithms");
|
||||
assertThat(algorithmsRegion.isEmpty()).isTrue();
|
||||
|
||||
algorithmRepo.save(new BinarySearch());
|
||||
algorithmRepo.save(new HeapSort());
|
||||
|
||||
assertFalse(algorithmsRegion.isEmpty());
|
||||
assertEquals(2, algorithmsRegion.size());
|
||||
assertThat(algorithmsRegion.isEmpty()).isFalse();
|
||||
assertThat(algorithmsRegion.size()).isEqualTo(2);
|
||||
|
||||
assertTrue(algorithmsRegion.get(BinarySearch.class.getSimpleName()) instanceof BinarySearch);
|
||||
assertTrue(algorithmsRegion.get(HeapSort.class.getSimpleName()) instanceof HeapSort);
|
||||
assertThat(algorithmsRegion.get(BinarySearch.class.getSimpleName()) instanceof BinarySearch).isTrue();
|
||||
assertThat(algorithmsRegion.get(HeapSort.class.getSimpleName()) instanceof HeapSort).isTrue();
|
||||
|
||||
HeapSort heapSort = algorithmRepo.findByName(HeapSort.class.getSimpleName());
|
||||
|
||||
assertNotNull(heapSort);
|
||||
assertEquals(HeapSort.class.getSimpleName(), heapSort.getName());
|
||||
assertThat(heapSort).isNotNull();
|
||||
assertThat(heapSort.getName()).isEqualTo(HeapSort.class.getSimpleName());
|
||||
|
||||
BinarySearch binarySearch = algorithmRepo.findByName(BinarySearch.class.getSimpleName());
|
||||
|
||||
assertNotNull(binarySearch);
|
||||
assertEquals(BinarySearch.class.getSimpleName(), binarySearch.getName());
|
||||
assertThat(binarySearch).isNotNull();
|
||||
assertThat(binarySearch.getName()).isEqualTo(BinarySearch.class.getSimpleName());
|
||||
}
|
||||
|
||||
protected static abstract class AbstractAlgorithm implements Algorithm {
|
||||
|
||||
@@ -13,60 +13,52 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.repository.sample;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.repository.Query;
|
||||
import org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The UsingQueryAnnotationExtensionsInUserRepositoryIntegrationTest class is a test suite of test cases testing
|
||||
* the contract and functionality of the Spring Data Commons Repository abstraction, Spring Data GemFire Repository
|
||||
* extention with custom OQL Query annotations.
|
||||
* Integration Tests for custom OQL {@link Query} annotations.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.data.gemfire.repository.GemfireRepository
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.data.gemfire.repository.GemfireRepository
|
||||
* @see org.springframework.data.gemfire.repository.Query
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("unused")
|
||||
public class UsingQueryAnnotationExtensionsInUserRepositoryIntegrationTest {
|
||||
public class UsingQueryAnnotationExtensionsInUserRepositoryIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Resource(name = "Users")
|
||||
private Region<String, User> users;
|
||||
|
||||
@Autowired
|
||||
private UsingQueryAnnotationExtensionsInUserRepository userRepository;
|
||||
|
||||
protected static User create(String username) {
|
||||
private static User create(String username) {
|
||||
return new User(username);
|
||||
}
|
||||
|
||||
protected static List<User> users(String... usernames) {
|
||||
List<User> users = new ArrayList<User>(usernames.length);
|
||||
private static List<User> users(String... usernames) {
|
||||
|
||||
List<User> users = new ArrayList<>(usernames.length);
|
||||
|
||||
for (String username : usernames) {
|
||||
users.add(create(username));
|
||||
@@ -75,21 +67,29 @@ public class UsingQueryAnnotationExtensionsInUserRepositoryIntegrationTest {
|
||||
return users;
|
||||
}
|
||||
|
||||
protected User put(User user) {
|
||||
@Resource(name = "Users")
|
||||
private Region<String, User> users;
|
||||
|
||||
@Autowired
|
||||
private UsingQueryAnnotationExtensionsInUserRepository userRepository;
|
||||
|
||||
private User put(User user) {
|
||||
return put(users, user);
|
||||
}
|
||||
|
||||
protected User put(Region<String, User> users, User user) {
|
||||
private User put(Region<String, User> users, User user) {
|
||||
users.put(user.getUsername(), user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
assertThat(users, is(notNullValue()));
|
||||
|
||||
assertThat(users).isNotNull();
|
||||
|
||||
if (users.isEmpty()) {
|
||||
assertThat(users.size(), is(equalTo(0)));
|
||||
|
||||
assertThat(users.size()).isEqualTo(0);
|
||||
|
||||
put(create("jonDoe"));
|
||||
put(create("joeDoe"));
|
||||
@@ -100,38 +100,40 @@ public class UsingQueryAnnotationExtensionsInUserRepositoryIntegrationTest {
|
||||
put(create("sourDoe"));
|
||||
put(create("toeDoe"));
|
||||
|
||||
assertThat(users.size(), is(equalTo(8)));
|
||||
assertThat(users.size()).isEqualTo(8);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryUsingFindBy() {
|
||||
|
||||
List<User> users = userRepository.findBy("j%Doe");
|
||||
|
||||
assertThat(users, is(notNullValue()));
|
||||
assertThat(users.isEmpty(), is(false));
|
||||
assertThat(users.size(), is(equalTo(1)));
|
||||
assertThat(users.get(0), is(equalTo(create("janeDoe"))));
|
||||
assertThat(users).isNotNull();
|
||||
assertThat(users.isEmpty()).isFalse();
|
||||
assertThat(users.size()).isEqualTo(1);
|
||||
assertThat(users.get(0)).isEqualTo(create("janeDoe"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryUsingFindByUsernameOrderedAndLimited() {
|
||||
|
||||
List<User> users = userRepository.findDistinctByUsernameLikeOrderByUsernameAsc("%o%Doe");
|
||||
|
||||
assertThat(users, is(notNullValue()));
|
||||
assertThat(users.isEmpty(), is(false));
|
||||
assertThat(users.size(), is(equalTo(5)));
|
||||
assertThat(users, is(equalTo(users("cookieDoe", "froDoe", "joeDoe", "jonDoe", "sourDoe"))));
|
||||
assertThat(users).isNotNull();
|
||||
assertThat(users.isEmpty()).isFalse();
|
||||
assertThat(users.size()).isEqualTo(5);
|
||||
assertThat(users).isEqualTo(users("cookieDoe", "froDoe", "joeDoe", "jonDoe", "sourDoe"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryUsingFindByUsernameOrderedAndUnderLimit() {
|
||||
|
||||
List<User> users = userRepository.findDistinctByUsernameLikeOrderByUsernameAsc("%oo%Doe");
|
||||
|
||||
assertThat(users, is(notNullValue()));
|
||||
assertThat(users.isEmpty(), is(false));
|
||||
assertThat(users.size(), is(equalTo(1)));
|
||||
assertThat(users.get(0), is(equalTo(create("cookieDoe"))));
|
||||
assertThat(users).isNotNull();
|
||||
assertThat(users.isEmpty()).isFalse();
|
||||
assertThat(users.size()).isEqualTo(1);
|
||||
assertThat(users.get(0)).isEqualTo(create("cookieDoe"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,64 +13,61 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.RegionAttributes;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.mapping.GemfireMappingContext;
|
||||
import org.springframework.data.gemfire.repository.sample.PersonRepository;
|
||||
|
||||
/**
|
||||
* The GemfireRepositoryFactoryBeanTest class is test suite of test cases testing the contract and functionality
|
||||
* of the GemfireRepositoryFactoryBean class.
|
||||
* Unit Tests for {@link GemfireRepositoryFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Rule
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean
|
||||
* @since 1.6.3
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class GemfireRepositoryFactoryBeanTest {
|
||||
public class GemfireRepositoryFactoryBeanUnitTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
GemfireRepositoryFactoryBean repositoryFactoryBean;
|
||||
private GemfireRepositoryFactoryBean repositoryFactoryBean;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
repositoryFactoryBean = new GemfireRepositoryFactoryBean<>(PersonRepository.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void rejectsMappingContextNotSet() {
|
||||
exception.expect(IllegalStateException.class);
|
||||
exception.expectMessage("GemfireMappingContext");
|
||||
|
||||
repositoryFactoryBean.afterPropertiesSet();
|
||||
try {
|
||||
repositoryFactoryBean.afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalStateException expected) {
|
||||
|
||||
assertThat(expected).hasMessage("GemfireMappingContext");
|
||||
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initializesWithMappingContext() {
|
||||
|
||||
RegionAttributes<?, ?> mockRegionAttributes = mock(RegionAttributes.class);
|
||||
|
||||
doReturn(Long.class).when(mockRegionAttributes).getKeyConstraint();
|
||||
@@ -89,6 +86,6 @@ public class GemfireRepositoryFactoryBeanTest {
|
||||
repositoryFactoryBean.setGemfireMappingContext(new GemfireMappingContext());
|
||||
repositoryFactoryBean.afterPropertiesSet();
|
||||
|
||||
assertThat(repositoryFactoryBean.getObject(), is(notNullValue()));
|
||||
assertThat(repositoryFactoryBean.getObject()).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -35,12 +32,16 @@ import org.springframework.data.repository.support.Repositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
* Integration test for {@link GemfireRepositoryFactory}.
|
||||
* Integration Tests for {@link GemfireRepositoryFactory}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.repository.support.AbstractGemfireRepositoryFactoryIntegrationTests
|
||||
* @see org.springframework.data.gemfire.repository.support.GemfireRepositoryFactory
|
||||
*/
|
||||
@ContextConfiguration("../config/repo-context.xml")
|
||||
@SuppressWarnings("unused")
|
||||
public class GemfireRepositoryFactoryIntegrationTests extends AbstractGemfireRepositoryFactoryIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -59,14 +60,13 @@ public class GemfireRepositoryFactoryIntegrationTests extends AbstractGemfireRep
|
||||
new GemfireRepositoryFactory(Collections.emptySet(), mappingContext).getRepository(PersonRepository.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SGF-140
|
||||
*/
|
||||
@Test
|
||||
public void exposesPersistentProperty() {
|
||||
|
||||
Repositories repositories = new Repositories(applicationContext);
|
||||
|
||||
PersistentEntity<?, ?> entity = repositories.getPersistentEntity(Person.class);
|
||||
|
||||
assertThat(entity, is(notNullValue()));
|
||||
assertThat(entity).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.repository.support;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -89,10 +86,11 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
assertNotNull("The 'Customers' Cache Region was not properly configured and initialized!", this.customers);
|
||||
assertEquals("Customers", this.customers.getName());
|
||||
assertEquals("/Customers", this.customers.getFullPath());
|
||||
assertTrue(this.customers.isEmpty());
|
||||
assertThat(this.customers).as("The 'Customers' Cache Region was not properly configured and initialized!")
|
||||
.isNotNull();
|
||||
assertThat(this.customers.getName()).isEqualTo("Customers");
|
||||
assertThat(this.customers.getFullPath()).isEqualTo("/Customers");
|
||||
assertThat(this.customers.isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -111,8 +109,8 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
|
||||
|
||||
this.customerService.saveAll(expectedCustomers);
|
||||
|
||||
assertFalse(this.customers.isEmpty());
|
||||
assertEquals(expectedCustomers.size(), this.customers.size());
|
||||
assertThat(this.customers.isEmpty()).isFalse();
|
||||
assertThat(this.customers.size()).isEqualTo(expectedCustomers.size());
|
||||
|
||||
try {
|
||||
this.customerService.removeAllCausingTransactionRollback();
|
||||
@@ -121,12 +119,12 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
|
||||
// the RuntimeException should cause the Cache Transaction to rollback and avoid the Region modification!
|
||||
}
|
||||
|
||||
assertFalse(this.customers.isEmpty());
|
||||
assertEquals(expectedCustomers.size(), this.customers.size());
|
||||
assertThat(this.customers.isEmpty()).isFalse();
|
||||
assertThat(this.customers.size()).isEqualTo(expectedCustomers.size());
|
||||
|
||||
this.customerService.removeAll();
|
||||
|
||||
assertTrue(this.customers.isEmpty());
|
||||
assertThat(this.customers.isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
public static class SerializableCustomer extends Customer implements Serializable {
|
||||
@@ -145,9 +143,9 @@ public class SimpleGemfireRepositoryTransactionalIntegrationTest extends Integra
|
||||
|
||||
public static class CustomerService {
|
||||
|
||||
private GemfireRepository<Customer, Long> customerRepository;
|
||||
private final GemfireRepository<Customer, Long> customerRepository;
|
||||
|
||||
private TransactionTemplate transactionTemplate;
|
||||
private final TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
@SuppressWarnings("all")
|
||||
|
||||
@@ -13,42 +13,42 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.serialization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.geode.DataSerializable;
|
||||
import org.apache.geode.Instantiator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class AsmInstantiatorFactoryTest {
|
||||
import org.apache.geode.DataSerializable;
|
||||
import org.apache.geode.Instantiator;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link AsmInstantiatorGenerator}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.Instantiator
|
||||
* @see org.springframework.data.gemfire.serialization.AsmInstantiatorGenerator
|
||||
*/
|
||||
public class AsmInstantiatorFactoryUnitTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class SomeClass implements DataSerializable {
|
||||
|
||||
public static boolean instantiated = false;
|
||||
|
||||
public SomeClass() {
|
||||
instantiated = true;
|
||||
}
|
||||
|
||||
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 {
|
||||
}
|
||||
}
|
||||
|
||||
private AsmInstantiatorGenerator asmFactory = null;
|
||||
@@ -60,31 +60,41 @@ public class AsmInstantiatorFactoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassGeneration() throws Exception {
|
||||
public void testClassGeneration() {
|
||||
|
||||
Instantiator instantiator = asmFactory.getInstantiator(SomeClass.class, 100);
|
||||
assertEquals(100, instantiator.getId());
|
||||
assertEquals(SomeClass.class, instantiator.getInstantiatedClass());
|
||||
|
||||
assertThat(instantiator.getId()).isEqualTo(100);
|
||||
assertThat(instantiator.getInstantiatedClass()).isEqualTo(SomeClass.class);
|
||||
|
||||
Object instance = instantiator.newInstance();
|
||||
assertEquals(SomeClass.class, instance.getClass());
|
||||
assertTrue(SomeClass.instantiated);
|
||||
|
||||
assertThat(instance.getClass()).isEqualTo(SomeClass.class);
|
||||
assertThat(SomeClass.instantiated).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeneratedClassName() throws Exception {
|
||||
public void testGeneratedClassName() {
|
||||
|
||||
Instantiator instantiator = asmFactory.getInstantiator(SomeClass.class, 100);
|
||||
assertTrue(instantiator.getClass().getName().contains("$"));
|
||||
|
||||
assertThat(instantiator.getClass().getName().contains("$")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterfaces() throws Exception {
|
||||
public void testInterfaces() {
|
||||
|
||||
Instantiator instantiator = asmFactory.getInstantiator(SomeClass.class, 100);
|
||||
assertTrue(instantiator instanceof Serializable);
|
||||
|
||||
assertThat(instantiator instanceof Serializable).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheInPlace() throws Exception {
|
||||
public void testCacheInPlace() {
|
||||
|
||||
Instantiator instance1 = asmFactory.getInstantiator(SomeClass.class, 120);
|
||||
Instantiator instance2 = asmFactory.getInstantiator(SomeClass.class, 125);
|
||||
assertSame(instance1, instance2);
|
||||
|
||||
assertThat(instance2).isSameAs(instance1);
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,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;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
@@ -41,11 +37,13 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests for {@link WiringInstantiator}.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author John Blum
|
||||
*
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.Instantiator
|
||||
* @see org.springframework.data.gemfire.serialization.WiringInstantiator
|
||||
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
@@ -53,7 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("simple-config.xml")
|
||||
@SuppressWarnings("unused")
|
||||
public class WiringInstantiatorTest extends IntegrationTestsSupport {
|
||||
public class WiringInstantiatorIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@@ -115,16 +113,16 @@ public class WiringInstantiatorTest extends IntegrationTestsSupport {
|
||||
|
||||
Object instance = instantiator.newInstance();
|
||||
|
||||
assertNotNull(instance);
|
||||
assertTrue(instance instanceof AnnotatedBean);
|
||||
assertThat(instance).isNotNull();
|
||||
assertThat(instance instanceof AnnotatedBean).isTrue();
|
||||
|
||||
AnnotatedBean bean = (AnnotatedBean) instance;
|
||||
|
||||
assertNotNull(bean.point);
|
||||
assertNotNull(bean.shape);
|
||||
assertThat(bean.point).isNotNull();
|
||||
assertThat(bean.shape).isNotNull();
|
||||
|
||||
assertSame(bean.point, applicationContext.getBean("point"));
|
||||
assertSame(bean.shape, applicationContext.getBean("area"));
|
||||
assertThat(applicationContext.getBean("point")).isSameAs(bean.point);
|
||||
assertThat(applicationContext.getBean("area")).isSameAs(bean.shape);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,19 +136,19 @@ public class WiringInstantiatorTest extends IntegrationTestsSupport {
|
||||
|
||||
Object instance = instantiator2.newInstance();
|
||||
|
||||
assertTrue(instance instanceof TemplateWiringBean);
|
||||
assertThat(instance instanceof TemplateWiringBean).isTrue();
|
||||
TemplateWiringBean bean = (TemplateWiringBean) instance;
|
||||
|
||||
assertNull(bean.point);
|
||||
assertNotNull(bean.beans);
|
||||
assertThat(bean.point).isNull();
|
||||
assertThat(bean.beans).isNotNull();
|
||||
|
||||
assertSame(bean.beans, applicationContext.getBean("beans"));
|
||||
assertThat(applicationContext.getBean("beans")).isSameAs(bean.beans);
|
||||
}
|
||||
|
||||
public void testInstantiatorFactoryBean() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Instantiator> list = (List<Instantiator>) applicationContext.getBean("instantiator-factory");
|
||||
assertNotNull(list);
|
||||
assertEquals(2, list.size());
|
||||
assertThat(list).isNotNull();
|
||||
assertThat(list.size()).isEqualTo(2);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.serialization.json;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalArgumentException;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -43,8 +43,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration Tests testings SDG support for storing and reading JSON data to/from a {@link Region}
|
||||
* by (un)marshalling JSON data using Jackson.
|
||||
* Integration Tests for storing and reading JSON data to and from a {@link Region} by (un)marshalling JSON data
|
||||
* using Jackson.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
@@ -91,11 +91,11 @@ public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
this.jsonRegion.put("keyOne", json);
|
||||
|
||||
assertEquals(json, this.jsonRegion.put("keyOne", json));
|
||||
assertThat(this.jsonRegion.put("keyOne", json)).isEqualTo(json);
|
||||
|
||||
this.jsonRegion.create("keyTwo", json);
|
||||
|
||||
assertEquals(json, this.jsonRegion.get("keyTwo"));
|
||||
assertThat(this.jsonRegion.get("keyTwo")).isEqualTo(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,8 +110,8 @@ public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
Map<Object, Object> results = this.jsonRegion.getAll(Arrays.asList("key1", "key2"));
|
||||
|
||||
assertEquals("{\"hello1\":\"world1\"}", results.get("key1"));
|
||||
assertEquals("{\"hello2\":\"world2\"}", results.get("key2"));
|
||||
assertThat(results.get("key1")).isEqualTo("{\"hello1\":\"world1\"}");
|
||||
assertThat(results.get("key2")).isEqualTo("{\"hello2\":\"world2\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,11 +123,11 @@ public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport {
|
||||
|
||||
String json = String.valueOf(this.jsonRegion.get("dave"));
|
||||
|
||||
assertEquals(json, toJson(davidTuranski));
|
||||
assertThat(toJson(davidTuranski)).isEqualTo(json);
|
||||
|
||||
Object result = jsonRegion.put("dave", davidTuranski);
|
||||
|
||||
assertEquals(toJson(davidTuranski), result);
|
||||
assertThat(result).isEqualTo(toJson(davidTuranski));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,7 +140,7 @@ public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport {
|
||||
SelectResults<String> results = this.template.find(String.format("SELECT * FROM %s WHERE firstname=$1",
|
||||
this.jsonRegion.getFullPath()), davidTuranski.getFirstname());
|
||||
|
||||
assertEquals(toJson(davidTuranski), results.iterator().next());
|
||||
assertThat(results.iterator().next()).isEqualTo(toJson(davidTuranski));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -153,7 +153,7 @@ public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport {
|
||||
String json = this.template.findUnique(String.format("SELECT * FROM %s WHERE firstname=$1",
|
||||
this.jsonRegion.getFullPath()), davidTuranski.getFirstname());
|
||||
|
||||
assertEquals(toJson(davidTuranski), json);
|
||||
assertThat(json).isEqualTo(toJson(davidTuranski));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,6 +166,6 @@ public class JSONRegionAdviceIntegrationTests extends IntegrationTestsSupport {
|
||||
SelectResults<String> results =
|
||||
this.template.query(String.format("firstname='%s'", davidTuranski.getFirstname()));
|
||||
|
||||
assertEquals(toJson(davidTuranski), results.iterator().next());
|
||||
assertThat(results.iterator().next()).isEqualTo(toJson(davidTuranski));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Matchers.same;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.same;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -34,41 +29,41 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.InterestRegistrationListener;
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
import org.apache.geode.cache.server.ClientSubscriptionConfig;
|
||||
import org.apache.geode.cache.server.ServerLoadProbe;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link CacheServerFactoryBean}.
|
||||
* Unit Tests for {@link CacheServerFactoryBean}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.springframework.data.gemfire.server.CacheServerFactoryBean
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class CacheServerFactoryBeanTest {
|
||||
public class CacheServerFactoryBeanUnitTests {
|
||||
|
||||
@Test
|
||||
public void testGetObjectUninitialized() {
|
||||
assertNull(new CacheServerFactoryBean().getObject());
|
||||
assertThat(new CacheServerFactoryBean().getObject()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetObjectType() {
|
||||
assertEquals(CacheServer.class, new CacheServerFactoryBean().getObjectType());
|
||||
assertThat(new CacheServerFactoryBean().getObjectType()).isEqualTo(CacheServer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSingleton() {
|
||||
assertTrue(new CacheServerFactoryBean().isSingleton());
|
||||
assertThat(new CacheServerFactoryBean().isSingleton()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,9 +92,8 @@ public class CacheServerFactoryBeanTest {
|
||||
factoryBean.setCache(mockCache);
|
||||
factoryBean.setBindAddress("10.124.62.5");
|
||||
factoryBean.setHostNameForClients("skullbox");
|
||||
factoryBean.setListeners(new HashSet<InterestRegistrationListener>(Arrays.asList(
|
||||
mockInterestRegistrationListenerOne, mockInterestRegistrationListenerTwo)));
|
||||
factoryBean.setLoadPollInterval(500l);
|
||||
factoryBean.setLoadPollInterval(500L);
|
||||
factoryBean.setListeners(new HashSet<>(Arrays.asList(mockInterestRegistrationListenerOne, mockInterestRegistrationListenerTwo)));
|
||||
factoryBean.setMaxConnections(200);
|
||||
factoryBean.setMaxMessageCount(1024);
|
||||
factoryBean.setMaxTimeBetweenPings(2000);
|
||||
@@ -115,14 +109,14 @@ public class CacheServerFactoryBeanTest {
|
||||
factoryBean.setSubscriptionDiskStore("toTheVoid");
|
||||
factoryBean.afterPropertiesSet();
|
||||
|
||||
assertSame(mockCacheServer, factoryBean.getObject());
|
||||
assertEquals(mockCacheServer.getClass(), factoryBean.getObjectType());
|
||||
assertThat(factoryBean.getObject()).isSameAs(mockCacheServer);
|
||||
assertThat(factoryBean.getObjectType()).isEqualTo(mockCacheServer.getClass());
|
||||
|
||||
verify(mockCache, times(1)).addCacheServer();
|
||||
verify(mockCacheServer, times(1)).setBindAddress(eq("10.124.62.5"));
|
||||
verify(mockCacheServer, times(1)).setGroups(eq(new String[] { "testGroup" }));
|
||||
verify(mockCacheServer, times(1)).setHostnameForClients(eq("skullbox"));
|
||||
verify(mockCacheServer, times(1)).setLoadPollInterval(eq(500l));
|
||||
verify(mockCacheServer, times(1)).setLoadPollInterval(eq(500L));
|
||||
verify(mockCacheServer, times(1)).setLoadProbe(same(mockServerLoadProbe));
|
||||
verify(mockCacheServer, times(1)).setMaxConnections(eq(200));
|
||||
verify(mockCacheServer, times(1)).setMaximumMessageCount(eq(1024));
|
||||
@@ -148,7 +142,7 @@ public class CacheServerFactoryBeanTest {
|
||||
new CacheServerFactoryBean().afterPropertiesSet();
|
||||
}
|
||||
catch (IllegalArgumentException expected) {
|
||||
assertEquals("Cache is required", expected.getMessage());
|
||||
assertThat(expected.getMessage()).isEqualTo("Cache is required");
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
@@ -157,26 +151,26 @@ public class CacheServerFactoryBeanTest {
|
||||
public void testSetAndGetAutoStartup() {
|
||||
CacheServerFactoryBean factoryBean = new CacheServerFactoryBean();
|
||||
|
||||
assertTrue(factoryBean.isAutoStartup());
|
||||
assertThat(factoryBean.isAutoStartup()).isTrue();
|
||||
|
||||
factoryBean.setAutoStartup(false);
|
||||
|
||||
assertFalse(factoryBean.isAutoStartup());
|
||||
assertThat(factoryBean.isAutoStartup()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAndGetSubscriptionEvictionPolicy() {
|
||||
CacheServerFactoryBean factoryBean = new CacheServerFactoryBean();
|
||||
|
||||
assertEquals(SubscriptionEvictionPolicy.DEFAULT, factoryBean.getSubscriptionEvictionPolicy());
|
||||
assertThat(factoryBean.getSubscriptionEvictionPolicy()).isEqualTo(SubscriptionEvictionPolicy.DEFAULT);
|
||||
|
||||
factoryBean.setSubscriptionEvictionPolicy(SubscriptionEvictionPolicy.MEM);
|
||||
|
||||
assertEquals(SubscriptionEvictionPolicy.MEM, factoryBean.getSubscriptionEvictionPolicy());
|
||||
assertThat(factoryBean.getSubscriptionEvictionPolicy()).isEqualTo(SubscriptionEvictionPolicy.MEM);
|
||||
|
||||
factoryBean.setSubscriptionEvictionPolicy(null);
|
||||
|
||||
assertEquals(SubscriptionEvictionPolicy.DEFAULT, factoryBean.getSubscriptionEvictionPolicy());
|
||||
assertThat(factoryBean.getSubscriptionEvictionPolicy()).isEqualTo(SubscriptionEvictionPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,48 +180,33 @@ public class CacheServerFactoryBeanTest {
|
||||
final AtomicBoolean running = new AtomicBoolean(false);
|
||||
final AtomicBoolean called = new AtomicBoolean(false);
|
||||
|
||||
doAnswer(new Answer() {
|
||||
@Override
|
||||
public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
|
||||
running.compareAndSet(false, true);
|
||||
return null;
|
||||
}
|
||||
doAnswer(invocationOnMock -> {
|
||||
running.compareAndSet(false, true);
|
||||
return null;
|
||||
}).when(mockCacheServer).start();
|
||||
|
||||
doAnswer(new Answer() {
|
||||
@Override
|
||||
public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
|
||||
running.compareAndSet(true, false);
|
||||
return null;
|
||||
}
|
||||
doAnswer(invocationOnMock -> {
|
||||
running.compareAndSet(true, false);
|
||||
return null;
|
||||
}).when(mockCacheServer).stop();
|
||||
|
||||
when(mockCacheServer.isRunning()).then(new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(final InvocationOnMock invocationOnMock) throws Throwable {
|
||||
return running.get();
|
||||
}
|
||||
});
|
||||
when(mockCacheServer.isRunning()).then((Answer<Boolean>) invocationOnMock -> running.get());
|
||||
|
||||
CacheServerFactoryBean factoryBean = new CacheServerFactoryBean();
|
||||
|
||||
factoryBean.setCacheServer(mockCacheServer);
|
||||
|
||||
assertSame(mockCacheServer, factoryBean.getObject());
|
||||
assertFalse(factoryBean.isRunning());
|
||||
assertThat(factoryBean.getObject()).isSameAs(mockCacheServer);
|
||||
assertThat(factoryBean.isRunning()).isFalse();
|
||||
|
||||
factoryBean.start();
|
||||
|
||||
assertTrue(factoryBean.isRunning());
|
||||
assertFalse(called.get());
|
||||
assertThat(factoryBean.isRunning()).isTrue();
|
||||
assertThat(called.get()).isFalse();
|
||||
|
||||
factoryBean.stop(new Runnable() {
|
||||
@Override public void run() {
|
||||
called.set(true);
|
||||
}
|
||||
});
|
||||
factoryBean.stop(() -> called.set(true));
|
||||
|
||||
assertFalse(factoryBean.isRunning());
|
||||
assertTrue(called.get());
|
||||
assertThat(factoryBean.isRunning()).isFalse();
|
||||
assertThat(called.get()).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.apache.geode.cache.server.ClientSubscriptionConfig;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The SubscriptionEvictionPolicyTest class is a test suite of test cases testing the contract and functionality
|
||||
* of the SubscriptionEvictionPolicy enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.server.SubscriptionEvictionPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class SubscriptionEvictionPolicyTest {
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
assertEquals(ClientSubscriptionConfig.DEFAULT_EVICTION_POLICY.toLowerCase(),
|
||||
SubscriptionEvictionPolicy.DEFAULT.name().toLowerCase());
|
||||
assertSame(SubscriptionEvictionPolicy.NONE, SubscriptionEvictionPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
assertEquals(SubscriptionEvictionPolicy.ENTRY, SubscriptionEvictionPolicy.valueOfIgnoreCase("entry"));
|
||||
assertEquals(SubscriptionEvictionPolicy.MEM, SubscriptionEvictionPolicy.valueOfIgnoreCase("Mem"));
|
||||
assertEquals(SubscriptionEvictionPolicy.NONE, SubscriptionEvictionPolicy.valueOfIgnoreCase("NOne"));
|
||||
assertEquals(SubscriptionEvictionPolicy.NONE, SubscriptionEvictionPolicy.valueOfIgnoreCase("nONE"));
|
||||
assertEquals(SubscriptionEvictionPolicy.NONE, SubscriptionEvictionPolicy.valueOfIgnoreCase("NONE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithIllegalValue() {
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase("KEYS"));
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase("Memory"));
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase("all"));
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase("no"));
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase("one"));
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase(" "));
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase(""));
|
||||
assertNull(SubscriptionEvictionPolicy.valueOfIgnoreCase(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetEvictionPolicy() {
|
||||
ClientSubscriptionConfig mockConfig = mock(ClientSubscriptionConfig.class,
|
||||
"testSetEvictionPolicy.ClientSubscriptionConfig");
|
||||
|
||||
ClientSubscriptionConfig returnedConfig = SubscriptionEvictionPolicy.MEM.setEvictionPolicy(mockConfig);
|
||||
|
||||
assertSame(mockConfig, returnedConfig);
|
||||
|
||||
verify(mockConfig, times(1)).setEvictionPolicy(eq("mem"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetEvictionPolicyWithNull() {
|
||||
assertNull(SubscriptionEvictionPolicy.ENTRY.setEvictionPolicy(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.server;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.server.ClientSubscriptionConfig;
|
||||
|
||||
/**
|
||||
* Unit Tests for {@link SubscriptionEvictionPolicy} enum.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.springframework.data.gemfire.server.SubscriptionEvictionPolicy
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public class SubscriptionEvictionPolicyUnitTests {
|
||||
|
||||
@Test
|
||||
public void testDefault() {
|
||||
|
||||
assertThat(SubscriptionEvictionPolicy.DEFAULT.name().toLowerCase())
|
||||
.isEqualTo(ClientSubscriptionConfig.DEFAULT_EVICTION_POLICY.toLowerCase());
|
||||
|
||||
assertThat(SubscriptionEvictionPolicy.DEFAULT).isSameAs(SubscriptionEvictionPolicy.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCase() {
|
||||
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("entry")).isEqualTo(SubscriptionEvictionPolicy.ENTRY);
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("Mem")).isEqualTo(SubscriptionEvictionPolicy.MEM);
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("NOne")).isEqualTo(SubscriptionEvictionPolicy.NONE);
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("nONE")).isEqualTo(SubscriptionEvictionPolicy.NONE);
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("NONE")).isEqualTo(SubscriptionEvictionPolicy.NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueOfIgnoreCaseWithIllegalValue() {
|
||||
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("KEYS")).isNull();
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("Memory")).isNull();
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("all")).isNull();
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("no")).isNull();
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("one")).isNull();
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase(" ")).isNull();
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase("")).isNull();
|
||||
assertThat(SubscriptionEvictionPolicy.valueOfIgnoreCase(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetEvictionPolicy() {
|
||||
|
||||
ClientSubscriptionConfig mockConfig =
|
||||
mock(ClientSubscriptionConfig.class,"testSetEvictionPolicy.ClientSubscriptionConfig");
|
||||
|
||||
ClientSubscriptionConfig returnedConfig = SubscriptionEvictionPolicy.MEM.setEvictionPolicy(mockConfig);
|
||||
|
||||
assertThat(returnedConfig).isSameAs(mockConfig);
|
||||
|
||||
verify(mockConfig, times(1)).setEvictionPolicy(eq("mem"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetEvictionPolicyWithNull() {
|
||||
assertThat(SubscriptionEvictionPolicy.ENTRY.setEvictionPolicy(null)).isNull();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user