diff --git a/pom.xml b/pom.xml
index 94f7828..9ffb42d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,12 @@
1.77
1.77
- 0.20.0
+ 0.20.1-SNAPSHOT
+ 3.25.3
+ 5.10.2
+ 1.5.5
+ 2.0.13
+ 1.19.7
@@ -136,15 +141,35 @@
1.15
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
- junit
- junit
- 4.13.2
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+ test
+
+
+ org.testcontainers
+ junit-jupiter
test
-
@@ -169,6 +194,34 @@
commons-io
2.15.1
+
+ org.assertj
+ assertj-bom
+ ${assertj.version}
+ pom
+ import
+
+
+ org.junit
+ junit-bom
+ ${junit.version}
+ pom
+ import
+
+
+ org.slf4j
+ slf4j-bom
+ ${slf4j.version}
+ pom
+ import
+
+
+ org.testcontainers
+ testcontainers-bom
+ ${testcontainers.version}
+ pom
+ import
+
@@ -205,6 +258,12 @@
2.0.0
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 3.2.5
+
+
org.apache.maven.plugins
maven-source-plugin
@@ -430,7 +489,7 @@
true
${project.build.directory}/it
setup
- verify
+
${project.build.directory}/local-repo
@@ -451,6 +510,18 @@
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+
+
+
+ integration-test
+ verify
+
+
+
+
diff --git a/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java b/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java
index 009a775..1c034bd 100644
--- a/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java
+++ b/src/main/java/de/dentrassi/rpm/builder/RpmUnpackMojo.java
@@ -28,6 +28,7 @@
import java.nio.file.attribute.UserPrincipalLookupService;
import java.nio.file.attribute.UserPrincipalNotFoundException;
import java.util.EnumSet;
+import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
@@ -383,41 +384,31 @@ private void setFileOwnership(final InputHeader payloadHeader,
}
private static String getName(final InputHeader payloadHeader, final RpmTag tag, final long id) {
- final Object values =
- payloadHeader.getEntry(tag)
- .orElseThrow(() -> new IllegalStateException("RPM lacks " + tag + " lookup table"))
- .getValue();
-
- if (!(values instanceof String[])) {
- throw new IllegalStateException("RPM " + tag + " header is not a list of Strings, got " +
- values.getClass());
+ final List names = payloadHeader.getStringList(tag);
+
+ if (names == null) {
+ throw new IllegalStateException("RPM lacks " + tag + " lookup table");
}
- final String[] names = (String[]) values;
- if (id < 0 || names.length <= id) {
- throw new IllegalArgumentException("id out of range [0," + names.length + ']');
+ if (id < 0 || names.size() <= id) {
+ throw new IllegalArgumentException("id out of range [0," + names.size() + ']');
}
- return names[(int) id];
+ return names.get((int) id);
}
private static String getLinkTarget(final InputHeader payloadHeader, final long inode) {
- final Object values =
- payloadHeader.getEntry(RpmTag.FILE_LINKTO)
- .orElseThrow(() ->
- new IllegalStateException("RPM contains symbolic link, but lacks linkTo header"))
- .getValue();
-
- if (!(values instanceof String[])) {
- throw new IllegalStateException("RPM linkTo header is not a list of Strings, got " + values.getClass());
+ final List linkTo = payloadHeader.getStringList(RpmTag.FILE_LINKTO);
+
+ if (linkTo == null) {
+ throw new IllegalStateException("RPM contains symbolic link, but lacks linkTo header");
}
- final String[] linkTo = (String[]) values;
- if (inode < 0 || linkTo.length <= inode) {
- throw new IllegalArgumentException("Symbolic link inode out of range [0," + linkTo.length + ']');
+ if (inode < 0 || linkTo.size() <= inode) {
+ throw new IllegalArgumentException("Symbolic link inode out of range [0," + linkTo.size() + ']');
}
- return linkTo[(int) inode];
+ return linkTo.get((int) inode);
}
public void setRpmFile(final File rpmFile) {
diff --git a/src/test/java/de/dentrassi/rpm/builder/EntryDetailsTest.java b/src/test/java/de/dentrassi/rpm/builder/EntryDetailsTest.java
index 9789749..da76b05 100644
--- a/src/test/java/de/dentrassi/rpm/builder/EntryDetailsTest.java
+++ b/src/test/java/de/dentrassi/rpm/builder/EntryDetailsTest.java
@@ -2,22 +2,21 @@
import org.eclipse.packager.rpm.FileFlags;
import org.eclipse.packager.rpm.build.FileInformation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Test class de.dentrassi.rpm.builder.EntryDetails.
*/
-public class EntryDetailsTest {
+class EntryDetailsTest {
/**
* Verify that empty {@link EntryDetails} result in empty set of {@link FileFlags}.
*/
@Test
- public void applyEmpty() {
+ void applyEmpty() {
final EntryDetails entryDetails = new EntryDetails();
doTest(new FileFlags[]{}, false, entryDetails);
}
@@ -26,7 +25,7 @@ public void applyEmpty() {
* Verify that {@link EntryDetails#setReadme(java.lang.Boolean)} correctly controls {@link FileFlags#README}.
*/
@Test
- public void applyReadmeTrue() {
+ void applyReadmeTrue() {
final EntryDetails entryDetails = new EntryDetails();
entryDetails.setReadme(true);
doTest(new FileFlags[]{FileFlags.README}, true, entryDetails);
@@ -36,7 +35,7 @@ public void applyReadmeTrue() {
* False negative? See https://github.com/ctron/rpm-builder/issues/42
*/
@Test
- public void applyReadmeFalse() {
+ void applyReadmeFalse() {
final EntryDetails entryDetails = new EntryDetails();
entryDetails.setReadme(false);
doTest(new FileFlags[]{FileFlags.README}, true, entryDetails); // questionable
@@ -51,8 +50,9 @@ public void applyReadmeFalse() {
*/
private static void doTest(FileFlags[] expectedResult, boolean expectedApplied, final EntryDetails entryDetails) {
final FileInformation fileInformation = new FileInformation();
- assertEquals(expectedApplied, entryDetails.apply(fileInformation));
+ assertThat(entryDetails.apply(fileInformation)).isEqualTo(expectedApplied);
final Set fileFlags = fileInformation.getFileFlags();
- assertArrayEquals(expectedResult, fileFlags.toArray());
+ assertThat(fileFlags.toArray()).isEqualTo(expectedResult);
}
-}
\ No newline at end of file
+}
+
diff --git a/src/test/java/de/dentrassi/rpm/builder/PackageEntryTest.java b/src/test/java/de/dentrassi/rpm/builder/PackageEntryTest.java
index 5ffc21a..d1cc708 100644
--- a/src/test/java/de/dentrassi/rpm/builder/PackageEntryTest.java
+++ b/src/test/java/de/dentrassi/rpm/builder/PackageEntryTest.java
@@ -1,49 +1,41 @@
package de.dentrassi.rpm.builder;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
import java.io.File;
-import org.junit.Test;
-
-public class PackageEntryTest {
- public PackageEntryTest() {
- super();
- }
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+class PackageEntryTest {
@Test
- public void testValidateNameNull() {
+ void testValidateNameNull() {
final PackageEntry entry = new PackageEntry();
entry.setLinkTo("something-to-link-to");
-
- assertThrows(IllegalStateException.class, () -> entry.validate());
+ assertThatThrownBy(entry::validate).isInstanceOf(IllegalStateException.class);
}
@Test
- public void testValidateNameEmpty() {
+ void testValidateNameEmpty() {
final PackageEntry entry = new PackageEntry();
entry.setName("");
entry.setLinkTo("something-to-link-to");
-
- assertThrows(IllegalStateException.class, () -> entry.validate());
+ assertThatThrownBy(entry::validate).isInstanceOf(IllegalStateException.class);
}
@Test
- public void testValidateNoSource() {
+ void testValidateNoSource() {
final PackageEntry entry = new PackageEntry();
entry.setName("some-entry");
-
- assertThrows(IllegalStateException.class, () -> entry.validate());
+ assertThatThrownBy(entry::validate).isInstanceOf(IllegalStateException.class);
}
@Test
- public void testValidateGhostNull() {
+ void testValidateGhostNull() {
final PackageEntry entry = new PackageEntry();
entry.setName("some-entry");
entry.setGhost(null);
-
- // no NullPointerException must be thrown
- assertThrows(IllegalStateException.class, () -> entry.validate());
+ assertThatThrownBy(entry::validate).isInstanceOf(IllegalStateException.class);
}
@Test
@@ -51,21 +43,15 @@ public void testValidateGhostSource() {
final PackageEntry entry = new PackageEntry();
entry.setName("some-entry");
entry.setGhost(Boolean.TRUE);
-
- try {
- entry.validate();
- } catch (final RuntimeException e) {
- fail("Ghost entries do not require other sources, got error: " + e.getMessage());
- }
+ assertThatCode(entry::validate).withFailMessage("Ghost entries do not require other sources").doesNotThrowAnyException();
}
@Test
- public void testValidateMultipleSourcesGhost() {
+ void testValidateMultipleSourcesGhost() {
final PackageEntry entry = new PackageEntry();
entry.setName("some-entry");
entry.setFile(new File("some-file-entry"));
entry.setGhost(Boolean.TRUE);
-
- assertThrows(IllegalStateException.class, () -> entry.validate());
+ assertThatThrownBy(entry::validate).isInstanceOf(IllegalStateException.class);
}
}
diff --git a/src/test/java/de/dentrassi/rpm/builder/RpmIT.java b/src/test/java/de/dentrassi/rpm/builder/RpmIT.java
new file mode 100644
index 0000000..0ff3cd0
--- /dev/null
+++ b/src/test/java/de/dentrassi/rpm/builder/RpmIT.java
@@ -0,0 +1,356 @@
+package de.dentrassi.rpm.builder;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.Container.ExecResult;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.MountableFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@Testcontainers
+class RpmIT {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RpmIT.class);
+
+ private static final String IMAGE_NAME = "registry.access.redhat.com/ubi9/ubi-minimal:latest";
+
+ private static final String COMMAND = "sleep infinity";
+
+ @Container
+ private static final GenericContainer> CONTAINER = new GenericContainer<>(DockerImageName.parse(IMAGE_NAME)).withCommand(COMMAND);
+
+ @BeforeAll
+ static void setup() throws IOException, InterruptedException {
+ Path itPath = Paths.get("target", "it");
+ List paths = FileUtils.listFiles(itPath.toFile(), new String[] { "rpm" }, true).stream().map(File::toPath).collect(Collectors.toList());
+
+ for (Path path : paths) {
+ MountableFile source = MountableFile.forHostPath(path);
+ Path dest = itPath.relativize(path);
+ LOGGER.info("Copying from host path {} to container path {}", source.getResolvedPath(), dest);
+ CONTAINER.copyFileToContainer(source, dest.toString());
+ }
+
+ ExecResult result = CONTAINER.execInContainer("rpm", "--version");
+ LOGGER.info("{}", result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ }
+
+ @Test
+ void test1() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test1/target/test1.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test2() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test2/target/test2.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test3() throws IOException, InterruptedException {
+ String expected = "(contains no files)";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test3/target/test3.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualToIgnoringNewLines(expected);
+ }
+
+ @Test
+ void test4Lowercase() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test4-lowercase/target/foo-bar*.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test4Uppercase() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test4-uppercase/target/Foo-Bar*.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test5() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test5-outname/target/my-foo-bar.abc.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test6Scanner() throws IOException, InterruptedException {
+ String expected =
+ "/usr/share/test6/a.foo\t\n" +
+ "/usr/share/test6/include\tdirectory\n" +
+ "/usr/share/test6/include/d.bar\t\n" +
+ "/usr/share/test6/link_to_a.foo\tsymbolic link to `a.foo'\n";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qp", "--fileclass", "/test6-scanner/target/test6.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualToIgnoringWhitespace(expected);
+ }
+
+ @Test
+ void test7Nosrcpkg() throws IOException, InterruptedException {
+ String notExpected = "Source RPM : test7-srcpkg-.*\\.rpm";
+ ExecResult result = CONTAINER.execInContainer( "rpm", "-qip", "/test7-nosrcpkg/target/test7.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).doesNotContainPattern(notExpected);
+ }
+
+ @Test
+ void test7Srcpkg() throws IOException, InterruptedException {
+ String expected = "Source RPM : test7-srcpkg-.*\\.rpm";
+ ExecResult result = CONTAINER.execInContainer( "rpm", "-qip", "/test7-srcpkg/target/test7.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).containsPattern(expected);
+ }
+
+ @Disabled
+ void test7Srcpkg2() throws IOException, InterruptedException {
+ String notExpected = "foo.bar";
+ ExecResult result = CONTAINER.execInContainer( "rpm", "-qip", "/test7-srcpkg2/target/test7.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).doesNotContain(notExpected);
+ }
+
+ private static String flagsForName(String name) throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "--qf", "%{" + name + "}", "-qp", "/test8-newflags/target/test8.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ return result.getStdout().trim();
+ }
+
+ @Test
+ void test8() throws IOException, InterruptedException {
+ String suggests = flagsForName("suggests");
+ LOGGER.info("Suggests: {}", suggests);
+
+ String recommends = flagsForName("recommends");
+ LOGGER.info("Recommends: {}", recommends);
+
+ String enhances = flagsForName("enhances");
+ LOGGER.info("Enhances: {}", enhances);
+
+ String supplements = flagsForName("supplements");
+ LOGGER.info("Supplements: {}", supplements);
+
+ assertThat(suggests).isEqualTo("suggest");
+ assertThat(recommends).isEqualTo("recommend");
+ assertThat(enhances).isEqualTo("enhance");
+ assertThat(supplements).isEqualTo("supplement");
+ }
+
+ @Test
+ void test10Ddfaultname() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test10-defaultname/target/test10-defaultname-1.0.0-1.noarch.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test10Legacyname() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test10-legacyname/target/test10-legacyname-1.0.0-1-noarch.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test11Prefixes() throws IOException, InterruptedException {
+ String expected = "/opt:/var/log:";
+ ExecResult result = CONTAINER.execInContainer("rpm", "--qf", "[%{Prefixes}:]", "-qp", "/test11-prefixes/target/test11.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualTo(expected);
+ }
+
+ @Test
+ void test12Disable() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/rpm12-disable/target/*.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEmpty();
+ }
+
+ @Test
+ void test13Skipentry() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test13-skipentry/target/test13.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout().trim()).isNotEmpty();
+ }
+
+ @Test
+ void test14Forcerelease() throws IOException, InterruptedException {
+ String expected = "(contains no files)";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test14-forcerelease/target/test14-forcerelease-4.5.6-1.noarch.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualToIgnoringNewLines(expected);
+ }
+
+ @Test
+ void test14Primaryname() throws IOException, InterruptedException {
+ String expected = "(contains no files)";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test14-primaryname/target/test14-primaryname-1.0.0-*.noarch.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualToIgnoringNewLines(expected);
+ }
+
+ @Test
+ void test14Snapshotname() throws IOException, InterruptedException {
+ String expected = "(contains no files)";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qlvvp", "/test14-snapshotname/target/test14-snapshotname-1.2.3-0.[0-9]*.noarch.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualToIgnoringNewLines(expected);
+ }
+
+ @Test
+ void test15Default() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-Kv", "/test15-default/target/test15.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).contains("Header SHA256 digest: OK");
+ assertThat(result.getStdout()).contains("Header SHA1 digest: OK");
+ assertThat(result.getStdout()).contains("Payload SHA256 digest: OK");
+ assertThat(result.getStdout()).contains("MD5 digest: OK");
+ }
+
+ @Test
+ void test15Md5only() throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-Kv", "/test15-md5-only/target/test15.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).contains("MD5 digest: OK");
+ assertThat(result.getStdout()).doesNotContain("SHA");
+ }
+
+ private static String flagsForOptions(String options) throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("rpm", "-l", options, "-qp", "/test16-ghost/target/test16.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ return result.getStdout().trim();
+ }
+
+ @Test
+ void test16Ghost() throws IOException, InterruptedException {
+ String allFiles = flagsForOptions("");
+ LOGGER.info("All files: {}", allFiles);
+
+ String noghostFiles = flagsForOptions("--noghost");
+ LOGGER.info("No ghost files: {}", noghostFiles);
+
+ assertThat(allFiles).isEqualTo("/tmp/ghost-file-entry");
+ assertThat(noghostFiles).isEmpty();
+ }
+
+ private static String generateMd5(String file) throws IOException, InterruptedException {
+ ExecResult result = CONTAINER.execInContainer("md5sum", file);
+ assertThat(result.getExitCode()).isZero();
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ return result.getStdout();
+ }
+
+ @Test
+ void test17ReproducibleDate() throws IOException, InterruptedException {
+ String file = "/test17-reproducible-date/target/test17-1.0.0-0.200901011100.noarch.rpm";
+ String expected = "93ebadf3ba02fe04ed2365cbc13c489f";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qilpv", "--dump", file);
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ String md5 = generateMd5(file);
+ assertThat(md5).isEqualToIgnoringNewLines(expected + " " + file);
+ }
+
+ @Test
+ void test17ReproducibleEpoch() throws IOException, InterruptedException {
+ String file = "/test17-reproducible-epoch/target/test17-1.0.0-0.197001010000.noarch.rpm";
+ String expected = "11162ad70ef55851a3e1375222cd1a4a";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-qilpv", "--dump", file);
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ String md5 = generateMd5(file);
+ assertThat(md5).isEqualToIgnoringNewLines(expected + " " + file);
+ }
+
+ @Test
+ void test18FileDigestDefault() throws IOException, InterruptedException {
+ String expected = "/etc/test.txt 11 1230807600 a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e 0100600 root root 0 0 0 X";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-q", "--dump", "-p", "/test18-file-digest-default/target/test18.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualToIgnoringNewLines(expected);
+ }
+
+ @Test
+ void test18FileDigestMd5() throws IOException, InterruptedException {
+ String expected = "/etc/test.txt 11 1230807600 b10a8db164e0754105b7a99be72e3fe5 0100600 root root 0 0 0 X";
+ ExecResult result = CONTAINER.execInContainer("rpm", "-q", "--dump", "-p", "/test18-file-digest-md5/target/test18.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(result.getStdout()).isEqualToIgnoringNewLines(expected);
+ }
+
+ @Test
+ void test19IntermediateDirectories() throws IOException, InterruptedException {
+ List expected = Arrays.stream((
+ "1 drwxrwxrwx myuser mygroup /opt/mycompany/myapp\n" +
+ "2 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/a\n" +
+ "3 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/a/b\n" +
+ "4 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/a/b/c\n" +
+ "5 -r-xr-xr-x myuser mygroup /opt/mycompany/myapp/a/b/c/foobar\n" +
+ "6 drwxr-xr-x root root /etc/mycompany/myapp\n" +
+ "7 drwxr-xr-x root root /etc/mycompany/myapp/defaults\n" +
+ "8 ---x--x--x mygeneraluser mygeneralgroup /opt/mycompany/otherapp/a/b/c/foobar\n").split("\n")).collect(Collectors.toList());
+ ExecResult result = CONTAINER.execInContainer("rpm", "-q", "--queryformat", "[%{FILEINODES} %{FILEMODES:perms} %-13{FILEUSERNAME} %-14{FILEGROUPNAME} %{FILENAMES}\\n]", "/test19-intermediate-directories/target/test19.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(Arrays.stream(result.getStdout().split("\n")).sorted().collect(Collectors.toList())).containsExactlyElementsOf(expected);
+ }
+
+ @Test
+ void test19IntermediateDirectoriesCollect() throws IOException, InterruptedException {
+ List expected = Arrays.stream((
+ "1 drwxrwxrwx myuser mygroup /opt/mycompany/myapp\n" +
+ "2 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/a\n" +
+ "3 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/a/b\n" +
+ "4 -r-xr-xr-x myuser mygroup /opt/mycompany/myapp/a/b/x/y/foobar\n" +
+ "5 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/c\n" +
+ "6 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/c/d\n" +
+ "7 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/c/d/x\n" +
+ "8 drwxrwxrwx myuser mygroup /opt/mycompany/myapp/c/d/x/y\n" +
+ "9 -r-xr-xr-x myuser mygroup /opt/mycompany/myapp/c/d/x/y/foobar").split("\n")).collect(Collectors.toList());
+ ExecResult result = CONTAINER.execInContainer("rpm", "-q", "--queryformat", "[%{FILEINODES} %{FILEMODES:perms} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\\n]", "/test19-intermediate-directories-collect/target/test19.rpm");
+ LOGGER.info("{}{}", System.lineSeparator(), result.getStdout());
+ assertThat(result.getExitCode()).isZero();
+ assertThat(Arrays.stream(result.getStdout().split("\n")).map(s -> s.replaceAll("\\s+", " ")).sorted().collect(Collectors.toList())).containsExactlyElementsOf(expected);
+ }
+}
diff --git a/src/test/java/de/dentrassi/rpm/builder/VerifyDetailsTest.java b/src/test/java/de/dentrassi/rpm/builder/VerifyDetailsTest.java
index 72beb76..e2b61b6 100644
--- a/src/test/java/de/dentrassi/rpm/builder/VerifyDetailsTest.java
+++ b/src/test/java/de/dentrassi/rpm/builder/VerifyDetailsTest.java
@@ -12,17 +12,16 @@
import org.eclipse.packager.rpm.VerifyFlags;
import org.eclipse.packager.rpm.build.FileInformation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
-import static junit.framework.TestCase.assertNull;
-import static org.junit.Assert.assertArrayEquals;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* See https://github.com/ctron/rpm-builder/issues/41
*/
-public class VerifyDetailsTest {
+class VerifyDetailsTest {
/**
* Verify that empty {@link VerifyDetails} result in empty set of {@link VerifyFlags}.
*/
@@ -72,13 +71,13 @@ public void applyLinktoFalse() {
public void noApply() {
final FileInformation fileInformation = new FileInformation();
final Set verifyFlags = fileInformation.getVerifyFlags();
- assertNull(verifyFlags);
+ assertThat(verifyFlags).isNull();
}
private static void doTest(VerifyFlags[] expectedResult, final VerifyDetails verifyDetails) {
final FileInformation fileInformation = new FileInformation();
verifyDetails.apply(fileInformation);
final Set verifyFlags = fileInformation.getVerifyFlags();
- assertArrayEquals(expectedResult, verifyFlags.toArray());
+ assertThat(verifyFlags.toArray()).isEqualTo(expectedResult);
}
}
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..40ee1ab
--- /dev/null
+++ b/src/test/resources/logback-test.xml
@@ -0,0 +1,17 @@
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+