Search in sources :

Example 61 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevCheckInCommandTest method testCheckinExplicitFiles.

@Test
public void testCheckinExplicitFiles() throws Exception {
    final List<File> files = new ArrayList<File>();
    files.add(new File("project/dir/pom.xml"));
    files.add(new File("project/dir/src/main/java/Bar.java"));
    final ScmFileSet testFileSet = new ScmFileSet(basedir, files);
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.promote(basedir, files, "A commit message")).thenReturn(files);
    AccuRevCheckInCommand command = new AccuRevCheckInCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "A commit message");
    CheckInScmResult result = command.checkIn(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getCheckedInFiles().size(), is(2));
    assertHasScmFile(result.getCheckedInFiles(), "project/dir/pom.xml", ScmFileStatus.CHECKED_IN);
    assertHasScmFile(result.getCheckedInFiles(), "project/dir/src/main/java/Bar.java", ScmFileStatus.CHECKED_IN);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ArrayList(java.util.ArrayList) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 62 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevLoginCommandTest method testWhenNotLoggedIn.

@Test
public void testWhenNotLoggedIn() throws Exception {
    repo.setUser("myUser");
    repo.setPassword("aPassword");
    info.setUser("(not logged in)");
    when(accurev.info(any(File.class))).thenReturn(info);
    when(accurev.login("myUser", "aPassword")).thenReturn(true);
    AccuRevLoginCommand command = new AccuRevLoginCommand(getLogger());
    LoginScmResult result = command.login(repo, new ScmFileSet(basedir), new CommandParameters());
    assertThat(result.isSuccess(), is(true));
    verify(accurev).login("myUser", "aPassword");
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) LoginScmResult(org.apache.maven.scm.command.login.LoginScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 63 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevLoginCommandTest method testWhenNoUserSuppliedAndAlreadyLoggedIn.

@Test
public void testWhenNoUserSuppliedAndAlreadyLoggedIn() throws Exception {
    repo.setUser(null);
    info.setUser("anyUser");
    when(accurev.info(any(File.class))).thenReturn(info);
    AccuRevLoginCommand command = new AccuRevLoginCommand(getLogger());
    LoginScmResult result = command.login(repo, new ScmFileSet(basedir), new CommandParameters());
    assertThat(result.isSuccess(), is(true));
    verify(accurev, never()).login(anyString(), anyString());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) LoginScmResult(org.apache.maven.scm.command.login.LoginScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 64 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AccuRevLoginCommandTest method testFailsWhenNoUserSuppliedAndNotLoggedIn.

@Test
public void testFailsWhenNoUserSuppliedAndNotLoggedIn() throws Exception {
    repo.setUser(null);
    info.setUser("(not logged in)");
    when(accurev.info(any(File.class))).thenReturn(info);
    AccuRevLoginCommand command = new AccuRevLoginCommand(getLogger());
    LoginScmResult result = command.login(repo, new ScmFileSet(basedir), new CommandParameters());
    assertThat(result.isSuccess(), is(false));
    verify(accurev, never()).login(anyString(), anyString());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) LoginScmResult(org.apache.maven.scm.command.login.LoginScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 65 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AbstractCvsMkdirCommand method executeMkdirCommand.

/**
 * {@inheritDoc}
 */
protected MkdirScmResult executeMkdirCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) throws ScmException {
    CommandParameters parameters = new CommandParameters();
    parameters.setString(CommandParameter.MESSAGE, message == null ? "" : message);
    parameters.setString(CommandParameter.BINARY, "false");
    // just invoke add command
    Command cmd = getAddCommand();
    cmd.setLogger(getLogger());
    ScmResult addResult = cmd.execute(repository, fileSet, parameters);
    if (!addResult.isSuccess()) {
        return new MkdirScmResult(addResult.getCommandLine().toString(), "The cvs command failed.", addResult.getCommandOutput(), false);
    }
    List<ScmFile> addedFiles = new ArrayList<ScmFile>();
    for (File file : fileSet.getFileList()) {
        ScmFile scmFile = new ScmFile(file.getPath(), ScmFileStatus.ADDED);
        addedFiles.add(scmFile);
    }
    return new MkdirScmResult(addResult.getCommandLine().toString(), addedFiles);
}
Also used : MkdirScmResult(org.apache.maven.scm.command.mkdir.MkdirScmResult) ScmResult(org.apache.maven.scm.ScmResult) AbstractMkdirCommand(org.apache.maven.scm.command.mkdir.AbstractMkdirCommand) Command(org.apache.maven.scm.command.Command) MkdirScmResult(org.apache.maven.scm.command.mkdir.MkdirScmResult) ArrayList(java.util.ArrayList) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

CommandParameters (org.apache.maven.scm.CommandParameters)68 ScmFileSet (org.apache.maven.scm.ScmFileSet)44 File (java.io.File)39 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)38 Test (org.junit.Test)38 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)23 ScmFile (org.apache.maven.scm.ScmFile)8 ScmTag (org.apache.maven.scm.ScmTag)7 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)7 Date (java.util.Date)6 ChangeFile (org.apache.maven.scm.ChangeFile)5 ChangeFileMatcher.changeFile (org.apache.maven.scm.ChangeFileMatcher.changeFile)5 ScmRevision (org.apache.maven.scm.ScmRevision)5 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)5 InfoScmResult (org.apache.maven.scm.command.info.InfoScmResult)5 LoginScmResult (org.apache.maven.scm.command.login.LoginScmResult)5 AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)5 Transaction (org.apache.maven.scm.provider.accurev.Transaction)5 ArrayList (java.util.ArrayList)4 ScmException (org.apache.maven.scm.ScmException)4