use of com.evolveum.midpoint.schema.internals.InternalMonitor in project midpoint by Evolveum.
the class AbstractIntegrationTest method initSystemConditional.
// We need this complicated init as we want to initialize repo only once.
// JUnit will
// create new class instance for every test, so @Before and @PostInit will
// not work
// directly. We also need to init the repo after spring autowire is done, so
// @BeforeClass won't work either.
@BeforeMethod
public void initSystemConditional() throws Exception {
// Check whether we are already initialized
assertNotNull("Repository is not wired properly", repositoryService);
assertNotNull("Task manager is not wired properly", taskManager);
LOGGER.trace("initSystemConditional: {} systemInitialized={}", this.getClass(), isSystemInitialized());
if (!isSystemInitialized()) {
PrettyPrinter.setDefaultNamespacePrefix(MidPointConstants.NS_MIDPOINT_PUBLIC_PREFIX);
PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY);
LOGGER.trace("initSystemConditional: invoking initSystem");
Task initTask = taskManager.createTaskInstance(this.getClass().getName() + ".initSystem");
initTask.setChannel(SchemaConstants.CHANNEL_GUI_INIT_URI);
OperationResult result = initTask.getResult();
InternalMonitor.reset();
InternalsConfig.setPrismMonitoring(true);
prismContext.setMonitor(new InternalMonitor());
initSystem(initTask, result);
postInitSystem(initTask, result);
result.computeStatus();
IntegrationTestTools.display("initSystem result", result);
TestUtil.assertSuccessOrWarning("initSystem failed (result)", result, 1);
setSystemInitialized();
}
}
use of com.evolveum.midpoint.schema.internals.InternalMonitor 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);
}
use of com.evolveum.midpoint.schema.internals.InternalMonitor in project midpoint by Evolveum.
the class MidPointPrismContextFactory method createPrismContext.
@Override
public PrismContext createPrismContext() throws SchemaException, IOException {
SchemaRegistryImpl schemaRegistry = createSchemaRegistry();
PrismContextImpl context = PrismContextImpl.create(schemaRegistry);
context.setDefinitionFactory(createDefinitionFactory());
context.setDefaultRelation(SchemaConstants.ORG_DEFAULT);
context.setObjectsElementName(SchemaConstants.C_OBJECTS);
context.setDefaultReferenceTypeName(ObjectReferenceType.COMPLEX_TYPE);
context.setExtensionContainerTypeName(ExtensionType.COMPLEX_TYPE);
if (InternalsConfig.isPrismMonitoring()) {
context.setMonitor(new InternalMonitor());
}
context.setParsingMigrator(new MidpointParsingMigrator());
context.setValueMetadataFactory(new MidpointValueMetadataFactory(context));
context.setProvenanceEquivalenceStrategy(MidpointProvenanceEquivalenceStrategy.INSTANCE);
context.registerQueryExpressionFactory(new PrismQueryExpressionSupport());
return context;
}
Aggregations