SGF-493 - Remove unnecessary GemFire/Geode version checks.
This commit is contained in:
@@ -16,15 +16,12 @@
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.springframework.data.gemfire.config.support.GemfireFeature;
|
||||
import org.springframework.data.gemfire.util.CacheUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import com.gemstone.gemfire.cache.CacheFactory;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.internal.GemFireVersion;
|
||||
|
||||
/**
|
||||
@@ -37,7 +34,6 @@ import com.gemstone.gemfire.internal.GemFireVersion;
|
||||
* @see com.gemstone.gemfire.cache.Region
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class GemfireUtils extends CacheUtils {
|
||||
|
||||
public final static String GEMFIRE_NAME = GemFireVersion.getProductName();
|
||||
@@ -115,48 +111,6 @@ public abstract class GemfireUtils extends CacheUtils {
|
||||
return isClassAvailable(GATEWAY_SENDER_TYPE_NAME);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static boolean isGemfireVersionGreaterThanEqualTo(double expectedVersion) {
|
||||
double actualVersion = Double.parseDouble(GEMFIRE_VERSION.substring(0, 3));
|
||||
return (actualVersion >= expectedVersion);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static boolean isGemfireVersion65OrAbove() {
|
||||
try {
|
||||
return isGemfireVersionGreaterThanEqualTo(6.5);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// NOTE based on logic from the PartitionedRegionFactoryBean class...
|
||||
return ConcurrentMap.class.isAssignableFrom(Region.class);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static boolean isGemfireVersion7OrAbove() {
|
||||
try {
|
||||
return isGemfireVersionGreaterThanEqualTo(7.0);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// NOTE the com.gemstone.gemfire.distributed.ServerLauncher class only exists in GemFire v 7.0.x or above...
|
||||
return ClassUtils.isPresent("com.gemstone.gemfire.distributed.ServerLauncher",
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static boolean isGemfireVersion8OrAbove() {
|
||||
try {
|
||||
return isGemfireVersionGreaterThanEqualTo(8.0);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// NOTE the com.gemstone.gemfire.management.internal.web.domain.LinkIndex class only exists
|
||||
// in GemFire v 8.0.0 or above...
|
||||
return ClassUtils.isPresent("com.gemstone.gemfire.management.internal.web.domain.LinkIndex",
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
System.out.printf("GemFire Product Name (%1$s) Version (%2$s)%n", GEMFIRE_NAME, GEMFIRE_VERSION);
|
||||
//System.out.printf("Is GemFire Version 6.5 of Above? %1$s%n", isGemfireVersion65OrAbove());
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -34,7 +32,6 @@ import org.junit.Test;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.distributed.DistributedSystem;
|
||||
import com.gemstone.gemfire.internal.GemFireVersion;
|
||||
|
||||
/**
|
||||
* The GemfireUtilsTest class is a test suite of test cases testing the contract and functionality of the GemfireUtils
|
||||
@@ -86,7 +83,7 @@ public class GemfireUtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isDurableWhenNotDurableClientIsFalse() {
|
||||
public void isDurableWithNonDurableClientIsFalse() {
|
||||
ClientCache mockClientCache = mock(ClientCache.class);
|
||||
DistributedSystem mockDistributedSystem = mock(DistributedSystem.class);
|
||||
|
||||
@@ -138,38 +135,4 @@ public class GemfireUtilsTest {
|
||||
verifyZeroInteractions(mockClientCache);
|
||||
}
|
||||
|
||||
// NOTE implementation is based on a GemFire internal class... com.gemstone.gemfire.internal.GemFireVersion.
|
||||
protected int getGemFireVersion() {
|
||||
try {
|
||||
String gemfireVersion = GemFireVersion.getGemFireVersion();
|
||||
|
||||
return Integer.decode(String.format("%1$d%2$d", GemFireVersion.getMajorVersion(gemfireVersion),
|
||||
GemFireVersion.getMinorVersion(gemfireVersion)));
|
||||
}
|
||||
catch (NumberFormatException ignore) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isGemfireVersion65OrAbove() {
|
||||
int gemfireVersion = getGemFireVersion();
|
||||
assumeTrue(gemfireVersion > -1);
|
||||
assertEquals(getGemFireVersion() >= 65, GemfireUtils.isGemfireVersion65OrAbove());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isGemfireVersion7OrAbove() {
|
||||
int gemfireVersion = getGemFireVersion();
|
||||
assumeTrue(gemfireVersion > -1);
|
||||
assertEquals(getGemFireVersion() >= 70, GemfireUtils.isGemfireVersion7OrAbove());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isGemfireVersion8OrAbove() {
|
||||
int gemfireVersion = getGemFireVersion();
|
||||
assumeTrue(gemfireVersion > -1);
|
||||
assertEquals(getGemFireVersion() >= 80, GemfireUtils.isGemfireVersion8OrAbove());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user