Search in sources :

Example 6 with LogLevel

use of org.finra.herd.core.helper.LogLevel in project herd by FINRAOS.

the class UploadDownloadServiceTest method testPerformCompleteUploadSingleMessageWithDebugLoggingEnabled.

@Test
public void testPerformCompleteUploadSingleMessageWithDebugLoggingEnabled() throws Exception {
    // Get the logger and the current logger level.
    LogLevel origLogLevel = getLogLevel(UploadDownloadServiceImpl.class);
    // Set logging level to DEBUG.
    setLogLevel(UploadDownloadServiceImpl.class, LogLevel.DEBUG);
    // Run the test and reset the logging level back to the original value.
    try {
        runPerformCompleteUploadSingleMessageTest();
    } finally {
        setLogLevel(UploadDownloadServiceImpl.class, origLogLevel);
    }
}
Also used : LogLevel(org.finra.herd.core.helper.LogLevel) Test(org.junit.Test)

Example 7 with LogLevel

use of org.finra.herd.core.helper.LogLevel in project herd by FINRAOS.

the class NotificationEventServiceTest method testProcessBusinessObjectDataStatusChangeNotificationEventSyncWithInfoLoggingEnabled.

@Test
public void testProcessBusinessObjectDataStatusChangeNotificationEventSyncWithInfoLoggingEnabled() throws Exception {
    // Get the logger and the current logger level.
    LogLevel origLogLevel = getLogLevel(BusinessObjectDataNotificationJobActionServiceImpl.class);
    // Set logging level to INFO.
    setLogLevel(BusinessObjectDataNotificationJobActionServiceImpl.class, LogLevel.INFO);
    // Run the test and reset the logging level back to the original value.
    try {
        runProcessBusinessObjectDataStatusChangeNotificationEventSyncTest();
    } finally {
        setLogLevel(BusinessObjectDataNotificationJobActionServiceImpl.class, origLogLevel);
    }
}
Also used : LogLevel(org.finra.herd.core.helper.LogLevel) Test(org.junit.Test)

Example 8 with LogLevel

use of org.finra.herd.core.helper.LogLevel in project herd by FINRAOS.

the class StopWatchAdviceTest method testLogMethodTimeWithInfoLoggingDisabled.

@Test
public void testLogMethodTimeWithInfoLoggingDisabled() throws Throwable {
    // Mock a join point of the method call.
    ProceedingJoinPoint joinPoint = getMockedProceedingJoinPoint(new StopWatchAdviceTest(), StopWatchAdviceTest.class.getDeclaredMethod("mockMethod"));
    // Get the logger and the current logger level.
    LogLevel origLogLevel = getLogLevel("org.finra.herd.core.StopWatchAdvice");
    // Set logging level to OFF.
    setLogLevel("org.finra.herd.core.StopWatchAdvice", LogLevel.OFF);
    // Run the test and reset the logging level back to the original value.
    try {
        // Call the method under test.
        stopWatchAdvice.logMethodTime(joinPoint);
    } finally {
        setLogLevel("org.finra.herd.core.StopWatchAdvice", origLogLevel);
    }
}
Also used : MockProceedingJoinPoint(org.finra.herd.core.MockProceedingJoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) LogLevel(org.finra.herd.core.helper.LogLevel) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 9 with LogLevel

use of org.finra.herd.core.helper.LogLevel in project herd by FINRAOS.

the class PublishNotificationMessagesAdviceTest method testPublishNotificationMessagesDebugEnabled.

