Search in sources :

Example 1 with ArtifactCoordinates

use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.

the class GradleResolverTest method testResolveArtifact_notExists.

@Test
public void testResolveArtifact_notExists() throws IOException {
    // GIVEN
    File dirFile = TempFileManager.INSTANCE.newTempDirectory("gradle", null);
    Path gradleCachePath = dirFile.toPath();
    String group = "org.wildfly.swarm";
    String packaging = "jar";
    String artifact = "test";
    String version = "1.0";
    String classifier = "sources";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version, classifier);
    Path artifactDir = Files.createDirectories(gradleCachePath.resolve(group).resolve(artifact).resolve(version).resolve("hash"));
    // Other packaging type
    File artifactFile = Files.createFile(artifactDir.resolve(artifact + "-" + version + "-" + classifier + ".pom")).toFile();
    // WHEN
    GradleResolver resolver = new GradleResolver(gradleCachePath.toString());
    File resolvedArtifactFile = resolver.resolveArtifact(artifactCoordinates, packaging);
    // THEN
    assertNull(resolvedArtifactFile);
}
Also used : Path(java.nio.file.Path) ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) Test(org.junit.Test)

Example 2 with ArtifactCoordinates

use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.

the class GradleResolverTest method testToGradleArtifactPath_withClassifier.

@Test
public void testToGradleArtifactPath_withClassifier() {
    // GIVEN
    String group = "org.jboss.ws.cxf";
    String artifact = "jbossws-cxf-resources";
    String version = "5.1.5.Final";
    String classifier = "wildfly1000";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version, classifier);
    // WHEN
    GradleResolver resolver = new GradleResolver(null);
    String artifactPath = resolver.toGradleArtifactPath(artifactCoordinates);
    // THEN
    assertEquals("org/jboss/ws/cxf/jbossws-cxf-resources/5.1.5.Final/jbossws-cxf-resources-5.1.5.Final-wildfly1000", artifactPath);
}
Also used : ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with ArtifactCoordinates

use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.

the class GradleResolverTest method testResolveArtifact_latest.

@Test
public void testResolveArtifact_latest() throws IOException, InterruptedException {
    // GIVEN
    File dirFile = TempFileManager.INSTANCE.newTempDirectory("gradle", null);
    Path gradleCachePath = dirFile.toPath();
    String group = "org.wildfly.swarm";
    String packaging = "jar";
    String artifact = "test";
    String version = "1.0";
    String classifier = "sources";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version, classifier);
    Path artifactDir = Files.createDirectories(gradleCachePath.resolve(group).resolve(artifact).resolve(version).resolve("hash1"));
    File artifactFile = Files.createFile(artifactDir.resolve(artifact + "-" + version + "-" + classifier + "." + packaging)).toFile();
    // Timestemp resolution of some filesystems are 2 seconds
    Thread.sleep(2000);
    Path artifactDirLatest = Files.createDirectories(gradleCachePath.resolve(group).resolve(artifact).resolve(version).resolve("hash2"));
    File artifactFileLatest = Files.createFile(artifactDirLatest.resolve(artifact + "-" + version + "-" + classifier + "." + packaging)).toFile();
    // WHEN
    GradleResolver resolver = new GradleResolver(gradleCachePath.toString());
    File resolvedArtifactFile = resolver.resolveArtifact(artifactCoordinates, packaging);
    // THEN
    assertEquals(artifactFileLatest, resolvedArtifactFile);
}
Also used : Path(java.nio.file.Path) ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) Test(org.junit.Test)

Example 4 with ArtifactCoordinates

use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.

the class GradleResolverTest method downloadFromRemoteRepository.

@Test
public void downloadFromRemoteRepository() throws IOException {
    // GIVEN
    File dirFile = TempFileManager.INSTANCE.newTempDirectory(".gradle", null);
    Path gradleCachePath = dirFile.toPath();
    String group = "org.wildfly.swarm";
    String packaging = "jar";
    String artifact = "bootstrap";
    String version = "2017.1.1";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version);
    Path artifactDirectory = gradleCachePath.resolve(group);
    GradleResolver resolver = spy(new GradleResolver(gradleCachePath.toString()));
    File targetFile = mock(File.class);
    doReturn(targetFile).when(resolver).doDownload(anyString(), anyString(), anyString(), eq(artifactCoordinates), eq(packaging), any(File.class), any(File.class));
    // WHEN
    File result = resolver.downloadFromRemoteRepository(artifactCoordinates, packaging, artifactDirectory);
    // THEN
    assertEquals(targetFile, result);
}
Also used : Path(java.nio.file.Path) ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) File(java.io.File) Test(org.junit.Test)

Example 5 with ArtifactCoordinates

use of org.jboss.modules.maven.ArtifactCoordinates in project wildfly-swarm by wildfly-swarm.

the class GradleResolverTest method testToGradleArtifactFileName.

@Test
public void testToGradleArtifactFileName() {
    // GIVEN
    String group = "org.wildfly.swarm";
    String packaging = "jar";
    String artifact = "test";
    String version = "1.0";
    ArtifactCoordinates artifactCoordinates = new ArtifactCoordinates(group, artifact, version);
    // WHEN
    GradleResolver resolver = new GradleResolver(null);
    String artifactFileName = resolver.toGradleArtifactFileName(artifactCoordinates, packaging);
    // THEN
    assertEquals(artifact + "-" + version + "." + packaging, artifactFileName);
}
Also used : ArtifactCoordinates(org.jboss.modules.maven.ArtifactCoordinates) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

ArtifactCoordinates (org.jboss.modules.maven.ArtifactCoordinates)13 Test (org.junit.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 File (java.io.File)7 Path (java.nio.file.Path)5 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 JarFile (java.util.jar.JarFile)1 NativeLibraryResourceLoader (org.jboss.modules.NativeLibraryResourceLoader)1 ResourceLoader (org.jboss.modules.ResourceLoader)1 MultiplePathFilterBuilder (org.jboss.modules.filter.MultiplePathFilterBuilder)1