49
49
import org .junit .jupiter .api .condition .OS ;
50
50
import org .junit .jupiter .params .ParameterizedTest ;
51
51
import org .junit .jupiter .params .provider .MethodSource ;
52
+ import org .junit .jupiter .params .provider .ValueSource ;
52
53
import org .opengrok .indexer .authorization .AuthControlFlag ;
53
54
import org .opengrok .indexer .authorization .AuthorizationFramework ;
54
55
import org .opengrok .indexer .authorization .AuthorizationPlugin ;
55
56
import org .opengrok .indexer .authorization .TestPlugin ;
56
57
import org .opengrok .indexer .condition .EnabledForRepository ;
58
+ import org .opengrok .indexer .configuration .IndexTimestamp ;
57
59
import org .opengrok .indexer .configuration .Project ;
58
60
import org .opengrok .indexer .configuration .RuntimeEnvironment ;
59
61
import org .opengrok .indexer .history .Annotation ;
@@ -655,8 +657,9 @@ public String getPathInfo() {
655
657
};
656
658
}
657
659
658
- @ Test
659
- void testIsNotModifiedEtag () {
660
+ @ ParameterizedTest
661
+ @ ValueSource (booleans = {true , false })
662
+ void testIsNotModifiedEtag (boolean createTimestamp ) throws IOException {
660
663
HttpServletRequest req = new DummyHttpServletRequest () {
661
664
@ Override
662
665
public String getHeader (String name ) {
@@ -672,6 +675,16 @@ public String getPathInfo() {
672
675
}
673
676
};
674
677
678
+ // The ETag value depends on the timestamp file.
679
+ RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
680
+ env .refreshDateForLastIndexRun ();
681
+ Path timestampPath = Path .of (env .getDataRootPath (), IndexTimestamp .TIMESTAMP_FILE_NAME );
682
+ Files .deleteIfExists (timestampPath );
683
+ if (createTimestamp ) {
684
+ Files .createFile (timestampPath );
685
+ assertTrue (timestampPath .toFile ().exists ());
686
+ }
687
+
675
688
PageConfig cfg = PageConfig .get (req );
676
689
HttpServletResponse resp = mock (HttpServletResponse .class );
677
690
assertFalse (cfg .isNotModified (req , resp ));
0 commit comments