@Test
public void testPublishNotificationMessagesDebugEnabled() throws Throwable {
    // Save the current log level.
    LogLevel originalLogLevel = getLogLevel(PublishNotificationMessagesAdvice.class);
    try {
        // Set the log level to debug.
        setLogLevel(PublishNotificationMessagesAdvice.class, LogLevel.DEBUG);
        // Create a notification message.
        NotificationMessage notificationMessage = new NotificationMessage(MessageTypeEntity.MessageEventTypes.SQS.name(), AWS_SQS_QUEUE_NAME, MESSAGE_TEXT, Collections.singletonList(new MessageHeader(KEY, VALUE)));
        // Mock a join point of the method call.
        ProceedingJoinPoint joinPoint = getMockedProceedingJoinPoint("testPublishNotificationMessages");
        // Mock the external calls.
        doCallRealMethod().when(notificationMessageInMemoryQueue).clear();
        doCallRealMethod().when(notificationMessageInMemoryQueue).add(notificationMessage);
        when(notificationMessageInMemoryQueue.size()).thenCallRealMethod();
        when(notificationMessageInMemoryQueue.isEmpty()).thenCallRealMethod();
        doCallRealMethod().when(notificationMessageInMemoryQueue).remove();
        // Clear the queue.
        notificationMessageInMemoryQueue.clear();
        // Add the notification message to the queue.
        notificationMessageInMemoryQueue.add(notificationMessage);
        // Validate that the queue is not empty now.
        assertFalse(notificationMessageInMemoryQueue.isEmpty());
        // Call the method under test.
        publishNotificationMessagesAdvice.publishNotificationMessages(joinPoint);
        // Verify the external calls.
        verify(notificationMessageInMemoryQueue, times(2)).clear();
        verify(notificationMessageInMemoryQueue).add(notificationMessage);
        verify(notificationMessageInMemoryQueue).size();
        verify(notificationMessageInMemoryQueue, times(3)).isEmpty();
        verify(notificationMessageInMemoryQueue).remove();
        verify(notificationMessagePublishingService).publishNotificationMessage(notificationMessage);
        verifyNoMoreInteractionsHelper();
        // Validate the results.
        assertTrue(notificationMessageInMemoryQueue.isEmpty());
    } finally {
        // Restore log level to the original value.
        setLogLevel(PublishNotificationMessagesAdvice.class, originalLogLevel);
    }
}
Also used : NotificationMessage(org.finra.herd.model.dto.NotificationMessage) MessageHeader(org.finra.herd.model.dto.MessageHeader) LogLevel(org.finra.herd.core.helper.LogLevel) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 10 with LogLevel

use of org.finra.herd.core.helper.LogLevel in project herd by FINRAOS.

the class S3DaoTest method testUploadFileListWithLoggerLevelSetToInfo.

/**
 * Test that we are able to perform the uploadFileList S3Dao operation on S3 using our DAO tier with logger level set to INFO.
 */
@Test
public void testUploadFileListWithLoggerLevelSetToInfo() throws IOException, InterruptedException {
    String loggerName = S3DaoImpl.class.getName();
    LogLevel origLoggerLevel = getLogLevel(loggerName);
    setLogLevel(loggerName, LogLevel.INFO);
    try {
        runUploadFileListTest();
    } finally {
        setLogLevel(loggerName, origLoggerLevel);
    }
}
Also used : LogLevel(org.finra.herd.core.helper.LogLevel) Test(org.junit.Test)

Aggregations

LogLevel (org.finra.herd.core.helper.LogLevel)15 Test (org.junit.Test)15 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)4 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)3 StringWriter (java.io.StringWriter)2 MockProceedingJoinPoint (org.finra.herd.core.MockProceedingJoinPoint)2 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)2 AmazonClientException (com.amazonaws.AmazonClientException)1 AmazonServiceException (com.amazonaws.AmazonServiceException)1 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)1 DeletedObject (com.amazonaws.services.s3.model.DeleteObjectsResult.DeletedObject)1 MultiObjectDeleteException (com.amazonaws.services.s3.model.MultiObjectDeleteException)1 DeleteError (com.amazonaws.services.s3.model.MultiObjectDeleteException.DeleteError)1 S3VersionSummary (com.amazonaws.services.s3.model.S3VersionSummary)1 VersionListing (com.amazonaws.services.s3.model.VersionListing)1 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1