1 package org.apache.maven.plugin.failsafe;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.artifact.Artifact;
23 import org.apache.maven.artifact.DefaultArtifact;
24 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
25 import org.apache.maven.project.MavenProject;
26 import org.junit.Before;
27 import org.junit.Test;
28
29 import java.io.File;
30 import java.io.IOException;
31
32 import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec;
33 import static org.mockito.Mockito.mock;
34 import static org.mockito.Mockito.spy;
35 import static org.mockito.Mockito.when;
36 import static org.fest.assertions.Assertions.assertThat;
37
38
39
40
41 public class IntegrationTestMojoTest
42 {
43 private IntegrationTestMojo mojo;
44
45 @Before
46 public void init() throws InvalidVersionSpecificationException, IOException
47 {
48 Artifact artifact = new DefaultArtifact( "g", "a", createFromVersionSpec( "1.0" ), "compile", "jar", "", null );
49 artifact.setFile( new File( "./target/tmp/a-1.0.jar" ) );
50 new File( "./target/tmp" ).mkdir();
51 artifact.getFile().createNewFile();
52 mojo = spy( IntegrationTestMojo.class );
53 MavenProject project = mock( MavenProject.class );
54 when( project.getArtifact() ).thenReturn( artifact );
55 when( mojo.getProject() ).thenReturn( project );
56 }
57
58 @Test
59 public void shouldBeJar()
60 {
61 mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
62 File binaries = mojo.getClassesDirectory();
63 assertThat( binaries.getName() ).isEqualTo( "a-1.0.jar" );
64 }
65
66 @Test
67 public void shouldBeAnotherJar()
68 {
69 mojo.setClassesDirectory( new File( "./target/another-1.0.jar" ) );
70 mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
71 File binaries = mojo.getClassesDirectory();
72 assertThat( binaries.getName() ).isEqualTo( "another-1.0.jar" );
73 }
74
75 @Test
76 public void shouldBeClasses()
77 {
78 mojo.setClassesDirectory( new File( "./target/classes" ) );
79 mojo.setDefaultClassesDirectory( new File( "./target/classes" ) );
80 File binaries = mojo.getClassesDirectory();
81 assertThat( binaries.getName() ).isEqualTo( "classes" );
82 }
83 }