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.
Togglz already supports Spring Boot 1.5.x so updating the sample apps is pretty easy.
- Loading branch information
Showing
11 changed files
with
68 additions
and
141 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
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
45 changes: 13 additions & 32 deletions
45
spring-boot-hello-world/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 |
---|---|---|
@@ -1,67 +1,48 @@ | ||
package sample; | ||
|
||
import org.junit.Before; | ||
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.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.SpringApplicationConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
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.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
import org.springframework.web.context.WebApplicationContext; | ||
import org.togglz.junit.TogglzRule; | ||
import sample.Application; | ||
import sample.MyFeatures; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringApplicationConfiguration(classes = Application.class) | ||
@WebAppConfiguration | ||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
public class HelloWorldControllerIntegrationTests { | ||
|
||
@Rule | ||
public TogglzRule togglzRule = TogglzRule.allDisabled(MyFeatures.class); | ||
|
||
@Autowired | ||
private WebApplicationContext webApplicationContext; | ||
|
||
private MockMvc mockMvc; | ||
|
||
@Before | ||
public void setUpMockMvc() { | ||
mockMvc = MockMvcBuilders | ||
.webAppContextSetup(webApplicationContext) | ||
.alwaysDo(print()) | ||
.build(); | ||
} | ||
|
||
@Test | ||
public void testHelloWorldFeatureDisabled() throws Exception { | ||
togglzRule.disable(MyFeatures.HELLO_WORLD); | ||
mockMvc.perform(get("")) | ||
.andExpect(status().isNotFound()); | ||
mockMvc.perform(get("")).andExpect(status().isNotFound()); | ||
} | ||
|
||
@Test | ||
public void testHelloWorldFeatureEnabled() throws Exception { | ||
togglzRule.enable(MyFeatures.HELLO_WORLD); | ||
mockMvc.perform(get("")) | ||
.andExpect(status().isOk()) | ||
mockMvc.perform(get("")).andExpect(status().isOk()) | ||
.andExpect(content().string("Greetings from Spring Boot!")); | ||
} | ||
|
||
@Test | ||
public void testHelloWorldFeatureAndReverseGreetingEnabled() throws Exception { | ||
togglzRule.enable(MyFeatures.HELLO_WORLD); | ||
togglzRule.enable(MyFeatures.REVERSE_GREETING); | ||
mockMvc.perform(get("")) | ||
.andExpect(status().isOk()) | ||
mockMvc.perform(get("")).andExpect(status().isOk()) | ||
.andExpect(content().string("!tooB gnirpS morf sgniteerG")); | ||
} | ||
} |
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: 10 additions & 24 deletions
34
...-provider-or-feature-enums/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
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
40 changes: 12 additions & 28 deletions
40
spring-boot-security/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
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