use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors_wrongType.
@Test
public void instantiate_extractors_wrongType() {
// GIVEN
AttributeConfig string = new AttributeConfig("iq", "java.lang.String");
// EXPECT
expected.expect(IllegalArgumentException.class);
// WHEN
instantiateExtractors(singletonList(string));
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors_withCustomClassLoader.
@Test
public void instantiate_extractors_withCustomClassLoader() {
// GIVEN
AttributeConfig iqExtractor = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
AttributeConfig nameExtractor = new AttributeConfig("name", "com.hazelcast.query.impl.getters.ExtractorHelperTest$NameExtractor");
Config config = new Config();
// For other custom class loaders (from OSGi bundles, for example)
ClassLoader customClassLoader = getClass().getClassLoader();
config.setClassLoader(customClassLoader);
// WHEN
Map<String, ValueExtractor> extractors = instantiateExtractors(asList(iqExtractor, nameExtractor));
// THEN
assertThat(extractors.get("iq"), instanceOf(IqExtractor.class));
assertThat(extractors.get("name"), instanceOf(NameExtractor.class));
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors_oneClassNotExisting.
@Test
public void instantiate_extractors_oneClassNotExisting() {
// GIVEN
AttributeConfig iqExtractor = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$IqExtractor");
AttributeConfig nameExtractor = new AttributeConfig("name", "not.existing.class");
// EXPECT
expected.expect(IllegalArgumentException.class);
expected.expectCause(isA(ClassNotFoundException.class));
// WHEN
instantiateExtractors(asList(iqExtractor, nameExtractor));
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class ExtractorHelperTest method instantiate_extractors_initException.
@Test
public void instantiate_extractors_initException() {
// GIVEN
AttributeConfig string = new AttributeConfig("iq", "com.hazelcast.query.impl.getters.ExtractorHelperTest$InitExceptionExtractor");
// EXPECT
expected.expect(IllegalArgumentException.class);
// WHEN
instantiateExtractors(singletonList(string));
}
use of com.hazelcast.config.AttributeConfig in project hazelcast by hazelcast.
the class AbstractDynamicConfigGeneratorTest method testMap.
// UTILITY - TESTS
private void testMap(MapStoreConfig mapStoreConfig) {
AttributeConfig attrConfig = new AttributeConfig().setName("power").setExtractorClassName("com.car.PowerExtractor");
EvictionConfig evictionConfig1 = new EvictionConfig().setSize(10).setMaxSizePolicy(MaxSizePolicy.FREE_NATIVE_MEMORY_SIZE);
IndexConfig indexConfig = new IndexConfig().addAttribute("attribute").setType(IndexType.SORTED);
EntryListenerConfig listenerConfig = new EntryListenerConfig("com.hazelcast.entrylistener", false, false);
EvictionConfig evictionConfig2 = new EvictionConfig().setMaxSizePolicy(MaxSizePolicy.FREE_NATIVE_MEMORY_SIZE).setSize(100).setComparatorClassName("comparatorClassName").setEvictionPolicy(EvictionPolicy.LRU);
PredicateConfig predicateConfig1 = new PredicateConfig();
predicateConfig1.setClassName("className");
PredicateConfig predicateConfig2 = new PredicateConfig();
predicateConfig2.setSql("sqlQuery");
QueryCacheConfig queryCacheConfig1 = new QueryCacheConfig().setName("queryCache1").setPredicateConfig(predicateConfig1).addEntryListenerConfig(listenerConfig).setBatchSize(230).setDelaySeconds(20).setPopulate(false).setBufferSize(8).setInMemoryFormat(InMemoryFormat.BINARY).setEvictionConfig(evictionConfig2).setIncludeValue(false).setCoalesce(false).addIndexConfig(indexConfig);
QueryCacheConfig queryCacheConfig2 = new QueryCacheConfig().setName("queryCache2").setPredicateConfig(predicateConfig2).addEntryListenerConfig(listenerConfig).setBatchSize(500).setDelaySeconds(10).setPopulate(true).setBufferSize(10).setInMemoryFormat(InMemoryFormat.OBJECT).setEvictionConfig(evictionConfig2).setIncludeValue(true).setCoalesce(true).addIndexConfig(indexConfig);
MapConfig expectedConfig = newMapConfig().setName("carMap").setEvictionConfig(evictionConfig1).setInMemoryFormat(InMemoryFormat.NATIVE).setMetadataPolicy(MetadataPolicy.CREATE_ON_UPDATE).setMaxIdleSeconds(100).setTimeToLiveSeconds(1000).setCacheDeserializedValues(CacheDeserializedValues.ALWAYS).setStatisticsEnabled(true).setPerEntryStatsEnabled(false).setReadBackupData(true).setBackupCount(2).setAsyncBackupCount(3).setMapStoreConfig(mapStoreConfig).setWanReplicationRef(wanReplicationRef()).setPartitioningStrategyConfig(new PartitioningStrategyConfig("partitionStrategyClass")).setMerkleTreeConfig(merkleTreeConfig()).setEventJournalConfig(eventJournalConfig()).setDataPersistenceConfig(dataPersistenceConfig()).addEntryListenerConfig(listenerConfig).setIndexConfigs(singletonList(indexConfig)).addAttributeConfig(attrConfig).setPartitionLostListenerConfigs(singletonList(new MapPartitionLostListenerConfig("partitionLostListener")));
expectedConfig.setQueryCacheConfigs(asList(queryCacheConfig1, queryCacheConfig2));
Config config = new Config().addMapConfig(expectedConfig);
Config decConfig = getNewConfigViaGenerator(config);
MapConfig actualConfig = decConfig.getMapConfig("carMap");
AttributeConfig decAttrConfig = actualConfig.getAttributeConfigs().get(0);
assertEquals(attrConfig.getName(), decAttrConfig.getName());
assertEquals(attrConfig.getExtractorClassName(), decAttrConfig.getExtractorClassName());
ConfigCompatibilityChecker.checkMapConfig(expectedConfig, actualConfig);
}
Aggregations