Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -30,22 +30,30 @@
import org.junit.Before;
/**
- * @author stevemoyer
- *
+ *
+ * @author swm16 (swm16@psu.edu)
*/
public abstract class AbstractJbossMavenPluginMojoTestCase extends AbstractMojoTestCase {
@Before
public void setUp() throws Exception {
-
+ super.setUp();
}
@After
public void tearDown() throws Exception {
-
+ super.tearDown();
}
- private Settings getSettings(File userSettingsFile) throws IOException {
+ /**
+ * Gets a settings.xml file from the input File and prepares it to be
+ * attached to a pom.xml
+ *
+ * @param a file object pointing to the candidate settings file
+ * @return the settings object
+ * @throws IOException - if the settings file can't be read
+ */
+ private Settings getSettingsFile(File userSettingsFile) throws IOException {
Map<String, ?> options = Collections.singletonMap( SettingsReader.IS_STRICT, Boolean.TRUE );
SettingsReader reader = new DefaultSettingsReader();
@@ -59,23 +67,50 @@ private Settings getSettings(File userSettingsFile) throws IOException {
return settings;
}
+ /**
+ * Creates a File object from the fileName provided and verifies that it
+ * exists.
+ *
+ * @param fileName the path of the test file
+ * @return a verified File object
+ */
public File getTestFileAndVerify(String fileName) {
- File pom = getTestFile(fileName);
- assertNotNull(pom);
- assertTrue(pom.exists());
- return pom;
+ File file = getTestFile(fileName);
+ assertNotNull(file);
+ assertTrue(file.exists());
+ return file;
}
+ /**
+ * Looks up the specified mojo by name, passing it the POM file that
+ * references it, then verifying that the lookup was successful.
+ *
+ * @param mojoName the name of the mojo being tested
+ * @param pomFile the pom.xml file to be used during testing
+ * @return the Mojo object under test
+ * @throws Exception if the mojo can not be found
+ */
public Mojo lookupMojoAndVerify(String mojoName, File pomFile) throws Exception {
Mojo mojo = lookupMojo(mojoName, pomFile);
assertNotNull(mojo);
return mojo;
}
+ /**
+ * Looks up the specified mojo by name, passing it the POM file that
+ * references it and a settings file that configures it, then verifying
+ * that the lookup was successful.
+ *
+ * @param mojoName the name of the mojo being tested
+ * @param pomFile the pom.xml file to be used during testing
+ * @param settingsFile the settings.xml file to be used during testing
+ * @return the Mojo object under test
+ * @throws Exception if the mojo can not be found
+ */
public Mojo lookupMojoVerifyAndApplySettings(String mojoName, File pomFile, File settingsFile) throws Exception {
Mojo mojo = lookupMojo(mojoName, pomFile);
assertNotNull(mojo);
- setVariableValueToObject(mojo, "settings", getSettings(settingsFile));
+ setVariableValueToObject(mojo, "settings", getSettingsFile(settingsFile));
return mojo;
}
Please sign in to comment.
Something went wrong with that request. Please try again.