Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into spring-projectsGH…
Browse files Browse the repository at this point in the history
  • Loading branch information
midumitrescu committed May 28, 2020
2 parents 9ce1fb6 + 7e2b817 commit a4b6280
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 25 deletions.
Expand Up @@ -34,7 +34,7 @@
import static java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME;

/**
* Represent the Content-Disposition type and parameters as defined in RFC 6266.
* Representation of the Content-Disposition type and parameters as defined in RFC 6266.
*
* @author Sebastien Deleuze
* @author Juergen Hoeller
Expand Down Expand Up @@ -520,7 +520,7 @@ public interface Builder {
/**
* Set the value of the {@literal size} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Apendix B</a>,
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Expand All @@ -529,7 +529,7 @@ public interface Builder {
/**
* Set the value of the {@literal creation-date} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Apendix B</a>,
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Expand All @@ -538,7 +538,7 @@ public interface Builder {
/**
* Set the value of the {@literal modification-date} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Apendix B</a>,
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Expand All @@ -547,7 +547,7 @@ public interface Builder {
/**
* Set the value of the {@literal read-date} parameter.
* @deprecated since 5.2.3 as per
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Apendix B</a>,
* <a href="https://tools.ietf.org/html/rfc6266#appendix-B">RFC 6266, Appendix B</a>,
* to be removed in a future release.
*/
@Deprecated
Expand Down Expand Up @@ -612,24 +612,28 @@ public Builder filename(String filename, Charset charset) {
}

@Override
@SuppressWarnings("deprecation")
public Builder size(Long size) {
this.size = size;
return this;
}

@Override
@SuppressWarnings("deprecation")
public Builder creationDate(ZonedDateTime creationDate) {
this.creationDate = creationDate;
return this;
}

@Override
@SuppressWarnings("deprecation")
public Builder modificationDate(ZonedDateTime modificationDate) {
this.modificationDate = modificationDate;
return this;
}

