mirror of https://github.com/apache/lucene.git
remove code duplication in tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1516661 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bc94ec4dc1
commit
f6318fab03
|
@ -43,7 +43,7 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
params.put("size", "100");
|
||||
params.put("initialSize", "10");
|
||||
params.put("autowarmCount", "100%");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = fastCache.init(params, null, cr);
|
||||
fastCache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 0; i < 101; i++) {
|
||||
|
@ -89,7 +89,7 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
params.put("size", String.valueOf(limit));
|
||||
params.put("initialSize", "10");
|
||||
params.put("autowarmCount", percentage + "%");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = fastCache.init(params, null, cr);
|
||||
fastCache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 1; i <= limit; i++) {
|
||||
|
@ -120,7 +120,7 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("size", "100");
|
||||
params.put("initialSize", "10");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = fastCache.init(params, null, cr);
|
||||
fastCache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 0; i < 101; i++) {
|
||||
|
@ -150,7 +150,7 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
params.put("size", "100");
|
||||
params.put("initialSize", "10");
|
||||
params.put("autowarmCount", "-1");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = cache.init(params, null, cr);
|
||||
cache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 0; i < 101; i++) {
|
||||
|
@ -173,20 +173,6 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
assertEquals("103", cacheNew.get(103));
|
||||
cacheNew.close();
|
||||
}
|
||||
|
||||
private CacheRegenerator createCodeRegenerator() {
|
||||
CacheRegenerator cr = new CacheRegenerator() {
|
||||
@Override
|
||||
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache,
|
||||
SolrCache oldCache, Object oldKey, Object oldVal) {
|
||||
newCache.put(oldKey, oldVal);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return cr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testSimple() throws IOException {
|
||||
FastLRUCache sc = new FastLRUCache();
|
||||
|
@ -194,7 +180,7 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
l.put("size", "100");
|
||||
l.put("initialSize", "10");
|
||||
l.put("autowarmCount", "25");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = sc.init(l, null, cr);
|
||||
sc.setState(SolrCache.State.LIVE);
|
||||
for (int i = 0; i < 101; i++) {
|
||||
|
|
|
@ -38,15 +38,6 @@ import java.util.Map;
|
|||
*/
|
||||
public class TestLFUCache extends SolrTestCaseJ4 {
|
||||
|
||||
private class LFURegenerator implements CacheRegenerator {
|
||||
@Override
|
||||
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache,
|
||||
SolrCache oldCache, Object oldKey, Object oldVal) throws IOException {
|
||||
newCache.put(oldKey, oldVal);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig-caching.xml", "schema.xml");
|
||||
|
@ -139,7 +130,7 @@ public class TestLFUCache extends SolrTestCaseJ4 {
|
|||
params.put("size", "100");
|
||||
params.put("initialSize", "10");
|
||||
params.put("autowarmCount", "25");
|
||||
LFURegenerator regenerator = new LFURegenerator();
|
||||
NoOpRegenerator regenerator = new NoOpRegenerator();
|
||||
Object initObj = lfuCache.init(params, null, regenerator);
|
||||
lfuCache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 0; i < 101; i++) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TestLRUCache extends LuceneTestCase {
|
|||
params.put("size", "100");
|
||||
params.put("initialSize", "10");
|
||||
params.put("autowarmCount", "100%");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = lruCache.init(params, null, cr);
|
||||
lruCache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 0; i < 101; i++) {
|
||||
|
@ -69,7 +69,7 @@ public class TestLRUCache extends LuceneTestCase {
|
|||
params.put("size", String.valueOf(limit));
|
||||
params.put("initialSize", "10");
|
||||
params.put("autowarmCount", percentage + "%");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = lruCache.init(params, null, cr);
|
||||
lruCache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 1; i <= limit; i++) {
|
||||
|
@ -98,7 +98,7 @@ public class TestLRUCache extends LuceneTestCase {
|
|||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("size", "100");
|
||||
params.put("initialSize", "10");
|
||||
CacheRegenerator cr = createCodeRegenerator();
|
||||
CacheRegenerator cr = new NoOpRegenerator();
|
||||
Object o = lruCache.init(params, null, cr);
|
||||
lruCache.setState(SolrCache.State.LIVE);
|
||||
for (int i = 0; i < 101; i++) {
|
||||
|
@ -121,17 +121,4 @@ public class TestLRUCache extends LuceneTestCase {
|
|||
assertEquals(null, lruCacheNew.get(50));
|
||||
lruCacheNew.close();
|
||||
}
|
||||
|
||||
private CacheRegenerator createCodeRegenerator() {
|
||||
CacheRegenerator cr = new CacheRegenerator() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean regenerateItem(SolrIndexSearcher newSearcher, SolrCache newCache,
|
||||
SolrCache oldCache, Object oldKey, Object oldVal) {
|
||||
newCache.put(oldKey, oldVal);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return cr;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue