Search in sources :

Example 46 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestLoggingConfiguration method test010AddModelSubsystemLogger.

@Test
public void test010AddModelSubsystemLogger() throws Exception {
    final String TEST_NAME = "test010AddModelSubsystemLogger";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Precondition
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_DEBUG, ProfilingDataManager.Subsystem.MODEL.name());
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.MODEL.name());
    // Setup
    PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
    LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
    applyTestLoggingConfig(logging);
    SubSystemLoggerConfigurationType modelSubSystemLogger = new SubSystemLoggerConfigurationType();
    modelSubSystemLogger.setComponent(LoggingComponentType.MODEL);
    modelSubSystemLogger.setLevel(LoggingLevelType.DEBUG);
    logging.getSubSystemLogger().add(modelSubSystemLogger);
    ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, ProfilingDataManager.Subsystem.MODEL.name());
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.MODEL.name());
    // Test that the class logger for this test messages works
    // GIVEN
    tailer.setExpecteMessage("This is THE MESSage");
    // WHEN
    display("This is THE MESSage");
    // THEN
    tailer.tail();
    tailer.assertExpectedMessage();
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType) Test(org.testng.annotations.Test)

Example 47 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestLoggingConfiguration method test002InitialConfiguration.

@Test
public void test002InitialConfiguration() throws Exception {
    final String TEST_NAME = "test002InitialConfiguration";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_FILE);
    LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
    applyTestLoggingConfig(logging);
    SubSystemLoggerConfigurationType modelSubSystemLogger = new SubSystemLoggerConfigurationType();
    modelSubSystemLogger.setComponent(LoggingComponentType.PROVISIONING);
    modelSubSystemLogger.setLevel(LoggingLevelType.TRACE);
    logging.getSubSystemLogger().add(modelSubSystemLogger);
    PrismObjectDefinition<SystemConfigurationType> systemConfigurationTypeDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(SystemConfigurationType.class);
    Collection<? extends ItemDelta> modifications = PropertyDelta.createModificationReplacePropertyCollection(SystemConfigurationType.F_LOGGING, systemConfigurationTypeDefinition, logging);
    // Modify directly in repository, so the logging code in model will not notice the change
    repositoryService.modifyObject(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, modifications, result);
    // precondition
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
    // WHEN
    repositoryService.postInit(result);
    modelService.postInit(result);
    // THEN
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SubSystemLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType) Test(org.testng.annotations.Test)

Example 48 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestLoggingConfiguration method test030ConnectorLogging.

/**
	 * Test if connectors log properly. The dummy connector logs on all levels when the
	 * "test" operation is invoked. So let's try it.
	 */
@Test
public void test030ConnectorLogging() throws Exception {
    final String TEST_NAME = "test030ConnectorLogging";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    // ICF logging is prefixing the messages;
    tailer.setAllowPrefix(true);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    importObjectFromFile(RESOURCE_DUMMY_FILE, result);
    // Setup
    PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
    LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
    applyTestLoggingConfig(logging);
    ClassLoggerConfigurationType classLogerCongif = new ClassLoggerConfigurationType();
    classLogerCongif.setPackage(DummyConnector.class.getPackage().getName());
    classLogerCongif.setLevel(LoggingLevelType.ALL);
    logging.getClassLogger().add(classLogerCongif);
    ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
    modelService.executeChanges(deltas, null, task, result);
    // INFO part
    java.util.logging.Logger dummyConnctorJulLogger = java.util.logging.Logger.getLogger(DummyConnector.class.getName());
    LOGGER.info("Dummy connector JUL logger as seen by the test: {}; classloader {}", dummyConnctorJulLogger, dummyConnctorJulLogger.getClass().getClassLoader());
    // WHEN
    modelService.testResource(RESOURCE_DUMMY_OID, task);
    // THEN
    tailer.tail();
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_ERROR, "DummyConnectorIcfError");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_WARN, "DummyConnectorIcfWarn");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "DummyConnectorIcfInfo");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, "DummyConnectorIcfOk");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_ERROR, "DummyConnectorJULsevere");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_WARN, "DummyConnectorJULwarning");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_INFO, "DummyConnectorJULinfo");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "DummyConnectorJULfine");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "DummyConnectorJULfiner");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, "DummyConnectorJULfinest");
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) DummyConnector(com.evolveum.icf.dummy.connector.DummyConnector) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Aggregations

LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)48 Test (org.testng.annotations.Test)48 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)28 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)26 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)21 Holder (javax.xml.ws.Holder)21 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)21 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 Task (com.evolveum.midpoint.task.api.Task)8 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)5 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)5 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)3 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)3 ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)2 SubSystemLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)2 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)2