Github user jburwell commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/1331#discussion_r59756105
--- Diff:
services/secondary-storage/server/test/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResourceTest.java
---
@@ -88,6 +93,19 @@ public void testMount() throws Exception {
}
}
+ @Test
+ public void testCleanupNfsStaging(){
+ TemplateObjectTO templateMock =
Mockito.mock(TemplateObjectTO.class);
+ Exception exception = new Exception();
+ resource.logger = Mockito.mock(Logger.class);
+
+ Mockito.doNothing().when(resource.logger).debug("Failed to clean
up staging area:", exception);
+
Mockito.when(resource.execute(any(DeleteCommand.class))).thenThrow(exception);
--- End diff --
Why are you using Mockito to mock the logger? Why not retrieve the logger
used by the class and add test logger to collect the log message? You can then
ask search the log messages in the appender to see if the log message you
expect is present. This avoids the overhead of Mockito, and much more
straightforward approach to observing that logging is behaving as expected.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---