I have a problem to implement some JUnit test for Gateway Application in Spring Boot Microservices
Here is the Gateway Service Application shown below
@EnableDiscoveryClient
@SpringBootApplication
public class GatewayServiceApplication {
/**
* The main method that starts the Spring Boot application.
*
* @param args The command-line arguments passed to the application.
*/
public static void main(String[] args) {
SpringApplication.run(GatewayServiceApplication.class, args);
}
}
Next, I try to write its JUnit tests shown below
@SpringBootTest
class GatewayServiceApplicationTest {
@Autowired
private ApplicationContext context;
@DisplayName("Application context loads without errors")
@Test
void contextLoads() {
assertThat(context).isNotNull();
}
@DisplayName("Gateway Service starts successfully via main method")
@Test
void mainMethodTest() {
GatewayServiceApplication.main(new String[]{});
}
@Test
@DisplayName("Gateway Service is enabled and running")
void gatewayServiceIsEnabledAndRunning() {
assertThat(context.getBean(GatewayServiceApplication.class)).isNotNull();
}
}
When I run any test, I got this error message shown below
java.lang.StackOverflowError
at java.util.IdentityHashMap.hash(IdentityHashMap.java:295)
at java.util.IdentityHashMap.put(IdentityHashMap.java:426)
at java.util.Collections$SetFromMap.add(Collections.java:5461)
How can I fix it?
As you know, this service is up after eureka server is up
I have a problem to implement some JUnit test for Gateway Application in Spring Boot Microservices.
The aim is to run all JUnit tests in GatewayServiceApplicationTest