Search in sources :

Example 1 with LocalizationServiceImpl

use of com.evolveum.midpoint.common.LocalizationServiceImpl in project midpoint by Evolveum.

the class AbstractIntegrationTest method initSystem.

/**
 * With TestNG+Spring we can use {@code PostConstruct} for class-wide initialization.
 * All test methods run on a single instance (unlike with JUnit).
 * Using {@code BeforeClass} is not good as the Spring wiring happens later.
 * <p>
 * There is still danger that annotation processor will run this multiple times
 * for web/servlet-based tests, see text context attributes
 * {@link DependencyInjectionTestExecutionListener#REINJECT_DEPENDENCIES_ATTRIBUTE}
 * and {@link ServletTestExecutionListener#RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE} for more.
 * That's why we start with the guard enforcing once-only initSystem execution.
 */
@PostConstruct
public void initSystem() throws Exception {
    if (initSystemExecuted) {
        logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName());
        return;
    }
    TestSpringBeans.setApplicationContext(Objects.requireNonNull(applicationContext, "No Spring application context present"));
    displayTestTitle("Initializing TEST CLASS: " + getClass().getName());
    initSystemExecuted = true;
    // Check whether we are already initialized
    assertNotNull(repositoryService, "Repository is not wired properly");
    assertNotNull(taskManager, "Task manager is not wired properly");
    PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX);
    PrismTestUtil.setPrismContext(prismContext);
    Task initTask = createPlainTask("INIT");
    initTask.setChannel(SchemaConstants.CHANNEL_INIT_URI);
    OperationResult result = initTask.getResult();
    InternalMonitor.reset();
    InternalsConfig.setPrismMonitoring(true);
    prismContext.setMonitor(new InternalMonitor());
    ((LocalizationServiceImpl) localizationService).setOverrideLocale(Locale.US);
    initSystem(initTask, result);
    postInitSystem(initTask, result);
    taskManager.registerNodeUp(result);
    result.computeStatus();
    IntegrationTestTools.display("initSystem result", result);
    TestUtil.assertSuccessOrWarning("initSystem failed (result)", result, 1);
}
Also used : InternalMonitor(com.evolveum.midpoint.schema.internals.InternalMonitor) LocalizationServiceImpl(com.evolveum.midpoint.common.LocalizationServiceImpl) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PostConstruct(javax.annotation.PostConstruct)

Aggregations

LocalizationServiceImpl (com.evolveum.midpoint.common.LocalizationServiceImpl)1 InternalMonitor (com.evolveum.midpoint.schema.internals.InternalMonitor)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 PostConstruct (javax.annotation.PostConstruct)1