Skip to content

MockMvc tests not working the same in 1.4 #5882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dsyer opened this issue May 6, 2016 · 0 comments
Closed

MockMvc tests not working the same in 1.4 #5882

dsyer opened this issue May 6, 2016 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@dsyer
Copy link
Member

dsyer commented May 6, 2016

This test is kind of unusual (in that it is its own configuration). It fails in 1.4 and passes in 1.3 though

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(SimpleIntegrationTests.class)
@WebAppConfiguration
@EnableAutoConfiguration(exclude = { JmxAutoConfiguration.class })
@RestController
public class SimpleIntegrationTests {

    private static Log logger = LogFactory.getLog(SimpleIntegrationTests.class);

    @Autowired
    private WebApplicationContext webApplicationContext;

    private MockMvc mockMvc;

    private static Object span;

    @Before
    public void setup() {
        DefaultMockMvcBuilder mockMvcBuilder = MockMvcBuilders
                .webAppContextSetup(this.webApplicationContext);
        this.mockMvc = mockMvcBuilder.build();
        SimpleIntegrationTests.span = null;
    }

    @RequestMapping("/ping")
    public String ping() {
        logger.info("ping");
        SimpleIntegrationTests.span = new Object();
        return "ping";
    }

    @RequestMapping("/future")
    public CompletableFuture<String> future() {
        logger.info("future");
        return CompletableFuture.completedFuture("ping");
    }

    @Test
    public void getCallsEndpoint() throws Exception {
        this.mockMvc.perform(get("/ping")).andReturn();
        assertThat(SimpleIntegrationTests.span).isNotNull();
    }

    @Test
    public void futureCreatesAsync() throws Exception {
        this.mockMvc.perform(get("/future")).andExpect(request().asyncStarted());
    }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants