changed code indent by space instead of tab

This commit is contained in:
Bhabani Prasad Patel
2021-05-27 11:42:38 +05:30
parent 0329542cf1
commit d1620c189b
6 changed files with 103 additions and 103 deletions

View File

@@ -8,8 +8,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ComponentScan({ "com.baeldung.sampleapp.web" })
public class MaxHTTPHeaderSizeConfig implements WebMvcConfigurer {
public MaxHTTPHeaderSizeConfig() {
super();
}
public MaxHTTPHeaderSizeConfig() {
super();
}
}

View File

@@ -9,9 +9,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(value = "/request-header-test")
public class MaxHttpHeaderSizeController {
@GetMapping
public boolean testMaxHTTPHeaderSize(@RequestHeader(value = "token") String token) {
return true;
}
@GetMapping
public boolean testMaxHTTPHeaderSize(@RequestHeader(value = "token") String token) {
return true;
}
}

View File

@@ -23,26 +23,26 @@ import com.baeldung.sampleapp.config.WebConfig;
@WebAppConfiguration
public class MaxHttpHeaderSizeControllerIntegrationTest {
private MockMvc mockMvc;
private MockMvc mockMvc;
@Autowired
private WebApplicationContext webApplicationContext;
@Autowired
private WebApplicationContext webApplicationContext;
@Before
public void setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Before
public void setUp() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Test
public void givenTokenWithLessThan8KBLegth_whenSendGetRequest_thenReturnsOK() throws Exception {
mockMvc.perform(get("/request-header-test").contentType(MediaType.APPLICATION_JSON_VALUE)
.with(httpBasic("user", "password")).header("token", "token")).andExpect(status().isOk());
}
@Test
public void givenTokenWithLessThan8KBLegth_whenSendGetRequest_thenReturnsOK() throws Exception {
mockMvc.perform(get("/request-header-test").contentType(MediaType.APPLICATION_JSON_VALUE)
.with(httpBasic("user", "password")).header("token", "token")).andExpect(status().isOk());
}
@Test
public void givenTokenIsMissingInHeade_whenSendGetRequest_thenThrowsBadRequest() throws Exception {
mockMvc.perform(get("/request-header-test").contentType(MediaType.APPLICATION_JSON_VALUE)
.with(httpBasic("user", "password"))).andExpect(status().isBadRequest());
}
@Test
public void givenTokenIsMissingInHeade_whenSendGetRequest_thenThrowsBadRequest() throws Exception {
mockMvc.perform(get("/request-header-test").contentType(MediaType.APPLICATION_JSON_VALUE)
.with(httpBasic("user", "password"))).andExpect(status().isBadRequest());
}
}

View File

@@ -25,29 +25,29 @@ import com.baeldung.sampleapp.config.MaxHTTPHeaderSizeConfig;
// Start MaxHttpHeaderSizeController Spring Boot App(MainApplication) first
public class MaxHttpHeaderSizeControllerLiveTest {
@Test(expected = HttpClientErrorException.class)
public void givenTokenWithGreaterThan8KBLegth_whenSendGetRequest_thenThrowsBadRequest() throws Exception {
final String url = "http://localhost:8080/request-header-test";
HttpHeaders headers = new HttpHeaders();
headers.set("token", readRandomStringFromFile());
@Test(expected = HttpClientErrorException.class)
public void givenTokenWithGreaterThan8KBLegth_whenSendGetRequest_thenThrowsBadRequest() throws Exception {
final String url = "http://localhost:8080/request-header-test";
HttpHeaders headers = new HttpHeaders();
headers.set("token", readRandomStringFromFile());
HttpEntity entity = new HttpEntity(headers);
final ResponseEntity<String> response = new RestTemplate().exchange(url, HttpMethod.GET, entity, String.class);
}
HttpEntity entity = new HttpEntity(headers);
final ResponseEntity<String> response = new RestTemplate().exchange(url, HttpMethod.GET, entity, String.class);
}
static String readRandomStringFromFile() throws IOException {
BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/randomSringForheader.txt"));
StringBuilder stringBuilder = new StringBuilder();
String line = null;
String ls = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
reader.close();
String content = stringBuilder.toString();
return content;
}
static String readRandomStringFromFile() throws IOException {
BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/randomSringForheader.txt"));
StringBuilder stringBuilder = new StringBuilder();
String line = null;
String ls = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
reader.close();
String content = stringBuilder.toString();
return content;
}
}