Search in sources :

Example 1 with CustomLogger

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

the class CustomLoggerTest method testLogTrace.

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

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

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

Example 2 with CustomLogger

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

the class CustomLoggerTest method testLogInfo.

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

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

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

Example 3 with CustomLogger

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

the class CustomLoggerTest method testLogError.

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

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

        {
            mockLogger.error(anyString);
            times = 1;
        }
    };
    new NonStrictExpectations() {

        {
            Logger.getLogger((Class) any);
            result = mockLogger;
            mockLogger.isEnabledFor(Level.ERROR);
            result = true;
        }
    };
    new CustomLogger(this.getClass()).LogError(new Throwable("This is ERROR message"));
    new Verifications() {

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

Example 4 with CustomLogger

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

the class CustomLoggerTest method testLogDebug.

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

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

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

Example 5 with CustomLogger

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

the class CustomLoggerTest method contructorCreatesLogger.

// Tests_SRS_CUSTOMERLOGGER_25_001: [The constructor shall create the logger instance.]
@Test
public void contructorCreatesLogger() {
    CustomLogger logger = new CustomLogger(this.getClass());
    assertThat(logger, notNullValue());
}
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