Search in sources :

Example 1 with UniverseResolver

use of org.jboss.galleon.universe.UniverseResolver in project galleon by wildfly.

the class FeaturePackLocationResolverTestCase method testResolutionLocalPathInstalled.

@Test
public void testResolutionLocalPathInstalled() throws Exception {
    FeaturePackLocation fpl = FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.0.0.Final");
    MavenArtifact artifact = new MavenArtifact().setGroupId(FP_GROUP_ID).setArtifactId(PRODUCER1_FP_ARTIFACT_ID).setExtension("zip").setVersion("5.0.0.Final");
    FeaturePackCreator.getInstance().addArtifactResolver(repo).newFeaturePack().setFPID(fpl.getFPID()).getCreator().install();
    Path path = resolver.resolve(fpl);
    Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    Path externalPath = repoHome.resolve("external").resolve(path.getFileName().toString());
    IoUtils.copy(path, externalPath);
    IoUtils.recursiveDelete(path);
    try {
        resolver.resolve(fpl);
        Assert.fail(String.format("The %s artifact is still installed in the local repository", artifact.getCoordsAsString()));
    } catch (ProvisioningException e) {
    // Expected exception
    }
    UniverseResolver resolver = UniverseResolver.builder().addArtifactResolver(repo).addLocalFeaturePack(externalPath).build();
    try {
        path = resolver.resolve(fpl);
        Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
    } catch (ProvisioningException e) {
        Assert.fail(String.format("Cannot resolve %s artifact using a resolved with a local feature pack location", artifact.getCoordsAsString()));
    }
}
Also used : Path(java.nio.file.Path) ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) UniverseResolver(org.jboss.galleon.universe.UniverseResolver) MavenArtifact(org.jboss.galleon.universe.maven.MavenArtifact) Test(org.junit.Test)

Example 2 with UniverseResolver

use of org.jboss.galleon.universe.UniverseResolver in project galleon by wildfly.

the class MavenUniverseFeaturePackCreatorTestCase method testMain.

@Test
public void testMain() throws Exception {
    final UniverseResolver universeResolver = UniverseResolver.builder().addArtifactResolver(SimplisticMavenRepoManager.getInstance(repoHome)).build();
    Path path = universeResolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + "(universe.maven.test:maven-universe1:[1.0,2.0-alpha)):1.0"));
    Assert.assertEquals("feature-pack1-1.0.0.Final.zip", path.getFileName().toString());
}
Also used : Path(java.nio.file.Path) UniverseResolver(org.jboss.galleon.universe.UniverseResolver) Test(org.junit.Test)

Aggregations

Path (java.nio.file.Path)2 UniverseResolver (org.jboss.galleon.universe.UniverseResolver)2 Test (org.junit.Test)2 ProvisioningException (org.jboss.galleon.ProvisioningException)1 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)1 MavenArtifact (org.jboss.galleon.universe.maven.MavenArtifact)1