Rewrite dublin core date test

Original code had a copyright notice and no license header. Completely
rewriting the code is one of the ways to make sure the code is licensed
under Apache license.
This commit is contained in:
mishako 2016-03-31 22:11:23 +02:00
parent 94861b0532
commit 15a5f15ed0
4 changed files with 43 additions and 59 deletions

View file

@ -0,0 +1,34 @@
/*
* 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 com.rometools.rome.unittest;
import java.util.Date;
import com.rometools.rome.feed.module.DCModule;
import com.rometools.rome.feed.synd.SyndEntry;
public class DublinCoreTest extends FeedTest {
public DublinCoreTest() {
super("dublin-core-date.xml");
}
public void testPubDateDoesNotOverrideDublinCoreDate() throws Exception {
final SyndEntry entry = this.getCachedSyndFeed().getEntries().get(0);
final DCModule dublinCore = (DCModule) entry.getModule(DCModule.URI);
assertEquals(new Date(1000), dublinCore.getDate());
}
}

View file

@ -1,30 +0,0 @@
/* ----------------------------------------------------------------------------
* (c) Mobile IQ Ltd 2009. All Rights Reserved.
* ----------------------------------------------------------------------------
*/
package com.rometools.rome.unittest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import com.rometools.rome.feed.module.DCModule;
import com.rometools.rome.feed.synd.SyndEntry;
import com.rometools.rome.feed.synd.SyndFeed;
public class TestDublinCore extends FeedTest {
public TestDublinCore() {
super("dublinCoreTest.xml");
}
public void testDublinCoreDateIsPreferredWhenAvailableRatherThanRss20PubDate() throws Exception {
final SyndFeed feed = this.getCachedSyndFeed();
final SyndEntry entry = feed.getEntries().get(0);
final DCModule dc = (DCModule) entry.getModule(DCModule.URI);
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
final Date expected = sdf.parse("2009-03-03T13:06:20Z");
assertEquals("<dc:date/> element is returned as date, rather than <pubDate/>.", expected, dc.getDate());
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<item>
<pubDate>Thu, 01 Jan 1970 00:00:00 GMT</pubDate>
<dc:date>1970-01-01T00:00:01Z</dc:date>
</item>
</channel>
</rss>

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"
version="2.0">
<channel>
<title>Title</title>
<link>http://example.com/</link>
<description>Some description</description>
<language>en-gb</language>
<lastBuildDate>Tue, 03 Mar 2009 13:06:20 GMT</lastBuildDate>
<ttl>15</ttl>
<image>
<title>Title</title>
<url>http://image.example.com/rss.gif</url>
<link>http://example.com</link>
</image>
<item>
<title>item title</title>
<link>http://example.com/articles/2009/03/03/some-article</link>
<description>Article description</description>
<pubDate>Tue, 03 Mar 2009 13:05:50 GMT</pubDate>
<guid>http://example.com/articles/2009/03/03/some-article</guid>
<dc:creator>Alice Bob</dc:creator>
<dc:subject>Bob news</dc:subject>
<dc:date>2009-03-03T13:06:20Z</dc:date>
<dc:type>Article</dc:type>
<atom:updated>2009-03-03T13:06:20Z</atom:updated>
</item>
</channel>
</rss>