Skip to content

Commit 7df63ae

Browse files
author
Mathias de Riese
committed
MDEPLOY-118: fix path-handling in surefire tests for Windows.
1 parent c6cb079 commit 7df63ae

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public void testBasicDeploy()
179179
assertEquals( "deploy-test", repo.getId() );
180180
assertEquals( "deploy-test", repo.getKey() );
181181
assertEquals( "file", repo.getProtocol() );
182-
assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() );
182+
assertEquals( "file://" + new File( getBasedir(), "/target/remote-repo/basic-deploy-test" ), repo.getUrl() );
183183

184184
mojo.execute();
185185

@@ -289,7 +289,7 @@ public void testSkippingDeploy()
289289
assertEquals( "deploy-test", repo.getId() );
290290
assertEquals( "deploy-test", repo.getKey() );
291291
assertEquals( "file", repo.getProtocol() );
292-
assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() );
292+
assertEquals( "file://" + new File( getBasedir(), "/target/remote-repo/basic-deploy-test" ), repo.getUrl() );
293293

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

@@ -717,13 +717,15 @@ public void testComparePomWithDeployed()
717717
}
718718
catch( MojoFailureException e )
719719
{
720-
assertEquals( e.getMessage(),
721-
"Project version org.apache.maven.test:maven-deploy-test:1.0 already deployed with a differing POM.");
722-
assertEquals( e.getLongMessage(),
720+
assertEquals(
721+
"Project version org.apache.maven.test:maven-deploy-test:1.0 already deployed with a differing POM.",
722+
e.getMessage() );
723+
assertEquals(
723724
"Project version org.apache.maven.test:maven-deploy-test:1.0 already deployed and the POM "
724725
+ "'org.apache.maven.test:maven-deploy-test:pom:1.0' deployed in repository "
725726
+ "'file://" + remoteRepo.getPath() + "' differs from the POM that would be deployed. "
726-
+ "No artifacts will be deployed.");
727+
+ "No artifacts will be deployed.",
728+
e.getLongMessage() );
727729
}
728730

729731
//check the artifacts in remote repository

src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* under the License.
2020
*/
2121

22+
import java.io.File;
2223
import org.apache.maven.artifact.Artifact;
2324
import org.apache.maven.artifact.metadata.ArtifactMetadata;
2425
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -31,18 +32,18 @@ public class ArtifactRepositoryStub
3132
extends StubArtifactRepository
3233
{
3334
private boolean blacklisted;
34-
35+
3536
private ArtifactRepositoryLayout layout;
36-
37+
3738
private String url;
38-
39+
3940
private String basedir = System.getProperty( "basedir" );
40-
41+
4142
public ArtifactRepositoryStub()
4243
{
4344
super( null );
4445
}
45-
46+
4647
public ArtifactRepositoryStub( String dir )
4748
{
4849
super( dir );
@@ -52,54 +53,54 @@ public String pathOf( Artifact artifact )
5253
{
5354
return getLayout().pathOf( artifact );
5455
}
55-
56+
5657
public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
5758
{
5859
return getLayout().pathOfRemoteRepositoryMetadata( artifactMetadata );
5960
}
60-
61+
6162
public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
6263
{
6364
return getLayout().pathOfLocalRepositoryMetadata( metadata, repository );
6465
}
65-
66+
6667
public String getUrl()
6768
{
6869
return url;
6970
}
70-
71+
7172
public void setAppendToUrl( String dir )
7273
{
73-
this.url = "file://" + basedir + "/target/remote-repo/" + dir;
74+
this.url = "file://" + new File( basedir + "/target/remote-repo/", dir ).getPath();
7475
}
75-
76+
7677
public String getBasedir()
7778
{
7879
return basedir;
7980
}
80-
81+
8182
public String getProtocol()
8283
{
8384
return "file";
8485
}
85-
86+
8687
public String getId()
8788
{
8889
return "deploy-test";
8990
}
90-
91+
9192
public ArtifactRepositoryPolicy getSnapshots()
9293
{
9394
return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
9495
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
9596
}
96-
97+
9798
public ArtifactRepositoryPolicy getReleases()
9899
{
99100
return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
100101
ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
101102
}
102-
103+
103104
public ArtifactRepositoryLayout getLayout()
104105
{
105106
if( layout != null )
@@ -111,7 +112,7 @@ public ArtifactRepositoryLayout getLayout()
111112
return new DefaultRepositoryLayout();
112113
}
113114
}
114-
115+
115116
public String getKey()
116117
{
117118
return getId();
@@ -121,7 +122,7 @@ public boolean isUniqueVersion()
121122
{
122123
return false;
123124
}
124-
125+
125126
public void setBlacklisted( boolean blackListed )
126127
{
127128
this.blacklisted = blackListed;

0 commit comments

Comments
 (0)