use of org.infinispan.commons.util.Features in project infinispan by infinispan.
the class ConfigurationBuilder method create.
@Override
public Configuration create() {
List<ServerConfiguration> servers = new ArrayList<>();
if (this.servers.size() > 0)
for (ServerConfigurationBuilder server : this.servers) {
servers.add(server.create());
}
else {
servers.add(new ServerConfiguration("127.0.0.1", ConfigurationProperties.DEFAULT_HOTROD_PORT));
}
List<ClusterConfiguration> serverClusterConfigs = clusters.stream().map(ClusterConfigurationBuilder::create).collect(Collectors.toList());
Marshaller buildMarshaller = this.marshaller;
if (buildMarshaller == null && marshallerClass == null) {
buildMarshaller = handleNullMarshaller();
}
Class<? extends Marshaller> buildMarshallerClass = this.marshallerClass;
if (buildMarshallerClass == null) {
// Populate the marshaller class as well, so it can be exported to properties
buildMarshallerClass = buildMarshaller.getClass();
} else {
if (buildMarshaller != null && !buildMarshallerClass.isInstance(buildMarshaller))
throw new IllegalArgumentException("Both marshaller and marshallerClass attributes are present, but marshaller is not an instance of marshallerClass");
}
Map<String, RemoteCacheConfiguration> remoteCaches = remoteCacheBuilders.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().create()));
return new Configuration(asyncExecutorFactory.create(), balancingStrategyFactory, classLoader == null ? null : classLoader.get(), clientIntelligence, connectionPool.create(), connectionTimeout, consistentHashImpl, forceReturnValues, keySizeEstimate, buildMarshaller, buildMarshallerClass, protocolVersion, servers, socketTimeout, security.create(), tcpNoDelay, tcpKeepAlive, valueSizeEstimate, maxRetries, nearCache.create(), serverClusterConfigs, allowListRegExs, batchSize, transaction.create(), statistics.create(), features, contextInitializers, remoteCaches, transportFactory);
}
use of org.infinispan.commons.util.Features in project infinispan by infinispan.
the class GlobalConfigurationBuilder method validate.
public void validate() {
features = new Features(cl);
List<RuntimeException> validationExceptions = new ArrayList<>();
Arrays.asList(cacheContainerConfiguration, site).forEach(c -> {
try {
c.validate();
} catch (RuntimeException e) {
validationExceptions.add(e);
}
});
modules.values().forEach(c -> {
try {
c.validate();
} catch (RuntimeException e) {
validationExceptions.add(e);
}
});
CacheConfigurationException.fromMultipleRuntimeExceptions(validationExceptions).ifPresent(e -> {
throw e;
});
}
use of org.infinispan.commons.util.Features in project infinispan by infinispan.
the class AbstractInfinispanServerDriver method prepare.
/**
* Prepare a server layout
*/
@Override
public void prepare(String name) {
this.name = name;
if (configuration.getFeatures() != null) {
// if the feature isn't enabled, the test will be skipped
Features features = new Features(this.getClass().getClassLoader());
for (String feature : configuration.getFeatures()) {
Assume.assumeTrue(String.format("%s is disabled", feature), features.isAvailable(feature));
}
}
String siteName = configuration.site() == null ? "" : configuration.site();
String testDir = CommonsTestingUtil.tmpDirectory(siteName + name);
Util.recursiveFileRemove(testDir);
rootDir = new File(testDir);
confDir = new File(rootDir, Server.DEFAULT_SERVER_CONFIG);
if (!confDir.mkdirs()) {
throw new RuntimeException("Failed to create server configuration directory " + confDir);
}
// if the file is not a default file, we need to copy the file from the resources folder to the server conf dir
if (!configuration.isDefaultFile()) {
copyProvidedServerConfigurationFile();
}
createUserFile("default");
createKeyStores();
}
use of org.infinispan.commons.util.Features in project infinispan by infinispan.
the class FeaturesListener method intercept.
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
Object instance = methods.get(0).getMethod().getInstance();
Features features = new Features(instance.getClass().getClassLoader());
AbstractInfinispanTest.FeatureCondition featureCondition = instance.getClass().getAnnotation(AbstractInfinispanTest.FeatureCondition.class);
if (featureCondition != null && !features.isAvailable(featureCondition.feature())) {
for (IMethodInstance methodInstance : methods) {
methodInstance.getMethod().setMissingGroup(featureCondition.feature() + " is disabled.");
}
// the annotation is based on the class
BaseTestMethod baseTestMethod = getBaseMethod(methods.get(0));
clearBeforeAfterClassMethods(baseTestMethod.getTestClass());
}
return methods;
}
Aggregations