diff --git a/src/test/java/org/springframework/data/gemfire/SimpleObjectSizer.java b/src/test/java/org/springframework/data/gemfire/SimpleObjectSizer.java new file mode 100644 index 00000000..6f8b97d7 --- /dev/null +++ b/src/test/java/org/springframework/data/gemfire/SimpleObjectSizer.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.gemfire; + +import com.gemstone.gemfire.cache.util.ObjectSizer; +import com.gemstone.gemfire.cache.util.ObjectSizerImpl; + +/** + * @author Costin Leau + */ +public class SimpleObjectSizer implements ObjectSizer { + + private static final ObjectSizer sizer = new ObjectSizerImpl(); + + public int sizeof(Object o) { + return sizer.sizeof(o); + } + +} diff --git a/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java b/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java index 2647d47b..4700a40b 100644 --- a/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/DiskStoreAndEvictionRegionParsingTest.java @@ -17,6 +17,7 @@ package org.springframework.data.gemfire.config; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.File; @@ -26,6 +27,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.data.gemfire.RegionFactoryBean; +import org.springframework.data.gemfire.SimpleObjectSizer; import org.springframework.data.gemfire.TestUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -36,6 +38,7 @@ import com.gemstone.gemfire.cache.EvictionAlgorithm; import com.gemstone.gemfire.cache.EvictionAttributes; import com.gemstone.gemfire.cache.RegionAttributes; import com.gemstone.gemfire.cache.Scope; +import com.gemstone.gemfire.cache.util.ObjectSizer; /** * @author Costin Leau @@ -65,6 +68,7 @@ public class DiskStoreAndEvictionRegionParsingTest { assertEquals(EvictionAction.OVERFLOW_TO_DISK, evicAttr.getAction()); assertEquals(EvictionAlgorithm.LRU_ENTRY, evicAttr.getAlgorithm()); assertEquals(50, evicAttr.getMaximum()); + assertNull(evicAttr.getObjectSizer()); } @Test @@ -78,5 +82,7 @@ public class DiskStoreAndEvictionRegionParsingTest { assertEquals(EvictionAlgorithm.LRU_MEMORY, evicAttr.getAlgorithm()); // for some reason GemFire resets this to 56 on my machine (not sure why) //assertEquals(10, evicAttr.getMaximum()); + ObjectSizer sizer = evicAttr.getObjectSizer(); + assertEquals(SimpleObjectSizer.class, sizer.getClass()); } } \ No newline at end of file diff --git a/src/test/resources/org/springframework/data/gemfire/config/diskstore-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/diskstore-ns.xml index 67974973..3be1f782 100644 --- a/src/test/resources/org/springframework/data/gemfire/config/diskstore-ns.xml +++ b/src/test/resources/org/springframework/data/gemfire/config/diskstore-ns.xml @@ -24,7 +24,11 @@ - + + + + + \ No newline at end of file