001package org.apache.maven.scm.provider.svn.command.mkdir;
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 java.io.File;
023
024import org.apache.maven.scm.ScmFileSet;
025import org.apache.maven.scm.command.list.ListScmResult;
026import org.apache.maven.scm.command.mkdir.MkdirScmResult;
027import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
028import org.apache.maven.scm.tck.command.mkdir.MkdirCommandTckTest;
029
030/**
031 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
032 *
033 */
034public class SvnMkdirCommandTckTest
035    extends MkdirCommandTckTest
036{
037    /** {@inheritDoc} */
038    public String getScmUrl()
039        throws Exception
040    {
041        return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) );
042    }
043
044    /** {@inheritDoc} */
045    public void initRepo()
046        throws Exception
047    {
048        SvnScmTestUtils.initializeRepository( getRepositoryRoot() );
049    }
050    
051    public void testMkdirCommandMkdirUrl()
052        throws Exception
053    {
054        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) );
055    
056        MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false );
057    
058        assertResultIsSuccess( result );
059    
060        assertNotNull( result.getRevision() );
061    
062        ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null );
063    
064        assertTrue( "Directory should have been found.", listResult.isSuccess() );
065    }
066    
067    public void testMkdirCommandDirAlreadyAdded()
068        throws Exception
069    {
070        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) );
071    
072        MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, null, false );
073    
074        assertResultIsSuccess( result );
075    
076        assertNotNull( result.getRevision() );
077    
078        ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null );
079        
080        assertTrue( "Directory should have been found.", listResult.isSuccess() );
081                
082        // add the directory again
083        result = getScmManager().mkdir( getScmRepository(), fileSet, null, false );
084    
085        printOutputError( result ); 
086        
087        assertFalse( result.isSuccess() );
088    }
089}