Update of /var/cvs/tests/convertimage/org/mmbase/bridge/tests
In directory 
james.mmbase.org:/tmp/cvs-serv14085/convertimage/org/mmbase/bridge/tests

Modified Files:
        ConvertImageTest.java 
Log Message:
A quick an ddirty test for MMB-1396. It seems that at least the binary files 
are not accessed (which is tested here). That's good.


See also: 
http://cvs.mmbase.org/viewcvs/tests/convertimage/org/mmbase/bridge/tests
See also: http://www.mmbase.org/jira/browse/MMB-1396


Index: ConvertImageTest.java
===================================================================
RCS file: 
/var/cvs/tests/convertimage/org/mmbase/bridge/tests/ConvertImageTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- ConvertImageTest.java       24 Sep 2008 06:14:58 -0000      1.7
+++ ConvertImageTest.java       24 Sep 2008 06:49:14 -0000      1.8
@@ -5,6 +5,8 @@
 import java.io.*;
 import java.util.*;
 import org.mmbase.util.images.*;
+import org.mmbase.util.transformers.AbstractCommandStringTransformer;
+import org.mmbase.util.transformers.CharTransformer;
 
 import org.mmbase.util.functions.Function;
 import org.mmbase.util.functions.Parameters;
@@ -13,7 +15,7 @@
  * JUnit tests for convertimage-interface implementation.
  *
  * @author Michiel Meeuwissen
- * @version $Id: ConvertImageTest.java,v 1.7 2008/09/24 06:14:58 michiel Exp $
+ * @version $Id: ConvertImageTest.java,v 1.8 2008/09/24 06:49:14 michiel Exp $
  */
 public class ConvertImageTest extends org.mmbase.tests.BridgeTest {
 
@@ -77,7 +79,6 @@
 
     protected void restoreImaging(Map<String, String> parameters) {
         Factory.shutdown();
-        System.err.println("Restoring with " + parameters);
         Factory.init(parameters);
     }
 
@@ -109,6 +110,39 @@
 
 
     }
+
+    /**
+     * Java api to get access times is only available in java 7. This is a 
quick and dirty hack, at
+     * least working in linux. It does not actually try to determin the access 
times of individual
+     * files, it simply returns a string containing the access times. For test 
cases 'equals' on the
+     * string should suffice.
+     */
+    public String getImagesAccessTimes() {
+        CharTransformer accessTimes = new AbstractCommandStringTransformer() {
+                public String[] getCommand() {
+                    return new String[] {"xargs", "ls", "-lu"};
+                }
+            };
+        return accessTimes.transform(System.getProperty("user.dir") + 
"/data/test/mmbasetests_images");
+    }
+
+    public void testAccessTime() throws InterruptedException {
+        if(System.getProperty("os.name") != null && 
System.getProperty("os.name").startsWith("Windows")) {
+            System.err.println("Pretty sure this test won't work in Windows. 
Skippig it.");
+        } else {
+            // MMB-1386
+            String accessTimesBefore = getImagesAccessTimes();
+            // make sure it is a minute later.
+            Thread.sleep(61000);
+            org.mmbase.cache.CacheManager.getCache("Nodes").clear();
+            Node node = cloud.getNode("jpeg.test.image");
+            assertEquals(accessTimesBefore, getImagesAccessTimes());
+            node.setStringValue("title", "the images title");
+            node.commit();
+            assertEquals(accessTimesBefore, getImagesAccessTimes());
+        }
+    }
+
     private static Cloud cloud;
     /**
      * Sets up before each test.
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to