Repository: oozie Updated Branches: refs/heads/master 669cea997 -> 67e93b134
OOZIE-2838 TestClassUtils,TestJsonUtils,TestWritableUtils,TestXmlUtils shall not be an Oozie XTestCase (asasvari via pbacsko) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/67e93b13 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/67e93b13 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/67e93b13 Branch: refs/heads/master Commit: 67e93b1345b632a2e7e0e16d40af2c28897e2c25 Parents: 669cea9 Author: Peter Bacsko <pbac...@cloudera.com> Authored: Fri Mar 24 11:19:30 2017 +0100 Committer: Peter Bacsko <pbac...@cloudera.com> Committed: Fri Mar 24 11:19:30 2017 +0100 ---------------------------------------------------------------------- .../apache/oozie/client/rest/TestJsonUtils.java | 21 +++++++++++--------- .../org/apache/oozie/util/TestClassUtils.java | 7 +++++-- .../apache/oozie/util/TestWritableUtils.java | 9 +++++++-- .../org/apache/oozie/util/TestXmlUtils.java | 8 ++++++-- release-log.txt | 1 + 5 files changed, 31 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/67e93b13/client/src/test/java/org/apache/oozie/client/rest/TestJsonUtils.java ---------------------------------------------------------------------- diff --git a/client/src/test/java/org/apache/oozie/client/rest/TestJsonUtils.java b/client/src/test/java/org/apache/oozie/client/rest/TestJsonUtils.java index d6d8135..4126f5b 100644 --- a/client/src/test/java/org/apache/oozie/client/rest/TestJsonUtils.java +++ b/client/src/test/java/org/apache/oozie/client/rest/TestJsonUtils.java @@ -19,25 +19,24 @@ package org.apache.oozie.client.rest; import java.text.SimpleDateFormat; -import junit.framework.TestCase; -import org.json.simple.JSONObject; -import org.json.simple.JSONArray; -import org.apache.oozie.client.rest.JsonUtils; +import org.junit.Test; -import java.util.Arrays; -import java.util.List; import java.util.Date; import java.util.Locale; -public class TestJsonUtils extends TestCase { +import static junit.framework.Assert.assertEquals; +public class TestJsonUtils { + + @Test public void testValidDate() { String str = "Thu, 01 Jan 2009 00:00:00 GMT"; Date date = JsonUtils.parseDateRfc822(str); String str1 = JsonUtils.formatDateRfc822(date); assertEquals(str, str1); } - + + @Test public void testValidNonGMTTimeZone() throws Exception { String gmtTime = "Thu, 01 Jan 2009 08:00:00 GMT"; SimpleDateFormat dateFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); @@ -45,7 +44,8 @@ public class TestJsonUtils extends TestCase { String pstTime = JsonUtils.formatDateRfc822(date, "PST"); assertEquals(pstTime, "Thu, 01 Jan 2009 00:00:00 PST"); } - + + @Test public void testInvalidTimeZone() throws Exception { String gmtTime = "Thu, 01 Jan 2009 00:00:00 GMT"; SimpleDateFormat dateFormatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); @@ -54,15 +54,18 @@ public class TestJsonUtils extends TestCase { assertEquals(asdTime, gmtTime); // defaults to GMT when can't parse time zone } + @Test public void testInvalidDateStr() { Date date = JsonUtils.parseDateRfc822("Xhu, 01 Jan 2009 00:00:00 GMT"); assertEquals(null, date); } + @Test public void testNullDateStr() { assertEquals(null, JsonUtils.parseDateRfc822(null)); } + @Test public void testNullDate() { assertEquals(null, JsonUtils.formatDateRfc822(null)); } http://git-wip-us.apache.org/repos/asf/oozie/blob/67e93b13/core/src/test/java/org/apache/oozie/util/TestClassUtils.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/util/TestClassUtils.java b/core/src/test/java/org/apache/oozie/util/TestClassUtils.java index 8582ca3..0406e28 100644 --- a/core/src/test/java/org/apache/oozie/util/TestClassUtils.java +++ b/core/src/test/java/org/apache/oozie/util/TestClassUtils.java @@ -18,11 +18,14 @@ package org.apache.oozie.util; -import junit.framework.TestCase; import org.json.simple.JSONArray; +import org.junit.Test; -public class TestClassUtils extends TestCase { +import static junit.framework.Assert.assertTrue; +public class TestClassUtils { + + @Test public void testContainingJar() { assertTrue(ClassUtils.findContainingJar(JSONArray.class).contains("json-simple")); } http://git-wip-us.apache.org/repos/asf/oozie/blob/67e93b13/core/src/test/java/org/apache/oozie/util/TestWritableUtils.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/util/TestWritableUtils.java b/core/src/test/java/org/apache/oozie/util/TestWritableUtils.java index 3525099..891fb75 100644 --- a/core/src/test/java/org/apache/oozie/util/TestWritableUtils.java +++ b/core/src/test/java/org/apache/oozie/util/TestWritableUtils.java @@ -19,7 +19,7 @@ package org.apache.oozie.util; import org.apache.hadoop.io.Text; -import org.apache.oozie.test.XTestCase; +import org.junit.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -27,8 +27,12 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -public class TestWritableUtils extends XTestCase { +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNull; +public class TestWritableUtils { + + @Test public void testWritableUtils() throws Exception { Text t = new Text(); t.set("hello"); @@ -37,6 +41,7 @@ public class TestWritableUtils extends XTestCase { assertEquals("hello", tt.toString()); } + @Test public void testWriteReadStr() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); http://git-wip-us.apache.org/repos/asf/oozie/blob/67e93b13/core/src/test/java/org/apache/oozie/util/TestXmlUtils.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/util/TestXmlUtils.java b/core/src/test/java/org/apache/oozie/util/TestXmlUtils.java index 4ceaede..ac0b5ed 100644 --- a/core/src/test/java/org/apache/oozie/util/TestXmlUtils.java +++ b/core/src/test/java/org/apache/oozie/util/TestXmlUtils.java @@ -18,19 +18,23 @@ package org.apache.oozie.util; -import org.apache.oozie.test.XTestCase; import org.jdom.Element; +import org.junit.Test; -public class TestXmlUtils extends XTestCase { +import static junit.framework.Assert.assertEquals; + +public class TestXmlUtils { private static String EXTERNAL_ENTITY_XML = "<!DOCTYPE foo [<!ENTITY xxe SYSTEM \"file:///etc/passwd\">]>\n" + "<foo>&xxe;</foo>"; + @Test public void testExternalEntity() throws Exception { Element e = XmlUtils.parseXml(EXTERNAL_ENTITY_XML); assertEquals(0, e.getText().length()); } + @Test public void testRemoveComments() throws Exception { String xmlStr = "<test1> <!-- Comment1 -->1234 <test2> ABCD <!-- Comment2 --> </test2> " + "<!-- Comment3 --> <test3> <!-- Comment4 -->EFGH </test3> <!-- Comment5 --></test1>"; http://git-wip-us.apache.org/repos/asf/oozie/blob/67e93b13/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 4e7097b..7fed4d6 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.4.0 release (trunk - unreleased) +OOZIE-2838 TestClassUtils,TestJsonUtils,TestWritableUtils,TestXmlUtils shall not be an Oozie XTestCase (asasvari via pbacsko) OOZIE-2811 amend Add support for filtering out properties from SparkConfigurationService OOZIE-2817 amend Increase test case stability in pre-commit job (gezapeti) OOZIE-2041 Add an admin command to run the PurgeXCommand (abhishekbafna)