This repository has been archived by the owner on Jul 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ralf-ueberfuhr-ars/feature/config
Configure application using application.yml and configuration class
- Loading branch information
Showing
8 changed files
with
129 additions
and
20 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...e-provider/src/main/java/de/sample/schulung/accounts/boundary/IndexPageConfiguration.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,28 @@ | ||
package de.sample.schulung.accounts.boundary; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
/* | ||
* Lösung lt. Spring MVC | ||
* - Implementiere einen WebMvcConfigurer | ||
* - Packe diese Implementierung (Objekt) in den Context (Eimer) | ||
*/ | ||
@Configuration // Spring Boot AutoConfiguration | ||
public class IndexPageConfiguration { | ||
|
||
@Bean //Rückgabewert der Methode wird in den Eimer gepackt | ||
WebMvcConfigurer indexPageConfig() { | ||
return new WebMvcConfigurer() { | ||
@Override | ||
public void addViewControllers(ViewControllerRegistry registry) { | ||
registry | ||
.addViewController("/") | ||
.setViewName("redirect:/index.html"); | ||
} | ||
}; | ||
} | ||
|
||
} |
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
4 changes: 4 additions & 0 deletions
4
account-service-provider/src/main/resources/application-local.yml
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,4 @@ | ||
application: | ||
customers: | ||
initialization: | ||
enabled: true |
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,9 @@ | ||
server: | ||
port: 8080 | ||
spring: | ||
jackson: | ||
property-naming-strategy: SNAKE_CASE | ||
application: | ||
customers: | ||
initialization: | ||
enabled: ${CUSTOMERS_INITIALIZATION_ENABLED:false} |
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
34 changes: 34 additions & 0 deletions
34
account-service-provider/src/test/java/de/sample/schulung/accounts/IndexPageTests.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,34 @@ | ||
package de.sample.schulung.accounts; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
public class IndexPageTests { | ||
|
||
@Autowired | ||
MockMvc mvc; | ||
|
||
@Test | ||
void shouldRedirectIndexPage() throws Exception { | ||
var location = mvc.perform( | ||
get("/") | ||
) | ||
.andExpect(status().isFound()) | ||
.andExpect(header().exists("Location")) | ||
.andReturn() | ||
.getResponse() | ||
.getHeader("Location"); | ||
assertThat(location).endsWith("/index.html"); | ||
} | ||
|
||
} |
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
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