001package org.apache.maven.scm.provider.jazz;
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;
023import java.util.ArrayList;
024import java.util.Iterator;
025import java.util.List;
026
027import org.apache.maven.scm.ScmFileSet;
028import org.apache.maven.scm.ScmTestCase;
029import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
030
031/**
032 * The base class for our Jazz test cases.
033 * It sets up a dummy JazzScmProviderRepository for testing purposes.
034 * 
035 * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
036 */
037public abstract class JazzScmTestCase
038    extends ScmTestCase
039{
040
041    /**
042     * Get a dummy JazzScmProviderRepostitory to allow us to test.
043     * @return The dummy JazzScmProviderRepository.
044     */
045    protected JazzScmProviderRepository getScmProviderRepository()
046    {
047        return new JazzScmProviderRepository( "https://localhost:9443/jazz", "myUserName", "myPassword",
048                                              "localhost", 9443, "Dave's Repository Workspace" );
049    }
050
051    /**
052     * Return a list of our files, space separated as a single string.
053     * @return The list of files.
054     */
055    protected String getFiles()
056    {
057        String path = "";
058        for ( Iterator<File> it = getScmFileSet().getFileList().iterator(); it.hasNext(); )
059        {
060            File file = (File) it.next();
061            path += file.getName() + " ";
062        }
063        return path.trim();
064    }
065
066    /**
067     * Return a dummy set of files.
068     * @return A ScmFileSet of dummy files to allow us to test. 
069     */
070    protected ScmFileSet getScmFileSet()
071    {
072        File file1 = new File( "file1" );
073        File file2 = new File( "file2" );
074        List<File> fileList = new ArrayList<File>();
075
076        fileList.add( file1 );
077        fileList.add( file2 );
078
079        return new ScmFileSet( getWorkingDirectory(), fileList );
080    }
081}