1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.repository;
20
21 import org.junit.jupiter.api.Test;
22
23 import static org.junit.jupiter.api.Assertions.*;
24
25
26
27 public class RemoteRepositoryTest {
28
29 @Test
30 void testGetProtocol() {
31 RemoteRepository.Builder builder = new RemoteRepository.Builder("id", "type", "");
32 RemoteRepository repo = builder.build();
33 assertEquals("", repo.getProtocol());
34
35 repo = builder.setUrl("http://localhost").build();
36 assertEquals("http", repo.getProtocol());
37
38 repo = builder.setUrl("HTTP://localhost").build();
39 assertEquals("HTTP", repo.getProtocol());
40
41 repo = builder.setUrl("dav+http://www.sonatype.org/").build();
42 assertEquals("dav+http", repo.getProtocol());
43
44 repo = builder.setUrl("dav:http://www.sonatype.org/").build();
45 assertEquals("dav:http", repo.getProtocol());
46
47 repo = builder.setUrl("file:/path").build();
48 assertEquals("file", repo.getProtocol());
49
50 repo = builder.setUrl("file:path").build();
51 assertEquals("file", repo.getProtocol());
52
53 repo = builder.setUrl("file:C:\\dir").build();
54 assertEquals("file", repo.getProtocol());
55
56 repo = builder.setUrl("file:C:/dir").build();
57 assertEquals("file", repo.getProtocol());
58 }
59
60 @Test
61 void testGetHost() {
62 RemoteRepository.Builder builder = new RemoteRepository.Builder("id", "type", "");
63 RemoteRepository repo = builder.build();
64 assertEquals("", repo.getHost());
65
66 repo = builder.setUrl("http://localhost").build();
67 assertEquals("localhost", repo.getHost());
68
69 repo = builder.setUrl("http://localhost/").build();
70 assertEquals("localhost", repo.getHost());
71
72 repo = builder.setUrl("http://localhost:1234/").build();
73 assertEquals("localhost", repo.getHost());
74
75 repo = builder.setUrl("http://127.0.0.1").build();
76 assertEquals("127.0.0.1", repo.getHost());
77
78 repo = builder.setUrl("http://127.0.0.1/").build();
79 assertEquals("127.0.0.1", repo.getHost());
80
81 repo = builder.setUrl("http://user@localhost/path").build();
82 assertEquals("localhost", repo.getHost());
83
84 repo = builder.setUrl("http://user:pass@localhost/path").build();
85 assertEquals("localhost", repo.getHost());
86
87 repo = builder.setUrl("http://user:pass@localhost:1234/path").build();
88 assertEquals("localhost", repo.getHost());
89 }
90 }