use of org.mule.runtime.core.api.config.builders.SimpleConfigurationBuilder in project mule by mulesoft.
the class AbstractMuleContextTestCase method createMuleContext.
protected MuleContext createMuleContext() throws Exception {
// Should we set up the manager for every method?
MuleContext context;
if (isDisposeContextPerClass() && muleContext != null) {
context = muleContext;
} else {
final ClassLoader executionClassLoader = getExecutionClassLoader();
final ClassLoader originalContextClassLoader = currentThread().getContextClassLoader();
try {
currentThread().setContextClassLoader(executionClassLoader);
MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
List<ConfigurationBuilder> builders = new ArrayList<>();
builders.add(new SimpleConfigurationBuilder(getStartUpRegistryObjects()));
addBuilders(builders);
builders.add(getBuilder());
MuleContextBuilder contextBuilder = MuleContextBuilder.builder(APP);
DefaultMuleConfiguration muleConfiguration = new DefaultMuleConfiguration();
String workingDirectory = this.workingDirectory.getRoot().getAbsolutePath();
LOGGER.info("Using working directory for test: " + workingDirectory);
muleConfiguration.setWorkingDirectory(workingDirectory);
muleConfiguration.setId(this.getClass().getSimpleName() + "#" + name.getMethodName());
contextBuilder.setMuleConfiguration(muleConfiguration);
contextBuilder.setExecutionClassLoader(executionClassLoader);
contextBuilder.setObjectSerializer(getObjectSerializer());
contextBuilder.setDeploymentProperties(getDeploymentProperties());
configureMuleContext(contextBuilder);
context = muleContextFactory.createMuleContext(builders, contextBuilder);
recordSchedulersOnInit(context);
if (!isGracefulShutdown()) {
// Even though graceful shutdown is disabled allow small amount of time to avoid rejection errors when stream emits
// complete signal
((DefaultMuleConfiguration) context.getConfiguration()).setShutdownTimeout(NON_GRACEFUL_SHUTDOWN_TIMEOUT);
}
} finally {
currentThread().setContextClassLoader(originalContextClassLoader);
}
}
return context;
}
use of org.mule.runtime.core.api.config.builders.SimpleConfigurationBuilder in project mule by mulesoft.
the class ArtifactFunctionalTestCase method addBuilders.
/**
* Adds a {@link ConfigurationBuilder} that sets the {@link org.mule.runtime.core.api.extension.ExtensionManager} into the
* {@link #muleContext}. This {@link ConfigurationBuilder} is set as the first element of the {@code builders} {@link List}
*
* @param builders the list of {@link ConfigurationBuilder}s that will be used to initialise the {@link #muleContext}
*/
@Override
protected void addBuilders(List<ConfigurationBuilder> builders) {
Class<?> runner = getAnnotationAttributeFrom(this.getClass(), RunWith.class, "value");
if (runner == null || !runner.equals(ArtifactClassLoaderRunner.class)) {
throw new IllegalStateException(this.getClass().getName() + " extends " + ArtifactFunctionalTestCase.class.getName() + " so it should be annotated to only run with: " + ArtifactClassLoaderRunner.class + ". See " + RunnerDelegateTo.class + " for defining a delegate runner to be used.");
}
if (extensionsManagerConfigurationBuilder != null) {
builders.add(0, extensionsManagerConfigurationBuilder);
}
builders.add(0, new TestBootstrapServiceDiscovererConfigurationBuilder(containerClassLoader, getExecutionClassLoader(), pluginClassLoaders));
builders.add(0, new SimpleConfigurationBuilder(singletonMap(OBJECT_CLASSLOADER_REPOSITORY, classLoaderRepository)));
}
Aggregations