use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class MavenModelProcessorTest method resolvePluginVersionFromPropertyInProfile.
@Test
public void resolvePluginVersionFromPropertyInProfile() throws Exception {
final URI src = new URI("http://nowhere.com/path/to/repo");
final ProjectVersionRef childRef = new SimpleProjectVersionRef("org.test", "test-pom", "1.0");
final LinkedHashMap<ProjectVersionRef, String> lineage = new LinkedHashMap<ProjectVersionRef, String>();
lineage.put(childRef, "test-pom-1.0.pom.xml");
final Location location = new SimpleLocation("test", src.toString(), false, true, true, false, true);
final String base = PROJ_BASE + "version-expression-in-a-profile/";
for (final Entry<ProjectVersionRef, String> entry : lineage.entrySet()) {
final ProjectVersionRef ref = entry.getKey();
final String filename = entry.getValue();
final String path = ArtifactPathUtils.formatArtifactPath(ref.asPomArtifact(), fixture.getTypeMapper());
fixture.getTransport().registerDownload(new ConcreteResource(location, path), new TestDownload(base + filename));
}
final Transfer transfer = fixture.getArtifactManager().retrieve(location, childRef.asPomArtifact());
final MavenPomView pomView = fixture.getPomReader().read(childRef, transfer, Collections.singletonList(location));
final List<PluginView> buildPlugins = pomView.getAllBuildPlugins();
assertThat(buildPlugins, notNullValue());
assertThat(buildPlugins.size(), equalTo(1));
final PluginView pv = buildPlugins.get(0);
assertThat(pv, notNullValue());
assertThat(pv.getVersion(), equalTo("2.0"));
final ModelProcessorConfig discoveryConfig = new ModelProcessorConfig();
discoveryConfig.setIncludeManagedDependencies(true);
discoveryConfig.setIncludeBuildSection(true);
discoveryConfig.setIncludeManagedPlugins(false);
EProjectDirectRelationships result = fixture.getModelProcessor().readRelationships(pomView, src, discoveryConfig);
final Set<ProjectRelationship<?, ?>> rels = result.getExactAllRelationships();
logger.info("Found {} relationships:\n\n {}", rels.size(), new JoinString("\n ", rels));
boolean seen = false;
for (final ProjectRelationship<?, ?> rel : rels) {
if (rel.getType() == RelationshipType.PLUGIN && !rel.isManaged()) {
if (seen) {
fail("Multiple plugins found!");
}
seen = true;
assertThat(rel.getTarget().getVersionString(), equalTo("2.0"));
}
}
if (!seen) {
fail("Plugin relationship not found!");
}
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class MavenModelProcessorTest method resolvePluginVersionFromManagementExpression.
@Test
public void resolvePluginVersionFromManagementExpression() throws Exception {
final URI src = new URI("http://nowhere.com/path/to/repo");
final ProjectVersionRef childRef = new SimpleProjectVersionRef("org.test", "test-child", "1.0");
final LinkedHashMap<ProjectVersionRef, String> lineage = new LinkedHashMap<ProjectVersionRef, String>();
lineage.put(childRef, "child.pom.xml");
lineage.put(new SimpleProjectVersionRef("org.test", "test-parent", "1.0"), "parent.pom.xml");
final Location location = new SimpleLocation("test", src.toString(), false, true, true, false, true);
final String base = PROJ_BASE + "version-expression-managed-parent-plugin/";
for (final Entry<ProjectVersionRef, String> entry : lineage.entrySet()) {
final ProjectVersionRef ref = entry.getKey();
final String filename = entry.getValue();
final String path = ArtifactPathUtils.formatArtifactPath(ref.asPomArtifact(), fixture.getTypeMapper());
fixture.getTransport().registerDownload(new ConcreteResource(location, path), new TestDownload(base + filename));
}
final Transfer transfer = fixture.getArtifactManager().retrieve(location, childRef.asPomArtifact());
final MavenPomView pomView = fixture.getPomReader().read(childRef, transfer, Collections.singletonList(location));
final List<PluginView> buildPlugins = pomView.getAllBuildPlugins();
assertThat(buildPlugins, notNullValue());
assertThat(buildPlugins.size(), equalTo(1));
final PluginView pv = buildPlugins.get(0);
assertThat(pv, notNullValue());
assertThat(pv.getVersion(), equalTo("1.0"));
final ModelProcessorConfig discoveryConfig = new ModelProcessorConfig();
discoveryConfig.setIncludeManagedDependencies(true);
discoveryConfig.setIncludeBuildSection(true);
discoveryConfig.setIncludeManagedPlugins(false);
EProjectDirectRelationships result = fixture.getModelProcessor().readRelationships(pomView, src, discoveryConfig);
final Set<ProjectRelationship<?, ?>> rels = result.getExactAllRelationships();
logger.info("Found {} relationships:\n\n {}", rels.size(), new JoinString("\n ", rels));
boolean seen = false;
for (final ProjectRelationship<?, ?> rel : rels) {
if (rel.getType() == RelationshipType.PLUGIN && !rel.isManaged()) {
if (seen) {
fail("Multiple plugins found!");
}
seen = true;
assertThat(rel.getTarget().getVersionString(), equalTo("1.0"));
}
}
if (!seen) {
fail("Plugin relationship not found!");
}
}
use of org.commonjava.maven.galley.model.SimpleLocation in project galley by Commonjava.
the class MavenModelProcessorTest method resolveExpressionsBothInDepAndProfile.
@Test
public void resolveExpressionsBothInDepAndProfile() throws Exception {
final URI src = new URI("http://nowhere.com/path/to/repo");
final ProjectVersionRef childRef = new SimpleProjectVersionRef("org.test", "test-pom", "1.0");
final LinkedHashMap<ProjectVersionRef, String> lineage = new LinkedHashMap<ProjectVersionRef, String>();
lineage.put(childRef, "test-pom-1.0.pom.xml");
final Location location = new SimpleLocation("test", src.toString(), false, true, true, false, true);
final String base = PROJ_BASE + "resolve-expression-in-a-profile/";
for (final Entry<ProjectVersionRef, String> entry : lineage.entrySet()) {
final ProjectVersionRef ref = entry.getKey();
final String filename = entry.getValue();
final String path = ArtifactPathUtils.formatArtifactPath(ref.asPomArtifact(), fixture.getTypeMapper());
fixture.getTransport().registerDownload(new ConcreteResource(location, path), new TestDownload(base + filename));
}
final Transfer transfer = fixture.getArtifactManager().retrieve(location, childRef.asPomArtifact());
final MavenPomView pomView = fixture.getPomReader().read(childRef, transfer, Collections.singletonList(location));
String url = pomView.resolveExpressions("${repo.url}", "test.oracle");
assertThat(url, equalTo("http://test.oracle.repository"));
List<DependencyView> dvs = pomView.getAllDirectDependencies();
assertThat(dvs.get(0).getVersion(), equalTo("2.5"));
String version = pomView.resolveExpressions("${commons.lang.value}");
assertThat(version, equalTo("2.5"));
}
use of org.commonjava.maven.galley.model.SimpleLocation in project indy by Commonjava.
the class ExpiringMemoryNotFoundCacheTest method expireUsingConfiguredValue.
@Test
public void expireUsingConfiguredValue() throws Exception {
final DefaultIndyConfiguration config = new DefaultIndyConfiguration();
config.setNotFoundCacheTimeoutSeconds(1);
final ExpiringMemoryNotFoundCache nfc = new ExpiringMemoryNotFoundCache(config);
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "/path/to/expired/object");
nfc.addMissing(res);
assertThat(nfc.isMissing(res), equalTo(true));
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
assertThat(nfc.isMissing(res), equalTo(false));
final Set<String> locMissing = nfc.getMissing(res.getLocation());
assertThat(locMissing == null || locMissing.isEmpty(), equalTo(true));
final Map<Location, Set<String>> allMissing = nfc.getAllMissing();
assertThat(allMissing == null || allMissing.isEmpty(), equalTo(true));
}
use of org.commonjava.maven.galley.model.SimpleLocation in project indy by Commonjava.
the class ContentControllerTest method detectHtml_HtmlDoctypeDeclaration.
@Test
public void detectHtml_HtmlDoctypeDeclaration() throws Exception {
final ConcreteResource res = new ConcreteResource(new SimpleLocation("test:uri"), "file.html");
final Transfer tx = fixture.getCache().getTransfer(res);
PrintWriter writer = null;
try {
writer = new PrintWriter(new OutputStreamWriter(tx.openOutputStream(TransferOperation.GENERATE)));
writer.print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
writer.flush();
} finally {
IOUtils.closeQuietly(writer);
}
assertThat(content.isHtmlContent(tx), equalTo(true));
}
Aggregations