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.tck.command.checkout;
020
021import java.util.Iterator;
022import java.util.List;
023import java.util.SortedSet;
024import java.util.TreeSet;
025
026import org.apache.maven.scm.ScmFile;
027import org.apache.maven.scm.ScmTckTestCase;
028import org.apache.maven.scm.command.checkout.CheckOutScmResult;
029import org.junit.Test;
030
031import static org.junit.Assert.fail;
032
033/**
034 * This test tests the check out command.
035 *
036 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
037 *
038 */
039public abstract class CheckOutCommandTckTest extends ScmTckTestCase {
040    @Test
041    public void testCheckOutCommandTest() throws Exception {
042        deleteDirectory(getWorkingCopy());
043
044        CheckOutScmResult result = checkOut(getWorkingCopy(), getScmRepository());
045
046        assertResultIsSuccess(result);
047
048        List<ScmFile> checkedOutFiles = result.getCheckedOutFiles();
049
050        if (checkedOutFiles.size() != 4) {
051            SortedSet<ScmFile> files = new TreeSet<>(checkedOutFiles);
052
053            int i = 0;
054
055            for (Iterator<ScmFile> it = files.iterator(); it.hasNext(); i++) {
056                ScmFile scmFile = it.next();
057
058                System.out.println("" + i + ": " + scmFile);
059            }
060
061            fail("Expected 4 files in the updated files list, was " + checkedOutFiles.size());
062        }
063    }
064}