Add proxyTargetBeans = false and fix some tests

This commit is contained in:
Dave Syer
2019-07-10 12:59:52 +01:00
committed by Oleg Zhurakousky
parent 521c6d3397
commit 307292b959
6 changed files with 40 additions and 19 deletions

View File

@@ -14,13 +14,13 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version> <version>2.2.0.M2</version>
<relativePath/> <relativePath/>
</parent> </parent>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<spring-cloud-function.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-function.version> <spring-cloud-function.version>3.0.0.BUILD-SNAPSHOT</spring-cloud-function.version>
<wrapper.version>1.0.21.RELEASE</wrapper.version> <wrapper.version>1.0.21.RELEASE</wrapper.version>
</properties> </properties>

View File

@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Configuration;
* @author Dave Syer * @author Dave Syer
* *
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public class LowercaseConfiguration { public class LowercaseConfiguration {
@Bean @Bean

View File

@@ -29,7 +29,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
// @checkstyle:off // @checkstyle:off
@SpringBootApplication @SpringBootApplication(proxyBeanMethods = false)
public class SampleApplication { public class SampleApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -20,7 +20,7 @@
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<spring-cloud-function.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-function.version> <spring-cloud-function.version>3.0.0.BUILD-SNAPSHOT</spring-cloud-function.version>
<wrapper.version>1.0.17.RELEASE</wrapper.version> <wrapper.version>1.0.17.RELEASE</wrapper.version>
</properties> </properties>

View File

@@ -16,33 +16,54 @@
package com.example; package com.example;
import org.junit.Ignore; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
/** /**
* @author Dave Syer * @author Dave Syer
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@WebMvcTest @SpringBootTest
@AutoConfigureMockMvc
public class SampleApplicationMvcTests { public class SampleApplicationMvcTests {
@Autowired @Autowired
private MockMvc mockMvc; private MockMvc mockMvc;
@Test @Test
@Ignore("FIXME")
public void words() throws Exception { public void words() throws Exception {
this.mockMvc.perform(get("/words")) MvcResult result = this.mockMvc.perform(get("/words")).andReturn();
.andExpect(content().string("[\"foo\",\"bar\"]")); mockMvc.perform(asyncDispatch(result)).andExpect(content().string("[\"foo\",\"bar\"]"));
}
@Test
public void uppercase() throws Exception {
MvcResult result = this.mockMvc.perform(post("/uppercase").contentType(MediaType.TEXT_PLAIN).content("foo")).andReturn();
mockMvc.perform(asyncDispatch(result)).andExpect(content().string("FOO"));
}
@Test
public void lowercase() throws Exception {
MvcResult result = this.mockMvc.perform(post("/lowercase").contentType(MediaType.TEXT_PLAIN).content("FOO")).andReturn();
mockMvc.perform(asyncDispatch(result)).andExpect(content().string("[\"foo\"]"));
}
@Test
public void lowercaseMulti() throws Exception {
MvcResult result = this.mockMvc.perform(post("/lowercase").contentType(MediaType.APPLICATION_JSON).content("[\"FOO\"]")).andReturn();
mockMvc.perform(asyncDispatch(result)).andExpect(content().string("[\"foo\"]"));
} }
} }

View File

@@ -16,19 +16,19 @@
package com.example; package com.example;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import reactor.core.publisher.Flux;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat; import reactor.core.publisher.Flux;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
@@ -124,7 +124,7 @@ public class SampleApplicationTests {
@Test @Test
public void testCharCounter() { public void testCharCounter() {
Integer length = this.charCounter.apply("the quick brown fox"); Integer length = this.charCounter.apply("the quick brown fox");
assertThat(length).isEqualTo(new Integer(19)); assertThat(length).isEqualTo(19);
} }
} }