Skip to content

Commit

Permalink
MDEPLOY-118: fix path-handling in surefire tests for Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias de Riese authored and mdrie committed Dec 20, 2022
1 parent 2e2ae57 commit ef26770
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void testBasicDeploy()
assertEquals( "deploy-test", repo.getId() );
assertEquals( "deploy-test", repo.getKey() );
assertEquals( "file", repo.getProtocol() );
assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() );
assertEquals( "file://" + new File( getBasedir(), "/target/remote-repo/basic-deploy-test" ), repo.getUrl() );

mojo.execute();

Expand Down Expand Up @@ -290,7 +290,7 @@ public void testSkippingDeploy()
assertEquals( "deploy-test", repo.getId() );
assertEquals( "deploy-test", repo.getKey() );
assertEquals( "file", repo.getProtocol() );
assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() );
assertEquals( "file://" + new File( getBasedir(), "/target/remote-repo/basic-deploy-test" ), repo.getUrl() );

setVariableValueToObject( mojo, "skip", Boolean.TRUE.toString() );

Expand Down Expand Up @@ -718,13 +718,15 @@ public void testComparePomWithDeployed()
}
catch( MojoFailureException e )
{
assertEquals( e.getMessage(),
"Project version org.apache.maven.test:maven-deploy-test:1.0 already deployed with a differing POM.");
assertEquals( e.getLongMessage(),
assertEquals(
"Project version org.apache.maven.test:maven-deploy-test:1.0 already deployed with a differing POM.",
e.getMessage() );
assertEquals(
"Project version org.apache.maven.test:maven-deploy-test:1.0 already deployed and the POM "
+ "'org.apache.maven.test:maven-deploy-test:pom:1.0' deployed in repository "
+ "'file://" + remoteRepo.getPath() + "' differs from the POM that would be deployed. "
+ "No artifacts will be deployed.");
+ "No artifacts will be deployed.",
e.getLongMessage() );
}

//check the artifacts in remote repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* under the License.
*/

import java.io.File;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
Expand All @@ -31,9 +32,9 @@ public class ArtifactRepositoryStub
extends StubArtifactRepository
{
private boolean blacklisted;

private ArtifactRepositoryLayout layout;

private String url;

private final String basedir = System.getProperty( "basedir" );
Expand All @@ -42,7 +43,7 @@ public ArtifactRepositoryStub()
{
super( null );
}

public ArtifactRepositoryStub( String dir )
{
super( dir );
Expand All @@ -52,54 +53,54 @@ public String pathOf( Artifact artifact )
{
return getLayout().pathOf( artifact );
}

public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
{
return getLayout().pathOfRemoteRepositoryMetadata( artifactMetadata );
}

public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
{
return getLayout().pathOfLocalRepositoryMetadata( metadata, repository );
}

public String getUrl()
{
return url;
}

public void setAppendToUrl( String dir )
{
this.url = "file://" + basedir + "/target/remote-repo/" + dir;
this.url = "file://" + new File( basedir + "/target/remote-repo/", dir ).getPath();
}

public String getBasedir()
{
return basedir;
}

public String getProtocol()
{
return "file";
}

public String getId()
{
return "deploy-test";
}

public ArtifactRepositoryPolicy getSnapshots()
{
return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
}

public ArtifactRepositoryPolicy getReleases()
{
return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
}

public ArtifactRepositoryLayout getLayout()
{
if( layout != null )
Expand All @@ -111,7 +112,7 @@ public ArtifactRepositoryLayout getLayout()
return new DefaultRepositoryLayout();
}
}

public String getKey()
{
return getId();
Expand All @@ -121,7 +122,7 @@ public boolean isUniqueVersion()
{
return false;
}

public void setBlacklisted( boolean blackListed )
{
this.blacklisted = blackListed;
Expand Down

0 comments on commit ef26770

Please sign in to comment.