Skip to content

Commit 8ff2c01

Browse files
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
1 parent e1922da commit 8ff2c01

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public EventVO answer(InvocationOnMock invocation) throws Throwable {
172172
account.setId(ACCOUNT_ID);
173173
user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone",
174174
UUID.randomUUID().toString(), User.Source.UNKNOWN);
175+
CallContext.register(user, account);
175176

176177
Mockito.when(accountDao.findById(ACCOUNT_ID)).thenReturn(account);
177178
}
@@ -197,6 +198,8 @@ public void teardown() {
197198

198199
utils.init();
199200

201+
CallContext.unregister();
202+
200203
componentContextMocked.close();
201204
}
202205

@@ -265,7 +268,6 @@ public void testInterceptException() throws NoSuchMethodException {
265268

266269
@Test
267270
public void testInterceptExceptionResource() throws NoSuchMethodException {
268-
CallContext.register(user, account);
269271
Long resourceId = 1L;
270272
ApiCommandResourceType resourceType = ApiCommandResourceType.VirtualMachine;
271273
CallContext.current().setEventResourceId(resourceId);
@@ -282,7 +284,6 @@ public void testInterceptExceptionResource() throws NoSuchMethodException {
282284
Assert.assertEquals(eventVO.getState(), com.cloud.event.Event.State.Completed);
283285
Assert.assertEquals(eventVO.getResourceId(), resourceId);
284286
Assert.assertEquals(eventVO.getResourceType(), resourceType.toString());
285-
CallContext.unregister();
286287
}
287288

288289
@Test

0 commit comments

Comments
 (0)