44import httpserver .request .Request ;
55import httpserver .MethodResponderSupplier ;
66import httpserver .response .Response ;
7+ import org .junit .Ignore ;
78import org .junit .Test ;
89
910import java .io .IOException ;
@@ -29,6 +30,7 @@ public GeneralResponderTest() {
2930
3031 @ Test
3132 public void callsSupplyResponderOnResponderSupplierWithRequest () throws Exception {
33+ when (methodResponderMock .allows (any (Request .class ))).thenReturn (true );
3234 when (methodResponderSupplierMock .supplyResponder (any ())).thenReturn (methodResponderMock );
3335
3436 generalResponder .respond (appConfigMock , requestMock );
@@ -37,8 +39,19 @@ public void callsSupplyResponderOnResponderSupplierWithRequest() throws Exceptio
3739 verify (methodResponderMock ).respond (appConfigMock , requestMock );
3840 }
3941
42+ @ Test
43+ public void returns405IfTheResponderCalledDoesntAllowTheRequest () throws Exception {
44+ when (methodResponderSupplierMock .supplyResponder (any ())).thenReturn (methodResponderMock );
45+ when (methodResponderMock .allows (any (Request .class ))).thenReturn (false );
46+
47+ Response response = generalResponder .respond (appConfigMock , requestMock );
48+
49+ assertEquals (405 , response .getStatusCode ());
50+ }
51+
4052 @ Test
4153 public void returnsServerErrorResponseIfTheResponderCalledReturnsAnError () throws Exception {
54+ when (methodResponderMock .allows (any (Request .class ))).thenReturn (true );
4255 when (methodResponderMock .respond (any (), any ())).thenThrow (new IOException ());
4356 when (methodResponderSupplierMock .supplyResponder (any ())).thenReturn (methodResponderMock );
4457
0 commit comments