Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Cleaned up the utility methods and added comments.

  • Loading branch information...
commit 61d8eefe9e07fad334f4f95dffc41cdec8787d41 1 parent d028989
Steve Moyer authored
55 src/test/java/org/jboss/as/plugin/common/AbstractJbossMavenPluginMojoTestCase.java
@@ -30,22 +30,30 @@
30 30 import org.junit.Before;
31 31
32 32 /**
33   - * @author stevemoyer
34   - *
  33 + *
  34 + * @author swm16 (swm16@psu.edu)
35 35 */
36 36 public abstract class AbstractJbossMavenPluginMojoTestCase extends AbstractMojoTestCase {
37 37
38 38 @Before
39 39 public void setUp() throws Exception {
40   -
  40 + super.setUp();
41 41 }
42 42
43 43 @After
44 44 public void tearDown() throws Exception {
45   -
  45 + super.tearDown();
46 46 }
47 47
48   - private Settings getSettings(File userSettingsFile) throws IOException {
  48 + /**
  49 + * Gets a settings.xml file from the input File and prepares it to be
  50 + * attached to a pom.xml
  51 + *
  52 + * @param a file object pointing to the candidate settings file
  53 + * @return the settings object
  54 + * @throws IOException - if the settings file can't be read
  55 + */
  56 + private Settings getSettingsFile(File userSettingsFile) throws IOException {
49 57 Map<String, ?> options = Collections.singletonMap( SettingsReader.IS_STRICT, Boolean.TRUE );
50 58 SettingsReader reader = new DefaultSettingsReader();
51 59
@@ -59,23 +67,50 @@ private Settings getSettings(File userSettingsFile) throws IOException {
59 67 return settings;
60 68 }
61 69
  70 + /**
  71 + * Creates a File object from the fileName provided and verifies that it
  72 + * exists.
  73 + *
  74 + * @param fileName the path of the test file
  75 + * @return a verified File object
  76 + */
62 77 public File getTestFileAndVerify(String fileName) {
63   - File pom = getTestFile(fileName);
64   - assertNotNull(pom);
65   - assertTrue(pom.exists());
66   - return pom;
  78 + File file = getTestFile(fileName);
  79 + assertNotNull(file);
  80 + assertTrue(file.exists());
  81 + return file;
67 82 }
68 83
  84 + /**
  85 + * Looks up the specified mojo by name, passing it the POM file that
  86 + * references it, then verifying that the lookup was successful.
  87 + *
  88 + * @param mojoName the name of the mojo being tested
  89 + * @param pomFile the pom.xml file to be used during testing
  90 + * @return the Mojo object under test
  91 + * @throws Exception if the mojo can not be found
  92 + */
69 93 public Mojo lookupMojoAndVerify(String mojoName, File pomFile) throws Exception {
70 94 Mojo mojo = lookupMojo(mojoName, pomFile);
71 95 assertNotNull(mojo);
72 96 return mojo;
73 97 }
74 98
  99 + /**
  100 + * Looks up the specified mojo by name, passing it the POM file that
  101 + * references it and a settings file that configures it, then verifying
  102 + * that the lookup was successful.
  103 + *
  104 + * @param mojoName the name of the mojo being tested
  105 + * @param pomFile the pom.xml file to be used during testing
  106 + * @param settingsFile the settings.xml file to be used during testing
  107 + * @return the Mojo object under test
  108 + * @throws Exception if the mojo can not be found
  109 + */
75 110 public Mojo lookupMojoVerifyAndApplySettings(String mojoName, File pomFile, File settingsFile) throws Exception {
76 111 Mojo mojo = lookupMojo(mojoName, pomFile);
77 112 assertNotNull(mojo);
78   - setVariableValueToObject(mojo, "settings", getSettings(settingsFile));
  113 + setVariableValueToObject(mojo, "settings", getSettingsFile(settingsFile));
79 114 return mojo;
80 115 }
81 116

0 comments on commit 61d8eef

Please sign in to comment.
Something went wrong with that request. Please try again.