Skip to content

Commit 1521094

Browse files
committed
MimeTypeUtils constants cleanup: deprecated web media types
Issue: SPR-15137
1 parent 0b81340 commit 1521094

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@
3737
* @author Rossen Stoyanchev
3838
* @since 4.0
3939
*/
40+
@SuppressWarnings("deprecation")
4041
public abstract class MimeTypeUtils {
4142

4243
private static final byte[] BOUNDARY_CHARS =
@@ -65,23 +66,31 @@ public abstract class MimeTypeUtils {
6566
public static final String ALL_VALUE = "*/*";
6667

6768
/**
68-
* Public constant mime type for {@code application/atom+xml}.
69+
* Public constant mime type for {@code application/atom+xml}.
70+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
6971
*/
72+
@Deprecated
7073
public final static MimeType APPLICATION_ATOM_XML;
7174

7275
/**
7376
* A String equivalent of {@link MimeTypeUtils#APPLICATION_ATOM_XML}.
77+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
7478
*/
79+
@Deprecated
7580
public final static String APPLICATION_ATOM_XML_VALUE = "application/atom+xml";
7681

7782
/**
7883
* Public constant mime type for {@code application/x-www-form-urlencoded}.
84+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
7985
* */
86+
@Deprecated
8087
public final static MimeType APPLICATION_FORM_URLENCODED;
8188

8289
/**
8390
* A String equivalent of {@link MimeTypeUtils#APPLICATION_FORM_URLENCODED}.
91+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
8492
*/
93+
@Deprecated
8594
public final static String APPLICATION_FORM_URLENCODED_VALUE = "application/x-www-form-urlencoded";
8695

8796
/**
@@ -106,12 +115,16 @@ public abstract class MimeTypeUtils {
106115

107116
/**
108117
* Public constant mime type for {@code application/xhtml+xml}.
109-
* */
118+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
119+
*/
120+
@Deprecated
110121
public final static MimeType APPLICATION_XHTML_XML;
111122

112123
/**
113124
* A String equivalent of {@link MimeTypeUtils#APPLICATION_XHTML_XML}.
125+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
114126
*/
127+
@Deprecated
115128
public final static String APPLICATION_XHTML_XML_VALUE = "application/xhtml+xml";
116129

117130
/**
@@ -156,12 +169,16 @@ public abstract class MimeTypeUtils {
156169

157170
/**
158171
* Public constant mime type for {@code multipart/form-data}.
159-
* */
172+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
173+
*/
174+
@Deprecated
160175
public final static MimeType MULTIPART_FORM_DATA;
161176

162177
/**
163178
* A String equivalent of {@link MimeTypeUtils#MULTIPART_FORM_DATA}.
179+
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
164180
*/
181+
@Deprecated
165182
public final static String MULTIPART_FORM_DATA_VALUE = "multipart/form-data";
166183

167184
/**

spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
import org.springframework.messaging.support.MessageHeaderAccessor;
3434
import org.springframework.util.AlternativeJdkIdGenerator;
3535
import org.springframework.util.LinkedMultiValueMap;
36+
import org.springframework.util.MimeType;
3637
import org.springframework.util.MimeTypeUtils;
3738
import org.springframework.util.MultiValueMap;
3839

@@ -48,9 +49,9 @@ public class StompHeaderAccessorTests {
4849

4950
private static final Charset UTF_8 = Charset.forName("UTF-8");
5051

52+
5153
@Test
5254
public void createWithCommand() {
53-
5455
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.CONNECTED);
5556
assertEquals(StompCommand.CONNECTED, accessor.getCommand());
5657

@@ -60,7 +61,6 @@ public void createWithCommand() {
6061

6162
@Test
6263
public void createWithSubscribeNativeHeaders() {
63-
6464
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
6565
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
6666
extHeaders.add(StompHeaderAccessor.STOMP_DESTINATION_HEADER, "/d");
@@ -75,7 +75,6 @@ public void createWithSubscribeNativeHeaders() {
7575

7676
@Test
7777
public void createWithUnubscribeNativeHeaders() {
78-
7978
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
8079
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
8180

@@ -88,7 +87,6 @@ public void createWithUnubscribeNativeHeaders() {
8887

8988
@Test
9089
public void createWithMessageFrameNativeHeaders() {
91-
9290
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
9391
extHeaders.add(StompHeaderAccessor.DESTINATION_HEADER, "/d");
9492
extHeaders.add(StompHeaderAccessor.STOMP_SUBSCRIPTION_HEADER, "s1");
@@ -103,7 +101,6 @@ public void createWithMessageFrameNativeHeaders() {
103101

104102
@Test
105103
public void createWithConnectNativeHeaders() {
106-
107104
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
108105
extHeaders.add(StompHeaderAccessor.STOMP_LOGIN_HEADER, "joe");
109106
extHeaders.add(StompHeaderAccessor.STOMP_PASSCODE_HEADER, "joe123");
@@ -124,7 +121,6 @@ public void createWithConnectNativeHeaders() {
124121

125122
@Test
126123
public void toNativeHeadersSubscribe() {
127-
128124
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
129125
headers.setSubscriptionId("s1");
130126
headers.setDestination("/d");
@@ -138,7 +134,6 @@ public void toNativeHeadersSubscribe() {
138134

139135
@Test
140136
public void toNativeHeadersUnsubscribe() {
141-
142137
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.UNSUBSCRIBE);
143138
headers.setSubscriptionId("s1");
144139

@@ -150,7 +145,6 @@ public void toNativeHeadersUnsubscribe() {
150145

151146
@Test
152147
public void toNativeHeadersMessageFrame() {
153-
154148
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
155149
headers.setSubscriptionId("s1");
156150
headers.setDestination("/d");
@@ -168,9 +162,8 @@ public void toNativeHeadersMessageFrame() {
168162

169163
@Test
170164
public void toNativeHeadersContentType() {
171-
172165
SimpMessageHeaderAccessor simpHeaderAccessor = SimpMessageHeaderAccessor.create();
173-
simpHeaderAccessor.setContentType(MimeTypeUtils.APPLICATION_ATOM_XML);
166+
simpHeaderAccessor.setContentType(MimeType.valueOf("application/atom+xml"));
174167
Message<byte[]> message = MessageBuilder.createMessage(new byte[0], simpHeaderAccessor.getMessageHeaders());
175168

176169
StompHeaderAccessor stompHeaderAccessor = StompHeaderAccessor.wrap(message);
@@ -181,7 +174,6 @@ public void toNativeHeadersContentType() {
181174

182175
@Test
183176
public void encodeConnectWithLoginAndPasscode() throws UnsupportedEncodingException {
184-
185177
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
186178
extHeaders.add(StompHeaderAccessor.STOMP_LOGIN_HEADER, "joe");
187179
extHeaders.add(StompHeaderAccessor.STOMP_PASSCODE_HEADER, "joe123");
@@ -195,7 +187,6 @@ public void encodeConnectWithLoginAndPasscode() throws UnsupportedEncodingExcept
195187

196188
@Test
197189
public void modifyCustomNativeHeader() {
198-
199190
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
200191
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
201192
extHeaders.add(StompHeaderAccessor.STOMP_DESTINATION_HEADER, "/d");

0 commit comments

Comments
 (0)