Search in sources :

Example 6 with CustomLogger

use of com.microsoft.azure.sdk.iot.device.CustomLogger in project azure-iot-sdk-java by Azure.

the class CustomLoggerTest method testLogWarn.

// Tests_SRS_CUSTOMERLOGGER_25_002: [The function shall print message for WARN level.]
@Test
public void testLogWarn(@Mocked final Logger mockLogger) {
    final String message = "This is WARN message";
    new NonStrictExpectations() {

        {
            Logger.getLogger((Class) any);
            result = mockLogger;
            mockLogger.isEnabledFor(Level.WARN);
            result = true;
        }
    };
    new CustomLogger(this.getClass()).LogWarn(message);
    new Verifications() {

        {
            mockLogger.warn(anyString);
            times = 1;
        }
    };
}
Also used : CustomLogger(com.microsoft.azure.sdk.iot.device.CustomLogger) Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 7 with CustomLogger

use of com.microsoft.azure.sdk.iot.device.CustomLogger in project azure-iot-sdk-java by Azure.

the class CustomLoggerTest method testLogFatal.

// Tests_SRS_CUSTOMERLOGGER_25_002: [The function shall print message for FATAL level.]
@Test
public void testLogFatal(@Mocked final Logger mockLogger) {
    final String message = "This is FATAL message";
    new NonStrictExpectations() {

        {
            Logger.getLogger((Class) any);
            result = mockLogger;
            mockLogger.isEnabledFor(Level.FATAL);
            result = true;
        }
    };
    new CustomLogger(this.getClass()).LogFatal(message);
    new Verifications() {

        {
            mockLogger.fatal(anyString);
            times = 1;
        }
    };
}
Also used : CustomLogger(com.microsoft.azure.sdk.iot.device.CustomLogger) Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 8 with CustomLogger

use of com.microsoft.azure.sdk.iot.device.CustomLogger in project azure-iot-sdk-java by Azure.

the class CustomLoggerTest method getExecutingMethodName.

// Tests_SRS_CUSTOMERLOGGER_25_002: [The function shall log message for all levels.]
@Test
public void getExecutingMethodName() {
    CustomLogger logger = new CustomLogger(this.getClass());
    String methodName = logger.getMethodName();
    assertThat("getExecutingMethodName", is(equalTo(methodName)));
}
Also used : CustomLogger(com.microsoft.azure.sdk.iot.device.CustomLogger) Test(org.junit.Test)

Example 9 with CustomLogger

use of com.microsoft.azure.sdk.iot.device.CustomLogger in project azure-iot-sdk-java by Azure.

the class CustomLoggerTest method testMethodSignature.

// Tests_SRS_CUSTOMERLOGGER_25_002: [The function shall log message for all levels.]
@Test
public void testMethodSignature() {
    CustomLogger logger = new CustomLogger(this.getClass());
    String message = "This is INFO message";
    logger.LogInfo(message, logger.getMethodName());
    message = "This is DEBUG message";
    logger.LogDebug(message, logger.getMethodName());
    message = "This is TRACE message";
    logger.LogTrace(message, logger.getMethodName());
    message = "This is WARN message";
    logger.LogWarn(message, logger.getMethodName());
    message = "This is FATAL message";
    logger.LogFatal(message, logger.getMethodName());
    message = "This is CUSTOM ERROR message";
    logger.LogError(message, logger.getMethodName());
    message = "This is ERROR message";
    logger.LogError(new Throwable(message));
}
Also used : CustomLogger(com.microsoft.azure.sdk.iot.device.CustomLogger) Test(org.junit.Test)

Aggregations

CustomLogger (com.microsoft.azure.sdk.iot.device.CustomLogger)9 Test (org.junit.Test)9 NonStrictExpectations (mockit.NonStrictExpectations)6 Verifications (mockit.Verifications)6