Skip to content

Commit d42e2aa

Browse files
committed
fix test
1 parent 3ee9608 commit d42e2aa

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

agent/src/test/java/com/cloud/agent/AgentShellTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,10 @@ public void testGetSslHandshakeTimeout() {
371371
}
372372

373373
private void mockLastSetupCompletedHost(String value) {
374-
PowerMockito.mockStatic(AgentPropertiesFileHandler.class);
375-
PowerMockito.when(AgentPropertiesFileHandler.getPropertyValue(Mockito.eq(AgentProperties.LAST_SETUP_COMPLETED_HOST))).thenReturn(value);
374+
agentPropertiesFileHandlerMocked.when(() -> AgentPropertiesFileHandler.getPropertyValue(Mockito.eq(AgentProperties.LAST_SETUP_COMPLETED_HOST))).thenReturn(value);
376375
}
377376

378377
@Test
379-
@PrepareForTest(AgentPropertiesFileHandler.class)
380378
public void getHostsTestAppendsLastSetupCompletedHostAsFallback() {
381379
mockLastSetupCompletedHost("30.3.3.3");
382380
agentShellSpy.setHosts("10.1.1.1,20.2.2.2");
@@ -385,7 +383,6 @@ public void getHostsTestAppendsLastSetupCompletedHostAsFallback() {
385383
}
386384

387385
@Test
388-
@PrepareForTest(AgentPropertiesFileHandler.class)
389386
public void getHostsTestSubstringHostDoesNotSuppressFallback() {
390387
// 10.0.0.1 is a substring of 10.0.0.10 but not the same host, so it must still be appended.
391388
mockLastSetupCompletedHost("10.0.0.1");
@@ -395,7 +392,6 @@ public void getHostsTestSubstringHostDoesNotSuppressFallback() {
395392
}
396393

397394
@Test
398-
@PrepareForTest(AgentPropertiesFileHandler.class)
399395
public void getHostsTestExactMatchIsNotDuplicated() {
400396
mockLastSetupCompletedHost("20.2.2.2");
401397
agentShellSpy.setHosts("10.1.1.1,20.2.2.2");
@@ -404,7 +400,6 @@ public void getHostsTestExactMatchIsNotDuplicated() {
404400
}
405401

406402
@Test
407-
@PrepareForTest(AgentPropertiesFileHandler.class)
408403
public void getHostsTestMatchIsCaseInsensitiveAndTrimmed() {
409404
mockLastSetupCompletedHost(" HOSTA.EXAMPLE.COM ");
410405
agentShellSpy.setHosts("hosta.example.com,hostb.example.com");
@@ -413,7 +408,6 @@ public void getHostsTestMatchIsCaseInsensitiveAndTrimmed() {
413408
}
414409

415410
@Test
416-
@PrepareForTest(AgentPropertiesFileHandler.class)
417411
public void getHostsTestBlankLastSetupCompletedHostReturnsConfiguredHostsOnly() {
418412
mockLastSetupCompletedHost(" ");
419413
agentShellSpy.setHosts("10.1.1.1,20.2.2.2");

0 commit comments

Comments
 (0)