blob: 2e2f86bf8053abcf472ad71d0bbddb0bbd45e587 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package org.eclipse.jgit.internal.storage.dfs;
import static org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheConfig.DEFAULT_NAME;
import static org.eclipse.jgit.internal.storage.dfs.DfsBlockCacheTable.BlockCacheStats;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.isA;
import java.util.List;
import org.junit.Test;
public class ClockBlockCacheTableTest {
private static final String NAME = "name";
@Test
public void getName_nameNotConfigured_returnsDefaultName() {
ClockBlockCacheTable cacheTable = new ClockBlockCacheTable(
createBlockCacheConfig());
assertThat(cacheTable.getName(), equalTo(DEFAULT_NAME));
}
@Test
public void getName_nameConfigured_returnsConfiguredName() {
ClockBlockCacheTable cacheTable = new ClockBlockCacheTable(
createBlockCacheConfig().setName(NAME));
assertThat(cacheTable.getName(), equalTo(NAME));
}
@Test
public void getBlockCacheStats_nameNotConfigured_returnsBlockCacheStatsWithDefaultName() {
ClockBlockCacheTable cacheTable = new ClockBlockCacheTable(
createBlockCacheConfig());
assertThat(cacheTable.getBlockCacheStats(), hasSize(1));
assertThat(cacheTable.getBlockCacheStats().get(0).getName(),
equalTo(DEFAULT_NAME));
}
@Test
public void getBlockCacheStats_nameConfigured_returnsBlockCacheStatsWithConfiguredName() {
ClockBlockCacheTable cacheTable = new ClockBlockCacheTable(
createBlockCacheConfig().setName(NAME));
assertThat(cacheTable.getBlockCacheStats(), hasSize(1));
assertThat(cacheTable.getBlockCacheStats().get(0).getName(),
equalTo(NAME));
}
@Test
public void getAllBlockCacheStats() {
ClockBlockCacheTable cacheTable = new ClockBlockCacheTable(
createBlockCacheConfig());
List<BlockCacheStats> blockCacheStats = cacheTable.getBlockCacheStats();
assertThat(blockCacheStats, contains(isA(BlockCacheStats.class)));
}
private static DfsBlockCacheConfig createBlockCacheConfig() {
return new DfsBlockCacheConfig().setBlockSize(512)
.setConcurrencyLevel(4).setBlockLimit(1024);
}
}
|