View Javadoc

1   package org.apache.maven.continuum.configuration;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.continuum.buildqueue.BuildQueueServiceException;
23  import org.apache.continuum.configuration.BuildAgentConfiguration;
24  import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
25  import org.apache.maven.continuum.model.project.BuildQueue;
26  import org.apache.maven.continuum.model.project.Schedule;
27  import org.apache.maven.continuum.store.ContinuumStoreException;
28  
29  import java.io.File;
30  import java.util.List;
31  import java.util.Map;
32  
33  /**
34   * Mock class for testing WagonContinuumNotifier's call to ConfigurationService.getBuildOutputFile()
35   *
36   * @author <a href="mailto:nramirez@exist">Napoleon Esmundo C. Ramirez</a>
37   */
38  public class ConfigurationServiceMock
39      implements ConfigurationService
40  {
41      private final String basedir;
42  
43      public ConfigurationServiceMock()
44      {
45          basedir = System.getProperty( "basedir" );
46      }
47  
48      public File getBuildOutputDirectory()
49      {
50          return new File( basedir, "src/test/resources" + "/" + "build-output-directory" );
51      }
52  
53      public File getBuildOutputDirectory( int projectId )
54      {
55          return new File( getBuildOutputDirectory(), Integer.toString( projectId ) );
56      }
57  
58      public File getBuildOutputFile( int buildId, int projectId )
59          throws ConfigurationException
60      {
61          File dir = getBuildOutputDirectory( projectId );
62  
63          if ( !dir.exists() && !dir.mkdirs() )
64          {
65              throw new ConfigurationException(
66                  "Could not make the build output directory: " + "'" + dir.getAbsolutePath() + "'." );
67          }
68  
69          return new File( dir, buildId + ".log.txt" );
70      }
71  
72      public File getWorkingDirectory()
73      {
74          return new File( basedir, "src/test/resources" + "/" + "working-directory" );
75      }
76  
77      public File getTestReportsDirectory( int buildId, int projectId )
78          throws ConfigurationException
79      {
80          File dir = getBuildOutputDirectory( projectId );
81  
82          if ( !dir.exists() && !dir.mkdirs() )
83          {
84              throw new ConfigurationException(
85                  "Could not make the build output directory: " + "'" + dir.getAbsolutePath() + "'." );
86          }
87          return new File( dir.getPath() + File.separatorChar + buildId + File.separatorChar + "surefire-reports " );
88      }
89  
90      public File getApplicationHome()
91      {
92          return null;
93      }
94  
95      public boolean isInitialized()
96      {
97          return false;
98      }
99  
100     public void setInitialized( boolean initialized )
101     {
102     }
103 
104     public String getUrl()
105     {
106         return null;
107     }
108 
109     public void setUrl( String url )
110     {
111     }
112 
113     public void setBuildOutputDirectory( File buildOutputDirectory )
114     {
115     }
116 
117     public void setWorkingDirectory( File workingDirectory )
118     {
119     }
120 
121     public File getDeploymentRepositoryDirectory()
122     {
123         return null;
124     }
125 
126     public void setDeploymentRepositoryDirectory( File deploymentRepositoryDirectory )
127     {
128     }
129 
130     public void setJdks( Map jdks )
131     {
132     }
133 
134     public String getCompanyLogo()
135     {
136         return null;
137     }
138 
139     public void setCompanyLogo( String companyLogoUrl )
140     {
141     }
142 
143     public String getCompanyName()
144     {
145         return null;
146     }
147 
148     public void setCompanyName( String companyName )
149     {
150     }
151 
152     public String getCompanyUrl()
153     {
154         return null;
155     }
156 
157     public void setCompanyUrl( String companyUrl )
158     {
159     }
160 
161     public boolean isGuestAccountEnabled()
162     {
163         return false;
164     }
165 
166     public void setGuestAccountEnabled( boolean enabled )
167     {
168     }
169 
170     public String getBuildOutput( int buildId, int projectId )
171         throws ConfigurationException
172     {
173         return null;
174     }
175 
176     public File getFile( String filename )
177     {
178         return null;
179     }
180 
181     public String getSharedSecretPassword()
182     {
183         return null;
184     }
185 
186     public void setSharedSecretPassword( String sharedSecretPassword )
187     {
188     }
189 
190     public boolean isLoaded()
191     {
192         return false;
193     }
194 
195     public void reload()
196         throws ConfigurationLoadingException
197     {
198     }
199 
200     public void store()
201         throws ConfigurationStoringException
202     {
203     }
204 
205     public BuildQueue getDefaultBuildQueue()
206         throws BuildQueueServiceException
207     {
208         return null;
209     }
210 
211     public Schedule getDefaultSchedule()
212         throws ContinuumStoreException
213     {
214         // TODO Auto-generated method stub
215         return null;
216     }
217 
218     public File getChrootJailDirectory()
219     {
220         // TODO Auto-generated method stub
221         return null;
222     }
223 
224     public void setChrootJailDirectory( File chrootJailDirectory )
225     {
226         // TODO Auto-generated method stub
227 
228     }
229 
230     public File getReleaseOutputDirectory()
231     {
232         return new File( basedir, "src/test/resources" + "/" + "release-output-directory" );
233     }
234 
235     public File getReleaseOutputDirectory( int projectGroupId )
236     {
237         return new File( getReleaseOutputDirectory(), Integer.toString( projectGroupId ) );
238     }
239 
240     public File getReleaseOutputFile( int projectGroupId, String releaseName )
241         throws ConfigurationException
242     {
243         File dir = getReleaseOutputDirectory( projectGroupId );
244 
245         if ( !dir.exists() && !dir.mkdirs() )
246         {
247             throw new ConfigurationException(
248                 "Could not make the release output directory: " + "'" + dir.getAbsolutePath() + "'." );
249         }
250 
251         return new File( dir, releaseName + ".log.txt" );
252     }
253 
254     public void setReleaseOutputDirectory( File releaseOutputDirectory )
255     {
256     }
257 
258     public String getReleaseOutput( int projectGroupId, String name )
259     {
260         return null;
261     }
262 
263     public int getNumberOfBuildsInParallel()
264     {
265         return 1;
266     }
267 
268     public void setNumberOfBuildsInParallel( int num )
269     {
270 
271     }
272 
273     public void addBuildAgent( BuildAgentConfiguration buildAgent )
274         throws ConfigurationException
275     {
276     }
277 
278     public List<BuildAgentConfiguration> getBuildAgents()
279     {
280         return null;
281     }
282 
283     public boolean isDistributedBuildEnabled()
284     {
285         return false;
286     }
287 
288     public void removeBuildAgent( BuildAgentConfiguration buildAgent )
289     {
290     }
291 
292     public void setDistributedBuildEnabled( boolean distributedBuildEnabled )
293     {
294     }
295 
296     public void updateBuildAgent( BuildAgentConfiguration buildAgent )
297     {
298     }
299 
300     public void addBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
301         throws ConfigurationException
302     {
303     }
304 
305     public void removeBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
306         throws ConfigurationException
307     {
308     }
309 
310     public void updateBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
311         throws ConfigurationException
312     {
313     }
314 
315     public List<BuildAgentGroupConfiguration> getBuildAgentGroups()
316     {
317         return null;
318     }
319 
320     public void addBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
321         throws ConfigurationException
322     {
323     }
324 
325     public void removeBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
326         throws ConfigurationException
327     {
328     }
329 
330     public BuildAgentGroupConfiguration getBuildAgentGroup( String name )
331     {
332         return null;
333     }
334 
335     public BuildAgentConfiguration getBuildAgent( String url )
336     {
337         return null;
338     }
339 
340     public boolean containsBuildAgentUrl( String buildAgentUrl, BuildAgentGroupConfiguration buildAgentGroup )
341     {
342         return false;
343     }
344 }