This repository has been archived by the owner on Jun 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Allow use of settings.xml for credentials. #27
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9b7aaf9
Stubbed out logic to load the username and password from the settings
smoyer64 0d1ec05
Added code to get the username and password from the settings.xml file
smoyer64 75d0401
Added libraries required to process the contents of the settings file as
smoyer64 5ce7f07
Copied a stubbed out example pom.xml and settings.xml file into the
smoyer64 a12a700
Stubbed out a base TestCase with some helper methods and added an empty
smoyer64 0c33375
Eliminated HTTP imports that weren't provided by Maven dependencies (or
smoyer64 d028989
Fixed the annotation on the new settings parameter.
smoyer64 61d8eef
Cleaned up the utility methods and added comments.
smoyer64 6013cf1
Added the rest of the pom.xml files and settings.xml file needed to test
smoyer64 ebe47be
Added the rest of the settings.xml and pom.xml files needed to
smoyer64 6cf9a6b
Added Mockito to the test dependencies so that the plugin's log could be
smoyer64 8904017
Completed the logic that determines how credentials are acquired by the
smoyer64 77b20d5
Finished writing tests for the 6 usable permutations of how credentials
smoyer64 6971ccd
Changed the last few log messages related to the acquisition of
smoyer64 5a086ca
Added version properties for all dependencies.
smoyer64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
src/test/java/org/jboss/as/plugin/common/AbstractJbossMavenPluginMojoTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,117 @@ | |||
/* | |||
* File: MojoTestUtilities.java | |||
* Date: Aug 5, 2011 | |||
* | |||
* Copyright (c) 2011 by Select Systems - All rights reserved. | |||
* | |||
* By: Select Systems | |||
* 111 Heritage Way, Suite S | |||
* Boalsburg, PA 16827 | |||
* | |||
* Revision history: | |||
* | |||
* | |||
*/ | |||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind making the change, but this needs to have the JBoss LGPL license on it. Is that acceptable to you? |
|||
|
|||
package org.jboss.as.plugin.common; | |||
|
|||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Collections; | |||
import java.util.Map; | |||
|
|||
import org.apache.maven.plugin.Mojo; | |||
import org.apache.maven.plugin.testing.AbstractMojoTestCase; | |||
import org.apache.maven.settings.Settings; | |||
import org.apache.maven.settings.io.DefaultSettingsReader; | |||
import org.apache.maven.settings.io.SettingsParseException; | |||
import org.apache.maven.settings.io.SettingsReader; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
|
|||
/** | |||
* | |||
* @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(); | |||
} | |||
|
|||
/** | |||
* 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(); | |||
|
|||
Settings settings = null; | |||
try { | |||
settings = reader.read(userSettingsFile, options); | |||
} catch(SettingsParseException e) { | |||
|
|||
} | |||
|
|||
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 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", getSettingsFile(settingsFile)); | |||
return mojo; | |||
} | |||
|
|||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the versions should use a property in the version.groupId.artifactId format or something similar to the version properties that are already in the POM.