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);
}
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");
}
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());
}
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());
}
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);
}
Aggregations