@@ -577,76 +577,6 @@ void testStopWithNoFileUsingExecutor() throws Exception {
577577 assertEquals (0 , listener .reachedEndOfFile , "end of file never reached" );
578578 }
579579
580- @ Test
581- void testTailerIgnoreTouch () throws Exception {
582- // Create & start the Tailer
583- final long delayMillis = 50 ;
584- final File file = new File (temporaryFolder , "tailer1-testIgnoreTouch.txt" );
585- createFile (file , 0 );
586- final TestTailerListener listener = new TestTailerListener ();
587- try (Tailer tailer = Tailer .builder ()
588- .setFile (file )
589- .setTailerListener (listener )
590- .setDelayDuration (Duration .ofMillis (delayMillis ))
591- .setStartThread (false )
592- .setIgnoreTouch (true )
593- .get ()) {
594- final Thread thread = new Thread (tailer );
595- thread .start ();
596-
597- // Write some lines to the file
598- write (file , "Line one" );
599- final long testDelayMillis = delayMillis * 10 ;
600- TestUtils .sleep (testDelayMillis );
601- List <String > lines = listener .getLines ();
602- assertEquals (1 , lines .size (), "1 line count" );
603- assertEquals ("Line one" , lines .get (0 ), "1 line 1" );
604- listener .clear ();
605-
606- // touch the file
607- file .setLastModified (System .currentTimeMillis ());
608- TestUtils .sleep (testDelayMillis );
609- lines = listener .getLines ();
610- assertEquals (0 , lines .size (), "nothing should have changed by touching" );
611- }
612- }
613-
614- @ Test
615- void testTailerReissueOnTouch () throws Exception {
616- // Create & start the Tailer
617- final long delayMillis = 50 ;
618- final File file = new File (temporaryFolder , "tailer1-testReissueOnTouch.txt" );
619- createFile (file , 0 );
620- final TestTailerListener listener = new TestTailerListener ();
621- try (Tailer tailer = Tailer .builder ()
622- .setFile (file )
623- .setTailerListener (listener )
624- .setDelayDuration (Duration .ofMillis (delayMillis ))
625- .setStartThread (false )
626- .setIgnoreTouch (false )
627- .get ()) {
628- final Thread thread = new Thread (tailer );
629- thread .start ();
630-
631- // Write some lines to the file
632- write (file , "Line one" );
633- final long testDelayMillis = delayMillis * 10 ;
634- TestUtils .sleep (testDelayMillis );
635- List <String > lines = listener .getLines ();
636- assertEquals (1 , lines .size (), "1 line count" );
637- assertEquals ("Line one" , lines .get (0 ), "1 line 1" );
638- listener .clear ();
639-
640- // touch the file
641- file .setLastModified (System .currentTimeMillis ());
642- TestUtils .sleep (testDelayMillis );
643- lines = listener .getLines ();
644- assertEquals (1 , lines .size (), "1 line count" );
645- assertEquals ("Line one" , lines .get (0 ), "1 line 1" );
646- listener .clear ();
647- }
648- }
649-
650580 @ Test
651581 void testTailer () throws Exception {
652582
@@ -775,6 +705,76 @@ void testTailerEof() throws Exception {
775705 }
776706 }
777707
708+ @ Test
709+ void testTailerIgnoreTouch () throws Exception {
710+ // Create & start the Tailer
711+ final long delayMillis = 50 ;
712+ final File file = new File (temporaryFolder , "tailer1-testIgnoreTouch.txt" );
713+ createFile (file , 0 );
714+ final TestTailerListener listener = new TestTailerListener ();
715+ try (Tailer tailer = Tailer .builder ()
716+ .setFile (file )
717+ .setTailerListener (listener )
718+ .setDelayDuration (Duration .ofMillis (delayMillis ))
719+ .setStartThread (false )
720+ .setIgnoreTouch (true )
721+ .get ()) {
722+ final Thread thread = new Thread (tailer );
723+ thread .start ();
724+
725+ // Write some lines to the file
726+ write (file , "Line one" );
727+ final long testDelayMillis = delayMillis * 10 ;
728+ TestUtils .sleep (testDelayMillis );
729+ List <String > lines = listener .getLines ();
730+ assertEquals (1 , lines .size (), "1 line count" );
731+ assertEquals ("Line one" , lines .get (0 ), "1 line 1" );
732+ listener .clear ();
733+
734+ // touch the file
735+ file .setLastModified (System .currentTimeMillis ());
736+ TestUtils .sleep (testDelayMillis );
737+ lines = listener .getLines ();
738+ assertEquals (0 , lines .size (), "nothing should have changed by touching" );
739+ }
740+ }
741+
742+ @ Test
743+ void testTailerReissueOnTouch () throws Exception {
744+ // Create & start the Tailer
745+ final long delayMillis = 50 ;
746+ final File file = new File (temporaryFolder , "tailer1-testReissueOnTouch.txt" );
747+ createFile (file , 0 );
748+ final TestTailerListener listener = new TestTailerListener ();
749+ try (Tailer tailer = Tailer .builder ()
750+ .setFile (file )
751+ .setTailerListener (listener )
752+ .setDelayDuration (Duration .ofMillis (delayMillis ))
753+ .setStartThread (false )
754+ .setIgnoreTouch (false )
755+ .get ()) {
756+ final Thread thread = new Thread (tailer );
757+ thread .start ();
758+
759+ // Write some lines to the file
760+ write (file , "Line one" );
761+ final long testDelayMillis = delayMillis * 10 ;
762+ TestUtils .sleep (testDelayMillis );
763+ List <String > lines = listener .getLines ();
764+ assertEquals (1 , lines .size (), "1 line count" );
765+ assertEquals ("Line one" , lines .get (0 ), "1 line 1" );
766+ listener .clear ();
767+
768+ // touch the file
769+ file .setLastModified (System .currentTimeMillis ());
770+ TestUtils .sleep (testDelayMillis );
771+ lines = listener .getLines ();
772+ assertEquals (1 , lines .size (), "1 line count" );
773+ assertEquals ("Line one" , lines .get (0 ), "1 line 1" );
774+ listener .clear ();
775+ }
776+ }
777+
778778 private void validateTailer (final TestTailerListener listener , final File file ) throws IOException , InterruptedException {
779779 write (file , "foo" );
780780 final int timeout = 30 ;
0 commit comments