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 * @version $Id: IntegrityCheckInCommandTest.java 1.1 2011/08/29 00:29:54EDT Cletus D'Souza (dsouza) Exp $
35 */
36 public class IntegrityCheckInCommandTest
37 extends IntegrityCommandTest
38 {
39 /**
40 * Sets up this unit test for execution
41 */
42 public void setUp()
43 throws Exception
44 {
45 super.setUp();
46 }
47
48 /**
49 * Executes the IntegrityCheckInCommand and validates the result
50 *
51 * @throws Exception
52 */
53 public void testCheckInCommandTest()
54 throws Exception
55 {
56 // First we need to make the workspace writable
57 IntegrityEditCommand edit = new IntegrityEditCommand();
58 edit.setLogger( logger );
59 assertResultIsSuccess( edit.execute( iRepo, fileSet, parameters ) );
60 // Now lets add something to the file we added in the add test
61 String nl = System.getProperty( "line.separator" );
62 BufferedWriter bw =
63 new BufferedWriter( new FileWriter( fileSet.getBasedir() + File.separator + fileName, true ) );
64 bw.write( nl + nl + "A new change appended to file by the check-in command test" + nl );
65 bw.flush();
66 bw.close();
67 // Set the message parameter required for the check-in command to work
68 parameters.setString( CommandParameter.MESSAGE, "Attempting change to an existing file " + fileName );
69 // Now execute the check-in command and validate the results
70 IntegrityCheckInCommand checkin = new IntegrityCheckInCommand();
71 checkin.setLogger( logger );
72 assertResultIsSuccess( checkin.execute( iRepo, fileSet, parameters ) );
73 }
74 }
75