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 .mockito .Mockito ;
53
52
import org .opengrok .indexer .authorization .AuthControlFlag ;
54
53
import org .opengrok .indexer .authorization .AuthorizationFramework ;
55
54
import org .opengrok .indexer .authorization .AuthorizationPlugin ;
73
72
import static org .junit .jupiter .api .Assumptions .assumeTrue ;
74
73
import static org .mockito .ArgumentMatchers .eq ;
75
74
import static org .mockito .ArgumentMatchers .startsWith ;
75
+ import static org .mockito .Mockito .mock ;
76
+ import static org .mockito .Mockito .verify ;
77
+ import static org .mockito .Mockito .when ;
76
78
import static org .opengrok .indexer .condition .RepositoryInstalled .Type .MERCURIAL ;
77
79
import static org .opengrok .indexer .history .LatestRevisionUtil .getLatestRevision ;
78
80
@@ -654,7 +656,7 @@ public String getPathInfo() {
654
656
}
655
657
656
658
@ Test
657
- void testIsNotModified () {
659
+ void testIsNotModifiedEtag () {
658
660
HttpServletRequest req = new DummyHttpServletRequest () {
659
661
@ Override
660
662
public String getHeader (String name ) {
@@ -671,8 +673,20 @@ public String getPathInfo() {
671
673
};
672
674
673
675
PageConfig cfg = PageConfig .get (req );
674
- HttpServletResponse resp = Mockito . mock (HttpServletResponse .class );
676
+ HttpServletResponse resp = mock (HttpServletResponse .class );
675
677
assertFalse (cfg .isNotModified (req , resp ));
676
- Mockito .verify (resp ).setHeader (eq (HttpHeaders .ETAG ), startsWith ("W/" ));
678
+ verify (resp ).setHeader (eq (HttpHeaders .ETAG ), startsWith ("W/" ));
679
+ }
680
+
681
+ @ Test
682
+ void testIsNotModifiedNotModified () {
683
+ DummyHttpServletRequest req = mock (DummyHttpServletRequest .class );
684
+ when (req .getPathInfo ()).thenReturn ("/" );
685
+ PageConfig cfg = PageConfig .get (req );
686
+ String etag = cfg .getEtag ();
687
+ when (req .getHeader (HttpHeaders .IF_NONE_MATCH )).thenReturn (etag );
688
+ HttpServletResponse resp = mock (HttpServletResponse .class );
689
+ assertTrue (cfg .isNotModified (req , resp ));
690
+ verify (resp ).setStatus (eq (HttpServletResponse .SC_NOT_MODIFIED ));
677
691
}
678
692
}
0 commit comments