|
| 1 | +/* |
| 2 | + * Copyright 2012-2021 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.boot.build.artifacts; |
| 18 | + |
| 19 | +import org.gradle.api.Project; |
| 20 | +import org.gradle.testfixtures.ProjectBuilder; |
| 21 | +import org.junit.jupiter.api.Test; |
| 22 | + |
| 23 | +import static org.assertj.core.api.Assertions.assertThat; |
| 24 | + |
| 25 | +/** |
| 26 | + * Tests for {@link ArtifactRelease}. |
| 27 | + * |
| 28 | + * @author Andy Wilkinson |
| 29 | + * @author Scott Frederick |
| 30 | + */ |
| 31 | +class ArtifactReleaseTests { |
| 32 | + |
| 33 | + @Test |
| 34 | + void whenProjectVersionIsSnapshotThenTypeIsSnapshot() { |
| 35 | + Project project = ProjectBuilder.builder().build(); |
| 36 | + project.setVersion("1.2.3-SNAPSHOT"); |
| 37 | + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("snapshot"); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + void whenProjectVersionIsMilestoneThenTypeIsMilestone() { |
| 42 | + Project project = ProjectBuilder.builder().build(); |
| 43 | + project.setVersion("1.2.3-M1"); |
| 44 | + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("milestone"); |
| 45 | + } |
| 46 | + |
| 47 | + @Test |
| 48 | + void whenProjectVersionIsReleaseCandidateThenTypeIsMilestone() { |
| 49 | + Project project = ProjectBuilder.builder().build(); |
| 50 | + project.setVersion("1.2.3-RC1"); |
| 51 | + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("milestone"); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + void whenProjectVersionIsReleaseThenTypeIsRelease() { |
| 56 | + Project project = ProjectBuilder.builder().build(); |
| 57 | + project.setVersion("1.2.3"); |
| 58 | + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("release"); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + void whenProjectVersionIsSnapshotThenRepositoryIsArtifactorySnapshot() { |
| 63 | + Project project = ProjectBuilder.builder().build(); |
| 64 | + project.setVersion("1.2.3-SNAPSHOT"); |
| 65 | + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/snapshot"); |
| 66 | + } |
| 67 | + |
| 68 | + @Test |
| 69 | + void whenProjectVersionIsMilestoneThenRepositoryIsArtifactoryMilestone() { |
| 70 | + Project project = ProjectBuilder.builder().build(); |
| 71 | + project.setVersion("1.2.3-M1"); |
| 72 | + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/milestone"); |
| 73 | + } |
| 74 | + |
| 75 | + @Test |
| 76 | + void whenProjectVersionIsReleaseCandidateThenRepositoryIsArtifactoryMilestone() { |
| 77 | + Project project = ProjectBuilder.builder().build(); |
| 78 | + project.setVersion("1.2.3-RC1"); |
| 79 | + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/milestone"); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + void whenProjectVersionIsReleaseThenRepositoryIsMavenCentral() { |
| 84 | + Project project = ProjectBuilder.builder().build(); |
| 85 | + project.setVersion("1.2.3"); |
| 86 | + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()) |
| 87 | + .contains("https://repo.maven.apache.org/maven2"); |
| 88 | + } |
| 89 | + |
| 90 | +} |
0 commit comments