1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.transformation.linkchecker; |
21 |
|
|
22 |
|
import org.junit.Rule; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
25 |
|
|
26 |
|
import com.github.tomakehurst.wiremock.junit.WireMockRule; |
27 |
|
|
28 |
|
import static com.github.tomakehurst.wiremock.client.RequestPatternBuilder.allRequests; |
29 |
|
import static com.github.tomakehurst.wiremock.client.WireMock.findAll; |
30 |
|
import static org.junit.Assert.*; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.17 |
|
38 |
|
public class DefaultHTTPCheckerTest |
39 |
|
{ |
40 |
|
@Rule |
41 |
|
public WireMockRule proxyWireMockRule = new WireMockRule(8888); |
42 |
|
|
43 |
|
@Rule |
44 |
|
public MockitoComponentMockingRule<DefaultHTTPChecker> mocker = |
45 |
|
new MockitoComponentMockingRule<>(DefaultHTTPChecker.class); |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
47 |
1 |
@Test... |
48 |
|
public void testProxy() throws Exception |
49 |
|
{ |
50 |
|
|
51 |
|
|
52 |
1 |
assertEquals(0, this.mocker.getComponentUnderTest().check("http://unknownhostforxwikitest")); |
53 |
1 |
assertTrue("The HTTP server was not called by the link checker", findAll(allRequests()).isEmpty()); |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
1 |
System.setProperty("http.proxyHost", "localhost"); |
58 |
1 |
System.setProperty("http.proxyPort", "8888"); |
59 |
1 |
assertEquals(404, this.mocker.getComponentUnderTest().check("http://unknownhostforxwikitest")); |
60 |
1 |
assertFalse("The HTTP server was called by the link checker", findAll(allRequests()).isEmpty()); |
61 |
|
} |
62 |
|
} |