View Javadoc

1   package org.apache.maven.continuum.execution.maven.m2;
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.ArrayList;
24  import java.util.List;
25  
26  import org.apache.maven.continuum.AbstractContinuumTest;
27  import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
28  import org.apache.maven.continuum.model.project.BuildDefinition;
29  import org.apache.maven.continuum.model.project.Project;
30  import org.apache.maven.continuum.model.scm.ChangeFile;
31  import org.apache.maven.continuum.model.scm.ChangeSet;
32  
33  /**
34   * @author olamy
35   * @since 1.2.3
36   * @version $Id: MavenTwoBuildExecutorTest.java 723121 2008-12-03 23:07:36Z olamy $
37   */
38  public class MavenTwoBuildExecutorTest
39      extends AbstractContinuumTest
40  {
41         
42      
43      @Override
44      protected String getSpringConfigLocation()
45      {
46          return "applicationContextSlf4jPlexusLogger.xml";
47      }
48  
49      public void testShouldNotBuildNonRecursive()
50          throws Exception
51      {
52          MavenTwoBuildExecutor executor = (MavenTwoBuildExecutor) lookup( ContinuumBuildExecutor.class, "maven2" );
53          BuildDefinition buildDefinition = new BuildDefinition();
54          buildDefinition.setArguments( "-N" );
55          Project continuumProject = new Project(){
56              {
57                  setVersion( "1.0.3" );
58              }
59          };
60          assertFalse( executor.shouldBuild( new ArrayList<ChangeSet>(), continuumProject, new File( "target/test-classes/projects/continuum" ),
61                                             buildDefinition ) );
62      }
63      
64      public void testShouldNotBuildNonRecursiveChangeInAModule()
65          throws Exception
66      {
67          MavenTwoBuildExecutor executor = (MavenTwoBuildExecutor) lookup( ContinuumBuildExecutor.class, "maven2" );
68          BuildDefinition buildDefinition = new BuildDefinition();
69          buildDefinition.setArguments( "-N -Dfoo=bar" );
70          Project continuumProject = new Project()
71          {
72              {
73                  setVersion( "1.0.3" );
74              }
75          };
76          final ChangeFile changeFile = new ChangeFile();
77          changeFile.setName( "continuum-notifiers/pom.xml");
78          ChangeSet changeSet = new ChangeSet()
79          {
80              {
81                  addFile( changeFile );
82              }
83          };
84          List<ChangeSet> changeSets = new ArrayList<ChangeSet>();
85          changeSets.add( changeSet );
86          assertFalse( executor.shouldBuild(changeSets , continuumProject,
87                                             new File( "target/test-classes/projects/continuum" ), buildDefinition ) );
88      }    
89      
90      public void testShouldBuildRecursiveChangeInAModule()
91          throws Exception
92      {
93          MavenTwoBuildExecutor executor = (MavenTwoBuildExecutor) lookup( ContinuumBuildExecutor.class, "maven2" );
94          BuildDefinition buildDefinition = new BuildDefinition();
95          buildDefinition.setArguments( "-Dfoo=bar" );
96          Project continuumProject = new Project()
97          {
98              {
99                  setVersion( "1.0.3" );
100             }
101         };
102         final ChangeFile changeFile = new ChangeFile();
103         changeFile.setName( "continuum-notifiers/pom.xml" );
104         ChangeSet changeSet = new ChangeSet()
105         {
106             {
107                 addFile( changeFile );
108             }
109         };
110         List<ChangeSet> changeSets = new ArrayList<ChangeSet>();
111         changeSets.add( changeSet );
112         assertTrue( executor.shouldBuild( changeSets, continuumProject,
113                                           new File( "target/test-classes/projects/continuum" ), buildDefinition ) );
114     }       
115 }