From 15a5f15ed055c2f373141d54a8b33264fe82ab14 Mon Sep 17 00:00:00 2001 From: mishako Date: Thu, 31 Mar 2016 22:11:23 +0200 Subject: [PATCH] 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. --- .../rome/unittest/DublinCoreTest.java | 34 +++++++++++++++++++ .../rome/unittest/TestDublinCore.java | 30 ---------------- rome/src/test/resources/dublin-core-date.xml | 9 +++++ rome/src/test/resources/dublinCoreTest.xml | 29 ---------------- 4 files changed, 43 insertions(+), 59 deletions(-) create mode 100644 rome/src/test/java/com/rometools/rome/unittest/DublinCoreTest.java delete mode 100644 rome/src/test/java/com/rometools/rome/unittest/TestDublinCore.java create mode 100644 rome/src/test/resources/dublin-core-date.xml delete mode 100644 rome/src/test/resources/dublinCoreTest.xml diff --git a/rome/src/test/java/com/rometools/rome/unittest/DublinCoreTest.java b/rome/src/test/java/com/rometools/rome/unittest/DublinCoreTest.java new file mode 100644 index 0000000..4e02b45 --- /dev/null +++ b/rome/src/test/java/com/rometools/rome/unittest/DublinCoreTest.java @@ -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()); + } +} diff --git a/rome/src/test/java/com/rometools/rome/unittest/TestDublinCore.java b/rome/src/test/java/com/rometools/rome/unittest/TestDublinCore.java deleted file mode 100644 index 4250c1b..0000000 --- a/rome/src/test/java/com/rometools/rome/unittest/TestDublinCore.java +++ /dev/null @@ -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(" element is returned as date, rather than .", expected, dc.getDate()); - } -} \ No newline at end of file diff --git a/rome/src/test/resources/dublin-core-date.xml b/rome/src/test/resources/dublin-core-date.xml new file mode 100644 index 0000000..ccdd2ad --- /dev/null +++ b/rome/src/test/resources/dublin-core-date.xml @@ -0,0 +1,9 @@ + + + + + Thu, 01 Jan 1970 00:00:00 GMT + 1970-01-01T00:00:01Z + + + diff --git a/rome/src/test/resources/dublinCoreTest.xml b/rome/src/test/resources/dublinCoreTest.xml deleted file mode 100644 index ec56da1..0000000 --- a/rome/src/test/resources/dublinCoreTest.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - Title - http://example.com/ - Some description - en-gb - Tue, 03 Mar 2009 13:06:20 GMT - 15 - - Title - http://image.example.com/rss.gif - http://example.com - - - item title - http://example.com/articles/2009/03/03/some-article - Article description - Tue, 03 Mar 2009 13:05:50 GMT - http://example.com/articles/2009/03/03/some-article - Alice Bob - Bob news - 2009-03-03T13:06:20Z - Article - 2009-03-03T13:06:20Z - - - \ No newline at end of file