Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
4a397f10
S
spring-framework
项目概览
sesemomo
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4a397f10
编写于
3月 19, 2019
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ResourceDecoder supports filename hint
Closes gh-22267
上级
5a3ff352
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
109 addition
and
32 deletion
+109
-32
spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java
.../java/org/springframework/core/codec/ResourceDecoder.java
+18
-3
spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java
.../org/springframework/core/codec/ResourceDecoderTests.java
+20
-14
spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageReader.java
...springframework/http/codec/ResourceHttpMessageReader.java
+56
-0
spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java
...springframework/http/codec/support/BaseDefaultCodecs.java
+3
-3
spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java
...mework/http/codec/support/ClientCodecConfigurerTests.java
+4
-4
spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java
...ingframework/http/codec/support/CodecConfigurerTests.java
+4
-4
spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java
...mework/http/codec/support/ServerCodecConfigurerTests.java
+4
-4
未找到文件。
spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java
浏览文件 @
4a397f10
/*
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
@@ -41,6 +41,10 @@ import org.springframework.util.MimeTypeUtils;
...
@@ -41,6 +41,10 @@ import org.springframework.util.MimeTypeUtils;
*/
*/
public
class
ResourceDecoder
extends
AbstractDataBufferDecoder
<
Resource
>
{
public
class
ResourceDecoder
extends
AbstractDataBufferDecoder
<
Resource
>
{
/** Name of hint with a filename for the resource(e.g. from "Content-Disposition" HTTP header). */
public
static
String
FILENAME_HINT
=
ResourceDecoder
.
class
.
getName
()
+
".filename"
;
public
ResourceDecoder
()
{
public
ResourceDecoder
()
{
super
(
MimeTypeUtils
.
ALL
);
super
(
MimeTypeUtils
.
ALL
);
}
}
...
@@ -72,11 +76,22 @@ public class ResourceDecoder extends AbstractDataBufferDecoder<Resource> {
...
@@ -72,11 +76,22 @@ public class ResourceDecoder extends AbstractDataBufferDecoder<Resource> {
}
}
Class
<?>
clazz
=
elementType
.
toClass
();
Class
<?>
clazz
=
elementType
.
toClass
();
String
filename
=
hints
!=
null
?
(
String
)
hints
.
get
(
FILENAME_HINT
)
:
null
;
if
(
clazz
==
InputStreamResource
.
class
)
{
if
(
clazz
==
InputStreamResource
.
class
)
{
return
new
InputStreamResource
(
new
ByteArrayInputStream
(
bytes
));
return
new
InputStreamResource
(
new
ByteArrayInputStream
(
bytes
))
{
@Override
public
String
getFilename
()
{
return
filename
;
}
};
}
}
else
if
(
Resource
.
class
.
isAssignableFrom
(
clazz
))
{
else
if
(
Resource
.
class
.
isAssignableFrom
(
clazz
))
{
return
new
ByteArrayResource
(
bytes
);
return
new
ByteArrayResource
(
bytes
)
{
@Override
public
String
getFilename
()
{
return
filename
;
}
};
}
}
else
{
else
{
throw
new
IllegalStateException
(
"Unsupported resource class: "
+
clazz
);
throw
new
IllegalStateException
(
"Unsupported resource class: "
+
clazz
);
...
...
spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java
浏览文件 @
4a397f10
/*
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
@@ -18,6 +18,7 @@ package org.springframework.core.codec;
...
@@ -18,6 +18,7 @@ package org.springframework.core.codec;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -100,23 +101,28 @@ public class ResourceDecoderTests extends AbstractDecoderTestCase<ResourceDecode
...
@@ -100,23 +101,28 @@ public class ResourceDecoderTests extends AbstractDecoderTestCase<ResourceDecode
}
}
@Override
@Override
public
void
decodeToMono
()
throws
Exception
{
public
void
decodeToMono
()
{
Flux
<
DataBuffer
>
input
=
Flux
.
concat
(
Flux
<
DataBuffer
>
input
=
Flux
.
concat
(
dataBuffer
(
this
.
fooBytes
),
dataBuffer
(
this
.
fooBytes
),
dataBuffer
(
this
.
barBytes
));
dataBuffer
(
this
.
barBytes
));
testDecodeToMonoAll
(
input
,
Resource
.
class
,
step
->
step
testDecodeToMonoAll
(
input
,
ResolvableType
.
forClass
(
Resource
.
class
),
.
consumeNextWith
(
resource
->
{
step
->
step
try
{
.
consumeNextWith
(
value
->
{
byte
[]
bytes
=
StreamUtils
.
copyToByteArray
(
resource
.
getInputStream
());
Resource
resource
=
(
Resource
)
value
;
assertEquals
(
"foobar"
,
new
String
(
bytes
));
try
{
}
byte
[]
bytes
=
StreamUtils
.
copyToByteArray
(
resource
.
getInputStream
());
catch
(
IOException
e
)
{
assertEquals
(
"foobar"
,
new
String
(
bytes
));
fail
(
e
.
getMessage
());
assertEquals
(
"testFile"
,
resource
.
getFilename
());
}
}
})
catch
(
IOException
e
)
{
.
expectComplete
()
fail
(
e
.
getMessage
());
.
verify
());
}
})
.
expectComplete
()
.
verify
(),
null
,
Collections
.
singletonMap
(
ResourceDecoder
.
FILENAME_HINT
,
"testFile"
));
}
}
}
}
spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageReader.java
0 → 100644
浏览文件 @
4a397f10
/*
* Copyright 2002-2019 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.http.codec
;
import
java.util.Map
;
import
org.springframework.core.ResolvableType
;
import
org.springframework.core.codec.Hints
;
import
org.springframework.core.codec.ResourceDecoder
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.util.StringUtils
;
/**
* Simple around around {@link ResourceDecoder} that extracts the filename from
* the "Content-Disposition" header, if available, and passes it as the hint
* {@link ResourceDecoder#FILENAME_HINT}.
*
* @author Rossen Stoyanchev
* @since 5.2
*/
public
class
ResourceHttpMessageReader
extends
DecoderHttpMessageReader
<
Resource
>
{
public
ResourceHttpMessageReader
()
{
super
(
new
ResourceDecoder
());
}
public
ResourceHttpMessageReader
(
ResourceDecoder
resourceDecoder
)
{
super
(
resourceDecoder
);
}
@Override
protected
Map
<
String
,
Object
>
getReadHints
(
ResolvableType
actualType
,
ResolvableType
elementType
,
ServerHttpRequest
request
,
ServerHttpResponse
response
)
{
String
name
=
request
.
getHeaders
().
getContentDisposition
().
getFilename
();
return
StringUtils
.
hasText
(
name
)
?
Hints
.
from
(
ResourceDecoder
.
FILENAME_HINT
,
name
)
:
Hints
.
none
();
}
}
spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java
浏览文件 @
4a397f10
/*
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
@@ -29,7 +29,6 @@ import org.springframework.core.codec.DataBufferDecoder;
...
@@ -29,7 +29,6 @@ import org.springframework.core.codec.DataBufferDecoder;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.ResourceDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.http.codec.CodecConfigurer
;
import
org.springframework.http.codec.CodecConfigurer
;
import
org.springframework.http.codec.DecoderHttpMessageReader
;
import
org.springframework.http.codec.DecoderHttpMessageReader
;
...
@@ -37,6 +36,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
...
@@ -37,6 +36,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageReader
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.json.Jackson2JsonDecoder
;
import
org.springframework.http.codec.json.Jackson2JsonDecoder
;
import
org.springframework.http.codec.json.Jackson2JsonEncoder
;
import
org.springframework.http.codec.json.Jackson2JsonEncoder
;
...
@@ -158,7 +158,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs {
...
@@ -158,7 +158,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs {
readers
.
add
(
new
DecoderHttpMessageReader
<>(
new
ByteArrayDecoder
()));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
new
ByteArrayDecoder
()));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
new
ByteBufferDecoder
()));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
new
ByteBufferDecoder
()));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
new
DataBufferDecoder
()));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
new
DataBufferDecoder
()));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
new
ResourceDecoder
()
));
readers
.
add
(
new
ResourceHttpMessageReader
(
));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
textPlainOnly
()));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
textPlainOnly
()));
if
(
protobufPresent
)
{
if
(
protobufPresent
)
{
Decoder
<?>
decoder
=
this
.
protobufDecoder
!=
null
?
this
.
protobufDecoder
:
new
ProtobufDecoder
();
Decoder
<?>
decoder
=
this
.
protobufDecoder
!=
null
?
this
.
protobufDecoder
:
new
ProtobufDecoder
();
...
...
spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java
浏览文件 @
4a397f10
/*
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
@@ -36,7 +36,6 @@ import org.springframework.core.codec.DataBufferDecoder;
...
@@ -36,7 +36,6 @@ import org.springframework.core.codec.DataBufferDecoder;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.ResourceDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
...
@@ -46,6 +45,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
...
@@ -46,6 +45,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageReader
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.ServerSentEventHttpMessageReader
;
import
org.springframework.http.codec.ServerSentEventHttpMessageReader
;
import
org.springframework.http.codec.json.Jackson2JsonDecoder
;
import
org.springframework.http.codec.json.Jackson2JsonDecoder
;
...
@@ -60,7 +60,7 @@ import org.springframework.http.codec.xml.Jaxb2XmlEncoder;
...
@@ -60,7 +60,7 @@ import org.springframework.http.codec.xml.Jaxb2XmlEncoder;
import
org.springframework.util.MimeTypeUtils
;
import
org.springframework.util.MimeTypeUtils
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
core
.
ResolvableType
.
forClass
;
import
static
org
.
springframework
.
core
.
ResolvableType
.
*
;
/**
/**
* Unit tests for {@link ClientCodecConfigurer}.
* Unit tests for {@link ClientCodecConfigurer}.
...
@@ -81,7 +81,7 @@ public class ClientCodecConfigurerTests {
...
@@ -81,7 +81,7 @@ public class ClientCodecConfigurerTests {
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
Decoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
HttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()
).
getClass
());
assertStringDecoder
(
getNextDecoder
(
readers
),
true
);
assertStringDecoder
(
getNextDecoder
(
readers
),
true
);
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
// SPR-16804
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
// SPR-16804
...
...
spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java
浏览文件 @
4a397f10
/*
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
@@ -32,7 +32,6 @@ import org.springframework.core.codec.DataBufferDecoder;
...
@@ -32,7 +32,6 @@ import org.springframework.core.codec.DataBufferDecoder;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.ResourceDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.codec.CodecConfigurer
;
import
org.springframework.http.codec.CodecConfigurer
;
...
@@ -41,6 +40,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
...
@@ -41,6 +40,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageReader
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.json.Jackson2JsonDecoder
;
import
org.springframework.http.codec.json.Jackson2JsonDecoder
;
import
org.springframework.http.codec.json.Jackson2JsonEncoder
;
import
org.springframework.http.codec.json.Jackson2JsonEncoder
;
...
@@ -76,7 +76,7 @@ public class CodecConfigurerTests {
...
@@ -76,7 +76,7 @@ public class CodecConfigurerTests {
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
Decoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
HttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()
).
getClass
());
assertStringDecoder
(
getNextDecoder
(
readers
),
true
);
assertStringDecoder
(
getNextDecoder
(
readers
),
true
);
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
...
@@ -128,7 +128,7 @@ public class CodecConfigurerTests {
...
@@ -128,7 +128,7 @@ public class CodecConfigurerTests {
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
Decoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
HttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()
).
getClass
());
assertEquals
(
StringDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
StringDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
...
...
spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java
浏览文件 @
4a397f10
/*
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
@@ -36,7 +36,6 @@ import org.springframework.core.codec.DataBufferDecoder;
...
@@ -36,7 +36,6 @@ import org.springframework.core.codec.DataBufferDecoder;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.DataBufferEncoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Decoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.Encoder
;
import
org.springframework.core.codec.ResourceDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.core.codec.StringDecoder
;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
...
@@ -45,6 +44,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
...
@@ -45,6 +44,7 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.FormHttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageReader
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.ResourceHttpMessageWriter
;
import
org.springframework.http.codec.ServerCodecConfigurer
;
import
org.springframework.http.codec.ServerCodecConfigurer
;
import
org.springframework.http.codec.ServerSentEventHttpMessageWriter
;
import
org.springframework.http.codec.ServerSentEventHttpMessageWriter
;
...
@@ -61,7 +61,7 @@ import org.springframework.http.codec.xml.Jaxb2XmlEncoder;
...
@@ -61,7 +61,7 @@ import org.springframework.http.codec.xml.Jaxb2XmlEncoder;
import
org.springframework.util.MimeTypeUtils
;
import
org.springframework.util.MimeTypeUtils
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
core
.
ResolvableType
.
forClass
;
import
static
org
.
springframework
.
core
.
ResolvableType
.
*
;
/**
/**
* Unit tests for {@link ServerCodecConfigurer}.
* Unit tests for {@link ServerCodecConfigurer}.
...
@@ -82,7 +82,7 @@ public class ServerCodecConfigurerTests {
...
@@ -82,7 +82,7 @@ public class ServerCodecConfigurerTests {
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteArrayDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ByteBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
DataBufferDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
Decoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
Resource
HttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()
).
getClass
());
assertStringDecoder
(
getNextDecoder
(
readers
),
true
);
assertStringDecoder
(
getNextDecoder
(
readers
),
true
);
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
ProtobufDecoder
.
class
,
getNextDecoder
(
readers
).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
assertEquals
(
FormHttpMessageReader
.
class
,
readers
.
get
(
this
.
index
.
getAndIncrement
()).
getClass
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录