slawekjaranowski commented on code in PR #313:
URL:
https://github.com/apache/maven-remote-resources-plugin/pull/313#discussion_r4287992619
##########
src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java:
##########
@@ -346,69 +398,36 @@ private static void assertContainsInOrder(String actual,
List<String> expected)
int fromIndex = 0;
for (String s : expected) {
int idx = actual.indexOf(s, fromIndex);
- assertTrue("expected \"" + s + "\" to occur in order in: " +
actual, idx >= 0);
+ assertTrue(idx >= 0, "expected \"" + s + "\" to occur in order in:
" + actual);
fromIndex = idx + s.length();
}
}
- protected MavenProjectResourcesStub createTestProject(final String
testName) throws Exception {
+ private MavenProjectResourcesStub createTestProject(final String testName)
throws Exception {
// this will automatically create the isolated
// test environment
return new MavenProjectResourcesStub(testName);
}
- protected void setupDefaultProject(final MavenProjectResourcesStub
project) throws Exception {
+ private void setupDefaultProject(final MavenProjectResourcesStub project)
throws Exception {
// put this on the root dir
project.addFile("pom.xml", MavenProjectBuildStub.ROOT_FILE);
project.setInceptionYear("2007");
// start creating the environment
project.setupBuildEnvironment();
}
- protected BundleRemoteResourcesMojo lookupBundleMojo() throws Exception {
- File pomFile = new File(getBasedir(), DEFAULT_BUNDLE_POM_PATH);
- BundleRemoteResourcesMojo mojo = (BundleRemoteResourcesMojo)
lookupMojo("bundle", pomFile);
-
- assertNotNull(mojo);
-
- return mojo;
- }
-
- protected BundleRemoteResourcesMojo
lookupBundleMojoWithDefaultSettings(final MavenProject project)
+ private void configureBundleMojo(
+ BundleRemoteResourcesMojo mojo, MavenProject project, File
resourceDir, String sourceEncoding)
throws Exception {
- File resourceDir = new File(project.getBasedir() +
"/src/main/resources");
- return lookupBundleMojoWithSettings(project, resourceDir, null);
- }
-
- protected BundleRemoteResourcesMojo lookupBundleMojoWithSettings(
- final MavenProject project, File resourceDir, String
sourceEncoding) throws Exception {
- final BundleRemoteResourcesMojo mojo = lookupBundleMojo();
-
setVariableValueToObject(mojo, "resourcesDirectory", resourceDir);
setVariableValueToObject(
mojo, "outputDirectory", new
File(project.getBuild().getOutputDirectory()));
setVariableValueToObject(mojo, "sourceEncoding", sourceEncoding);
- return mojo;
}
- protected ProcessRemoteResourcesMojo lookupProcessMojo() throws Exception {
- File pomFile = new File(getBasedir(), DEFAULT_PROCESS_POM_PATH);
- ProcessRemoteResourcesMojo mojo = (ProcessRemoteResourcesMojo)
lookupMojo("process", pomFile);
-
- assertNotNull(mojo);
-
- return mojo;
- }
-
- protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings(final
MavenProject project, String[] bundles)
+ private void configureProcessMojo(ProcessRemoteResourcesMojo mojo,
MavenProject project, List<String> bundles)
throws Exception {
- return lookupProcessMojoWithSettings(project, new
ArrayList<>(Arrays.asList(bundles)));
- }
-
- protected ProcessRemoteResourcesMojo lookupProcessMojoWithSettings(
- final MavenProject project, ArrayList<String> bundles) throws
Exception {
- final ProcessRemoteResourcesMojo mojo = lookupProcessMojo();
-
DefaultRepositorySystemSession reposession =
MavenRepositorySystemUtils.newSession();
Review Comment:
You can use: `@MojoTest(realRepositorySession = true)` instead of manual
mange
https://maven.apache.org/plugin-testing/maven-plugin-testing-harness/examples/repositories.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]