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();
}
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();
}
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();
}
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();
}
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);
}
Aggregations