Search in sources :

Example 1 with LogfileTestTailer

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

the class TestLoggingConfiguration method test021JulLoggingEnabled.

@Test
public void test021JulLoggingEnabled() throws Exception {
    final String TEST_NAME = "test021JulLoggingEnabled";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(JUL_LOGGER_NAME);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Setup
    PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
    LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
    applyTestLoggingConfig(logging);
    ClassLoggerConfigurationType classLogerCongif = new ClassLoggerConfigurationType();
    classLogerCongif.setPackage(JUL_LOGGER_NAME);
    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);
    // WHEN
    julLogger.severe(LogfileTestTailer.MARKER + " JULsevere");
    julLogger.warning(LogfileTestTailer.MARKER + " JULwarning");
    julLogger.info(LogfileTestTailer.MARKER + " JULinfo");
    julLogger.fine(LogfileTestTailer.MARKER + " JULfine");
    julLogger.finer(LogfileTestTailer.MARKER + " JULfiner");
    julLogger.finest(LogfileTestTailer.MARKER + " JULfinest");
    tailer.tail();
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_ERROR, "JULsevere");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_WARN, "JULwarning");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_INFO, "JULinfo");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "JULfine");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_DEBUG, "JULfiner");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, "JULfinest");
    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) 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)

Example 2 with LogfileTestTailer

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

the class TestLoggingConfiguration method test020JulLoggingDisabled.

@Test
public void test020JulLoggingDisabled() throws Exception {
    final String TEST_NAME = "test020JulLoggingDisabled";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(JUL_LOGGER_NAME);
    // WHEN
    julLogger.severe(LogfileTestTailer.MARKER + " JULsevere");
    julLogger.warning(LogfileTestTailer.MARKER + " JULwarning");
    julLogger.info(LogfileTestTailer.MARKER + " JULinfo");
    julLogger.fine(LogfileTestTailer.MARKER + " JULfine");
    julLogger.finer(LogfileTestTailer.MARKER + " JULfiner");
    julLogger.finest(LogfileTestTailer.MARKER + " JULfinest");
    tailer.tail();
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_ERROR, "JULsevere");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_WARN, "JULwarning");
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_INFO, "JULinfo");
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_DEBUG, "JULfine");
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_DEBUG, "JULfiner");
    tailer.assertMarkerNotLogged(LogfileTestTailer.LEVEL_TRACE, "JULfinest");
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Test(org.testng.annotations.Test)

Example 3 with LogfileTestTailer

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

the class TestLoggingConfiguration method test001CreateSystemConfiguration.

@Test
public void test001CreateSystemConfiguration() throws Exception {
    final String TEST_NAME = "test001CreateSystemConfiguration";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(SYSTEM_CONFIGURATION_FILE);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectDelta<SystemConfigurationType> systemConfigurationAddDelta = ObjectDelta.createAddDelta(systemConfiguration);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigurationAddDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    tailer.logAndTail();
    assertBasicLogging(tailer);
    // TODO: more asserts
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Example 4 with LogfileTestTailer

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

the class TestScriptingBasic method test120Log.

@Test
public void test120Log() throws Exception {
    final String TEST_NAME = "test120Log";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(DOT_CLASS + TEST_NAME);
    OperationResult result = task.getResult();
    PrismProperty<ScriptingExpressionType> logAction = parseAnyData(LOG_FILE);
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    tailer.tail();
    tailer.setExpecteMessage("Custom message:");
    // WHEN
    ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(logAction.getAnyValue().getValue(), task, result);
    // THEN
    dumpOutput(output, result);
    assertNoOutputData(output);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    tailer.tail();
    tailer.assertExpectedMessage();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 5 with LogfileTestTailer

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

the class TestWSSanity method test100AddUserJack.

// TODO: test unreachable resource
@Test
public void test100AddUserJack() throws Exception {
    final String TEST_NAME = "test100AddUserJack";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    UserType userNobody = ModelClientUtil.unmarshallFile(USER_JACK_FILE);
    XMLGregorianCalendar startTs = TestUtil.currentTime();
    // WHEN
    String oid = addObject(userNobody);
    // THEN
    XMLGregorianCalendar endTs = TestUtil.currentTime();
    tailer.tail();
    displayAudit(tailer);
    assertAuditLoginLogout(tailer);
    assertAuditIds(tailer);
    assertAuditOperation(tailer, "ADD_OBJECT");
    tailer.assertAudit(4);
    // GET user
    UserType userAfter = getObject(UserType.class, USER_JACK_OID);
    display(userAfter);
    assertUser(userAfter, oid, USER_JACK_USERNAME, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME);
    assertCreateMetadata(userAfter, USER_ADMINISTRATOR_OID, startTs, endTs);
    assertPasswordCreateMetadata(userAfter, USER_ADMINISTRATOR_OID, startTs, endTs);
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) 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