Search in sources :

Example 6 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevTagCommand method executeAccurevCommand.

@Override
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
    AccuRev accuRev = repository.getAccuRev();
    String snapshotName = parameters.getString(CommandParameter.TAG_NAME);
    snapshotName = repository.getSnapshotName(snapshotName);
    File basedir = fileSet.getBasedir();
    boolean success = true;
    AccuRevInfo info = accuRev.info(basedir);
    List<File> taggedFiles = null;
    success = accuRev.mksnap(snapshotName, info.getBasis());
    if (success) {
        taggedFiles = accuRev.statTag(snapshotName);
    }
    if (success && taggedFiles != null) {
        return new TagScmResult(accuRev.getCommandLines(), getScmFiles(taggedFiles, ScmFileStatus.TAGGED));
    } else {
        return new TagScmResult(accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(), false);
    }
}
Also used : AccuRev(org.apache.maven.scm.provider.accurev.AccuRev) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) File(java.io.File) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo)

Example 7 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevTagCommandTest method testTag.

@Test
public void testTag() throws Exception {
    final ScmFileSet testFileSet = new ScmFileSet(new File("/my/workspace/project/dir"));
    final File basedir = testFileSet.getBasedir();
    final String basisStream = "basisStream";
    final AccuRevInfo info = new AccuRevInfo(basedir);
    info.setBasis(basisStream);
    AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
    repo.setStreamName("myStream");
    repo.setAccuRev(accurev);
    repo.setProjectPath("/project/dir");
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.mksnap("theTagName", basisStream)).thenReturn(Boolean.TRUE);
    List<File> taggedFiles = Collections.singletonList(new File("tagged/file"));
    when(accurev.statTag("theTagName")).thenReturn(taggedFiles);
    AccuRevTagCommand command = new AccuRevTagCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.TAG_NAME, "theTagName");
    TagScmResult result = command.tag(repo, testFileSet, commandParameters);
    assertThat(result.isSuccess(), is(true));
    assertThat(result.getTaggedFiles().size(), is(1));
    assertHasScmFile(result.getTaggedFiles(), "tagged/file", ScmFileStatus.TAGGED);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) AccuRevScmProviderRepository(org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository) CommandParameters(org.apache.maven.scm.CommandParameters) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) File(java.io.File) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 8 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AbstractAccuRevCommandTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    logger = AccuRevJUnitUtil.getLogger(getContainer());
    basedir = getWorkingCopy();
    sequence = inOrder(accurev);
    info = new AccuRevInfo(basedir);
    info.setUser("me");
    when(accurev.getCommandLines()).thenReturn("accurev mock");
    when(accurev.getErrorOutput()).thenReturn("accurev mock error output");
    when(accurev.getClientVersion()).thenReturn("4.9.0");
    when(accurev.showStream("myStream")).thenReturn(new Stream("myStream", 10L, "myDepot", 1L, "myDepot", new Date(), "normal"));
    when(accurev.info(null)).thenReturn(info);
    when(accurev.info(basedir)).thenReturn(info);
    repo.setLogger(getLogger());
    repo.setStreamName("myStream");
    repo.setAccuRev(accurev);
    repo.setProjectPath("/project/dir");
}
Also used : Stream(org.apache.maven.scm.provider.accurev.Stream) InputStream(java.io.InputStream) Date(java.util.Date) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Before(org.junit.Before)

Example 9 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevCheckInCommandTest method testCheckInRecursive.

@Test
public void testCheckInRecursive() 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);
    List<File> promotedFiles = Arrays.asList(new File("kept/file"), new File("promoted/file"));
    when(accurev.promoteAll(basedir, "A commit message")).thenReturn(promotedFiles);
    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(), "kept/file", ScmFileStatus.CHECKED_IN);
    assertHasScmFile(result.getCheckedInFiles(), "promoted/file", ScmFileStatus.CHECKED_IN);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) 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) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 10 with AccuRevInfo

use of org.apache.maven.scm.provider.accurev.AccuRevInfo in project maven-scm by apache.

the class AccuRevCheckInCommandTest method testCheckinRecursiveSubDirectoryNotSupported.

@Test(expected = ScmException.class)
public void testCheckinRecursiveSubDirectoryNotSupported() throws AccuRevException, ScmException {
    final ScmFileSet testFileSet = new ScmFileSet(basedir);
    final AccuRevInfo info = new AccuRevInfo(basedir);
    info.setTop(basedir.getParent());
    // TODO test basedir is top + project path. is OK.
    when(accurev.info(basedir)).thenReturn(info);
    AccuRevCheckInCommand command = new AccuRevCheckInCommand(getLogger());
    CommandParameters commandParameters = new CommandParameters();
    commandParameters.setString(CommandParameter.MESSAGE, "Commit message");
    command.checkIn(repo, testFileSet, commandParameters);
    fail("Expected ScmException");
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) CommandParameters(org.apache.maven.scm.CommandParameters) AccuRevInfo(org.apache.maven.scm.provider.accurev.AccuRevInfo) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Aggregations

AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)18 File (java.io.File)10 Test (org.junit.Test)8 AccuRev (org.apache.maven.scm.provider.accurev.AccuRev)6 CommandParameters (org.apache.maven.scm.CommandParameters)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)5 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)5 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)4 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)3 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)3 AccuRevException (org.apache.maven.scm.provider.accurev.AccuRevException)3 ScmFile (org.apache.maven.scm.ScmFile)2 AccuRevScmProviderRepository (org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository)2 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ScmException (org.apache.maven.scm.ScmException)1 ScmVersion (org.apache.maven.scm.ScmVersion)1