Search in sources :

Example 6 with ManipulationSession

use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.

the class PropertiesUtilsTest method testUpdateNestedProperties3.

@Test
public void testUpdateNestedProperties3() throws Exception {
    // io.hawt:project:1.4.9
    final Model modelParent = TestUtils.resolveModelResource(RESOURCE_BASE, "project-1.4.9.pom");
    Project pP = new Project(modelParent);
    ManipulationSession session = createUpdateSession();
    assertTrue(updateProperties(session, pP, false, "perfectus-build", "610379.redhat-1") == PropertiesUtils.PropertyUpdate.FOUND);
    try {
        assertTrue(updateProperties(session, pP, false, "perfectus-build", "610.NOTTHEVALUE.redhat-1") == PropertiesUtils.PropertyUpdate.FOUND);
    } catch (ManipulationException e) {
        e.printStackTrace();
    // Pass.
    }
    try {
        assertTrue(updateProperties(session, pP, true, "perfectus-build", "610.NOTTHEVALUE.redhat-1") == PropertiesUtils.PropertyUpdate.FOUND);
    } catch (ManipulationException e) {
        e.printStackTrace();
    // Pass.
    }
}
Also used : Project(org.commonjava.maven.ext.common.model.Project) Model(org.apache.maven.model.Model) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) ManipulationException(org.commonjava.maven.ext.common.ManipulationException) Test(org.junit.Test)

Example 7 with ManipulationSession

use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.

the class PropertiesUtilsTest method testUpdateProjectVersionProperty.

@Test
public void testUpdateProjectVersionProperty() throws Exception {
    Project pP = getProject();
    ManipulationSession session = createUpdateSession();
    assertFalse(updateProperties(session, pP, false, "project.version", "5.0.4.Final-redhat-1") == PropertiesUtils.PropertyUpdate.FOUND);
}
Also used : Project(org.commonjava.maven.ext.common.model.Project) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) Test(org.junit.Test)

Example 8 with ManipulationSession

use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.

the class CliTest method checkLocalRepositoryWithExplicitMavenRepo.

@Test
public void checkLocalRepositoryWithExplicitMavenRepo() throws Exception {
    File folder = temp.newFolder();
    Cli c = new Cli();
    executeMethod(c, "run", new Object[] { new String[] { "-Dmaven.repo.local=" + folder.toString() } });
    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()));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) File(java.io.File) Test(org.junit.Test)

Example 9 with ManipulationSession

use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.

the class CliTest method checkLocalRepositoryWithDefaults.

@Test
public void checkLocalRepositoryWithDefaults() throws Exception {
    Cli c = new Cli();
    File settings = writeSettings(temp.newFile());
    executeMethod(c, "run", new Object[] { new String[] { "-s", settings.toString() } });
    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("File " + new File(ms.getRequest().getLocalRepository().getBasedir()).getParentFile().toString() + " was not equal to " + System.getProperty("user.home") + File.separatorChar + ".m2", new File(ms.getRequest().getLocalRepository().getBasedir()).getParentFile().toString().equals(System.getProperty("user.home") + File.separatorChar + ".m2"));
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) File(java.io.File) Test(org.junit.Test)

Example 10 with ManipulationSession

use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.

the class CliTest method checkTargetDefaultMatches.

@Test
public void checkTargetDefaultMatches() throws Exception {
    Cli c = new Cli();
    executeMethod(c, "run", new Object[] { new String[] {} });
    ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true);
    File defaultTarget = (File) FieldUtils.readField(c, "target", true);
    assertTrue("Session file should match", defaultTarget.equals(session.getPom()));
}
Also used : ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) File(java.io.File) Test(org.junit.Test)

Aggregations

ManipulationSession (org.commonjava.maven.ext.core.ManipulationSession)23 Test (org.junit.Test)20 Project (org.commonjava.maven.ext.common.model.Project)9 File (java.io.File)8 MavenSession (org.apache.maven.execution.MavenSession)7 Model (org.apache.maven.model.Model)4 ArtifactRef (org.commonjava.maven.atlas.ident.ref.ArtifactRef)3 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)2 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)2 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)2 Dependency (org.apache.maven.model.Dependency)2 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)2 PlexusContainer (org.codehaus.plexus.PlexusContainer)2 ManipulationException (org.commonjava.maven.ext.common.ManipulationException)2 VersioningState (org.commonjava.maven.ext.core.state.VersioningState)2 PomIO (org.commonjava.maven.ext.io.PomIO)2 GalleyAPIWrapper (org.commonjava.maven.ext.io.resolver.GalleyAPIWrapper)2 GalleyInfrastructure (org.commonjava.maven.ext.io.resolver.GalleyInfrastructure)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1