-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactored layered jar tests, no mocks required
Signed-off-by: Marc Nuri <marc@marcnuri.com>
- Loading branch information
Showing
10 changed files
with
409 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
...ng-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootLayeredJarExecUtilsTest.java
This file was deleted.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
...-kit-spring-boot/src/test/java/org/eclipse/jkube/springboot/SpringBootLayeredJarTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.springboot; | ||
|
||
import org.eclipse.jkube.kit.common.KitLogger; | ||
import org.eclipse.jkube.kit.common.assertj.FileAssertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; | ||
|
||
class SpringBootLayeredJarTest { | ||
|
||
@TempDir | ||
private File projectDir; | ||
|
||
private SpringBootLayeredJar springBootLayeredJar; | ||
|
||
@Nested | ||
@DisplayName("with invalid jar") | ||
class InvalidJar { | ||
@BeforeEach | ||
void setup() { | ||
springBootLayeredJar = new SpringBootLayeredJar(new File(projectDir, "invalid.jar"), new KitLogger.SilentLogger()); | ||
} | ||
|
||
@Test | ||
void listLayers_whenJarInvalid_thenThrowException() { | ||
assertThatIllegalStateException() | ||
.isThrownBy(() -> springBootLayeredJar.listLayers()) | ||
.withMessage("Failure in getting spring boot jar layers information"); | ||
} | ||
|
||
@Test | ||
void extractLayers_whenJarInvalid_thenThrowException() { | ||
assertThatIllegalStateException() | ||
.isThrownBy(() -> springBootLayeredJar.extractLayers(projectDir)) | ||
.withMessage("Failure in extracting spring boot jar layers"); | ||
} | ||
} | ||
@Nested | ||
@DisplayName("with valid jar") | ||
class ValidJar { | ||
@BeforeEach | ||
void setup() throws IOException { | ||
final File layeredJar = new File(projectDir, "layered.jar"); | ||
Files.copy( | ||
Objects.requireNonNull(SpringBootLayeredJarTest.class.getResourceAsStream("/generator-integration-test/layered-jar.jar")), | ||
new File(projectDir, "layered.jar").toPath() | ||
); | ||
springBootLayeredJar = new SpringBootLayeredJar(layeredJar, new KitLogger.SilentLogger()); | ||
} | ||
|
||
@Test | ||
void listLayers_whenJarInvalid_thenThrowException() { | ||
// When | ||
final List<String> result = springBootLayeredJar.listLayers(); | ||
// Then | ||
assertThat(result) | ||
.containsExactly("dependencies", "spring-boot-loader", "snapshot-dependencies", "application"); | ||
} | ||
|
||
@Test | ||
void extractLayers_whenJarInvalid_thenThrowException() throws IOException { | ||
// Given | ||
final File extractionDir = Files.createDirectory(new File(projectDir, "extracted").toPath()).toFile(); | ||
// When | ||
springBootLayeredJar.extractLayers(extractionDir); | ||
// Then | ||
FileAssertions.assertThat(extractionDir) | ||
.fileTree() | ||
.contains("dependencies", "spring-boot-loader", "snapshot-dependencies", "application"); | ||
} | ||
} | ||
} |
Oops, something went wrong.