This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to use Environment properties instead of enums
Spring Boot users will prefer this style of configuration. (Requires changes in togglz, submitted as a PR)
- Loading branch information
Showing
18 changed files
with
107 additions
and
122 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
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
20 changes: 0 additions & 20 deletions
20
spring-boot-hello-world/src/main/java/sample/MyFeatures.java
This file was deleted.
Oops, something went wrong.
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
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
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
20 changes: 12 additions & 8 deletions
20
spring-boot-security/src/main/java/sample/HelloWorldController.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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
20 changes: 0 additions & 20 deletions
20
spring-boot-thymeleaf/src/main/java/sample/MyFeatures.java
This file was deleted.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
spring-boot-thymeleaf/src/test/java/sample/HelloWorldControllerIntegrationTests.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,55 @@ | ||
package sample; | ||
|
||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
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.context.junit4.SpringRunner; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.togglz.core.Feature; | ||
import org.togglz.core.repository.FeatureState; | ||
import org.togglz.core.repository.StateRepository; | ||
import org.togglz.core.util.NamedFeature; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
public class HelloWorldControllerIntegrationTests { | ||
|
||
private static Feature HELLO_WORLD = new NamedFeature("HELLO_WORLD"); | ||
|
||
private static Feature REVERSE_GREETING = new NamedFeature("REVERSE_GREETING"); | ||
|
||
@Autowired | ||
private StateRepository state; | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Test | ||
public void testHelloWorldFeatureDisabled() throws Exception { | ||
state.setFeatureState(new FeatureState(HELLO_WORLD, false)); | ||
mockMvc.perform(get("")).andExpect(status().isOk()) | ||
.andExpect(content().string(not(containsString("Greetings from Spring Boot!")))); | ||
} | ||
|
||
@Test | ||
public void testHelloWorldFeatureEnabled() throws Exception { | ||
mockMvc.perform(get("")).andExpect(status().isOk()) | ||
.andExpect(content().string(containsString("Greetings from Spring Boot!"))); | ||
} | ||
|
||
@Test | ||
public void testHelloWorldFeatureAndReverseGreetingEnabled() throws Exception { | ||
state.setFeatureState(new FeatureState(REVERSE_GREETING, true)); | ||
mockMvc.perform(get("")).andExpect(status().isOk()) | ||
.andExpect(content().string(containsString("!tooB gnirpS morf sgniteerG"))); | ||
} | ||
} |