@Override
@SuppressWarnings("deprecation")
public Builder readDate(ZonedDateTime readDate) {
this.readDate = readDate;
return this;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
Expand Down Expand Up @@ -142,10 +142,10 @@ protected static final class DefaultCustomCodecs implements CustomCodecs {
* @since 5.1.12
*/
DefaultCustomCodecs(DefaultCustomCodecs other) {
other.typedReaders.putAll(this.typedReaders);
other.typedWriters.putAll(this.typedWriters);
other.objectReaders.putAll(this.objectReaders);
other.objectWriters.putAll(this.objectWriters);
this.typedReaders.putAll(other.typedReaders);
this.typedWriters.putAll(other.typedWriters);
this.objectReaders.putAll(other.objectReaders);
this.objectWriters.putAll(other.objectWriters);
}

@Override
Expand Down
Expand Up @@ -69,15 +69,15 @@
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
*/
public class CodecConfigurerTests {
class CodecConfigurerTests {

private final CodecConfigurer configurer = new TestCodecConfigurer();

private final AtomicInteger index = new AtomicInteger(0);


@Test
public void defaultReaders() {
void defaultReaders() {
List<HttpMessageReader<?>> readers = this.configurer.getReaders();
assertThat(readers.size()).isEqualTo(12);
assertThat(getNextDecoder(readers).getClass()).isEqualTo(ByteArrayDecoder.class);
Expand All @@ -95,7 +95,7 @@ public void defaultReaders() {
}

@Test
public void defaultWriters() {
void defaultWriters() {
List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
assertThat(writers.size()).isEqualTo(11);
assertThat(getNextEncoder(writers).getClass()).isEqualTo(ByteArrayEncoder.class);
Expand All @@ -112,7 +112,7 @@ public void defaultWriters() {
}

@Test
public void defaultAndCustomReaders() {
void defaultAndCustomReaders() {
Decoder<?> customDecoder1 = mock(Decoder.class);
Decoder<?> customDecoder2 = mock(Decoder.class);

Expand Down Expand Up @@ -153,7 +153,7 @@ public void defaultAndCustomReaders() {
}

@Test
public void defaultAndCustomWriters() {
void defaultAndCustomWriters() {
Encoder<?> customEncoder1 = mock(Encoder.class);
Encoder<?> customEncoder2 = mock(Encoder.class);

Expand Down Expand Up @@ -193,7 +193,7 @@ public void defaultAndCustomWriters() {
}

@Test
public void defaultsOffCustomReaders() {
void defaultsOffCustomReaders() {
Decoder<?> customDecoder1 = mock(Decoder.class);
Decoder<?> customDecoder2 = mock(Decoder.class);

Expand Down Expand Up @@ -224,7 +224,7 @@ public void defaultsOffCustomReaders() {
}

@Test
public void defaultsOffWithCustomWriters() {
void defaultsOffWithCustomWriters() {
Encoder<?> customEncoder1 = mock(Encoder.class);
Encoder<?> customEncoder2 = mock(Encoder.class);

Expand Down Expand Up @@ -255,7 +255,7 @@ public void defaultsOffWithCustomWriters() {
}

@Test
public void encoderDecoderOverrides() {
void encoderDecoderOverrides() {
Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder();
Jackson2JsonEncoder jacksonEncoder = new Jackson2JsonEncoder();
Jackson2SmileDecoder smileDecoder = new Jackson2SmileDecoder();
Expand Down Expand Up @@ -285,23 +285,45 @@ public void encoderDecoderOverrides() {
}

@Test
public void cloneCustomCodecs() {
void cloneEmptyCustomCodecs() {
this.configurer.registerDefaults(false);
CodecConfigurer clone = this.configurer.clone();
assertThat(this.configurer.getReaders()).isEmpty();
assertThat(this.configurer.getWriters()).isEmpty();

CodecConfigurer clone = this.configurer.clone();
clone.customCodecs().register(new Jackson2JsonEncoder());
clone.customCodecs().register(new Jackson2JsonDecoder());
clone.customCodecs().register(new ServerSentEventHttpMessageReader());
clone.customCodecs().register(new ServerSentEventHttpMessageWriter());

assertThat(this.configurer.getReaders().size()).isEqualTo(0);
assertThat(this.configurer.getWriters().size()).isEqualTo(0);
assertThat(clone.getReaders().size()).isEqualTo(2);
assertThat(clone.getWriters().size()).isEqualTo(2);
assertThat(this.configurer.getReaders()).isEmpty();
assertThat(this.configurer.getWriters()).isEmpty();
assertThat(clone.getReaders()).hasSize(2);
assertThat(clone.getWriters()).hasSize(2);
}

@Test
void cloneCustomCodecs() {
this.configurer.registerDefaults(false);
assertThat(this.configurer.getReaders()).isEmpty();
assertThat(this.configurer.getWriters()).isEmpty();

this.configurer.customCodecs().register(new Jackson2JsonEncoder());
this.configurer.customCodecs().register(new Jackson2JsonDecoder());
this.configurer.customCodecs().register(new ServerSentEventHttpMessageReader());
this.configurer.customCodecs().register(new ServerSentEventHttpMessageWriter());
assertThat(this.configurer.getReaders()).hasSize(2);
assertThat(this.configurer.getWriters()).hasSize(2);

CodecConfigurer clone = this.configurer.clone();
assertThat(this.configurer.getReaders()).hasSize(2);
assertThat(this.configurer.getWriters()).hasSize(2);
assertThat(clone.getReaders()).hasSize(2);
assertThat(clone.getWriters()).hasSize(2);
}

@Test
public void cloneDefaultCodecs() {
void cloneDefaultCodecs() {
CodecConfigurer clone = this.configurer.clone();

Jackson2JsonDecoder jacksonDecoder = new Jackson2JsonDecoder();
Expand Down

0 comments on commit a4b6280

Please sign in to comment.