1 package org.apache.maven.scm.provider.local.repository;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.ScmTestCase;
23 import org.apache.maven.scm.provider.ScmProviderRepository;
24 import org.apache.maven.scm.repository.ScmRepository;
25 import org.apache.maven.scm.repository.ScmRepositoryException;
26 import org.codehaus.plexus.util.FileUtils;
27
28
29
30
31
32 public class LocalRepositoryTest
33 extends ScmTestCase
34 {
35 public void setUp()
36 throws Exception
37 {
38 super.setUp();
39
40 FileUtils.mkdir( getWorkingDirectory().getAbsolutePath() );
41 }
42
43 public void testExistingRepository()
44 throws Exception
45 {
46 ScmRepository repository = getScmManager().makeScmRepository( "scm:local:src/test/repository:test-repo" );
47
48 assertNotNull( repository );
49
50 assertEquals( "local", repository.getProvider() );
51
52
53
54 ScmProviderRepository providerRepository = repository.getProviderRepository();
55
56 assertNotNull( providerRepository );
57
58 assertTrue( providerRepository instanceof LocalScmProviderRepository );
59
60 LocalScmProviderRepository local = (LocalScmProviderRepository) providerRepository;
61
62 assertEquals( getTestFile( "src/test/repository" ).getAbsolutePath(), local.getRoot() );
63
64 assertEquals( "test-repo", local.getModule() );
65 }
66
67 public void testMissingRepositoryRoot()
68 throws Exception
69 {
70 try
71 {
72 getScmManager().makeScmRepository( "scm:local:" );
73
74 fail( "Expected ScmRepositoryException." );
75 }
76 catch ( ScmRepositoryException ex )
77 {
78
79 }
80 }
81
82 public void testNonExistingMissingRepositoryRoot()
83 throws Exception
84 {
85 try
86 {
87 getScmManager().makeScmRepository( "scm:local:non-existing-directory:module" );
88
89 fail( "Expected ScmRepositoryException." );
90 }
91 catch ( ScmRepositoryException ex )
92 {
93
94 }
95 }
96
97 public void testMissingModule()
98 throws Exception
99 {
100 try
101 {
102 getScmManager().makeScmRepository( "scm:local:src/test/repository" );
103
104 fail( "Expected ScmRepositoryException." );
105 }
106 catch ( ScmRepositoryException ex )
107 {
108
109 }
110
111 try
112 {
113 getScmManager().makeScmRepository( "scm:local:src/test/repository:" );
114
115 fail( "Expected ScmRepositoryException." );
116 }
117 catch ( ScmRepositoryException ex )
118 {
119
120 }
121 }
122
123
124 public void testNonExistingModule()
125 throws Exception
126 {
127 try
128 {
129 getScmManager().makeScmRepository( "scm:local:src/test/repository:non-existing-module" );
130
131 fail( "Expected ScmRepositoryException." );
132 }
133 catch ( ScmRepositoryException ex )
134 {
135
136 }
137 }
138
139 protected String getScmUrl()
140 {
141 return "scm:local|" + getRepository() + "|" + getModule();
142 }
143 }