"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java" between
spring-framework-5.3.7.tar.gz and spring-framework-5.3.8.tar.gz

About: Spring Framework is an application framework for the Java platform and .NET Framework. Community edition.

MultipartHttpMessageWriterTests.java  (spring-framework-5.3.7):MultipartHttpMessageWriterTests.java  (spring-framework-5.3.8)
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
skipping to change at line 107 skipping to change at line 107
}; };
Flux<DataBuffer> bufferPublisher = Flux.just( Flux<DataBuffer> bufferPublisher = Flux.just(
this.bufferFactory.wrap("Aa".getBytes(StandardCha rsets.UTF_8)), this.bufferFactory.wrap("Aa".getBytes(StandardCha rsets.UTF_8)),
this.bufferFactory.wrap("Bb".getBytes(StandardCha rsets.UTF_8)), this.bufferFactory.wrap("Bb".getBytes(StandardCha rsets.UTF_8)),
this.bufferFactory.wrap("Cc".getBytes(StandardCha rsets.UTF_8)) this.bufferFactory.wrap("Cc".getBytes(StandardCha rsets.UTF_8))
); );
FilePart mockPart = mock(FilePart.class); FilePart mockPart = mock(FilePart.class);
HttpHeaders partHeaders = new HttpHeaders(); HttpHeaders partHeaders = new HttpHeaders();
partHeaders.setContentType(MediaType.TEXT_PLAIN); partHeaders.setContentType(MediaType.TEXT_PLAIN);
partHeaders.setContentDispositionFormData("filePublisher", "file. txt"); partHeaders.setContentDispositionFormData("foo", "file.txt");
partHeaders.add("foo", "bar"); partHeaders.add("foo", "bar");
given(mockPart.headers()).willReturn(partHeaders); given(mockPart.headers()).willReturn(partHeaders);
given(mockPart.content()).willReturn(bufferPublisher); given(mockPart.content()).willReturn(bufferPublisher);
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder(); MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
bodyBuilder.part("name 1", "value 1"); bodyBuilder.part("name 1", "value 1");
bodyBuilder.part("name 2", "value 2+1"); bodyBuilder.part("name 2", "value 2+1");
bodyBuilder.part("name 2", "value 2+2"); bodyBuilder.part("name 2", "value 2+2");
bodyBuilder.part("logo", logo); bodyBuilder.part("logo", logo);
bodyBuilder.part("utf8", utf8); bodyBuilder.part("utf8", utf8);
skipping to change at line 161 skipping to change at line 161
assertThat(part.headers().getContentLength()).isEqualTo(logo.getF ile().length()); assertThat(part.headers().getContentLength()).isEqualTo(logo.getF ile().length());
part = requestParts.getFirst("utf8"); part = requestParts.getFirst("utf8");
assertThat(part instanceof FilePart).isTrue(); assertThat(part instanceof FilePart).isTrue();
assertThat(part.name()).isEqualTo("utf8"); assertThat(part.name()).isEqualTo("utf8");
assertThat(((FilePart) part).filename()).isEqualTo("Hall\u00F6le. jpg"); assertThat(((FilePart) part).filename()).isEqualTo("Hall\u00F6le. jpg");
assertThat(part.headers().getContentType()).isEqualTo(MediaType.I MAGE_JPEG); assertThat(part.headers().getContentType()).isEqualTo(MediaType.I MAGE_JPEG);
assertThat(part.headers().getContentLength()).isEqualTo(utf8.getF ile().length()); assertThat(part.headers().getContentLength()).isEqualTo(utf8.getF ile().length());
part = requestParts.getFirst("json"); part = requestParts.getFirst("json");
assertThat(part).isNotNull();
assertThat(part.name()).isEqualTo("json"); assertThat(part.name()).isEqualTo("json");
assertThat(part.headers().getContentType()).isEqualTo(MediaType.A PPLICATION_JSON); assertThat(part.headers().getContentType()).isEqualTo(MediaType.A PPLICATION_JSON);
String value = decodeToString(part); String value = decodeToString(part);
assertThat(value).isEqualTo("{\"bar\":\"bar\"}"); assertThat(value).isEqualTo("{\"bar\":\"bar\"}");
part = requestParts.getFirst("publisher"); part = requestParts.getFirst("publisher");
assertThat(part).isNotNull();
assertThat(part.name()).isEqualTo("publisher"); assertThat(part.name()).isEqualTo("publisher");
value = decodeToString(part); value = decodeToString(part);
assertThat(value).isEqualTo("foobarbaz"); assertThat(value).isEqualTo("foobarbaz");
part = requestParts.getFirst("filePublisher"); part = requestParts.getFirst("filePublisher");
assertThat(part).isNotNull();
assertThat(part.name()).isEqualTo("filePublisher"); assertThat(part.name()).isEqualTo("filePublisher");
assertThat(part.headers()).containsEntry("foo", Collections.singl etonList("bar")); assertThat(part.headers()).containsEntry("foo", Collections.singl etonList("bar"));
assertThat(((FilePart) part).filename()).isEqualTo("file.txt"); assertThat(((FilePart) part).filename()).isEqualTo("file.txt");
value = decodeToString(part); value = decodeToString(part);
assertThat(value).isEqualTo("AaBbCc"); assertThat(value).isEqualTo("AaBbCc");
} }
@Test // gh-24582 @Test // gh-24582
public void writeMultipartRelated() { public void writeMultipartRelated() {
 End of changes. 5 change blocks. 
2 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)