Search in sources :

Example 36 with Artifact

use of io.fabric8.patch.management.Artifact in project fabric8 by jboss-fuse.

the class MavenProxyResolutionTest method releaseIsAvailableInRemoteRepositoryUpdatingRelease.

@Test
public void releaseIsAvailableInRemoteRepositoryUpdatingRelease() throws IOException, InvalidMavenArtifactRequest {
    File remoteRepository = initFileRepository("rr");
    MavenResolver resolver = new ResolverBuilder().withRemoteRepositories(Collections.singletonList(remoteRepository)).withReleaseUpdates().withUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS).build();
    MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
    mvnInstall(remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0", at("10:00"), "a");
    File file = servlet.download("io/fabric8/test/universalis-api/0.1.0/universalis-api-0.1.0.jar");
    // first resolution
    assertThat(FileUtils.readFileToString(file), equalTo("a"));
    // don't do that, it's not proper use of maven. But sometimes we just have another deployment to public repository...
    mvnInstall(remoteRepository, "io.fabric8.test", "universalis-api", "0.1.0", at("11:00"), "b");
    // second resolution
    file = servlet.download("io/fabric8/test/universalis-api/0.1.0/universalis-api-0.1.0.jar");
    assertThat("Artifact will be updated though it's not proper usage of Maven", FileUtils.readFileToString(file), equalTo("b"));
}
Also used : MavenResolver(io.fabric8.maven.MavenResolver) File(java.io.File) Test(org.junit.Test)

Example 37 with Artifact

use of io.fabric8.patch.management.Artifact in project fabric8 by jboss-fuse.

the class MavenProxySnapshotResolutionTest method snapshotIsAvailableInTwoDefaultRepositories.

@Test
public void snapshotIsAvailableInTwoDefaultRepositories() throws IOException, InvalidMavenArtifactRequest {
    File defaultRepository1 = initFileRepository("dr1");
    File defaultRepository2 = initFileRepository("dr2");
    MavenResolver resolver = new ResolverBuilder().withDefaultRepositories(Arrays.asList(defaultRepository1, defaultRepository2)).build();
    MavenDownloadProxyServlet servlet = new MavenDownloadProxyServlet(resolver, runtime, null, 1, 0);
    servlet.start();
    mvnInstall(defaultRepository1, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("10:00"), "a");
    mvnInstall(defaultRepository2, "io.fabric8.test", "universalis-api", "0.1.0-SNAPSHOT", at("11:00"), "b");
    File file = servlet.download("io/fabric8/test/universalis-api/0.1.0-SNAPSHOT/maven-metadata.xml");
    Metadata metadata = readMetadata(file);
    assertThat("Resolution done in first default repository, even if second one has newer artifact", metadata.getVersioning().getSnapshotVersions().get(0).getUpdated(), is("20170101100000"));
}
Also used : MavenResolver(io.fabric8.maven.MavenResolver) Metadata(org.apache.maven.artifact.repository.metadata.Metadata) File(java.io.File) Test(org.junit.Test)

Example 38 with Artifact

use of io.fabric8.patch.management.Artifact in project fabric8-maven-plugin by fabric8io.

the class ContainerHandlerTest method getContainerWithGroupArtifactTest.

@Test
public void getContainerWithGroupArtifactTest() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
    // container name with group id and aritact id without alias and user
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compression("gzip").dockerFile("testFile").dockerFileDir("/demo").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("test-group-test-artifact", containers.get(0).getName());
    assertEquals("docker.io/test", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 39 with Artifact

use of io.fabric8.patch.management.Artifact in project fabric8-maven-plugin by fabric8io.

the class ContainerHandlerTest method getContainersWithAliasTest.

@Test
public void getContainersWithAliasTest() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    ContainerHandler handler = new ContainerHandler(project, envVarHandler, probeHandler);
    // container name with alias
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("test-app", containers.get(0).getName());
    assertEquals("docker.io/test", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Test(org.junit.Test)

Example 40 with Artifact

use of io.fabric8.patch.management.Artifact in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method init.

@Before
public void init() {
    String version = getSpringBootVersion();
    this.propertyHelper = new SpringBootConfigurationHelper(version);
    final MavenProject project = new MavenProject();
    Set<Artifact> artifacts = new HashSet<>();
    Artifact a = new DefaultArtifact("org.springframework.boot", "spring-boot", version, "compile", "jar", "", null);
    a.setResolved(true);
    artifacts.add(a);
    project.setArtifacts(artifacts);
    new Expectations() {

        {
            context.getProject();
            result = project;
        }
    };
}
Also used : Expectations(mockit.Expectations) SpringBootConfigurationHelper(io.fabric8.maven.core.util.SpringBootConfigurationHelper) MavenProject(org.apache.maven.project.MavenProject) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Artifact(org.apache.maven.artifact.Artifact) DefaultArtifact(org.apache.maven.artifact.DefaultArtifact) Before(org.junit.Before)

Aggregations

File (java.io.File)22 Artifact (io.fabric8.patch.management.Artifact)11 Test (org.junit.Test)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)8 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)8 FileInputStream (java.io.FileInputStream)6 MavenResolver (io.fabric8.maven.MavenResolver)5 PatchException (io.fabric8.patch.management.PatchException)5 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)5 FileOutputStream (java.io.FileOutputStream)4 MalformedURLException (java.net.MalformedURLException)4 Git (org.eclipse.jgit.api.Git)4 Version (org.osgi.framework.Version)4 DeployResults (io.fabric8.deployer.dto.DeployResults)3 Artifact.isSameButVersion (io.fabric8.patch.management.Artifact.isSameButVersion)3 Patch (io.fabric8.patch.management.Patch)3 Utils.mvnurlToArtifact (io.fabric8.patch.management.Utils.mvnurlToArtifact)3 HashSet (java.util.HashSet)3