1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.repository.xwiki.internal; |
21 |
|
|
22 |
|
import java.net.URI; |
23 |
|
import java.net.URISyntaxException; |
24 |
|
|
25 |
|
import org.junit.Rule; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.component.manager.ComponentLookupException; |
28 |
|
import org.xwiki.extension.ResolveException; |
29 |
|
import org.xwiki.extension.repository.DefaultExtensionRepositoryDescriptor; |
30 |
|
import org.xwiki.extension.repository.ExtensionRepository; |
31 |
|
import org.xwiki.extension.repository.ExtensionRepositoryException; |
32 |
|
import org.xwiki.extension.repository.ExtensionRepositoryFactory; |
33 |
|
import org.xwiki.test.annotation.AllComponents; |
34 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
35 |
|
|
36 |
|
import com.github.tomakehurst.wiremock.junit.WireMockRule; |
37 |
|
|
38 |
|
import static com.github.tomakehurst.wiremock.client.RequestPatternBuilder.allRequests; |
39 |
|
import static com.github.tomakehurst.wiremock.client.WireMock.findAll; |
40 |
|
import static org.junit.Assert.assertFalse; |
41 |
|
import static org.junit.Assert.assertTrue; |
42 |
|
|
43 |
|
@AllComponents |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.33 |
|
44 |
|
public class SystemHTTPProxyTest |
45 |
|
{ |
46 |
|
@Rule |
47 |
|
public WireMockRule proxyWireMockRule = new WireMockRule(8888); |
48 |
|
|
49 |
|
@Rule |
50 |
|
public MockitoComponentMockingRule<ExtensionRepositoryFactory> repositoryFactory = |
51 |
|
new MockitoComponentMockingRule<ExtensionRepositoryFactory>(XWikiExtensionRepositoryFactory.class); |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void testProxy() throws ExtensionRepositoryException, ComponentLookupException, URISyntaxException |
55 |
|
{ |
56 |
1 |
ExtensionRepository repository = this.repositoryFactory.getComponentUnderTest() |
57 |
|
.createRepository(new DefaultExtensionRepositoryDescriptor("id", "xwiki", new URI("http://host"))); |
58 |
|
|
59 |
1 |
try { |
60 |
1 |
repository.resolveVersions("id", 0, -1); |
61 |
|
} catch (ResolveException e) { |
62 |
|
|
63 |
|
} |
64 |
|
|
65 |
1 |
assertTrue("The repository did not requested the proxy server", findAll(allRequests()).isEmpty()); |
66 |
|
|
67 |
1 |
System.setProperty("http.proxyHost", "localhost"); |
68 |
1 |
System.setProperty("http.proxyPort", "8888"); |
69 |
|
|
70 |
1 |
try { |
71 |
1 |
repository.resolveVersions("id", 0, -1); |
72 |
|
} catch (ResolveException e) { |
73 |
|
|
74 |
|
} |
75 |
|
|
76 |
1 |
assertFalse("The repository did not requested the proxy server", findAll(allRequests()).isEmpty()); |
77 |
|
} |
78 |
|
} |