1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718package org .apache .commons .release .plugin .mojos ;
1819
1920import static junit .framework .TestCase .assertTrue ;
2021import static org .junit .Assert .assertFalse ;
21- import static org .junit .Assert .assertNotNull ;
2222
2323import java .io .File ;
2424
25- import org .apache .maven .plugin .testing .MojoRule ;
25+ import org .apache .maven .api .plugin .testing .InjectMojo ;
26+ import org .apache .maven .api .plugin .testing .MojoTest ;
2627import org .codehaus .plexus .util .FileUtils ;
27- import org .junit .Before ;
28- import org .junit .Rule ;
29- import org .junit .Test ;
28+ import org .junit .jupiter .api .BeforeEach ;
29+ import org .junit .jupiter .api .Test ;
3030
3131/**
3232 * Unit tests for {@link CommonsDistributionStagingMojo}.
3333 */
34+ @ MojoTest
3435public class CommonsDistributionStagingMojoTest {
3536
3637 private static final String COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH = "target/testing-commons-release-plugin" ;
3738
38- @ Rule
39- public final MojoRule rule = new MojoRule () {
40- @ Override
41- protected void after () {
42- // noop
43- }
44-
45- @ Override
46- protected void before () throws Throwable {
47- // noop
48- }
49- };
50-
51- private CommonsDistributionDetachmentMojo detachmentMojo ;
52-
53- private CommonsDistributionStagingMojo mojoForTest ;
54-
5539 private void assertRequisiteFilesExist () {
5640 final File targetScmDirectory = new File (COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1" );
5741 final File releaseNotes = new File (COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/RELEASE-NOTES.txt" );
@@ -105,7 +89,7 @@ private void assertRequisiteFilesExist() {
10589 assertTrue (siteSubdirectoryIndexHtml .exists ());
10690 }
10791
108- @ Before
92+ @ BeforeEach
10993 public void setUp () throws Exception {
11094 final File testingDirectory = new File (COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH );
11195 if (testingDirectory .exists ()) {
@@ -114,26 +98,19 @@ public void setUp() throws Exception {
11498 }
11599
116100 @ Test
117- public void testDisabled () throws Exception {
118- final File testPom = new File ("src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml" );
119- assertNotNull (testPom );
120- assertTrue (testPom .exists ());
121- mojoForTest = (CommonsDistributionStagingMojo ) rule .lookupMojo ("stage-distributions" , testPom );
101+ public void testDisabled (
102+ @ InjectMojo (goal = "stage-distributions" , pom = "src/test/resources/mojos/stage-distributions/stage-distributions-disabled.xml" ) final CommonsDistributionStagingMojo mojoForTest )
103+ throws Exception {
122104 mojoForTest .execute ();
123105 final File testingDirectory = new File (COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH );
124106 assertFalse (testingDirectory .exists ());
125107 }
126108
127109 @ Test
128- public void testSuccess () throws Exception {
129- final File testPom = new File ("src/test/resources/mojos/stage-distributions/stage-distributions.xml" );
130- assertNotNull (testPom );
131- assertTrue (testPom .exists ());
132- final File detachmentPom = new File ("src/test/resources/mojos/detach-distributions/detach-distributions.xml" );
133- assertNotNull (detachmentPom );
134- assertTrue (detachmentPom .exists ());
135- mojoForTest = (CommonsDistributionStagingMojo ) rule .lookupMojo ("stage-distributions" , testPom );
136- detachmentMojo = (CommonsDistributionDetachmentMojo ) rule .lookupMojo ("detach-distributions" , detachmentPom );
110+ public void testSuccess (
111+ @ InjectMojo (goal = "stage-distributions" , pom = "src/test/resources/mojos/stage-distributions/stage-distributions.xml" ) final CommonsDistributionStagingMojo mojoForTest ,
112+ @ InjectMojo (goal = "detach-distributions" , pom = "src/test/resources/mojos/detach-distributions/detach-distributions.xml" ) final CommonsDistributionDetachmentMojo detachmentMojo )
113+ throws Exception {
137114 detachmentMojo .execute ();
138115 final File releaseNotesBasedir = new File ("src/test/resources/mojos/stage-distributions/" );
139116 mojoForTest .setBaseDir (releaseNotesBasedir );
0 commit comments