001package org.apache.maven.scm.provider.integrity.command.checkin; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.scm.CommandParameter; 023import org.apache.maven.scm.provider.integrity.command.IntegrityCommandTest; 024import org.apache.maven.scm.provider.integrity.command.edit.IntegrityEditCommand; 025 026import java.io.BufferedWriter; 027import java.io.File; 028import java.io.FileWriter; 029 030/** 031 * IntegrityCheckInCommandTest unit test class 032 * 033 * @author <a href="mailto:cletus@mks.com">Cletus D'Souza</a> 034 */ 035public class IntegrityCheckInCommandTest 036 extends IntegrityCommandTest 037{ 038 /** 039 * Sets up this unit test for execution 040 */ 041 public void setUp() 042 throws Exception 043 { 044 super.setUp(); 045 } 046 047 /** 048 * Executes the IntegrityCheckInCommand and validates the result 049 * 050 * @throws Exception 051 */ 052 public void testCheckInCommandTest() 053 throws Exception 054 { 055 // First we need to make the workspace writable 056 IntegrityEditCommand edit = new IntegrityEditCommand(); 057 edit.setLogger( logger ); 058 assertResultIsSuccess( edit.execute( iRepo, fileSet, parameters ) ); 059 // Now lets add something to the file we added in the add test 060 String nl = System.getProperty( "line.separator" ); 061 BufferedWriter bw = 062 new BufferedWriter( new FileWriter( fileSet.getBasedir() + File.separator + fileName, true ) ); 063 bw.write( nl + nl + "A new change appended to file by the check-in command test" + nl ); 064 bw.flush(); 065 bw.close(); 066 // Set the message parameter required for the check-in command to work 067 parameters.setString( CommandParameter.MESSAGE, "Attempting change to an existing file " + fileName ); 068 // Now execute the check-in command and validate the results 069 IntegrityCheckInCommand checkin = new IntegrityCheckInCommand(); 070 checkin.setLogger( logger ); 071 assertResultIsSuccess( checkin.execute( iRepo, fileSet, parameters ) ); 072 } 073} 074