1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
37
37
38
38
import static java .nio .charset .StandardCharsets .UTF_8 ;
39
39
import static org .assertj .core .api .Assertions .assertThat ;
40
+ import static org .springframework .core .ResolvableType .forClass ;
40
41
import static org .springframework .core .io .buffer .DataBufferUtils .release ;
41
42
42
43
/**
@@ -52,19 +53,13 @@ public Jaxb2XmlEncoderTests() {
52
53
@ Override
53
54
@ Test
54
55
public void canEncode () {
55
- assertThat (this .encoder .canEncode (ResolvableType .forClass (Pojo .class ),
56
- MediaType .APPLICATION_XML )).isTrue ();
57
- assertThat (this .encoder .canEncode (ResolvableType .forClass (Pojo .class ),
58
- MediaType .TEXT_XML )).isTrue ();
59
- assertThat (this .encoder .canEncode (ResolvableType .forClass (Pojo .class ),
60
- MediaType .APPLICATION_JSON )).isFalse ();
61
-
62
- assertThat (this .encoder .canEncode (
63
- ResolvableType .forClass (Jaxb2XmlDecoderTests .TypePojo .class ),
64
- MediaType .APPLICATION_XML )).isTrue ();
65
-
66
- assertThat (this .encoder .canEncode (ResolvableType .forClass (getClass ()),
67
- MediaType .APPLICATION_XML )).isFalse ();
56
+ assertThat (this .encoder .canEncode (forClass (Pojo .class ), MediaType .APPLICATION_XML )).isTrue ();
57
+ assertThat (this .encoder .canEncode (forClass (Pojo .class ), MediaType .TEXT_XML )).isTrue ();
58
+ assertThat (this .encoder .canEncode (forClass (Pojo .class ), new MediaType ("application" , "foo+xml" ))).isTrue ();
59
+ assertThat (this .encoder .canEncode (forClass (Pojo .class ), MediaType .APPLICATION_JSON )).isFalse ();
60
+
61
+ assertThat (this .encoder .canEncode (forClass (Jaxb2XmlDecoderTests .TypePojo .class ), MediaType .APPLICATION_XML )).isTrue ();
62
+ assertThat (this .encoder .canEncode (forClass (getClass ()), MediaType .APPLICATION_XML )).isFalse ();
68
63
69
64
// SPR-15464
70
65
assertThat (this .encoder .canEncode (ResolvableType .NONE , null )).isFalse ();
0 commit comments