This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 8ff2c018cc5 test: fix test failures in ActionEventInterceptorTest
(#8938)
8ff2c018cc5 is described below
commit 8ff2c018cc5b3fc69bcd8756695d04b384e46ab8
Author: Wei Zhou <[email protected]>
AuthorDate: Fri Apr 19 15:10:38 2024 +0200
test: fix test failures in ActionEventInterceptorTest (#8938)
* test: fix test failures in ActionEventInterceptorTest
```
Error: Failures:
Error: ActionEventInterceptorTest.testInterceptComplete:247
Error: ActionEventInterceptorTest.testInterceptException:261
Error: ActionEventInterceptorTest.testInterceptStartAsync:234
expected:<Starting VM[. Id: 0 Name: null]> but was:<Starting VM[]>
```
* Update 8938: move CallContext.unregister as well
---
server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git
a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java
b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java
index 9211ce16759..109cb585d8e 100644
--- a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java
+++ b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java
@@ -172,6 +172,7 @@ public class ActionEventInterceptorTest {
account.setId(ACCOUNT_ID);
user = new UserVO(1, "testuser", "password", "firstname", "lastName",
"email", "timezone",
UUID.randomUUID().toString(), User.Source.UNKNOWN);
+ CallContext.register(user, account);
Mockito.when(accountDao.findById(ACCOUNT_ID)).thenReturn(account);
}
@@ -197,6 +198,8 @@ public class ActionEventInterceptorTest {
utils.init();
+ CallContext.unregister();
+
componentContextMocked.close();
}
@@ -265,7 +268,6 @@ public class ActionEventInterceptorTest {
@Test
public void testInterceptExceptionResource() throws NoSuchMethodException {
- CallContext.register(user, account);
Long resourceId = 1L;
ApiCommandResourceType resourceType =
ApiCommandResourceType.VirtualMachine;
CallContext.current().setEventResourceId(resourceId);
@@ -282,7 +284,6 @@ public class ActionEventInterceptorTest {
Assert.assertEquals(eventVO.getState(),
com.cloud.event.Event.State.Completed);
Assert.assertEquals(eventVO.getResourceId(), resourceId);
Assert.assertEquals(eventVO.getResourceType(),
resourceType.toString());
- CallContext.unregister();
}
@Test