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