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 java.io.File;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.apache.continuum.buildqueue.BuildQueueServiceException;
27  import org.apache.continuum.configuration.BuildAgentConfiguration;
28  import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
29  import org.apache.maven.continuum.model.project.BuildQueue;
30  import org.apache.maven.continuum.model.project.Schedule;
31  import org.apache.maven.continuum.store.ContinuumStoreException;
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 boolean isLoaded()
182     {
183         return false;
184     }
185 
186     public void reload()
187         throws ConfigurationLoadingException
188     {
189     }
190 
191     public void store()
192         throws ConfigurationStoringException
193     {
194     }
195 
196     public BuildQueue getDefaultBuildQueue()
197         throws BuildQueueServiceException
198     {
199         return null;
200     }
201 
202     public Schedule getDefaultSchedule()
203         throws ContinuumStoreException
204     {
205         // TODO Auto-generated method stub
206         return null;
207     }
208 
209     public File getChrootJailDirectory()
210     {
211         // TODO Auto-generated method stub
212         return null;
213     }
214 
215     public void setChrootJailDirectory( File chrootJailDirectory )
216     {
217         // TODO Auto-generated method stub
218 
219     }
220 
221     public File getReleaseOutputDirectory()
222     {
223         return new File( basedir, "src/test/resources" + "/" + "release-output-directory" );
224     }
225 
226     public File getReleaseOutputDirectory( int projectGroupId )
227     {
228         return new File( getReleaseOutputDirectory(), Integer.toString( projectGroupId ) );
229     }
230 
231     public File getReleaseOutputFile( int projectGroupId, String releaseName )
232         throws ConfigurationException
233     {
234         File dir = getReleaseOutputDirectory( projectGroupId );
235 
236         if ( !dir.exists() && !dir.mkdirs() )
237         {
238             throw new ConfigurationException(
239                 "Could not make the release output directory: " + "'" + dir.getAbsolutePath() + "'." );
240         }
241 
242         return new File( dir, releaseName + ".log.txt" );
243     }
244 
245     public void setReleaseOutputDirectory( File releaseOutputDirectory )
246     {
247     }
248 
249     public String getReleaseOutput( int projectGroupId, String name )
250     {
251         return null;
252     }
253 
254     public int getNumberOfBuildsInParallel()
255     {
256         return 1;
257     }
258 
259     public void setNumberOfBuildsInParallel( int num )
260     {
261 
262     }
263 
264     public void addBuildAgent( BuildAgentConfiguration buildAgent )
265         throws ConfigurationException
266     {
267     }
268 
269     public List<BuildAgentConfiguration> getBuildAgents()
270     {
271         return null;
272     }
273 
274     public boolean isDistributedBuildEnabled()
275     {
276         return false;
277     }
278 
279     public void removeBuildAgent( BuildAgentConfiguration buildAgent )
280     {
281     }
282 
283     public void setDistributedBuildEnabled( boolean distributedBuildEnabled )
284     {
285     }
286 
287     public void updateBuildAgent( BuildAgentConfiguration buildAgent )
288     {
289     }
290 
291     public void addBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
292         throws ConfigurationException
293     {
294     }
295 
296     public void removeBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
297         throws ConfigurationException
298     {
299     }
300 
301     public void updateBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
302         throws ConfigurationException
303     {
304     }
305 
306     public List<BuildAgentGroupConfiguration> getBuildAgentGroups()
307     {
308         return null;
309     }
310 
311     public void addBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
312         throws ConfigurationException
313     {
314     }
315 
316     public void removeBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
317         throws ConfigurationException
318     {
319     }
320 
321     public BuildAgentGroupConfiguration getBuildAgentGroup( String name )
322     {
323         return null;
324     }
325 
326     public BuildAgentConfiguration getBuildAgent( String url )
327     {
328         return null;
329     }
330 
331     public boolean containsBuildAgentUrl( String buildAgentUrl, BuildAgentGroupConfiguration buildAgentGroup )
332     {
333         return false;
334     }
335 }