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 */
037public class SvnMkdirCommandTckTest extends MkdirCommandTckTest {
038    /**
039     * {@inheritDoc}
040     */
041    public String getScmUrl() throws Exception {
042        return SvnScmTestUtils.getScmUrl(new File(getRepositoryRoot(), "trunk"));
043    }
044
045    /**
046     * {@inheritDoc}
047     */
048    public void initRepo() throws Exception {
049        SvnScmTestUtils.initializeRepository(getRepositoryRoot());
050    }
051
052    @Test
053    public void testMkdirCommandMkdirUrl() throws Exception {
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    @Test
068    public void testMkdirCommandDirAlreadyAdded() throws Exception {
069        ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory()));
070
071        MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, null, false);
072
073        assertResultIsSuccess(result);
074
075        assertNotNull(result.getRevision());
076
077        ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null);
078
079        assertTrue("Directory should have been found.", listResult.isSuccess());
080
081        // add the directory again
082        result = getScmManager().mkdir(getScmRepository(), fileSet, null, false);
083
084        printOutputError(result);
085
086        assertFalse(result.isSuccess());
087    }
088}