package com.perforce.maven.scm.provider.p4.command.tag; /* * Copyright (c) 2010 Perforce Software. All rights reserved. */ import java.io.File; import java.io.FileWriter; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.command.checkin.CheckInScmResult; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.command.tag.TagScmResult; import org.apache.maven.scm.tck.command.tag.TagCommandTckTest; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import com.perforce.maven.scm.provider.p4.P4ScmTestUtils; public class P4TagCommandTckTest extends TagCommandTckTest { /** {@inheritDoc} */ public String getScmUrl() throws Exception { return P4ScmTestUtils.getScmUrl(); } /** {@inheritDoc} */ public void initRepo() throws Exception { P4ScmTestUtils.initRepo(); resetToOrignalFiles(); } public void testTagWithLabelSync() throws Exception { String tag = getTagName(); @SuppressWarnings( "deprecation" ) TagScmResult tagResult = getScmManager().getProviderByUrl( getScmUrl() ).tag( getScmRepository(), new ScmFileSet( getWorkingCopy(), "readme.txt" ), tag ); assertResultIsSuccess( tagResult ); // see https://jira.codehaus.org/browse/SCM-754 // assertEquals( "check all 4 files tagged", 4, tagResult.getTaggedFiles().size() ); File readmeTxt = new File( getWorkingCopy(), "readme.txt" ); assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) ); this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() ); changeReadmeTxt( readmeTxt ); CheckInScmResult checkinResult = getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "commit message" ); assertResultIsSuccess( checkinResult ); CheckOutScmResult checkoutResult = getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); assertResultIsSuccess( checkoutResult ); readmeTxt = new File( getAssertionCopy(), "readme.txt" ); assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead( readmeTxt ) ); deleteDirectory( getAssertionCopy() ); assertFalse( "check previous assertion copy deleted", getAssertionCopy().exists() ); //not sure why next checkout require this directory getAssertionCopy().mkdirs(); checkoutResult = getScmManager().getProviderByUrl( getScmUrl() ).checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ), new ScmTag( tag ) ); assertResultIsSuccess( checkoutResult ); assertEquals( "check readme.txt contents is from tagged version", "/readme.txt", FileUtils.fileRead( readmeTxt ) ); assertFalse( "tag should not have pom.xml due to label sync", new File( getAssertionCopy(), "pom.xml").exists() ); assertEquals( "tag should have only one file", 1, getAssertionCopy().list().length ); } private void resetToOrignalFiles() throws Exception { checkOut( getWorkingCopy(), getScmRepository() ); 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() ); } protected String getTagName() { return "groupId:artifactId:tck-tag-" + System.currentTimeMillis(); } private void changeReadmeTxt( File readmeTxt ) throws Exception { FileWriter output = new FileWriter( readmeTxt ); try { output.write( "changed file" ); } finally { IOUtil.close( output ); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 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 |
||
#6 | 9677 | dantran | test unedit part of checkin test, test tag with label sync | ||
#5 | 9632 | dantran |
- use groupId:artifactId:version to test release automation - Implment p4maven-settings.xml's p4Port field |
||
#4 | 9579 | dantran | dont overwrite existing tag, cleanup Tag command | ||
#3 | 9533 | dantran | source format | ||
#2 | 9525 | dantran | isolate the location of initial dataset into one place | ||
#1 | 9519 | dantran | folder rename to match with its artifactId | ||
//guest/dantran/p4maven/com.perforce.maven/src/test/java/com/perforce/maven/scm/provider/p4/command/tag/P4TagCommandTckTest.java | |||||
#5 | 9509 | dantran | adjust TCK's new data location which under src/it/template | ||
#4 | 9424 | dantran | add list and status TCK | ||
#3 | 9423 | dantran | get all test to use the same setup, handle checkout with tag, need to revisit how we handle ScmVersion | ||
#2 | 9297 | dantran | Add CheckOut TCK Implementation | ||
#1 | 9276 | dantran | Implement maven scm Tag tck test. |