use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class CliTest method checkLocalRepositoryWithExplicitMavenRepoAndSettings.
@Test
public void checkLocalRepositoryWithExplicitMavenRepoAndSettings() throws Exception {
File folder = temp.newFolder();
Cli c = new Cli();
executeMethod(c, "run", new Object[] { new String[] { "-settings=" + getClass().getResource("/settings-test.xml").getFile(), "-Dmaven.repo.local=" + folder.toString() } });
ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true);
MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true);
assertTrue(ms.getLocalRepository().getBasedir().equals(folder.toString()));
assertTrue(ms.getRequest().getLocalRepository().getBasedir().equals(ms.getRequest().getLocalRepositoryPath().toString()));
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class CliTest method checkTargetMatchesWithRun.
@Test
public void checkTargetMatchesWithRun() throws Exception {
Cli c = new Cli();
File pom1 = temp.newFile();
executeMethod(c, "run", new Object[] { new String[] { "-f", pom1.toString() } });
assertTrue("Session file should match", pom1.equals(((ManipulationSession) FieldUtils.readField(c, "session", true)).getPom()));
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class CliTest method checkLocalRepositoryWithSettings.
@Test
public void checkLocalRepositoryWithSettings() throws Exception {
Cli c = new Cli();
executeMethod(c, "run", new Object[] { new String[] { "-settings=" + getClass().getResource("/settings-test.xml").getFile() } });
ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true);
MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true);
assertTrue(ms.getRequest().getLocalRepository().getBasedir().equals(ms.getRequest().getLocalRepositoryPath().toString()));
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class CliTest method checkTargetMatches.
@Test
public void checkTargetMatches() throws Exception {
Cli c = new Cli();
File pom1 = temp.newFile();
File settings = writeSettings(temp.newFile());
executeMethod(c, "createSession", new Object[] { pom1, settings });
assertTrue("Session file should match", pom1.equals(((ManipulationSession) FieldUtils.readField(c, "session", true)).getPom()));
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class CliTest method checkLocalRepositoryWithDefaultsAndModifiedUserSettings.
@Test
public void checkLocalRepositoryWithDefaultsAndModifiedUserSettings() throws Exception {
boolean restore = false;
Path source = Paths.get(System.getProperty("user.home") + File.separatorChar + ".m2" + File.separatorChar + "settings.xml");
Path backup = Paths.get(source.toString() + '.' + UUID.randomUUID().toString());
Path tmpSettings = Paths.get(getClass().getResource("/settings-test.xml").getFile());
try {
if (source.toFile().exists()) {
System.out.println("Backing up settings.xml to " + backup);
restore = true;
Files.move(source, backup, StandardCopyOption.ATOMIC_MOVE);
}
Files.copy(tmpSettings, source);
Cli c = new Cli();
executeMethod(c, "run", new Object[] { new String[] {} });
ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true);
MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true);
assertTrue(ms.getRequest().getLocalRepository().getBasedir().equals(ms.getRequest().getLocalRepositoryPath().toString()));
assertTrue(ms.getLocalRepository().getBasedir().equals(System.getProperty("user.home") + File.separatorChar + ".m2-mead-test"));
} finally {
if (restore) {
Files.move(backup, source, StandardCopyOption.ATOMIC_MOVE);
} else {
Files.delete(source);
}
}
}
Aggregations