Search in sources :

Example 1 with TestAppender

use of com.cloud.test.TestAppender in project cloudstack by apache.

the class NfsSecondaryStorageResourceTest method testCleanupStagingNfs.

@Test
public void testCleanupStagingNfs() throws Exception {
    NfsSecondaryStorageResource spyResource = spy(resource);
    RuntimeException exception = new RuntimeException();
    doThrow(exception).when(spyResource).execute(any(DeleteCommand.class));
    TemplateObjectTO mockTemplate = Mockito.mock(TemplateObjectTO.class);
    TestAppender.TestAppenderBuilder appenderBuilder = new TestAppender.TestAppenderBuilder();
    appenderBuilder.addExpectedPattern(Level.DEBUG, "Failed to clean up staging area:");
    TestAppender testLogAppender = appenderBuilder.build();
    TestAppender.safeAddAppender(NfsSecondaryStorageResource.s_logger, testLogAppender);
    spyResource.cleanupStagingNfs(mockTemplate);
    testLogAppender.assertMessagesLogged();
}
Also used : DeleteCommand(org.apache.cloudstack.storage.command.DeleteCommand) TestAppender(com.cloud.test.TestAppender) TemplateObjectTO(org.apache.cloudstack.storage.to.TemplateObjectTO) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

TestAppender (com.cloud.test.TestAppender)1 DeleteCommand (org.apache.cloudstack.storage.command.DeleteCommand)1 TemplateObjectTO (org.apache.cloudstack.storage.to.TemplateObjectTO)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1