Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
Update to Spring Boot 1.5.4
Browse files Browse the repository at this point in the history
Togglz already supports Spring Boot 1.5.x so updating the sample
apps is pretty easy.
  • Loading branch information
dsyer committed Jul 3, 2017
1 parent 48970b4 commit 621b768
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 141 deletions.
31 changes: 29 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@

<properties>
<java.version>1.7</java.version>
<togglz.version>2.3.0-SNAPSHOT</togglz.version>
<spring-boot.version>1.3.2.RELEASE</spring-boot.version>
<togglz.version>2.5.0-SNAPSHOT</togglz.version>
<spring-boot.version>1.5.4.RELEASE</spring-boot.version>
</properties>

<modules>
<module>spring-boot-hello-world</module>
<module>spring-boot-no-feature-provider-or-feature-enums</module>
<module>spring-boot-security</module>
<module>spring-boot-thymeleaf</module>
</modules>
Expand Down Expand Up @@ -103,7 +104,16 @@
<version>${togglz.version}</version>
</dependency>

<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>

</dependencyManagement>

<build>
Expand All @@ -122,6 +132,23 @@
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
</excludes>
<systemPropertyVariables>
<java.security.egd>file:/dev/./urandom</java.security.egd>
<java.awt.headless>true</java.awt.headless>
</systemPropertyVariables>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
13 changes: 0 additions & 13 deletions spring-boot-hello-world/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@
</developer>
</developers>

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class HelloWorldController {
private static final String GREETING = "Greetings from Spring Boot!";

@RequestMapping("/")
public ResponseEntity index() {
public ResponseEntity<?> index() {
if (MyFeatures.HELLO_WORLD.isActive()) {
StringBuilder sb = new StringBuilder(GREETING);
if (MyFeatures.REVERSE_GREETING.isActive()) {
Expand Down
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"));
}
}
13 changes: 0 additions & 13 deletions spring-boot-no-feature-provider-or-feature-enums/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@
</developer>
</developers>

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
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.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 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 {

@Autowired
private WebApplicationContext webApplicationContext;

private MockMvc mockMvc;

@Before
public void setUpMockMvc() {
mockMvc = MockMvcBuilders
.webAppContextSetup(webApplicationContext)
.alwaysDo(print())
.build();
}

@Test
public void testHelloWorld() throws Exception {
mockMvc.perform(get(""))
Expand Down
13 changes: 0 additions & 13 deletions spring-boot-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@
</developer>
</developers>

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
Expand Down
3 changes: 2 additions & 1 deletion spring-boot-security/src/main/java/sample/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@SpringBootApplication
public class Application {

@Bean
@SuppressWarnings("unchecked")
@Bean
public FeatureProvider featureProvider() {
return new EnumBasedFeatureProvider(MyFeatures.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public HelloWorldController(FeatureManager featureManager) {
}

@RequestMapping("/")
public ResponseEntity index() {
public ResponseEntity<?> index() {
if (featureManager.isActive(MyFeatures.HELLO_WORLD)) {
StringBuilder sb = new StringBuilder(GREETING);
if (featureManager.isActive(MyFeatures.REVERSE_GREETING)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
package sample;

import org.junit.Before;
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.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import sample.Application;

import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
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
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
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;

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class HelloWorldControllerIntegrationTests {

@Autowired
private WebApplicationContext webApplicationContext;

private MockMvc mockMvc;

@Before
public void setUpMockMvc() {
mockMvc = MockMvcBuilders
.webAppContextSetup(webApplicationContext)
.apply(springSecurity())
.alwaysDo(print())
.build();
}

@Test
public void testHelloWorldFeatureWithAdmin() throws Exception {
mockMvc.perform(get("")
Expand Down
13 changes: 0 additions & 13 deletions spring-boot-thymeleaf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@
</developer>
</developers>

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.3.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
Expand Down

0 comments on commit 621b768

Please sign in to comment.