+\r
+ @Test\r
+ public void testUpdateStatTester() {\r
+\r
+ ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);\r
+ ScheduledFuture<?> sf = executor.scheduleAtFixedRate(\r
+ new ExecutionStatCollector(LOCAL_JOBS, 1), 1, 10,\r
+ TimeUnit.SECONDS);\r
+\r
+ try {\r
+ Thread.sleep(1000 * 35);\r
+ executor.shutdown();\r
+ executor.awaitTermination(300, TimeUnit.SECONDS);\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ Assert.fail(e.getMessage());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * This test will fail in time as it relies on last access time for file in\r
+ * the filesystem! This OK as it has been tested by then.\r
+ * \r
+ */\r
+ @Test\r
+ public void testHasTimedOut() {\r
+ ExecutionStatCollector ecol = new ExecutionStatCollector(LOCAL_JOBS, 1);\r
+ File f = new File(LOCAL_JOBS + File.separator\r
+ + "ClustalW#1015373448154965");\r
+ File timedOut = new File(LOCAL_JOBS + File.separator\r
+ + "Mafft#7868649707286965");\r
+\r
+ JobDirectory jd = new JobDirectory(f);\r
+ JobDirectory timedOutDir = new JobDirectory(timedOut);\r
+ System.out.println("! " + new Date(f.lastModified()));\r
+\r
+ assertTrue((System.currentTimeMillis() - f.lastModified())\r
+ / (1000 * 60 * 60) < 1);\r
+ assertFalse((System.currentTimeMillis() - timedOut.lastModified())\r
+ / (1000 * 60 * 60) < 1);\r
+ assertFalse(ecol.hasTimedOut(jd));\r
+ assertTrue(ecol.hasTimedOut(timedOutDir));\r
+ }\r
+\r
+ @Test\r
+ public void testHasCompleted() {\r
+ ExecutionStatCollector ecol_no_timeout = new ExecutionStatCollector(\r
+ LOCAL_JOBS, 10000000);\r
+ ExecutionStatCollector ecol = new ExecutionStatCollector(LOCAL_JOBS, 1);\r
+\r
+ File normal = new File(LOCAL_JOBS + File.separator\r
+ + "ClustalW#100368900075204");\r
+ File finished = new File(LOCAL_JOBS + File.separator\r
+ + "ClustalW#1015373448154965");\r
+ File cancelled = new File(LOCAL_JOBS + File.separator\r
+ + "Mafft#7918237850044965");\r
+ File noresult = new File(LOCAL_JOBS + File.separator\r
+ + "ClustalW#1015343425414965");\r
+\r
+ JobDirectory dnormal = new JobDirectory(normal);\r
+ JobDirectory dfinished = new JobDirectory(finished);\r
+ JobDirectory dcancelled = new JobDirectory(cancelled);\r
+\r
+ JobDirectory dnoresult = new JobDirectory(noresult);\r
+\r
+ assertTrue(ecol.hasCompleted(dnormal));\r
+ assertTrue(ecol.hasCompleted(dfinished));\r
+ assertTrue(ecol.hasCompleted(dcancelled));\r
+\r
+ assertTrue(ecol.hasCompleted(dnoresult));\r
+ assertFalse(ecol_no_timeout.hasCompleted(dnoresult));\r