001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.maven.scm.provider.svn.command.mkdir;
020
021import java.io.File;
022
023import org.apache.maven.scm.ScmFileSet;
024import org.apache.maven.scm.command.list.ListScmResult;
025import org.apache.maven.scm.command.mkdir.MkdirScmResult;
026import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
027import org.apache.maven.scm.tck.command.mkdir.MkdirCommandTckTest;
028import org.junit.Test;
029
030import static org.junit.Assert.assertFalse;
031import static org.junit.Assert.assertNotNull;
032import static org.junit.Assert.assertTrue;
033
034/**
035 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
036 *
037 */
038public class SvnMkdirCommandTckTest extends MkdirCommandTckTest {
039    /** {@inheritDoc} */
040    public String getScmUrl() throws Exception {
041        return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk"));
042    }
043
044    /** {@inheritDoc} */
045    public void initRepo() throws Exception {
046        SvnScmTestUtils.initializeRepository(getRepositoryRoot());
047    }
048
049    @Test
050    public void testMkdirCommandMkdirUrl() throws Exception {
051        ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory()));
052
053        MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false);
054
055        assertResultIsSuccess(result);
056
057        assertNotNull(result.getRevision());
058
059        ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null);
060
061        assertTrue("Directory should have been found.", listResult.isSuccess());
062    }
063
064    @Test
065    public void testMkdirCommandDirAlreadyAdded() throws Exception {
066        ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory()));
067
068        MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, null, false);
069
070        assertResultIsSuccess(result);
071
072        assertNotNull(result.getRevision());
073
074        ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null);
075
076        assertTrue("Directory should have been found.", listResult.isSuccess());
077
078        // add the directory again
079        result = getScmManager().mkdir(getScmRepository(), fileSet, null, false);
080
081        printOutputError(result);
082
083        assertFalse(result.isSuccess());
084    }
085}