Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
5303ab68
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5303ab68
编写于
3月 05, 2010
作者:
A
Arjen Poutsma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Atom Feed HttpMessageConverter
上级
c91ff130
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
520 addition
and
0 deletion
+520
-0
org.springframework.web/ivy.xml
org.springframework.web/ivy.xml
+5
-0
org.springframework.web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java
.../converter/feed/AbstractWireFeedHttpMessageConverter.java
+101
-0
org.springframework.web/src/main/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverter.java
...ork/http/converter/feed/AtomFeedHttpMessageConverter.java
+47
-0
org.springframework.web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java
...k/http/converter/feed/RssChannelHttpMessageConverter.java
+47
-0
org.springframework.web/src/main/java/org/springframework/http/converter/feed/package-info.java
...org/springframework/http/converter/feed/package-info.java
+23
-0
org.springframework.web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java
...ttp/converter/feed/AtomFeedHttpMessageConverterTests.java
+130
-0
org.springframework.web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java
...p/converter/feed/RssChannelHttpMessageConverterTests.java
+138
-0
org.springframework.web/src/test/resources/org/springframework/http/converter/feed/atom.xml
...esources/org/springframework/http/converter/feed/atom.xml
+14
-0
org.springframework.web/src/test/resources/org/springframework/http/converter/feed/rss.xml
...resources/org/springframework/http/converter/feed/rss.xml
+14
-0
org.springframework.web/template.mf
org.springframework.web/template.mf
+1
-0
未找到文件。
org.springframework.web/ivy.xml
浏览文件 @
5303ab68
...
...
@@ -17,6 +17,7 @@
<conf
name=
"commons-fileupload"
extends=
"runtime"
description=
"JARs needed to run with Commons Fileupload"
/>
<conf
name=
"el"
extends=
"runtime"
description=
"JARs needed to use EL"
/>
<conf
name=
"faces"
extends=
"runtime"
description=
"JARs neeeded to use JSF"
/>
<conf
name=
"feed"
extends=
"runtime"
description=
"JARs needed to create use Atom and RSS feeds"
/>
<conf
name=
"hessian"
extends=
"runtime"
description=
"JARs needed to use Hessian"
/>
<conf
name=
"httpclient"
extends=
"runtime"
description=
"JARs needed to use HTTPClient"
/>
<conf
name=
"jackson"
extends=
"runtime"
description=
"JARs needed to use the Jackson JSON converter"
/>
...
...
@@ -34,6 +35,8 @@
<dependencies>
<dependency
org=
"com.caucho"
name=
"com.springsource.com.caucho"
rev=
"3.2.1"
conf=
"optional, hessian, burlap->compile"
/>
<dependency
org=
"com.sun.syndication"
name=
"com.springsource.com.sun.syndication"
rev=
"1.0.0"
conf=
"optional, feed->compile"
/>
<dependency
org=
"javax.el"
name=
"com.springsource.javax.el"
rev=
"1.0.0"
conf=
"provided, el->compile"
/>
<dependency
org=
"javax.faces"
name=
"com.springsource.javax.faces"
rev=
"1.2.0.08"
conf=
"provided, faces->compile"
/>
...
...
@@ -59,6 +62,8 @@
conf=
"optional, log4j->compile"
/>
<dependency
org=
"org.codehaus.jackson"
name=
"com.springsource.org.codehaus.jackson.mapper"
rev=
"1.4.2"
conf=
"optional, jackson->compile"
/>
<dependency
org=
"org.jdom"
name=
"com.springsource.org.jdom"
rev=
"1.1.0"
conf=
"optional, feed->compile"
/>
<dependency
org=
"org.springframework"
name=
"org.springframework.aop"
rev=
"latest.integration"
conf=
"compile->compile"
/>
<dependency
org=
"org.springframework"
name=
"org.springframework.beans"
rev=
"latest.integration"
...
...
org.springframework.web/src/main/java/org/springframework/http/converter/feed/AbstractWireFeedHttpMessageConverter.java
0 → 100644
浏览文件 @
5303ab68
/*
* Copyright 2002-2010 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
*
* http://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.converter.feed
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.Reader
;
import
java.io.Writer
;
import
java.nio.charset.Charset
;
import
com.sun.syndication.feed.WireFeed
;
import
com.sun.syndication.io.FeedException
;
import
com.sun.syndication.io.WireFeedInput
;
import
com.sun.syndication.io.WireFeedOutput
;
import
org.springframework.http.HttpInputMessage
;
import
org.springframework.http.HttpOutputMessage
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.AbstractHttpMessageConverter
;
import
org.springframework.http.converter.HttpMessageNotReadableException
;
import
org.springframework.http.converter.HttpMessageNotWritableException
;
import
org.springframework.util.StringUtils
;
/**
* Abstract base class for Atom and RSS Feed message converters, using java.net's
* <a href="https://rome.dev.java.net/">ROME</a> package.
*
* @author Arjen Poutsma
* @since 3.0.2
* @see AtomFeedHttpMessageConverter
* @see RssChannelHttpMessageConverter
*/
public
abstract
class
AbstractWireFeedHttpMessageConverter
<
T
extends
WireFeed
>
extends
AbstractHttpMessageConverter
<
T
>
{
public
static
final
Charset
DEFAULT_CHARSET
=
Charset
.
forName
(
"UTF-8"
);
protected
AbstractWireFeedHttpMessageConverter
(
MediaType
supportedMediaType
)
{
super
(
supportedMediaType
);
}
@Override
@SuppressWarnings
(
"unchecked"
)
protected
T
readInternal
(
Class
<?
extends
T
>
clazz
,
HttpInputMessage
inputMessage
)
throws
IOException
,
HttpMessageNotReadableException
{
WireFeedInput
feedInput
=
new
WireFeedInput
();
MediaType
contentType
=
inputMessage
.
getHeaders
().
getContentType
();
Charset
charset
;
if
(
contentType
!=
null
&&
contentType
.
getCharSet
()
!=
null
)
{
charset
=
contentType
.
getCharSet
();
}
else
{
charset
=
DEFAULT_CHARSET
;
}
try
{
Reader
reader
=
new
InputStreamReader
(
inputMessage
.
getBody
(),
charset
);
return
(
T
)
feedInput
.
build
(
reader
);
}
catch
(
FeedException
ex
)
{
throw
new
HttpMessageNotReadableException
(
"Could not read WireFeed: "
+
ex
.
getMessage
(),
ex
);
}
}
@Override
protected
void
writeInternal
(
T
wireFeed
,
HttpOutputMessage
outputMessage
)
throws
IOException
,
HttpMessageNotWritableException
{
String
wireFeedEncoding
=
wireFeed
.
getEncoding
();
if
(!
StringUtils
.
hasLength
(
wireFeedEncoding
))
{
wireFeedEncoding
=
DEFAULT_CHARSET
.
name
();
}
MediaType
contentType
=
outputMessage
.
getHeaders
().
getContentType
();
if
(
contentType
!=
null
)
{
Charset
wireFeedCharset
=
Charset
.
forName
(
wireFeedEncoding
);
contentType
=
new
MediaType
(
contentType
.
getType
(),
contentType
.
getSubtype
(),
wireFeedCharset
);
outputMessage
.
getHeaders
().
setContentType
(
contentType
);
}
WireFeedOutput
feedOutput
=
new
WireFeedOutput
();
try
{
Writer
writer
=
new
OutputStreamWriter
(
outputMessage
.
getBody
(),
wireFeedEncoding
);
feedOutput
.
output
(
wireFeed
,
writer
);
}
catch
(
FeedException
ex
)
{
throw
new
HttpMessageNotWritableException
(
"Could not write WiredFeed: "
+
ex
.
getMessage
(),
ex
);
}
}
}
org.springframework.web/src/main/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverter.java
0 → 100644
浏览文件 @
5303ab68
/*
* Copyright 2002-2010 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
*
* http://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.converter.feed
;
import
com.sun.syndication.feed.atom.Feed
;
import
org.springframework.http.MediaType
;
/**
* Implementation of {@link org.springframework.http.converter.HttpMessageConverter} that can read and write Atom feeds.
* Specifically, this converter can handle {@link Feed} objects, from the <a href="https://rome.dev.java.net/">ROME</a>
* project.
*
* <p>By default, this converter reads and writes the media type ({@code application/atom+xml}). This can
* be overridden by setting the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes} property.
*
* @author Arjen Poutsma
* @see Feed
* @since 3.0.2
*/
public
class
AtomFeedHttpMessageConverter
extends
AbstractWireFeedHttpMessageConverter
<
Feed
>
{
public
AtomFeedHttpMessageConverter
()
{
super
(
new
MediaType
(
"application"
,
"atom+xml"
));
}
@Override
protected
boolean
supports
(
Class
<?>
clazz
)
{
return
Feed
.
class
.
isAssignableFrom
(
clazz
);
}
}
org.springframework.web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java
0 → 100644
浏览文件 @
5303ab68
/*
* Copyright 2002-2010 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
*
* http://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.converter.feed
;
import
com.sun.syndication.feed.rss.Channel
;
import
org.springframework.http.MediaType
;
/**
* Implementation of {@link org.springframework.http.converter.HttpMessageConverter} that can read and write RSS feeds.
* Specifically, this converter can handle {@link Channel} objects, from the <a href="https://rome.dev.java.net/">ROME</a>
* project.
*
* <p>By default, this converter reads and writes the media type ({@code application/rss+xml}). This can
* be overridden by setting the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes} property.
*
* @author Arjen Poutsma
* @see Channel
* @since 3.0.2
*/
public
class
RssChannelHttpMessageConverter
extends
AbstractWireFeedHttpMessageConverter
<
Channel
>
{
public
RssChannelHttpMessageConverter
()
{
super
(
new
MediaType
(
"application"
,
"rss+xml"
));
}
@Override
protected
boolean
supports
(
Class
<?>
clazz
)
{
return
Channel
.
class
.
isAssignableFrom
(
clazz
);
}
}
\ No newline at end of file
org.springframework.web/src/main/java/org/springframework/http/converter/feed/package-info.java
0 → 100644
浏览文件 @
5303ab68
/*
* Copyright 2002-2010 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
*
* http://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.
*/
/**
*
* Provides HttpMessageConverter implementations for handling Atom and RSS feeds.
*
*/
package
org.springframework.http.converter.feed
;
org.springframework.web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java
0 → 100644
浏览文件 @
5303ab68
/*
* Copyright 2002-2010 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
*
* http://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.converter.feed
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.sun.syndication.feed.atom.Entry
;
import
com.sun.syndication.feed.atom.Feed
;
import
static
org
.
custommonkey
.
xmlunit
.
XMLAssert
.*;
import
org.custommonkey.xmlunit.XMLUnit
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.xml.sax.SAXException
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MockHttpInputMessage
;
import
org.springframework.http.MockHttpOutputMessage
;
/** @author Arjen Poutsma */
public
class
AtomFeedHttpMessageConverterTests
{
private
AtomFeedHttpMessageConverter
converter
;
private
Charset
utf8
;
@Before
public
void
setUp
()
{
utf8
=
Charset
.
forName
(
"UTF-8"
);
converter
=
new
AtomFeedHttpMessageConverter
();
XMLUnit
.
setIgnoreWhitespace
(
true
);
}
@Test
public
void
canRead
()
{
assertTrue
(
converter
.
canRead
(
Feed
.
class
,
new
MediaType
(
"application"
,
"atom+xml"
)));
assertTrue
(
converter
.
canRead
(
Feed
.
class
,
new
MediaType
(
"application"
,
"atom+xml"
,
utf8
)));
}
@Test
public
void
canWrite
()
{
assertTrue
(
converter
.
canWrite
(
Feed
.
class
,
new
MediaType
(
"application"
,
"atom+xml"
)));
assertTrue
(
converter
.
canWrite
(
Feed
.
class
,
new
MediaType
(
"application"
,
"atom+xml"
,
Charset
.
forName
(
"UTF-8"
))));
}
@Test
public
void
read
()
throws
IOException
{
InputStream
is
=
getClass
().
getResourceAsStream
(
"atom.xml"
);
MockHttpInputMessage
inputMessage
=
new
MockHttpInputMessage
(
is
);
inputMessage
.
getHeaders
().
setContentType
(
new
MediaType
(
"application"
,
"atom+xml"
,
utf8
));
Feed
result
=
converter
.
read
(
Feed
.
class
,
inputMessage
);
assertEquals
(
"title"
,
result
.
getTitle
());
assertEquals
(
"subtitle"
,
result
.
getSubtitle
().
getValue
());
List
entries
=
result
.
getEntries
();
assertEquals
(
2
,
entries
.
size
());
Entry
entry1
=
(
Entry
)
entries
.
get
(
0
);
assertEquals
(
"id1"
,
entry1
.
getId
());
assertEquals
(
"title1"
,
entry1
.
getTitle
());
Entry
entry2
=
(
Entry
)
entries
.
get
(
1
);
assertEquals
(
"id2"
,
entry2
.
getId
());
assertEquals
(
"title2"
,
entry2
.
getTitle
());
}
@Test
public
void
write
()
throws
IOException
,
SAXException
{
Feed
feed
=
new
Feed
(
"atom_1.0"
);
feed
.
setTitle
(
"title"
);
Entry
entry1
=
new
Entry
();
entry1
.
setId
(
"id1"
);
entry1
.
setTitle
(
"title1"
);
Entry
entry2
=
new
Entry
();
entry2
.
setId
(
"id2"
);
entry2
.
setTitle
(
"title2"
);
List
entries
=
new
ArrayList
(
2
);
entries
.
add
(
entry1
);
entries
.
add
(
entry2
);
feed
.
setEntries
(
entries
);
MockHttpOutputMessage
outputMessage
=
new
MockHttpOutputMessage
();
converter
.
write
(
feed
,
null
,
outputMessage
);
assertEquals
(
"Invalid content-type"
,
new
MediaType
(
"application"
,
"atom+xml"
,
utf8
),
outputMessage
.
getHeaders
().
getContentType
());
String
expected
=
"<feed xmlns=\"http://www.w3.org/2005/Atom\">"
+
"<title>title</title>"
+
"<entry><id>id1</id><title>title1</title></entry>"
+
"<entry><id>id2</id><title>title2</title></entry></feed>"
;
assertXMLEqual
(
expected
,
outputMessage
.
getBodyAsString
(
utf8
));
}
@Test
public
void
writeOtherCharset
()
throws
IOException
,
SAXException
{
Feed
feed
=
new
Feed
(
"atom_1.0"
);
feed
.
setTitle
(
"title"
);
String
encoding
=
"ISO-8859-1"
;
feed
.
setEncoding
(
encoding
);
MockHttpOutputMessage
outputMessage
=
new
MockHttpOutputMessage
();
converter
.
write
(
feed
,
null
,
outputMessage
);
assertEquals
(
"Invalid content-type"
,
new
MediaType
(
"application"
,
"atom+xml"
,
Charset
.
forName
(
encoding
)),
outputMessage
.
getHeaders
().
getContentType
());
}
}
org.springframework.web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java
0 → 100644
浏览文件 @
5303ab68
/*
* Copyright 2002-2010 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
*
* http://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.converter.feed
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.sun.syndication.feed.rss.Channel
;
import
com.sun.syndication.feed.rss.Item
;
import
static
org
.
custommonkey
.
xmlunit
.
XMLAssert
.*;
import
org.custommonkey.xmlunit.XMLUnit
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.xml.sax.SAXException
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MockHttpInputMessage
;
import
org.springframework.http.MockHttpOutputMessage
;
/** @author Arjen Poutsma */
public
class
RssChannelHttpMessageConverterTests
{
private
RssChannelHttpMessageConverter
converter
;
private
Charset
utf8
;
@Before
public
void
setUp
()
{
utf8
=
Charset
.
forName
(
"UTF-8"
);
converter
=
new
RssChannelHttpMessageConverter
();
XMLUnit
.
setIgnoreWhitespace
(
true
);
}
@Test
public
void
canRead
()
{
assertTrue
(
converter
.
canRead
(
Channel
.
class
,
new
MediaType
(
"application"
,
"rss+xml"
)));
assertTrue
(
converter
.
canRead
(
Channel
.
class
,
new
MediaType
(
"application"
,
"rss+xml"
,
utf8
)));
}
@Test
public
void
canWrite
()
{
assertTrue
(
converter
.
canWrite
(
Channel
.
class
,
new
MediaType
(
"application"
,
"rss+xml"
)));
assertTrue
(
converter
.
canWrite
(
Channel
.
class
,
new
MediaType
(
"application"
,
"rss+xml"
,
Charset
.
forName
(
"UTF-8"
))));
}
@Test
public
void
read
()
throws
IOException
{
InputStream
is
=
getClass
().
getResourceAsStream
(
"rss.xml"
);
MockHttpInputMessage
inputMessage
=
new
MockHttpInputMessage
(
is
);
inputMessage
.
getHeaders
().
setContentType
(
new
MediaType
(
"application"
,
"rss+xml"
,
utf8
));
Channel
result
=
converter
.
read
(
Channel
.
class
,
inputMessage
);
assertEquals
(
"title"
,
result
.
getTitle
());
assertEquals
(
"http://example.com"
,
result
.
getLink
());
assertEquals
(
"description"
,
result
.
getDescription
());
List
items
=
result
.
getItems
();
assertEquals
(
2
,
items
.
size
());
Item
item1
=
(
Item
)
items
.
get
(
0
);
assertEquals
(
"title1"
,
item1
.
getTitle
());
Item
item2
=
(
Item
)
items
.
get
(
1
);
assertEquals
(
"title2"
,
item2
.
getTitle
());
}
@Test
public
void
write
()
throws
IOException
,
SAXException
{
Channel
channel
=
new
Channel
(
"rss_2.0"
);
channel
.
setTitle
(
"title"
);
channel
.
setLink
(
"http://example.com"
);
channel
.
setDescription
(
"description"
);
Item
item1
=
new
Item
();
item1
.
setTitle
(
"title1"
);
Item
item2
=
new
Item
();
item2
.
setTitle
(
"title2"
);
List
items
=
new
ArrayList
(
2
);
items
.
add
(
item1
);
items
.
add
(
item2
);
channel
.
setItems
(
items
);
MockHttpOutputMessage
outputMessage
=
new
MockHttpOutputMessage
();
converter
.
write
(
channel
,
null
,
outputMessage
);
assertEquals
(
"Invalid content-type"
,
new
MediaType
(
"application"
,
"rss+xml"
,
utf8
),
outputMessage
.
getHeaders
().
getContentType
());
String
expected
=
"<rss version=\"2.0\">"
+
"<channel><title>title</title><link>http://example.com</link><description>description</description>"
+
"<item><title>title1</title></item>"
+
"<item><title>title2</title></item>"
+
"</channel></rss>"
;
assertXMLEqual
(
expected
,
outputMessage
.
getBodyAsString
(
utf8
));
}
@Test
public
void
writeOtherCharset
()
throws
IOException
,
SAXException
{
Channel
channel
=
new
Channel
(
"rss_2.0"
);
channel
.
setTitle
(
"title"
);
channel
.
setLink
(
"http://example.com"
);
channel
.
setDescription
(
"description"
);
String
encoding
=
"ISO-8859-1"
;
channel
.
setEncoding
(
encoding
);
Item
item1
=
new
Item
();
item1
.
setTitle
(
"title1"
);
MockHttpOutputMessage
outputMessage
=
new
MockHttpOutputMessage
();
converter
.
write
(
channel
,
null
,
outputMessage
);
assertEquals
(
"Invalid content-type"
,
new
MediaType
(
"application"
,
"rss+xml"
,
Charset
.
forName
(
encoding
)),
outputMessage
.
getHeaders
().
getContentType
());
}
}
\ No newline at end of file
org.springframework.web/src/test/resources/org/springframework/http/converter/feed/atom.xml
0 → 100644
浏览文件 @
5303ab68
<?xml version="1.0" encoding="utf-8"?>
<feed
xmlns=
"http://www.w3.org/2005/Atom"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.w3.org/2005/Atom http://www.kbcafe.com/rss/atom.xsd.xml"
>
<title>
title
</title>
<subtitle>
subtitle
</subtitle>
<entry>
<id>
id1
</id>
<title>
title1
</title>
</entry>
<entry>
<id>
id2
</id>
<title>
title2
</title>
</entry>
</feed>
org.springframework.web/src/test/resources/org/springframework/http/converter/feed/rss.xml
0 → 100644
浏览文件 @
5303ab68
<?xml version="1.0" encoding="utf-8"?>
<rss
version=
"2.0"
>
<channel>
<title>
title
</title>
<link>
http://example.com
</link>
<description>
description
</description>
<item>
<title>
title1
</title>
</item>
<item>
<title>
title2
</title>
</item>
</channel>
</rss>
\ No newline at end of file
org.springframework.web/template.mf
浏览文件 @
5303ab68
...
...
@@ -4,6 +4,7 @@ Bundle-Vendor: SpringSource
Bundle-ManifestVersion: 2
Import-Template:
com.caucho.*;version="[3.2.0, 5.0.0)";resolution:=optional,
com.sun.syndication.*;version="[1.0.0, 2.0.0)";resolution:=optional,
org.codehaus.jackson.*;version="[1.0.0, 2.0.0)";resolution:=optional,
com.sun.net.*;version="0";resolution:=optional,
javax.el.*;version="[1.0.0, 3.0.0)";resolution:=optional,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录