Search in sources :

Example 16 with ClassLoggerConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType in project midpoint by Evolveum.

the class TestLoggingConfiguration method applyTestLoggingConfig.

private void applyTestLoggingConfig(LoggingConfigurationType logging) {
    // Make sure that this class has a special entry in the config so we will see the messages from this test code
    ClassLoggerConfigurationType testClassLogger = new ClassLoggerConfigurationType();
    testClassLogger.setPackage(TestLoggingConfiguration.class.getName());
    testClassLogger.setLevel(LoggingLevelType.TRACE);
    logging.getClassLogger().add(testClassLogger);
    ClassLoggerConfigurationType integrationTestToolsLogger = new ClassLoggerConfigurationType();
    integrationTestToolsLogger.setPackage(IntegrationTestTools.class.getName());
    integrationTestToolsLogger.setLevel(LoggingLevelType.TRACE);
    logging.getClassLogger().add(integrationTestToolsLogger);
}
Also used : ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) IntegrationTestTools(com.evolveum.midpoint.test.IntegrationTestTools)

Example 17 with ClassLoggerConfigurationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType 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

ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)17 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)5 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)3 LoggingDto (com.evolveum.midpoint.web.page.admin.configuration.dto.LoggingDto)3 SubSystemLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)3 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)2 AppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType)2 AssignmentPolicyEnforcementType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType)2 AuditingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType)2 CleanupPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType)2 FileAppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.FileAppenderConfigurationType)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 Test (org.testng.annotations.Test)2 DummyConnector (com.evolveum.icf.dummy.connector.DummyConnector)1 IntegrationTestTools (com.evolveum.midpoint.test.IntegrationTestTools)1 ClassLogger (com.evolveum.midpoint.web.page.admin.configuration.dto.ClassLogger)1