This is an automated email from the ASF dual-hosted git repository.

asalamon74 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/oozie.git


The following commit(s) were added to refs/heads/master by this push:
     new ee244a3  OOZIE-3505 [Java 11] Fix TestDBLoadDump (kmarton via 
asalamon74)
ee244a3 is described below

commit ee244a3760976dc86b03518b22552c9d67a973ca
Author: Andras Salamon <[email protected]>
AuthorDate: Fri Jun 7 16:15:16 2019 +0200

    OOZIE-3505 [Java 11] Fix TestDBLoadDump (kmarton via asalamon74)
---
 pom.xml                                            |  2 +-
 release-log.txt                                    |  1 +
 .../org/apache/oozie/tools/OozieDBExportCLI.java   |  3 ++-
 .../org/apache/oozie/tools/TestDBLoadDump.java     | 23 +++++++++++++---------
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/pom.xml b/pom.xml
index 207e3ce..923b973 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1624,7 +1624,7 @@
             <dependency>
                 <groupId>com.google.code.gson</groupId>
                 <artifactId>gson</artifactId>
-                <version>2.7</version>
+                <version>2.8.5</version>
             </dependency>
             <dependency>
                 <groupId>com.google.inject</groupId>
diff --git a/release-log.txt b/release-log.txt
index 89e6392..333af1a 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 5.2.0 release (trunk - unreleased)
 
+OOZIE-3505 [Java 11] Fix TestDBLoadDump (kmarton via asalamon74)
 OOZIE-2879 Remove unused class SLAStore and related classes (asalamon74 via 
kmarton)
 OOZIE-3510 TestProxyUserService.testInvalidGroup fails if executed by nobody 
(asalamon74 via kmarton)
 OOZIE-3499 [Java 11] Fix TestLiteWorkflowAppParser (kmarton via asalamon74)
diff --git a/tools/src/main/java/org/apache/oozie/tools/OozieDBExportCLI.java 
b/tools/src/main/java/org/apache/oozie/tools/OozieDBExportCLI.java
index 0d3aba8..340572e 100644
--- a/tools/src/main/java/org/apache/oozie/tools/OozieDBExportCLI.java
+++ b/tools/src/main/java/org/apache/oozie/tools/OozieDBExportCLI.java
@@ -19,6 +19,7 @@
 package org.apache.oozie.tools;
 
 import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.oozie.cli.CLIParser;
@@ -176,7 +177,7 @@ public class OozieDBExportCLI {
     }
 
     private static int exportTableToJSON(Query query, ZipOutputStream 
zipOutputStream, String filename) throws IOException {
-        Gson gson = new Gson();
+        Gson gson = new GsonBuilder().setDateFormat("MMM d, yyyy h:mm:ss 
a").create();
         ZipEntry zipEntry = new ZipEntry(filename);
         zipOutputStream.putNextEntry(zipEntry);
         BufferedWriter writer = new BufferedWriter(new 
OutputStreamWriter(zipOutputStream, StandardCharsets.UTF_8.name()));
diff --git a/tools/src/test/java/org/apache/oozie/tools/TestDBLoadDump.java 
b/tools/src/test/java/org/apache/oozie/tools/TestDBLoadDump.java
index bd67af6..75d2ef5 100644
--- a/tools/src/test/java/org/apache/oozie/tools/TestDBLoadDump.java
+++ b/tools/src/test/java/org/apache/oozie/tools/TestDBLoadDump.java
@@ -19,7 +19,6 @@ package org.apache.oozie.tools;
 
 import org.apache.commons.cli.ParseException;
 import org.apache.oozie.*;
-import org.apache.oozie.service.ConfigurationService;
 import org.apache.oozie.service.JPAService;
 import org.apache.oozie.service.ServiceException;
 import org.apache.oozie.service.Services;
@@ -35,14 +34,13 @@ import javax.persistence.EntityManager;
 import javax.persistence.EntityTransaction;
 import javax.persistence.Query;
 import javax.persistence.TypedQuery;
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
 import java.security.Permission;
+import java.util.Enumeration;
 import java.util.List;
+import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipOutputStream;
 
@@ -97,11 +95,18 @@ public class TestDBLoadDump extends XTestCase {
 
         exportFromDB(newZipDump);
 
-        assertEquals(validZipDump.length(), newZipDump.length());
-        final ZipFile zip = new ZipFile(newZipDump);
-        final BufferedReader reader = new BufferedReader(new InputStreamReader(
-                zip.getInputStream(zip.getEntry("ooziedb_wf.json")), 
StandardCharsets.UTF_8));
-        
assertTrue(reader.readLine().contains("0000003-160720041037822-oozie-oozi-W"));
+        validateZipContent(new ZipFile(validZipDump), new ZipFile(newZipDump));
+    }
+
+    private void validateZipContent(ZipFile expectedZip, ZipFile actualZip) {
+        assertEquals("Unexpected zip file size", expectedZip.size(), 
actualZip.size());
+        for (Enumeration e = expectedZip.entries(); e.hasMoreElements();) {
+            ZipEntry entry = ((ZipEntry)e.nextElement());
+            String fileName = entry.getName();
+            long expectedChecksum = entry.getCrc();
+            long actualChecksum = actualZip.getEntry(fileName).getCrc();
+            assertEquals("Checksum mismatch for file: " + fileName, 
expectedChecksum, actualChecksum);
+        }
     }
 
     @Test

Reply via email to