View Javadoc
1   package org.apache.maven.scm.provider.integrity.command.checkin;
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.maven.scm.CommandParameter;
23  import org.apache.maven.scm.provider.integrity.command.IntegrityCommandTest;
24  import org.apache.maven.scm.provider.integrity.command.edit.IntegrityEditCommand;
25  
26  import java.io.BufferedWriter;
27  import java.io.File;
28  import java.io.FileWriter;
29  
30  /**
31   * IntegrityCheckInCommandTest unit test class
32   *
33   * @author <a href="mailto:cletus@mks.com">Cletus D'Souza</a>
34   */
35  public class IntegrityCheckInCommandTest
36      extends IntegrityCommandTest
37  {
38      /**
39       * Sets up this unit test for execution
40       */
41      public void setUp()
42          throws Exception
43      {
44          super.setUp();
45      }
46  
47      /**
48       * Executes the IntegrityCheckInCommand and validates the result
49       *
50       * @throws Exception
51       */
52      public void testCheckInCommandTest()
53          throws Exception
54      {
55          // First we need to make the workspace writable
56          IntegrityEditCommand edit = new IntegrityEditCommand();
57          edit.setLogger( logger );
58          assertResultIsSuccess( edit.execute( iRepo, fileSet, parameters ) );
59          // Now lets add something to the file we added in the add test
60          String nl = System.getProperty( "line.separator" );
61          BufferedWriter bw =
62              new BufferedWriter( new FileWriter( fileSet.getBasedir() + File.separator + fileName, true ) );
63          bw.write( nl + nl + "A new change appended to file by the check-in command test" + nl );
64          bw.flush();
65          bw.close();
66          // Set the message parameter required for the check-in command to work
67          parameters.setString( CommandParameter.MESSAGE, "Attempting change to an existing file " + fileName );
68          // Now execute the check-in command and validate the results
69          IntegrityCheckInCommand checkin = new IntegrityCheckInCommand();
70          checkin.setLogger( logger );
71          assertResultIsSuccess( checkin.execute( iRepo, fileSet, parameters ) );
72      }
73  }
74