package com.perforce.maven.scm.provider.p4.command.info; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.ScmTckTestCase; import org.apache.maven.scm.command.info.InfoScmResult; import org.apache.maven.scm.provider.ScmProvider; import org.codehaus.plexus.util.FileUtils; import org.junit.Assert; import com.perforce.maven.scm.provider.p4.P4ScmTestUtils; public class P4InfoCommandTckTest extends ScmTckTestCase // There is no Info command TCK test, so we write our own { /** {@inheritDoc} */ public String getScmUrl() throws Exception { return P4ScmTestUtils.getScmUrl(); } /** {@inheritDoc} */ public void initRepo() throws Exception { P4ScmTestUtils.initRepo(); resetToOriginalFiles(); } private long initialRevision = 0; private void resetToOriginalFiles() throws Exception { checkOut( getWorkingCopy(), getScmRepository() ); initialRevision = this.geRevision( null ); ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), P4ScmTestUtils.getAddedIncludes(), null ); getScmManager().getProviderByUrl( getScmUrl() ).remove( getScmRepository(), fileSet, "Remove previous test files" ); fileSet = new ScmFileSet( getWorkingDirectory(), P4ScmTestUtils.getTestIncludes(), null ); getScmManager().getProviderByUrl( getScmUrl() ).edit( getScmRepository(), fileSet ); P4ScmTestUtils.populateOriginalData( getBasedir(), getWorkingCopy() ); checkIn( getWorkingCopy(), getScmRepository() ); FileUtils.deleteDirectory( getWorkingDirectory() ); } @SuppressWarnings( "deprecation" ) public void testInfoCommand() throws Exception { long latestRevision = this.geRevision( null ); Assert.assertEquals( initialRevision + 1, latestRevision ); String tag = getTagName(); getScmManager().getProviderByUrl( getScmUrl() ).tag( getScmRepository(), new ScmFileSet( getWorkingCopy() ), tag ); Assert.assertEquals( latestRevision, geRevision( tag ) ); } private long geRevision( String tagName ) throws Exception { CommandParameters parameters = null; if ( tagName != null ) { parameters = new CommandParameters(); parameters.setScmVersion( CommandParameter.SCM_VERSION, new ScmTag( tagName ) ); } ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() ); ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() ); InfoScmResult result = provider.info( getScmRepository().getProviderRepository(), fileSet, parameters ); return Long.parseLong( result.getInfoItems().get( 0 ).getLastChangedRevision() ); } private String getTagName() { return "groupId:artifactId:tck-info-" + System.currentTimeMillis(); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 11508 | dantran | Add test to covert both obtain revision from last sync and from repo | ||
#3 | 11506 | dantran | Minor typos cleanup | ||
#2 | 11424 | dantran |
- P4Java logs are no under debug mode to reduce verbosity. To enable, pass in -X into mvn command - Info command now supports tag - Add p4java into export extension - Use BSD for license name - Update doc |
||
#1 | 11392 | dantran |
Add missing provider info implementation. This is needed by buildnumber-maven-plugin to create build number using latest changelist |