Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matko Medenjak committed Jun 26, 2019
1 parent 80ed8d8 commit 297bb97
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
3 changes: 3 additions & 0 deletions hazelcast/src/main/java/com/hazelcast/config/CacheConfig.java
Expand Up @@ -522,6 +522,7 @@ public void writeData(ObjectDataOutput out) throws IOException {
out.writeBoolean(isStatisticsEnabled);
out.writeBoolean(hotRestartConfig.isEnabled());
out.writeBoolean(hotRestartConfig.isFsync());
out.writeObject(eventJournalConfig);

out.writeUTF(quorumName);

Expand Down Expand Up @@ -563,6 +564,7 @@ public void readData(ObjectDataInput in) throws IOException {
isStatisticsEnabled = in.readBoolean();
hotRestartConfig.setEnabled(in.readBoolean());
hotRestartConfig.setFsync(in.readBoolean());
eventJournalConfig = in.readObject();

quorumName = in.readUTF();

Expand Down Expand Up @@ -694,6 +696,7 @@ public <T extends CacheConfig<K, V>> T copy(T target, boolean resolved) {
target.setDisablePerEntryInvalidationEvents(isDisablePerEntryInvalidationEvents());
target.setEvictionConfig(getEvictionConfig());
target.setHotRestartConfig(getHotRestartConfig());
target.setEventJournalConfig(getEventJournalConfig());
target.setInMemoryFormat(getInMemoryFormat());
if (resolved) {
target.setKeyType(getKeyType());
Expand Down
Expand Up @@ -197,16 +197,15 @@ public void readData(ObjectDataInput in) throws IOException {
}

@Override
public boolean equals(Object o) {
public final boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (!(o instanceof EventJournalConfig)) {
return false;
}

EventJournalConfig that = (EventJournalConfig) o;

if (enabled != that.enabled) {
return false;
}
Expand All @@ -218,7 +217,7 @@ public boolean equals(Object o) {
}

@Override
public int hashCode() {
public final int hashCode() {
int result = (enabled ? 1 : 0);
result = 31 * result + capacity;
result = 31 * result + timeToLiveSeconds;
Expand Down
Expand Up @@ -60,13 +60,11 @@ public void init() {
protected Config getConfig() {
CacheSimpleConfig cacheConfig = new CacheSimpleConfig().setName("*");
cacheConfig.getEvictionConfig().setSize(Integer.MAX_VALUE);
Config config = super.getConfig();
config.getCacheConfig("default")
.setEventJournalConfig(new EventJournalConfig().setEnabled(true));
cacheConfig.setEventJournalConfig(new EventJournalConfig().setEnabled(true));

return config
.setProperty(GroupProperty.PARTITION_COUNT.getName(), String.valueOf(PARTITION_COUNT))
.addCacheConfig(cacheConfig);
return super.getConfig()
.setProperty(GroupProperty.PARTITION_COUNT.getName(), String.valueOf(PARTITION_COUNT))
.addCacheConfig(cacheConfig);
}

@Test
Expand Down
Expand Up @@ -48,24 +48,21 @@ public class CacheEventJournalBasicTest<K, V> extends AbstractEventJournalBasicT

@Override
protected Config getConfig() {
final CacheSimpleConfig nonEvictingCache = new CacheSimpleConfig()
.setName(NON_EVICTING_CACHE)
.setInMemoryFormat(getInMemoryFormat());
final MaxSizePolicy maxSizePolicy = getInMemoryFormat() == InMemoryFormat.NATIVE
Config config = super.getConfig();
CacheSimpleConfig nonEvictingCache = config.getCacheConfig(NON_EVICTING_CACHE)
.setInMemoryFormat(getInMemoryFormat());
MaxSizePolicy maxSizePolicy = getInMemoryFormat() == InMemoryFormat.NATIVE
? USED_NATIVE_MEMORY_SIZE
: DEFAULT_MAX_SIZE_POLICY;
nonEvictingCache.getEvictionConfig()
.setMaximumSizePolicy(maxSizePolicy)
.setSize(Integer.MAX_VALUE);

final CacheSimpleConfig evictingCache = new CacheSimpleConfig()
.setName(EVICTING_CACHE)
.setInMemoryFormat(getInMemoryFormat());
final CacheSimpleConfig evictingCache = config.getCacheConfig(EVICTING_CACHE)
.setInMemoryFormat(getInMemoryFormat());
evictingCache.getEvictionConfig().setMaximumSizePolicy(maxSizePolicy);

return super.getConfig()
.addCacheConfig(nonEvictingCache)
.addCacheConfig(evictingCache);
return config;
}

protected InMemoryFormat getInMemoryFormat() {
Expand Down
Expand Up @@ -46,21 +46,20 @@ public class MapEventJournalBasicTest<K, V> extends AbstractEventJournalBasicTes

@Override
protected Config getConfig() {
final MapStoreConfig mapStoreConfig = new MapStoreConfig()
Config config = super.getConfig();
MapStoreConfig mapStoreConfig = new MapStoreConfig()
.setEnabled(true)
.setInitialLoadMode(EAGER)
.setImplementation(new CustomMapStore());

final MapConfig nonExpiringMapConfig = new MapConfig(NON_EXPIRING_MAP)
.setInMemoryFormat(getInMemoryFormat())
.setMapStoreConfig(mapStoreConfig);
config.getMapConfig(NON_EXPIRING_MAP)
.setInMemoryFormat(getInMemoryFormat())
.setMapStoreConfig(mapStoreConfig);

final MapConfig expiringMapConfig = new MapConfig(EXPIRING_MAP).setTimeToLiveSeconds(1)
.setInMemoryFormat(getInMemoryFormat());
config.getMapConfig(EXPIRING_MAP).setTimeToLiveSeconds(1)
.setInMemoryFormat(getInMemoryFormat());

return super.getConfig()
.addMapConfig(nonExpiringMapConfig)
.addMapConfig(expiringMapConfig);
return config;
}

protected InMemoryFormat getInMemoryFormat() {
Expand Down

0 comments on commit 297bb97

Please sign in to comment.