]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Check modification dates in the unit test of a document replacing.
authorrkv <rkv@opencascade.com>
Thu, 11 Apr 2013 05:01:20 +0000 (05:01 +0000)
committerrkv <rkv@opencascade.com>
Thu, 11 Apr 2013 05:01:20 +0000 (05:01 +0000)
Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java

index ccd85661676a6577f13b3bf9c498cb3e0c1e428b..98c56206f79b99b35c9872accc7c0069e57024cc 100644 (file)
@@ -21,6 +21,7 @@ import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -716,7 +717,7 @@ public class TestPublicationService extends BaseTest {
                Assert.assertTrue(ht.find("from File").size() >= 2,
                                "Files were not created in the database.");
 
-               Date modifTime = new Date();
+               Date modifTime = Calendar.getInstance().getTime();
 
                // TEST CALL: Replace a file in the study step
                aStudy = _studyService.selectStudy(studyId);
@@ -735,18 +736,22 @@ public class TestPublicationService extends BaseTest {
                ht.flush();
 
                ht.clear();
+               // Remove milliseconds because they are lost after saving in the database
+               modifTime.setTime((modifTime.getTime() / 1000) * 1000);
 
                Document doc = ht.get(Document.class, id1);
                String txt = readFile(doc.getFile().asFile());
                Assert.assertTrue(doc.getFile().getName().contains("_document1"));
                Assert.assertEquals(doc.getFile().getFormat(), format1);
                Assert.assertTrue(txt.contains("replaced1.ddd"));
+               Assert.assertEquals(doc.getLastModificationDate(), modifTime);
 
                doc = ht.get(Document.class, id2);
                txt = readFile(doc.getFile().asFile());
                Assert.assertTrue(doc.getFile().getName().contains("_sdocument1"));
-               Assert.assertEquals(doc.getFile().getFormat(), format1);
+               Assert.assertEquals(doc.getFile().getFormat(), format2);
                Assert.assertTrue(txt.contains("replaced2.ddd"));
+               Assert.assertEquals(doc.getLastModificationDate(), modifTime);
                
                rollbackNestedTransaction();
                LOG.debug(">>>>> END testReplace()");