Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove junit5-capture-system-output-extension and use junit-pioneer #193

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-finder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
</filters>
<minimizeJar>true</minimizeJar>
<shadedArtifactAttached>false</shadedArtifactAttached>
<shadedClassifierName />
<shadedClassifierName></shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
Expand Down
60 changes: 26 additions & 34 deletions cli/src/test/java/org/jboss/pnc/build/finder/cli/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/
package org.jboss.pnc.build.finder.cli;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.emptyArray;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.hamcrest.Matchers.hasSize;

import java.io.File;
Expand All @@ -34,14 +36,12 @@
import org.jboss.pnc.build.finder.core.Utils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.api.parallel.ResourceAccessMode;
import org.junit.jupiter.api.parallel.ResourceLock;
import org.junit.jupiter.api.parallel.Resources;
import org.junitpioneer.jupiter.StdIo;
import org.junitpioneer.jupiter.StdOut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
import com.github.blindpirate.extensions.CaptureSystemOutput;

import ch.qos.logback.classic.Level;
import picocli.CommandLine;
Expand All @@ -54,12 +54,10 @@ private static ParseResult parseCommandLine(Object command, String[] args) {
return cmd.parseArgs(args);
}

@CaptureSystemOutput
@ExpectSystemExitWithStatus(0)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_OUT)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_ERR)
@StdIo
@Test
void verifyHelp(CaptureSystemOutput.OutputCapture outputCapture) {
void verifyHelp(StdOut out) {
String[] args = { "--help" };

ParseResult parseResult = parseCommandLine(new Main(), args);
Expand All @@ -68,27 +66,27 @@ void verifyHelp(CaptureSystemOutput.OutputCapture outputCapture) {

Main.main(args);

outputCapture.expect(containsString("Usage:"));
assertThat(out.capturedLines(), hasItemInArray(containsString("Usage:")));
}

@CaptureSystemOutput
@ExpectSystemExitWithStatus(0)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_OUT)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_ERR)
@StdIo
@Test
void verifyVersion(CaptureSystemOutput.OutputCapture outputCapture) {
void verifyVersion(StdOut out) {
String[] args = { "--version" };
ParseResult parseResult = parseCommandLine(new Main(), args);

assertThat(parseResult.hasMatchedOption("--version"), is(true));

Main.main(args);

outputCapture.expect(containsString(Utils.getBuildFinderVersion()));

outputCapture.expect(containsString(Utils.getBuildFinderScmRevision()));

outputCapture.expect(not(containsString("unknown")));
assertThat(
out.capturedLines(),
hasItemInArray(
allOf(
containsString(Utils.getBuildFinderVersion()),
containsString(Utils.getBuildFinderScmRevision()),
not(containsString("unknown")))));
}

@Test
Expand Down Expand Up @@ -168,12 +166,10 @@ void verifyParsing(@TempDir File folder) throws IOException {
assertThat(parseResult.matchedOption("--krb-service").getValue(), is(krbService));
}

@CaptureSystemOutput
@ExpectSystemExitWithStatus(0)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_OUT)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_ERR)
@StdIo
@Test
void verifyConfig(@TempDir File folder, CaptureSystemOutput.OutputCapture outputCapture) throws IOException {
void verifyConfig(@TempDir File folder, StdOut out) throws IOException {
File configFile = TestUtils.loadFile("config.json");
File inputFile = TestUtils.loadFile("nested.war");

Expand Down Expand Up @@ -204,15 +200,13 @@ void verifyConfig(@TempDir File folder, CaptureSystemOutput.OutputCapture output

Main.main(args);

outputCapture.expect(containsString(".war!"));
assertThat(out.capturedLines(), hasItemInArray(containsString(".war!")));
}

@CaptureSystemOutput
@ExpectSystemExitWithStatus(0)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_OUT)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_ERR)
@StdIo
@Test
void verifyDebug(@TempDir File folder, CaptureSystemOutput.OutputCapture outputCapture) throws IOException {
void verifyDebug(@TempDir File folder, StdOut out) throws IOException {
File configFile = TestUtils.loadFile("config.json");
File inputFile = TestUtils.loadFile("nested.war");

Expand Down Expand Up @@ -257,18 +251,16 @@ void verifyDebug(@TempDir File folder, CaptureSystemOutput.OutputCapture outputC

assertThat(root.isDebugEnabled(), is(true));

outputCapture.expect(containsString("DEBUG"));
assertThat(out.capturedLines(), hasItemInArray(containsString("DEBUG")));
} finally {
root.setLevel(level);
}
}

@CaptureSystemOutput
@ExpectSystemExitWithStatus(0)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_OUT)
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_ERR)
@StdIo
@Test
void verifyQuiet(@TempDir File folder, CaptureSystemOutput.OutputCapture outputCapture) throws IOException {
void verifyQuiet(@TempDir File folder, StdOut out) throws IOException {
File configFile = TestUtils.loadFile("config.json");
File inputFile = TestUtils.loadFile("nested.war");

Expand Down Expand Up @@ -313,7 +305,7 @@ void verifyQuiet(@TempDir File folder, CaptureSystemOutput.OutputCapture outputC

assertThat(root.isEnabledFor(Level.OFF), is(true));

outputCapture.expect(emptyString());
assertThat(out.capturedLines(), is(emptyArray()));
} finally {
root.setLevel(level);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.hasSize;

Expand All @@ -46,11 +47,8 @@
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.api.parallel.ResourceAccessMode;
import org.junit.jupiter.api.parallel.ResourceLock;
import org.junit.jupiter.api.parallel.Resources;

import com.github.blindpirate.extensions.CaptureSystemOutput;
import org.junitpioneer.jupiter.StdIo;
import org.junitpioneer.jupiter.StdOut;

class DistributionAnalyzerTest {
@Test
Expand Down Expand Up @@ -137,18 +135,17 @@ void loadNestedWar() throws IOException {
assertThat(checksums.get(ChecksumType.md5).size(), is(7));
}

@CaptureSystemOutput
@ResourceLock(mode = ResourceAccessMode.READ_WRITE, value = Resources.SYSTEM_OUT)
@StdIo
@Test
void loadManPageZip(CaptureSystemOutput.OutputCapture outputCapture) throws IOException {
void loadManPageZip(StdOut out) throws IOException {
List<String> target = Collections.singletonList(TestUtils.loadFile("symbolic.zip").getPath());
BuildConfig config = new BuildConfig();
config.setArchiveExtensions(Collections.emptyList());
DistributionAnalyzer da = new DistributionAnalyzer(target, config);
Map<ChecksumType, MultiValuedMap<String, String>> checksums = da.checksumFiles();

assertThat(checksums.get(ChecksumType.md5).size(), is(4));
outputCapture.expect(containsString("Unable to process archive/compressed file"));
assertThat(out.capturedLines(), hasItemInArray(containsString("Unable to process archive/compressed file")));
}

@Test
Expand Down
19 changes: 4 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@
</scm>

<properties>
<koji.hub.url />
<koji.web.url />
<koji.hub.url></koji.hub.url>
<koji.web.url></koji.web.url>
<mavenVersion>3.3.9</mavenVersion>
<pnc.url />
<pnc.url></pnc.url>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipITs>true</skipITs>
<version.ch.qos.logback>1.2.3</version.ch.qos.logback>
<version.com.fasterxml.jackson>2.11.2</version.com.fasterxml.jackson>
<version.com.ginsberg.junit5-system-exit>1.0.0</version.com.ginsberg.junit5-system-exit>
<version.com.github.blindpirate>0.1.2</version.com.github.blindpirate>
<version.com.github.ekryd.sortpom>2.12.0</version.com.github.ekryd.sortpom>
<version.com.github.luben>1.4.5-6</version.com.github.luben>
<version.com.github.sparkmuse>1.1.13</version.com.github.sparkmuse>
Expand Down Expand Up @@ -410,12 +409,6 @@
<version>${version.com.ginsberg.junit5-system-exit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.blindpirate</groupId>
<artifactId>junit5-capture-system-output-extension</artifactId>
<version>${version.com.github.blindpirate}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.sparkmuse</groupId>
<artifactId>wiremock-junit-jupiter</artifactId>
Expand Down Expand Up @@ -486,10 +479,6 @@
<groupId>com.ginsberg</groupId>
<artifactId>junit5-system-exit</artifactId>
</dependency>
<dependency>
<groupId>com.github.blindpirate</groupId>
<artifactId>junit5-capture-system-output-extension</artifactId>
</dependency>
<dependency>
<groupId>com.spotify</groupId>
<artifactId>hamcrest-optional</artifactId>
Expand Down Expand Up @@ -1024,7 +1013,7 @@ limitations under the License.]]></inlineHeader>
<requireMavenVersion>
<version>${mavenVersion}</version>
</requireMavenVersion>
<requireSameVersions />
<requireSameVersions></requireSameVersions>
</rules>
</configuration>
</execution>
Expand Down