From 8d91efc2094f1ee605637ce76eab6faf6f5a7f66 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 30 Mar 2024 00:18:53 +0300 Subject: Fix tests --- src/main/java/com/juick/config/WebConfig.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/com/juick/config/WebConfig.java b/src/main/java/com/juick/config/WebConfig.java index 43857bb5..a5545c48 100644 --- a/src/main/java/com/juick/config/WebConfig.java +++ b/src/main/java/com/juick/config/WebConfig.java @@ -61,6 +61,7 @@ public class WebConfig implements WebMvcConfigurer { @Inject private UserService userService; + private boolean testsAreRunning = false; private boolean devToolsArePresent = false; @PostConstruct public void initConfiguration() { @@ -70,6 +71,11 @@ public class WebConfig implements WebMvcConfigurer { } catch (ClassNotFoundException e) { // release mode } + for (StackTraceElement s : Thread.currentThread().getStackTrace()) { + if (s.getClassName().contains("org.springframework.boot.test.context.SpringBootContextLoader")) { + testsAreRunning = true; + } + } } @Override @@ -122,7 +128,7 @@ public class WebConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { try { - if (devToolsArePresent) { + if (devToolsArePresent && !testsAreRunning) { registry .addResourceHandler("/**", "/i/a/**") .addResourceLocations("classpath:/static/", Paths.get(baseDir, "/i/a/").toUri().toURL().toString()); -- cgit v1.2.3