Browse Source

Polishing

pull/31445/head
Sam Brannen 1 year ago
parent
commit
87127ab684
  1. 2
      spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotProcessingTests.java
  2. 2
      spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeClassLevelTests.java
  3. 2
      spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeMethodLevelTests.java
  4. 9
      spring-test/src/test/java/org/springframework/test/context/hierarchies/web/EarTests.java
  5. 33
      spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.java
  6. 30
      spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.java

2
spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotProcessingTests.java

@ -47,7 +47,7 @@ public class DisabledInAotProcessingTests { @@ -47,7 +47,7 @@ public class DisabledInAotProcessingTests {
assertThat(enigma).isEqualTo("puzzle");
}
@Configuration
@Configuration(proxyBeanMethods = false)
static class Config {
@Bean

2
spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeClassLevelTests.java

@ -61,7 +61,7 @@ public class DisabledInAotRuntimeClassLevelTests { @@ -61,7 +61,7 @@ public class DisabledInAotRuntimeClassLevelTests {
}
@Configuration(proxyBeanMethods = false)
static class BasicTestConfiguration {
static class Config {
@Bean
MessageService defaultMessageService() {

2
spring-test/src/test/java/org/springframework/test/context/aot/samples/basic/DisabledInAotRuntimeMethodLevelTests.java

@ -63,7 +63,7 @@ public class DisabledInAotRuntimeMethodLevelTests { @@ -63,7 +63,7 @@ public class DisabledInAotRuntimeMethodLevelTests {
}
@Configuration(proxyBeanMethods = false)
static class BasicTestConfiguration {
static class Config {
@Bean
MessageService defaultMessageService() {

9
spring-test/src/test/java/org/springframework/test/context/hierarchies/web/EarTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,14 +17,12 @@ @@ -17,14 +17,12 @@
package org.springframework.test.context.hierarchies.web;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.web.context.WebApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
@ -33,8 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -33,8 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 3.2.2
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@SpringJUnitConfig
class EarTests {
@Configuration

33
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,24 +16,18 @@ @@ -16,24 +16,18 @@
package org.springframework.test.web.servlet.samples.spr;
import java.net.URI;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.ui.Model;
@ -59,23 +53,18 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC @@ -59,23 +53,18 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
*
* @author Sebastien Deleuze
*/
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
@SpringJUnitWebConfig
public class EncodedUriTests {
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
private final MockMvc mockMvc;
@BeforeEach
public void setup() {
this.mockMvc = webAppContextSetup(this.wac).build();
EncodedUriTests(WebApplicationContext wac) {
this.mockMvc = webAppContextSetup(wac).build();
}
@Test
public void test() throws Exception {
void test() throws Exception {
String id = "a/b";
URI url = UriComponentsBuilder.fromUriString("/circuit").pathSegment(id).build().encode().toUri();
ResultActions result = mockMvc.perform(get(url));
@ -88,12 +77,12 @@ public class EncodedUriTests { @@ -88,12 +77,12 @@ public class EncodedUriTests {
static class WebConfig implements WebMvcConfigurer {
@Bean
public MyController myController() {
MyController myController() {
return new MyController();
}
@Bean
public HandlerMappingConfigurer myHandlerMappingConfigurer() {
HandlerMappingConfigurer myHandlerMappingConfigurer() {
return new HandlerMappingConfigurer();
}
@ -107,7 +96,7 @@ public class EncodedUriTests { @@ -107,7 +96,7 @@ public class EncodedUriTests {
private static class MyController {
@RequestMapping(value = "/circuit/{id}", method = RequestMethod.GET)
public String getCircuit(@PathVariable String id, Model model) {
String getCircuit(@PathVariable String id, Model model) {
model.addAttribute("receivedId", id);
return "result";
}

30
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,17 +18,12 @@ package org.springframework.test.web.servlet.samples.spr; @@ -18,17 +18,12 @@ package org.springframework.test.web.servlet.samples.spr;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -47,24 +42,21 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC @@ -47,24 +42,21 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
*
* @author Arnaud Cogoluègnes
*/
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
@SpringJUnitWebConfig
public class HttpOptionsTests {
@Autowired
private WebApplicationContext wac;
private final WebApplicationContext wac;
private MockMvc mockMvc;
private final MockMvc mockMvc;
@BeforeEach
public void setup() {
HttpOptionsTests(WebApplicationContext wac) {
this.wac = wac;
this.mockMvc = webAppContextSetup(this.wac).dispatchOptions(true).build();
}
@Test
public void test() throws Exception {
void test() throws Exception {
MyController controller = this.wac.getBean(MyController.class);
int initialCount = controller.counter.get();
this.mockMvc.perform(options("/myUrl")).andExpect(status().isOk());
@ -78,7 +70,7 @@ public class HttpOptionsTests { @@ -78,7 +70,7 @@ public class HttpOptionsTests {
static class WebConfig implements WebMvcConfigurer {
@Bean
public MyController myController() {
MyController myController() {
return new MyController();
}
}
@ -91,7 +83,7 @@ public class HttpOptionsTests { @@ -91,7 +83,7 @@ public class HttpOptionsTests {
@RequestMapping(value = "/myUrl", method = RequestMethod.OPTIONS)
@ResponseBody
public void handle() {
void handle() {
counter.incrementAndGet();
}
}

Loading…
Cancel
Save