use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AccuRevChangeLogCommandTest method testChangeLogFailed.
@Test
public void testChangeLogFailed() throws Exception {
// Workspace to root stream, keeps and promotes
// Setup test data so that the checkin area is the repo's project path.
final ScmFileSet testFileSet = new ScmFileSet(new File(basedir, "project/dir"));
final Date dateFrom = getDate(2009, 0, 01, 10, 00, 00, null);
final Date dateTo = getDate(2009, 0, 12, 13, 00, 00, null);
// start tran (35)
List<Transaction> startTransaction = Collections.singletonList(new Transaction(35L, new Date(), "sometran", "anyone"));
when(accurev.history("myStream", "2009/01/01 10:00:00", null, 1, true, true)).thenReturn(startTransaction);
// end tran (42)
List<Transaction> endTransaction = Collections.singletonList(new Transaction(42L, new Date(), "sometran", "anyone"));
when(accurev.history("myStream", "2009/01/12 13:00:00", null, 1, true, true)).thenReturn(endTransaction);
when(accurev.history(eq("myStream"), any(String.class), any(String.class), eq(0), eq(false), eq(false))).thenReturn(null);
AccuRevChangeLogCommand command = new AccuRevChangeLogCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString(CommandParameter.MESSAGE, "A commit message");
commandParameters.setDate(CommandParameter.START_DATE, dateFrom);
commandParameters.setDate(CommandParameter.END_DATE, dateTo);
ChangeLogScmResult result = command.changelog(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(false));
assertThat(result.getProviderMessage(), notNullValue());
}
use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AccuRevCheckInCommandTest method testCheckInFailure.
@Test
public void testCheckInFailure() throws Exception {
// Setup test data so that the checkin area is the repo's project path.
final ScmFileSet testFileSet = new ScmFileSet(new File(basedir, "project/dir"));
final File basedir = testFileSet.getBasedir();
final AccuRevInfo info = new AccuRevInfo(basedir);
info.setTop(basedir.getAbsolutePath());
when(accurev.info(basedir)).thenReturn(info);
when(accurev.promoteAll(basedir, "A commit message")).thenReturn(null);
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(false));
assertThat(result.getProviderMessage(), notNullValue());
}
use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AccuRevLoginCommandTest method testWhenAlreadyLoggedInAsRequiredUser.
@Test
public void testWhenAlreadyLoggedInAsRequiredUser() throws Exception {
repo.setUser("myUser");
repo.setPassword("aPassword");
info.setUser("myUser");
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));
// This is an important case as logging in will start an expiry timer
// that might be shorter than the current expiry timer!
verify(accurev, never()).login(eq("myUser"), anyString());
}
use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.
the class AccuRevLoginCommandTest method testWhenAlreadyLoggedInAsSomeoneElse.
@Test
public void testWhenAlreadyLoggedInAsSomeoneElse() throws Exception {
repo.setUser("myUser");
repo.setPassword("aPassword");
info.setUser("A.N.Other");
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 AccuRevAddCommandTest method testAdd.
@Test
public void testAdd() throws Exception {
final ScmFileSet testFileSet = new ScmFileSet(basedir, new File("src/main/java/Foo.java"));
final List<File> files = testFileSet.getFileList();
when(accurev.add(basedir, files, "A new file")).thenReturn(Collections.singletonList(new File("added/file")));
AccuRevAddCommand command = new AccuRevAddCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString(CommandParameter.MESSAGE, "A new file");
AddScmResult result = command.add(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(true));
assertThat(result.getAddedFiles().size(), is(1));
assertHasScmFile(result.getAddedFiles(), "added/file", ScmFileStatus.ADDED);
}
Aggregations