MimeTypeUtils constants cleanup: deprecated web media types

Issue: SPR-15137
This commit is contained in:
Juergen Hoeller 2017-01-12 23:43:00 +01:00
parent 0b8134049c
commit 1521094c5b
2 changed files with 25 additions and 17 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -37,6 +37,7 @@ import org.springframework.util.MimeType.SpecificityComparator;
* @author Rossen Stoyanchev
* @since 4.0
*/
@SuppressWarnings("deprecation")
public abstract class MimeTypeUtils {
private static final byte[] BOUNDARY_CHARS =
@ -65,23 +66,31 @@ public abstract class MimeTypeUtils {
public static final String ALL_VALUE = "*/*";
/**
* Public constant mime type for {@code application/atom+xml}.
* Public constant mime type for {@code application/atom+xml}.
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
*/
@Deprecated
public final static MimeType APPLICATION_ATOM_XML;
/**
* A String equivalent of {@link MimeTypeUtils#APPLICATION_ATOM_XML}.
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
*/
@Deprecated
public final static String APPLICATION_ATOM_XML_VALUE = "application/atom+xml";
/**
* Public constant mime type for {@code application/x-www-form-urlencoded}.
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
* */
@Deprecated
public final static MimeType APPLICATION_FORM_URLENCODED;
/**
* A String equivalent of {@link MimeTypeUtils#APPLICATION_FORM_URLENCODED}.
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
*/
@Deprecated
public final static String APPLICATION_FORM_URLENCODED_VALUE = "application/x-www-form-urlencoded";
/**
@ -106,12 +115,16 @@ public abstract class MimeTypeUtils {
/**
* Public constant mime type for {@code application/xhtml+xml}.
* */
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
*/
@Deprecated
public final static MimeType APPLICATION_XHTML_XML;
/**
* A String equivalent of {@link MimeTypeUtils#APPLICATION_XHTML_XML}.
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
*/
@Deprecated
public final static String APPLICATION_XHTML_XML_VALUE = "application/xhtml+xml";
/**
@ -156,12 +169,16 @@ public abstract class MimeTypeUtils {
/**
* Public constant mime type for {@code multipart/form-data}.
* */
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
*/
@Deprecated
public final static MimeType MULTIPART_FORM_DATA;
/**
* A String equivalent of {@link MimeTypeUtils#MULTIPART_FORM_DATA}.
* @deprecated as of 4.3.6, in favor of {@code MediaType} constants
*/
@Deprecated
public final static String MULTIPART_FORM_DATA_VALUE = "multipart/form-data";
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 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.
@ -33,6 +33,7 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.messaging.support.MessageHeaderAccessor;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.util.MultiValueMap;
@ -48,9 +49,9 @@ public class StompHeaderAccessorTests {
private static final Charset UTF_8 = Charset.forName("UTF-8");
@Test
public void createWithCommand() {
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.CONNECTED);
assertEquals(StompCommand.CONNECTED, accessor.getCommand());
@ -60,7 +61,6 @@ public class StompHeaderAccessorTests {
@Test
public void createWithSubscribeNativeHeaders() {
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
extHeaders.add(StompHeaderAccessor.STOMP_DESTINATION_HEADER, "/d");
@ -75,7 +75,6 @@ public class StompHeaderAccessorTests {
@Test
public void createWithUnubscribeNativeHeaders() {
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
@ -88,7 +87,6 @@ public class StompHeaderAccessorTests {
@Test
public void createWithMessageFrameNativeHeaders() {
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
extHeaders.add(StompHeaderAccessor.DESTINATION_HEADER, "/d");
extHeaders.add(StompHeaderAccessor.STOMP_SUBSCRIPTION_HEADER, "s1");
@ -103,7 +101,6 @@ public class StompHeaderAccessorTests {
@Test
public void createWithConnectNativeHeaders() {
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
extHeaders.add(StompHeaderAccessor.STOMP_LOGIN_HEADER, "joe");
extHeaders.add(StompHeaderAccessor.STOMP_PASSCODE_HEADER, "joe123");
@ -124,7 +121,6 @@ public class StompHeaderAccessorTests {
@Test
public void toNativeHeadersSubscribe() {
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
headers.setSubscriptionId("s1");
headers.setDestination("/d");
@ -138,7 +134,6 @@ public class StompHeaderAccessorTests {
@Test
public void toNativeHeadersUnsubscribe() {
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.UNSUBSCRIBE);
headers.setSubscriptionId("s1");
@ -150,7 +145,6 @@ public class StompHeaderAccessorTests {
@Test
public void toNativeHeadersMessageFrame() {
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
headers.setSubscriptionId("s1");
headers.setDestination("/d");
@ -168,9 +162,8 @@ public class StompHeaderAccessorTests {
@Test
public void toNativeHeadersContentType() {
SimpMessageHeaderAccessor simpHeaderAccessor = SimpMessageHeaderAccessor.create();
simpHeaderAccessor.setContentType(MimeTypeUtils.APPLICATION_ATOM_XML);
simpHeaderAccessor.setContentType(MimeType.valueOf("application/atom+xml"));
Message<byte[]> message = MessageBuilder.createMessage(new byte[0], simpHeaderAccessor.getMessageHeaders());
StompHeaderAccessor stompHeaderAccessor = StompHeaderAccessor.wrap(message);
@ -181,7 +174,6 @@ public class StompHeaderAccessorTests {
@Test
public void encodeConnectWithLoginAndPasscode() throws UnsupportedEncodingException {
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
extHeaders.add(StompHeaderAccessor.STOMP_LOGIN_HEADER, "joe");
extHeaders.add(StompHeaderAccessor.STOMP_PASSCODE_HEADER, "joe123");
@ -195,7 +187,6 @@ public class StompHeaderAccessorTests {
@Test
public void modifyCustomNativeHeader() {
MultiValueMap<String, String> extHeaders = new LinkedMultiValueMap<>();
extHeaders.add(StompHeaderAccessor.STOMP_ID_HEADER, "s1");
extHeaders.add(StompHeaderAccessor.STOMP_DESTINATION_HEADER, "/d");