use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class VersioningCalculatorTest method setupSession.
private VersioningState setupSession(final Properties properties, final Map<ProjectRef, String[]> versionMap) throws Exception {
final ArtifactRepository ar = new MavenArtifactRepository("test", "http://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy());
final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(properties).setRemoteRepositories(Arrays.asList(ar));
final PlexusContainer container = new DefaultPlexusContainer();
final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
session = new ManipulationSession();
session.setMavenSession(mavenSession);
final VersioningState state = new VersioningState(properties);
session.setState(state);
final Map<String, byte[]> dataMap = new HashMap<>();
if (versionMap != null && !versionMap.isEmpty()) {
for (final Map.Entry<ProjectRef, String[]> entry : versionMap.entrySet()) {
final String path = toMetadataPath(entry.getKey());
final byte[] data = setupMetadataVersions(entry.getValue());
dataMap.put(path, data);
}
}
final Location mdLoc = MavenLocationExpander.EXPANSION_TARGET;
final Transport mdTrans = new StubTransport(dataMap);
modder = new TestVersionCalculator(new ManipulationSession(), mdLoc, mdTrans, temp.newFolder("galley-cache"));
return state;
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class ModelResolverTest method resolveArtifactTest.
@Test(expected = ManipulationException.class)
@BMRule(name = "retrieve-first-null", targetClass = "ArtifactManagerImpl", targetMethod = "retrieveFirst(List<? extends Location> locations, ArtifactRef ref)", targetLocation = "AT ENTRY", action = "RETURN null")
public void resolveArtifactTest() throws Exception {
final ManipulationSession session = new ManipulationSession();
final GalleyInfrastructure galleyInfra = new GalleyInfrastructure(session.getTargetDir(), session.getRemoteRepositories(), session.getLocalRepository(), session.getSettings(), session.getActiveProfiles(), null, null, null, temp.newFolder("cache-dir"));
final GalleyAPIWrapper wrapper = new GalleyAPIWrapper(galleyInfra);
final ModelIO model = new ModelIO();
FieldUtils.writeField(model, "galleyWrapper", wrapper, true);
model.resolveRawModel(SimpleProjectVersionRef.parse("org.commonjava:commonjava:5"));
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class PropertiesUtilsTest method testUpdateNestedProperties.
@Test
public void testUpdateNestedProperties() throws Exception {
Project pP = getProject();
ManipulationSession session = createUpdateSession();
assertTrue(updateProperties(session, pP, false, "version.hibernate.core", "5.0.4.Final-redhat-1") == PropertiesUtils.PropertyUpdate.FOUND);
assertTrue(updateProperties(session, pP, false, "version.scala", "2.11.7.redhat-1") == PropertiesUtils.PropertyUpdate.FOUND);
try {
updateProperties(session, pP, false, "version.scala", "3.11.7-redhat-1");
} catch (ManipulationException e) {
// Pass.
}
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class PropertiesUtilsTest method testStrictWithTimeStamp.
@Test
public void testStrictWithTimeStamp() throws Exception {
String suffix = "t-20170216-223844-555-rebuild";
p.setProperty("version.suffix", suffix + "-1");
ManipulationSession session = createUpdateSession();
assertTrue(PropertiesUtils.getSuffix(session).equals(suffix));
assertTrue(PropertiesUtils.checkStrictValue(session, "1.0.0.Final", "1.0.0.Final-t-20170216-223844-555-rebuild-1"));
assertTrue(PropertiesUtils.checkStrictValue(session, "1.0", "1.0.0.t-20170216-223844-555-rebuild-1"));
assertTrue(PropertiesUtils.checkStrictValue(session, "1.0-SNAPSHOT", "1.0.0.t-20170216-223844-555-rebuild-1"));
suffix = "t20170216223844555-rebuild";
p.setProperty("version.suffix", suffix + "-2");
session = createUpdateSession();
assertTrue(PropertiesUtils.getSuffix(session).equals(suffix));
assertTrue(PropertiesUtils.checkStrictValue(session, "1.0.0.Final", "1.0.0.Final-t20170216223844555-rebuild-2"));
assertTrue(PropertiesUtils.checkStrictValue(session, "1.0", "1.0.0.t20170216223844555-rebuild-2"));
assertTrue(PropertiesUtils.checkStrictValue(session, "1.0-SNAPSHOT", "1.0.0.t20170216223844555-rebuild-2"));
}
use of org.commonjava.maven.ext.core.ManipulationSession in project pom-manipulation-ext by release-engineering.
the class PropertiesUtilsTest method testResolveProperties.
@Test
public void testResolveProperties() throws Exception {
final Model modelChild = TestUtils.resolveModelResource(RESOURCE_BASE, "inherited-properties.pom");
final Model modelParent = TestUtils.resolveModelResource(RESOURCE_BASE, "infinispan-bom-8.2.0.Final.pom");
ManipulationSession session = createUpdateSession();
Project pP = new Project(modelParent);
Project pC = new Project(modelChild);
List<Project> al = new ArrayList<>();
al.add(pC);
al.add(pP);
String result = PropertyResolver.resolveProperties(session, al, "${version.scala.major}.${version.scala.minor}");
assertTrue(result.equals("2.11.7"));
result = PropertyResolver.resolveProperties(session, al, "TestSTART.and.${version.scala.major}.now.${version.scala.minor}");
assertTrue(result.equals("TestSTART.and.2.11.now.7"));
result = PropertyResolver.resolveProperties(session, al, "${project.version}");
assertTrue(result.equals("1"));
}
Aggregations