com.gemstone.gemfire.internal.cache.Bug48182JUnitTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-junit Show documentation
Show all versions of gemfire-junit Show documentation
SnappyData store based off Pivotal GemFireXD
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* 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. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.cache;
import java.util.Properties;
import junit.framework.TestCase;
import com.gemstone.gemfire.cache.CacheClosedException;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionDestroyedException;
import com.gemstone.gemfire.cache.RegionShortcut;
/**
* TestCase that emulates the conditions that produce defect 48182 and ensures that the fix works under those conditions.
* 48182: Unexpected EntryNotFoundException while shutting down members with off-heap
* https://svn.gemstone.com/trac/gemfire/ticket/48182
* @author rholmes
*/
public class Bug48182JUnitTest extends TestCase {
/**
* A region entry key.
*/
private static final String KEY = "KEY";
/**
* A region entry value.
*/
private static final String VALUE = " Vestibulum quis lobortis risus. Cras cursus eget dolor in facilisis. Curabitur purus arcu, dignissim ac lorem non, venenatis condimentum tellus. Praesent at erat dapibus, bibendum nunc sed, congue nulla";
/**
* A cache.
*/
private GemFireCacheImpl cache = null;
/**
* Create a new Bug48182JUnitTest.
*/
public Bug48182JUnitTest() {
super("defect48182JUnitTest");
}
/**
* Create a new Bug48182JUnitTest.
*/
public Bug48182JUnitTest(String name) {
super(name);
}
@Override
public void setUp() throws Exception {
// Create our cache
this.cache = createCache();
}
@Override
public void tearDown() throws Exception {
AbstractRegionMap.testHookRunnableFor48182 = null;
// Cleanup our cache
closeCache(this.cache);
}
/**
* @return the test's cache.
*/
protected GemFireCacheImpl getCache() {
return this.cache;
}
/**
* Close a cache.
* @param gfc the cache to close.
*/
protected void closeCache(GemFireCacheImpl gfc) {
gfc.close();
}
/**
* @return the test's off heap memory size.
*/
protected String getOffHeapMemorySize() {
return "2m";
}
/**
* @return the type of region for the test.
*/
protected RegionShortcut getRegionShortcut() {
return RegionShortcut.REPLICATE;
}
/**
* @return the region containing our test data.
*/
protected String getRegionName() {
return "region1";
}
/**
* Creates and returns the test region with concurrency checks enabled.
*/
protected Region