SGF-17
+ object sizer tests
This commit is contained in:
costin
2010-09-15 17:37:48 +03:00
parent 9f4b5f440d
commit b6897115c3
3 changed files with 44 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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());
}
}