1 package org.apache.maven.scm.provider;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import junit.framework.TestCase;
23
24
25
26
27
28 public class ScmUrlUtilsTest
29 extends TestCase
30 {
31 private static final String SCM_URL_CVS_COLON = "scm:cvs:local:repository:module";
32
33 private static final String SCM_URL_CVS_PIPE = "scm:cvs|local|repository|module";
34
35 private static final String SCM_URL_CVS_INVALID = "scm|cvs|local|repository|module";
36
37 private static final String SCM_URL_INVALID_1 = null;
38
39 private static final String SCM_URL_INVALID_2 = "scm";
40
41 private static final String SCM_URL_INVALID_3 = "scm:a";
42
43 private static final String SCM_URL_INVALID_4 = "scm:a-";
44
45 private static final String SCM_URL_VALID_1 = "scm:a:";
46
47 private static final String SCM_URL_VALID_2 = "scm:a|";
48
49 private static final String SCM_URL_VALID_3 = "scm:a:provider-specific-part";
50
51 private static final String SCM_URL_VALID_4 = "scm:a|provider-specific-part";
52
53 public void testGetDelimiter()
54 throws Exception
55 {
56 assertEquals( ":", ScmUrlUtils.getDelimiter( SCM_URL_CVS_COLON ) );
57 assertEquals( "|", ScmUrlUtils.getDelimiter( SCM_URL_CVS_PIPE ) );
58 assertEquals( "|", ScmUrlUtils.getDelimiter( SCM_URL_CVS_INVALID ) );
59 }
60
61 public void testGetProvider()
62 throws Exception
63 {
64 assertEquals( "cvs", ScmUrlUtils.getProvider( SCM_URL_CVS_COLON ) );
65 assertEquals( "cvs", ScmUrlUtils.getProvider( SCM_URL_CVS_PIPE ) );
66 assertEquals( "cvs", ScmUrlUtils.getProvider( SCM_URL_CVS_INVALID ) );
67
68 assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_1 ) );
69 assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_2 ) );
70 assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_3 ) );
71 assertEquals( "a", ScmUrlUtils.getProvider( SCM_URL_VALID_4 ) );
72 }
73
74 public void testGetProviderSpecificPart()
75 throws Exception
76 {
77 assertEquals( "local:repository:module", ScmUrlUtils.getProviderSpecificPart( SCM_URL_CVS_COLON ) );
78 assertEquals( "local|repository|module", ScmUrlUtils.getProviderSpecificPart( SCM_URL_CVS_PIPE ) );
79 assertEquals( "local|repository|module", ScmUrlUtils.getProviderSpecificPart( SCM_URL_CVS_INVALID ) );
80
81 assertEquals( "", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_1 ) );
82 assertEquals( "", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_2 ) );
83 assertEquals( "provider-specific-part", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_3 ) );
84 assertEquals( "provider-specific-part", ScmUrlUtils.getProviderSpecificPart( SCM_URL_VALID_4 ) );
85 }
86
87 public void testIsValid()
88 throws Exception
89 {
90 assertTrue( ScmUrlUtils.isValid( SCM_URL_CVS_COLON ) );
91 assertTrue( ScmUrlUtils.isValid( SCM_URL_CVS_PIPE ) );
92 assertFalse( ScmUrlUtils.isValid( SCM_URL_CVS_INVALID ) );
93
94 assertTrue( ScmUrlUtils.isValid( SCM_URL_VALID_1 ) );
95 assertTrue( ScmUrlUtils.isValid( SCM_URL_VALID_2 ) );
96 assertTrue( ScmUrlUtils.isValid( SCM_URL_VALID_3 ) );
97 assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_1 ) );
98 assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_2 ) );
99 assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_3 ) );
100 assertFalse( ScmUrlUtils.isValid( SCM_URL_INVALID_4 ) );
101 }
102 }