Skip to content

Commit

Permalink
migrated junit 4 tests to junit 5
Browse files Browse the repository at this point in the history
  • Loading branch information
wipu committed Nov 17, 2024
1 parent df4e853 commit 69cf903
Show file tree
Hide file tree
Showing 27 changed files with 100 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.fluentjava.iwant.api.antrunner;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.Project;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class MinimalAntLoggerTest {

Expand All @@ -19,7 +19,7 @@ public class MinimalAntLoggerTest {
private PrintStream err;
private Project project;

@Before
@BeforeEach
public void before() {
logger = new MinimalAntLogger();
errBytes = new ByteArrayOutputStream();
Expand All @@ -28,7 +28,7 @@ public void before() {
project = new Project();
}

@After
@AfterEach
public void after() {
err.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Arrays;

import org.fluentjava.iwant.api.core.ScriptGenerated;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class BashScriptTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.fluentjava.iwant.api.bash;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Arrays;
import java.util.List;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class IndentedStringArrayParserTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.fluentjava.iwant.api.bash;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Arrays;
import java.util.List;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class IngredientTypeNameValueTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.fluentjava.iwant.api.core;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;

Expand All @@ -10,8 +10,8 @@
import org.fluentjava.iwant.api.model.TargetEvaluationContext;
import org.fluentjava.iwant.api.target.TargetBase;
import org.fluentjava.iwant.apimocks.TargetMock;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class IngredientsAndParametersTest {

Expand All @@ -20,7 +20,7 @@ public class IngredientsAndParametersTest {
private Path i3s;
private Path i4t;

@Before
@BeforeEach
public void before() {
i1s = Source.underWsroot("i1");
i2t = new TargetMock("i2");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.fluentjava.iwant.api.javamodules;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class JavaComplianceTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.fluentjava.iwant.api.javamodules;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.fluentjava.iwant.api.core.SubPath;
import org.fluentjava.iwant.api.zip.Unzipped;
import org.fluentjava.iwant.core.download.Downloaded;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class KotlinVersionTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.fluentjava.iwant.api.javamodules;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.fluentjava.iwant.core.download.Downloaded;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ScalaVersionTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.fluentjava.iwant.api.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.io.IOException;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ExternalSourceTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.fluentjava.iwant.api.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;

import org.fluentjava.iwant.api.model.SystemEnv.SystemEnvPlease;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class SystemEnvTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.fluentjava.iwant.api.target;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.fluentjava.iwant.api.model.Source;
import org.fluentjava.iwant.api.model.SystemEnv;
import org.fluentjava.iwant.api.model.Target;
import org.fluentjava.iwant.api.model.TargetEvaluationContext;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TargetBaseTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.fluentjava.iwant.core.javafinder;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;

import org.fluentjava.iwant.api.javamodules.JavaModule;
import org.fluentjava.iwant.api.model.ExternalSource;
import org.fluentjava.iwant.api.model.Path;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class PathToClasspathLocationOfTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.fluentjava.iwant.core.javafinder;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.Set;

Expand All @@ -12,14 +12,14 @@
import org.fluentjava.iwant.api.wsdef.IwantPluginWishes;
import org.fluentjava.iwant.api.wsdef.WishDefinitionContext;
import org.fluentjava.iwant.entry.Iwant.IwantException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class WsdefJavaOfTest {

private Ctx ctx;

@Before
@BeforeEach
public void before() {
ctx = new Ctx();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.fluentjava.iwant.core.javamodules;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.Iterator;
import java.util.List;
Expand All @@ -16,7 +16,7 @@
import org.fluentjava.iwant.api.zip.Jar;
import org.fluentjava.iwant.core.download.Downloaded;
import org.fluentjava.iwant.core.download.GnvArtifact;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class JavaModulesTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.fluentjava.iwant.api.core.Concatenated;
import org.fluentjava.iwant.api.core.Concatenated.ConcatenatedBuilder;
import org.fluentjava.iwant.api.model.Target;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TargetNameCheckerMicrobenchmarkTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.fluentjava.iwant.entry3;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.Arrays;

Expand All @@ -10,7 +10,7 @@
import org.fluentjava.iwant.api.model.Path;
import org.fluentjava.iwant.api.model.Source;
import org.fluentjava.iwant.api.model.Target;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TargetNameCheckerTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
package org.fluentjava.iwant.plugin.testng;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.fluentjava.iwant.entry.Iwant;
import org.fluentjava.iwant.entry.Iwant.ExitCalledException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class TestngRunnerTest {

private static SecurityManager originalSecurityManager;

@BeforeClass
@BeforeAll
public static void beforeClass() {
originalSecurityManager = System.getSecurityManager();
System.setSecurityManager(new Iwant.ExitCatcher());
}

@AfterClass
@AfterAll
public static void afterClass() {
System.setSecurityManager(originalSecurityManager);
}

@Before
@BeforeEach
public void before() {
Successful1.test1Executed = false;
Successful1.test2Executed = false;
Expand Down
2 changes: 2 additions & 0 deletions private/iwant-docs/backlog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- simplify iwant for iwant (our iwant.sh): simply use a magic string for tmp, remove by it from cache
- optional old runner when defining javamodules: fluent methods for these
- convert all tests to junit 5
+ 4
- 3
- document: in own modules class it's wise to funnel throug a myModule method
- deprecate and even remove commonSettins
- ha, maybe even force by defining abstract myModule method
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.fluentjava.iwant.entry.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -31,10 +31,10 @@
import org.apache.commons.io.FileUtils;
import org.fluentjava.iwant.entry.Iwant;
import org.fluentjava.iwant.testarea.TestArea;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
Expand All @@ -53,12 +53,12 @@ public class HttpDownloadTest {
private SSLSocketFactory defaultSocketFactory;
private TrustManager[] defaultTrustManagers;

@BeforeClass
@BeforeAll
public static void beforeClass() {
vertx = Vertx.vertx();
}

@Before
@BeforeEach
public void before() throws InterruptedException, URISyntaxException,
NoSuchAlgorithmException, KeyStoreException, KeyManagementException,
UnrecoverableKeyException {
Expand All @@ -67,7 +67,7 @@ public void before() throws InterruptedException, URISyntaxException,
disableCertificateChecks();
}

@After
@AfterEach
public void after() throws InterruptedException, KeyManagementException,
NoSuchAlgorithmException {
enableDefaultCertificateChecks();
Expand Down
Loading

0 comments on commit 69cf903

Please sign in to comment.