-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Eugene Zimin <[email protected]>
- Loading branch information
Eugene Zimin
committed
Oct 16, 2023
1 parent
192925c
commit 191287b
Showing
4 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...va-spring-boot-autoconfigure/src/test/java/com/health/base/SolaceHealthIndicatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.health.base; | ||
|
||
import com.solacesystems.jcsmp.FlowEvent; | ||
import com.solacesystems.jcsmp.FlowEventArgs; | ||
import com.solacesystems.jcsmp.SessionEvent; | ||
import com.solacesystems.jcsmp.SessionEventArgs; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.actuate.health.Health; | ||
import org.springframework.boot.actuate.health.Status; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class SolaceHealthIndicatorTest { | ||
|
||
private SolaceHealthIndicator solaceHealthIndicator; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.solaceHealthIndicator = new SolaceHealthIndicator(); | ||
} | ||
|
||
@Test | ||
void healthUp() { | ||
this.solaceHealthIndicator.healthUp(); | ||
assertEquals(this.solaceHealthIndicator.getHealth(), Health.up().build()); | ||
} | ||
|
||
@Test | ||
void healthReconnecting() { | ||
this.solaceHealthIndicator.healthReconnecting(null); | ||
assertEquals(this.solaceHealthIndicator.getHealth(), Health.status("RECONNECTING").build()); | ||
} | ||
|
||
@Test | ||
void healthDown() { | ||
this.solaceHealthIndicator.healthDown(null); | ||
assertEquals(this.solaceHealthIndicator.getHealth(), Health.down().build()); | ||
} | ||
|
||
@Test | ||
void addFlowEventDetails() { | ||
// as SessionEventArgs constructor has package level access modifier, we have to test with FlowEventArgs only | ||
FlowEventArgs flowEventArgs = new FlowEventArgs(FlowEvent.FLOW_DOWN, "String_infoStr", | ||
new Exception("Test Exception"), 500); | ||
Health health = this.solaceHealthIndicator.addEventDetails(Health.down(),flowEventArgs).build(); | ||
|
||
assertEquals(health.getStatus(), Status.DOWN); | ||
assertEquals(health.getDetails().get("error"), "java.lang.Exception: Test Exception"); | ||
assertEquals(health.getDetails().get("responseCode"), 500); | ||
} | ||
|
||
@Test | ||
void getHealth() { | ||
this.solaceHealthIndicator.setHealth(Health.up().build()); | ||
assertEquals(this.solaceHealthIndicator.getHealth(), Health.up().build()); | ||
} | ||
|
||
@Test | ||
void setHealth() { | ||
this.solaceHealthIndicator.setHealth(Health.down().build()); | ||
assertEquals(this.solaceHealthIndicator.getHealth(), Health.down().build()); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...boot-autoconfigure/src/test/java/com/health/indicators/SolaceFlowHealthIndicatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.health.indicators; | ||
|
||
import com.health.base.SolaceHealthIndicator; | ||
import com.solacesystems.jcsmp.FlowEvent; | ||
import com.solacesystems.jcsmp.FlowEventArgs; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.actuate.health.Health; | ||
import org.springframework.boot.actuate.health.Status; | ||
|
||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class SolaceFlowHealthIndicatorTest { | ||
|
||
private SolaceFlowHealthIndicator solaceHealthIndicator; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.solaceHealthIndicator = new SolaceFlowHealthIndicator(); | ||
} | ||
|
||
@Test | ||
void up() { | ||
this.solaceHealthIndicator.up(); | ||
assertEquals(this.solaceHealthIndicator.getHealth(), Health.up().build()); | ||
} | ||
|
||
@Test | ||
void reconnecting() { | ||
FlowEventArgs flowEventArgs = new FlowEventArgs(FlowEvent.FLOW_RECONNECTING, "String_infoStr", | ||
new Exception("Test Exception"), 500); | ||
this.solaceHealthIndicator.reconnecting(flowEventArgs); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getStatus(), Health.status("RECONNECTING").build().getStatus()); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getDetails().get("error"), "java.lang.Exception: Test Exception"); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getDetails().get("responseCode"), 500); | ||
|
||
} | ||
|
||
@Test | ||
void down() { | ||
FlowEventArgs flowEventArgs = new FlowEventArgs(FlowEvent.FLOW_DOWN, "String_infoStr", | ||
new Exception("Test Exception"), 500); | ||
this.solaceHealthIndicator.down(flowEventArgs); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getStatus(), Status.DOWN); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getDetails().get("error"), "java.lang.Exception: Test Exception"); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getDetails().get("responseCode"), 500); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...t-autoconfigure/src/test/java/com/health/indicators/SolaceSessionHealthIndicatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.health.indicators; | ||
|
||
import com.solacesystems.jcsmp.FlowEvent; | ||
import com.solacesystems.jcsmp.FlowEventArgs; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.actuate.health.Health; | ||
import org.springframework.boot.actuate.health.Status; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class SolaceSessionHealthIndicatorTest { | ||
|
||
private SolaceSessionHealthIndicator solaceHealthIndicator; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.solaceHealthIndicator = new SolaceSessionHealthIndicator(); | ||
} | ||
|
||
@Test | ||
void up() { | ||
this.solaceHealthIndicator.up(); | ||
assertEquals(this.solaceHealthIndicator.getHealth(), Health.up().build()); | ||
} | ||
|
||
@Test | ||
void reconnecting() { | ||
this.solaceHealthIndicator.reconnecting(null); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getStatus(), Health.status("RECONNECTING").build().getStatus()); | ||
} | ||
|
||
@Test | ||
void down() { | ||
this.solaceHealthIndicator.down(null); | ||
assertEquals(this.solaceHealthIndicator.getHealth().getStatus(), Status.DOWN); | ||
} | ||
} |