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