From 70961e815aad1ee8c8b69b5a05c1654abf6e60a9 Mon Sep 17 00:00:00 2001 From: Ville Oikarinen Date: Sun, 17 Nov 2024 14:08:39 +0200 Subject: [PATCH] all tests migrated to junit 5 --- .../fluentjava/iwant/wsdef/IwantModules.java | 3 +- .../api/bash/TargetImplementedInBashTest.java | 40 ++-- .../iwant/api/core/ClassNameListTest.java | 27 ++- .../iwant/api/core/ConcatenatedTest.java | 18 +- .../iwant/api/core/DirectoryTest.java | 23 +- .../iwant/api/core/HelloTargetTest.java | 16 +- .../iwant/api/core/ScriptGeneratedTest.java | 25 ++- .../api/core/StringFilterByEqualityTest.java | 14 +- .../iwant/api/core/SubPathTest.java | 23 +- .../javamodules/CodeFormatterPolicyTest.java | 22 +- .../api/javamodules/CodeStylePolicyTest.java | 18 +- .../DefaultTestClassNameFilterTest.java | 23 +- .../api/javamodules/JavaBinModuleTest.java | 67 ++++-- .../JavaClassesAndSourcesTest.java | 10 +- .../api/javamodules/JavaClassesTest.java | 105 ++++++--- .../api/javamodules/JavaSrcModuleTest.java | 201 ++++++++++++------ .../javamodules/KotlinAndJavaClassesTest.java | 23 +- .../api/javamodules/ScalaClassesTest.java | 10 +- .../iwant/api/model/SourceTest.java | 16 +- .../org/fluentjava/iwant/api/zip/JarTest.java | 13 +- .../iwant/api/zip/UnzippedTest.java | 13 +- .../iwant/core/ant/AntGeneratedTest.java | 22 +- .../iwant/core/download/DownloadedTest.java | 33 ++- .../core/download/FromRepositoryTest.java | 22 +- .../download/TestedIwantDependenciesTest.java | 9 +- .../iwant/core/ContentDefinitionsTest.java | 8 +- .../iwant/core/EmbeddedUsageTest.java | 6 +- .../org/fluentjava/iwant/core/IwantTest.java | 22 +- .../fluentjava/iwant/core/LocationsTest.java | 4 +- .../fluentjava/iwant/core/PathDiggerTest.java | 10 +- .../iwant/core/PrintPrefixesTest.java | 8 +- .../fluentjava/iwant/core/RefresherTest.java | 18 +- .../core/WorkspaceBuilderArgumentsTest.java | 2 +- .../iwant/core/WorkspaceBuilderTest.java | 68 +++--- .../iwant/core/WorkspaceBuilderTestBase.java | 2 +- .../iwant/coreservices/FileUtilTest.java | 43 ++-- .../IwantCoreServicesImplTest.java | 59 +++-- .../iwant/coreservices/StreamUtilTest.java | 9 +- .../eclipsesettings/DotClasspathTest.java | 26 ++- .../iwant/eclipsesettings/DotProjectTest.java | 31 ++- .../eclipsesettings/EclipseAntScriptTest.java | 15 +- .../eclipsesettings/EclipseProjectTest.java | 87 +++++--- .../eclipsesettings/EclipseSettingsTest.java | 56 +++-- .../EclipseSettingsWriterTest.java | 12 +- .../OrgEclipseCoreResourcesPrefsTest.java | 9 +- .../OrgEclipseJdtCorePrefsTest.java | 33 ++- .../OrgEclipseJdtUiPrefsTest.java | 9 +- .../OrgJetbrainsKotlinCorePrefsTest.java | 9 +- .../ProjectExternalBuilderLaunchTest.java | 22 +- .../embedded/AsEmbeddedIwantUserTest.java | 19 +- .../iwant/entry2/FileFilterTest.java | 22 +- .../fluentjava/iwant/entry2/Iwant2Test.java | 35 +-- .../iwant/entry2/TimestampHandlerTest.java | 38 ++-- .../iwant/entry3/CachesImplTest.java | 44 ++-- .../entry3/ExampleWsDefGeneratorTest.java | 67 +++--- ...ntCheckingTargetEvaluationContextTest.java | 41 ++-- .../fluentjava/iwant/entry3/Iwant3Test.java | 124 ++++++----- .../PathDefinitionConflictCheckerTest.java | 41 ++-- .../iwant/entry3/TargetRefreshTaskTest.java | 100 ++++++--- .../iwant/entry3/UserPrefsImplTest.java | 20 +- .../iwant/entry3/WishEvaluatorTest.java | 130 +++++++---- .../iwant/entry3/WishScriptGeneratorTest.java | 12 +- .../WorkspaceDefinitionContextImplTest.java | 49 +++-- .../fluentjava/iwant/entry3/WsInfoTest.java | 37 ++-- .../IwantWsRootFinderTest.java | 13 +- .../iwant/plannerapi/TaskDirtinessTest.java | 10 +- .../fluentjava/iwant/planner/PlannerTest.java | 55 +++-- .../iwant/planner/TaskQueueTest.java | 43 ++-- .../iwant/plugin/ant/UntarredTest.java | 16 +- .../findbugs/FindbugsDistributionTest.java | 19 +- .../plugin/findbugs/FindbugsReportTest.java | 41 ++-- .../iwant/plugin/github/FromGithubTest.java | 10 +- .../plugin/jacoco/JacocoCoverageTest.java | 53 +++-- .../plugin/jacoco/JacocoDistributionTest.java | 16 +- .../jacoco/JacocoInstrumentationTest.java | 20 +- .../iwant/plugin/jacoco/JacocoReportTest.java | 11 +- .../JacocoTargetsOfJavaModulesTest.java | 38 +++- .../iwant/plugin/pmd/CopyPasteReportTest.java | 30 ++- .../iwant/plugin/pmd/PmdReportTest.java | 26 ++- .../fluentjava/iwant/plugin/war/WarTest.java | 22 +- .../iwant/apimocks/IwantTestCase.java | 12 +- private/iwant-docs/backlog.txt | 4 +- .../iwant/entry/tests/DownloadingTest.java | 21 +- .../entry/tests/FilenameEscapingTest.java | 55 +++-- .../tests/HttpProxyInitializationTest.java | 39 ++-- .../iwant/entry/tests/IwantTest.java | 92 +++++--- .../entry/tests/JavaUrlLearningTest.java | 13 +- .../iwant/entry/tests/LocationsTest.java | 14 +- .../iwant/entry/tests/TheSoleChildOfTest.java | 25 ++- .../entry/tests/UnmodifiableSourceTest.java | 9 +- .../iwant/entry/tests/UnzippingTest.java | 27 ++- 91 files changed, 1901 insertions(+), 976 deletions(-) diff --git a/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java b/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java index 001866df..42fe6cf4 100644 --- a/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java +++ b/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java @@ -244,7 +244,8 @@ private JavaSrcModule iwantCoreservices() { private JavaSrcModule iwantApimocks() { return lazy(() -> privateModule("apimocks") .mainDeps(iwantApiModel(), iwantCoreservices(), iwantEntry(), - iwantEntrymocks(), iwantTestarea(), junit()) + iwantEntrymocks(), iwantTestarea()) + .mainDeps(ctx.iwantPlugin().junit5runner().withDependencies()) .noTestJava().end()); } diff --git a/essential/iwant-api-bash/src/test/java/org/fluentjava/iwant/api/bash/TargetImplementedInBashTest.java b/essential/iwant-api-bash/src/test/java/org/fluentjava/iwant/api/bash/TargetImplementedInBashTest.java index ae80d24a..49f97ebe 100644 --- a/essential/iwant-api-bash/src/test/java/org/fluentjava/iwant/api/bash/TargetImplementedInBashTest.java +++ b/essential/iwant-api-bash/src/test/java/org/fluentjava/iwant/api/bash/TargetImplementedInBashTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.api.bash; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -12,6 +15,7 @@ import org.fluentjava.iwant.api.wsdef.TargetDefinitionContext; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.entry.Iwant.IwantException; +import org.junit.jupiter.api.Test; public class TargetImplementedInBashTest extends IwantTestCase { @@ -38,7 +42,8 @@ private void prepareContext(TargetImplementedInBash target, target.setIngredientDefinitionContext(ctx); } - public void testScriptIsAnIngredient() { + @Test + public void scriptIsAnIngredient() { wsRootHasFile("script", "path() {\n" + "echo 'hello' > \"$(iwant-dest)\"\n" + "}\n"); TargetImplementedInBash target = new TargetImplementedInBash("t", @@ -51,7 +56,8 @@ public void testScriptIsAnIngredient() { assertEquals("script", ingr.name()); } - public void testIngredientlessAsPath() throws Exception { + @Test + public void ingredientlessAsPath() throws Exception { wsRootHasFile("script", "path() {\n" + "echo 'hello' > \"$IWANT_DEST\"\n" + "}\n"); TargetImplementedInBash target = new TargetImplementedInBash("t", @@ -63,7 +69,8 @@ public void testIngredientlessAsPath() throws Exception { assertEquals("hello\n", contentOfCached(target)); } - public void testTargetWithTargetIngredient() throws Exception { + @Test + public void targetWithTargetIngredient() throws Exception { Target ingr = new HelloTarget("ingr", "ingr content"); ingr.path(ctx); @@ -82,7 +89,8 @@ public void testTargetWithTargetIngredient() throws Exception { contentOfCached(target)); } - public void testTargetWithSourceIngredient() throws Exception { + @Test + public void targetWithSourceIngredient() throws Exception { wsRootHasFile("ingr", "ingr content"); wsRootHasFile("script", @@ -100,7 +108,8 @@ public void testTargetWithSourceIngredient() throws Exception { contentOfCached(target)); } - public void testIndexWithNoTargetsDefined() { + @Test + public void indexWithNoTargetsDefined() { File indexSh = wsRootHasFile("_index.sh", ""); try { @@ -115,7 +124,8 @@ public void testIndexWithNoTargetsDefined() { err()); } - public void testIndexWithEmptyTargetList() { + @Test + public void indexWithEmptyTargetList() { wsRootHasFile("_index.sh", "targets() { true; }"); List targets = TargetImplementedInBash @@ -124,7 +134,8 @@ public void testIndexWithEmptyTargetList() { assertEquals(0, targets.size()); } - public void testIndexAndSimpleTargetDirectlyInWsroot() { + @Test + public void indexAndSimpleTargetDirectlyInWsroot() { wsRootHasFile("_index.sh", "targets() { target simple; }"); List targets = TargetImplementedInBash @@ -136,7 +147,8 @@ public void testIndexAndSimpleTargetDirectlyInWsroot() { assertEquals("[]", targets.get(0).arguments().toString()); } - public void testIndexAndSimpleTargetUnderSubDirectory() { + @Test + public void indexAndSimpleTargetUnderSubDirectory() { wsRootHasFile("a/b/_index.sh", "targets() { target simple2; }"); List targets = TargetImplementedInBash @@ -149,7 +161,8 @@ public void testIndexAndSimpleTargetUnderSubDirectory() { assertEquals("[]", targets.get(0).arguments().toString()); } - public void testIndexWithTargetsWithScriptAndArgs() { + @Test + public void indexWithTargetsWithScriptAndArgs() { wsRootHasFile("scripts/_index.sh", "targets() { target t0 t0.sh t0a0; target t1 t1.sh t1a0 t1a1; }"); @@ -171,7 +184,8 @@ public void testIndexWithTargetsWithScriptAndArgs() { /** * There was a bug with this */ - public void testIngredientWhoseNameIsContainedInTargetsOwnName() + @Test + public void ingredientWhoseNameIsContainedInTargetsOwnName() throws Exception { Target ingr = new HelloTarget("ingr", "ingr content"); ingr.path(ctx); @@ -192,7 +206,8 @@ public void testIngredientWhoseNameIsContainedInTargetsOwnName() contentOfCached(target)); } - public void testNonexistentIndexShCausesFriendlyWarning() { + @Test + public void nonexistentIndexShCausesFriendlyWarning() { try { TargetImplementedInBash.instancesFromIndexSh(tdCtx(), Source.underWsroot("_index.sh")); @@ -204,7 +219,8 @@ public void testNonexistentIndexShCausesFriendlyWarning() { } - public void testNonexistentDefaultIndexShCausesFriendlyWarningWithCorrectLocation() { + @Test + public void nonexistentDefaultIndexShCausesFriendlyWarningWithCorrectLocation() { ctxMock().hasWsdefModule(JavaSrcModule.with().name("wsdef") .locationUnderWsRoot("wsdef-location").end()); diff --git a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ClassNameListTest.java b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ClassNameListTest.java index 3a138df0..9e3da2e7 100644 --- a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ClassNameListTest.java +++ b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ClassNameListTest.java @@ -1,13 +1,17 @@ package org.fluentjava.iwant.api.core; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.fluentjava.iwant.api.model.Path; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.StringFilter; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class ClassNameListTest extends IwantTestCase { - public void testGivenClassesIsIngredient() { + @Test + public void givenClassesIsIngredient() { Path classes = Source.underWsroot("classes"); ClassNameList list = ClassNameList.with().name("list").classes(classes) @@ -16,7 +20,8 @@ public void testGivenClassesIsIngredient() { assertEquals("[classes]", list.ingredients().toString()); } - public void testDescriptorOfListWithJustClasses() { + @Test + public void descriptorOfListWithJustClasses() { Path classes = Source.underWsroot("classes"); ClassNameList list = ClassNameList.with().name("list").classes(classes) @@ -42,7 +47,8 @@ public String toString() { } - public void testFilterIsIncludedInDescriptor() { + @Test + public void filterIsIncludedInDescriptor() { Path classes = Source.underWsroot("classes2"); ClassNameList list = ClassNameList.with().name("list").classes(classes) @@ -55,7 +61,8 @@ public void testFilterIsIncludedInDescriptor() { list.contentDescriptor()); } - public void testAllClassesFromEmptyDirectory() throws Exception { + @Test + public void allClassesFromEmptyDirectory() throws Exception { wsRootHasDirectory("classes"); ClassNameList list = ClassNameList.with().name("list") @@ -65,7 +72,8 @@ public void testAllClassesFromEmptyDirectory() throws Exception { assertEquals("", contentOf(ctx.cached(list))); } - public void testAllClassesFromDirectoryWithOneClassInDefaultPackage() + @Test + public void allClassesFromDirectoryWithOneClassInDefaultPackage() throws Exception { wsRootHasFile("classes/A.class", "whatever"); @@ -76,7 +84,8 @@ public void testAllClassesFromDirectoryWithOneClassInDefaultPackage() assertEquals("A\n", contentOf(ctx.cached(list))); } - public void testAllClassesFromDirectoryWithClassInManyPackages() + @Test + public void allClassesFromDirectoryWithClassInManyPackages() throws Exception { wsRootHasFile("classes/A.class", "whatever"); wsRootHasFile("classes/b/B.class", "whatever"); @@ -89,7 +98,8 @@ public void testAllClassesFromDirectoryWithClassInManyPackages() assertEquals("A\nb.B\nc.subc.C\n", contentOf(ctx.cached(list))); } - public void testNonClassFilesAreExcludedAutomatically() throws Exception { + @Test + public void nonClassFilesAreExcludedAutomatically() throws Exception { wsRootHasFile("classes/A.notclass", "whatever"); wsRootHasFile("classes/b/B1.class", "whatever"); wsRootHasFile("classes/b/B2.notclass", "whatever"); @@ -103,7 +113,8 @@ public void testNonClassFilesAreExcludedAutomatically() throws Exception { assertEquals("b.B1\nc.subc.C1\n", contentOf(ctx.cached(list))); } - public void testFilterIsAppliedIfGiven() throws Exception { + @Test + public void filterIsAppliedIfGiven() throws Exception { wsRootHasFile("classes/a/A.class", "whatever"); wsRootHasFile("classes/a/ATest.class", "whatever"); wsRootHasFile("classes/a/AbstractATest.class", "whatever"); diff --git a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ConcatenatedTest.java b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ConcatenatedTest.java index 565d344b..bb06e353 100644 --- a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ConcatenatedTest.java +++ b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ConcatenatedTest.java @@ -1,13 +1,17 @@ package org.fluentjava.iwant.api.core; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.File; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class ConcatenatedTest extends IwantTestCase { - public void testIngredients() { + @Test + public void ingredients() { assertEquals("[]", Concatenated.named("no-paths").bytes(1, 2) .string("s").end().ingredients().toString()); assertEquals("[src, target, target2]", @@ -17,7 +21,8 @@ public void testIngredients() { .ingredients().toString()); } - public void testContentDescriptor() { + @Test + public void contentDescriptor() { assertEquals( "org.fluentjava.iwant.api.core.Concatenated\n" + "p:bytes:\n" + " [1, 2]\n" + "p:string:\n" + " s\n" + "", @@ -34,14 +39,16 @@ public void testContentDescriptor() { .contentDescriptor()); } - public void testPathToEmpty() throws Exception { + @Test + public void pathToEmpty() throws Exception { Concatenated c = Concatenated.named("empty").end(); c.path(ctx); assertEquals("", contentOf(new File(cached, "empty"))); } - public void testPathToConcatenationOfAllKinds() throws Exception { + @Test + public void pathToConcatenationOfAllKinds() throws Exception { wsRootHasFile("src", "src-content"); Source src = Source.underWsroot("src"); HelloTarget target = new HelloTarget("target", "target-content"); @@ -62,7 +69,8 @@ public void testPathToConcatenationOfAllKinds() throws Exception { /** * Handy when generating scripts for cygwin on Windows */ - public void testUnixPathVersusNativePath() throws Exception { + @Test + public void unixPathVersusNativePath() throws Exception { ctx.iwant().shallMockWintoySafePaths(); Source src = Source.underWsroot("src"); diff --git a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/DirectoryTest.java b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/DirectoryTest.java index 430257bc..5094bf1d 100644 --- a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/DirectoryTest.java +++ b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/DirectoryTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.api.core; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.util.Arrays; @@ -7,10 +11,12 @@ import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class DirectoryTest extends IwantTestCase { - public void testContentDescriptorAndIngredientsOfEmpty() { + @Test + public void contentDescriptorAndIngredientsOfEmpty() { Directory dir = Directory.named("empty").end(); assertEquals( @@ -20,7 +26,8 @@ public void testContentDescriptorAndIngredientsOfEmpty() { assertEquals("[]", dir.ingredients().toString()); } - public void testContentDescriptorAndIngredientsOfDirWithDirsAndPaths() { + @Test + public void contentDescriptorAndIngredientsOfDirWithDirsAndPaths() { Source ingr1 = Source.underWsroot("src"); Target ingr2 = new HelloTarget("hello", "hello content"); Directory dir = Directory.named("nonempty").dir("empty-sub").end() @@ -37,7 +44,8 @@ public void testContentDescriptorAndIngredientsOfDirWithDirsAndPaths() { assertEquals("[src, hello]", dir.ingredients().toString()); } - public void testCorrectCachedContentOfEmpty() throws Exception { + @Test + public void correctCachedContentOfEmpty() throws Exception { Directory empty = Directory.named("empty").end(); empty.path(ctx); @@ -47,7 +55,8 @@ public void testCorrectCachedContentOfEmpty() throws Exception { assertEquals("[]", Arrays.toString(cachedEmpty.list())); } - public void testCorrectCachedContentOfNonEmpty() throws Exception { + @Test + public void correctCachedContentOfNonEmpty() throws Exception { Source src = Source.underWsroot("src"); Target hello1 = new HelloTarget("hello1", "hello1 content"); Target hello2 = new HelloTarget("hello2", "hello2 content"); @@ -69,7 +78,8 @@ public void testCorrectCachedContentOfNonEmpty() throws Exception { contentOfCached(nonempty, "nonempty-sub/hello2-renamed")); } - public void testCopyOfNormalFileIsExecutableOnlyIfDeclaredSo() + @Test + public void copyOfNormalFileIsExecutableOnlyIfDeclaredSo() throws Exception { Target i1 = new HelloTarget("i1", "i1"); Target i2 = new HelloTarget("i2", "i2"); @@ -89,7 +99,8 @@ public void testCopyOfNormalFileIsExecutableOnlyIfDeclaredSo() assertTrue(new File(cached, "root/i3").canExecute()); } - public void testCopyOfDirectoryIsExecutableUnlessToldNotToBe() + @Test + public void copyOfDirectoryIsExecutableUnlessToldNotToBe() throws Exception { Target i1 = Directory.named("i1").end(); Target i2 = Directory.named("i2").end(); diff --git a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/HelloTargetTest.java b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/HelloTargetTest.java index 74f0b86c..7b651631 100644 --- a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/HelloTargetTest.java +++ b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/HelloTargetTest.java @@ -1,12 +1,17 @@ package org.fluentjava.iwant.api.core; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.coreservices.StreamUtil; +import org.junit.jupiter.api.Test; public class HelloTargetTest extends IwantTestCase { - public void testNullMessageContent() throws Exception { + @Test + public void nullMessageContent() throws Exception { Target t = new HelloTarget("null", null); try { t.content(ctx); @@ -16,7 +21,8 @@ public void testNullMessageContent() throws Exception { } } - public void testNullMessageRefreshTo() throws Exception { + @Test + public void nullMessageRefreshTo() throws Exception { Target t = new HelloTarget("null", null); try { t.path(ctx); @@ -26,12 +32,14 @@ public void testNullMessageRefreshTo() throws Exception { } } - public void testNonNullMessageContent() throws Exception { + @Test + public void nonNullMessageContent() throws Exception { Target t = new HelloTarget("non-null", "hello content"); assertEquals("hello content", StreamUtil.toString(t.content(ctx))); } - public void testNonNullMessagePath() throws Exception { + @Test + public void nonNullMessagePath() throws Exception { Target target = new HelloTarget("non-null", "hello content"); target.path(ctx); diff --git a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ScriptGeneratedTest.java b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ScriptGeneratedTest.java index 746d45b4..071781a3 100644 --- a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ScriptGeneratedTest.java +++ b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/ScriptGeneratedTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.api.core; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.Arrays; @@ -8,10 +11,12 @@ import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.Test; public class ScriptGeneratedTest extends IwantTestCase { - public void testContentDescriptor() { + @Test + public void contentDescriptor() { assertEquals( "org.fluentjava.iwant.api.core.ScriptGenerated\n" + "i:script:\n" + " src1.sh\n" + "", @@ -26,7 +31,8 @@ public void testContentDescriptor() { .contentDescriptor()); } - public void testScriptIsTheIngredient() { + @Test + public void scriptIsTheIngredient() { assertEquals("[src1.sh]", ScriptGenerated.named("s1") .byScript(Source.underWsroot("src1.sh")).ingredients() @@ -37,7 +43,8 @@ public void testScriptIsTheIngredient() { .toString()); } - public void testEchoToDestFile() throws Exception { + @Test + public void echoToDestFile() throws Exception { ConcatenatedBuilder scriptContent = Concatenated.named("script"); scriptContent.string("#!/bin/bash\n"); scriptContent.string("set -eu\n"); @@ -55,7 +62,8 @@ public void testEchoToDestFile() throws Exception { assertEquals("hello from script\n", contentOfCached(sg)); } - public void testScriptThatDemonstratesItsEnvironment() throws Exception { + @Test + public void scriptThatDemonstratesItsEnvironment() throws Exception { ConcatenatedBuilder scriptContent = Concatenated.named("script"); scriptContent.string("#!/bin/bash\n"); scriptContent.string("set -eu\n"); @@ -80,7 +88,8 @@ public void testScriptThatDemonstratesItsEnvironment() throws Exception { assertEquals("hello from env demo\n", contentOfCached(sg)); } - public void testFailingScript() throws Exception { + @Test + public void failingScript() throws Exception { ConcatenatedBuilder scriptContent = Concatenated.named("script"); scriptContent.string("#!/bin/bash\n"); scriptContent.string("set -eu\n"); @@ -107,7 +116,8 @@ public void testFailingScript() throws Exception { assertEquals("hello from failing script\n", contentOfCached(sg)); } - public void testExecutionEnvUsesProperWrapperWhenCygwinBashExeExists() + @Test + public void executionEnvUsesProperWrapperWhenCygwinBashExeExists() throws Exception { File mockCygwinBashExe = new File("mock-bash.exe"); ctx.iwant().shallFindCygwinBashExeAt(mockCygwinBashExe); @@ -137,7 +147,8 @@ public void testExecutionEnvUsesProperWrapperWhenCygwinBashExeExists() contentOf(wrapper)); } - public void testExecutionEnvDoesNotUseWrapperWhenCygwinBashExeDoesNotExist() + @Test + public void executionEnvDoesNotUseWrapperWhenCygwinBashExeDoesNotExist() throws Exception { ctx.iwant().shallNotFindCygwinBash(); ctx.iwant().shallMockWintoySafePaths(); diff --git a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/StringFilterByEqualityTest.java b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/StringFilterByEqualityTest.java index f9192153..b1ba1677 100644 --- a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/StringFilterByEqualityTest.java +++ b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/StringFilterByEqualityTest.java @@ -1,10 +1,15 @@ package org.fluentjava.iwant.api.core; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class StringFilterByEqualityTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testMatchingAndNonMatching() { +public class StringFilterByEqualityTest { + + @Test + public void matchingAndNonMatching() { StringFilterByEquality a = new StringFilterByEquality("a"); assertTrue(a.matches("a")); assertFalse(a.matches("b")); @@ -14,7 +19,8 @@ public void testMatchingAndNonMatching() { assertFalse(b.matches("a")); } - public void testToString() { + @Test + public void toStringIsReadable() { assertEquals("StringFilterByEquality:a", new StringFilterByEquality("a").toString()); assertEquals("StringFilterByEquality:b", diff --git a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/SubPathTest.java b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/SubPathTest.java index 39541e74..1b601a86 100644 --- a/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/SubPathTest.java +++ b/essential/iwant-api-core/src/test/java/org/fluentjava/iwant/api/core/SubPathTest.java @@ -1,13 +1,19 @@ package org.fluentjava.iwant.api.core; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; + import org.fluentjava.iwant.api.model.Path; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class SubPathTest extends IwantTestCase { - public void testParentAndRelativePath() { + @Test + public void parentAndRelativePath() { Path parent = Source.underWsroot("parent"); SubPath s = new SubPath("s", parent, "rel"); @@ -15,7 +21,8 @@ public void testParentAndRelativePath() { assertEquals("rel", s.relativePath()); } - public void testIngredientsAndContentDescriptor() { + @Test + public void ingredientsAndContentDescriptor() { Path parent = Source.underWsroot("parent"); Path parent2 = Source.underWsroot("parent2"); SubPath s = new SubPath("s", parent, "rel"); @@ -34,7 +41,8 @@ public void testIngredientsAndContentDescriptor() { s2.contentDescriptor().toString()); } - public void testNonDirectorySubPathAsPath() throws Exception { + @Test + public void nonDirectorySubPathAsPath() throws Exception { wsRootHasFile("parent/file", "file content"); Source parent = Source.underWsroot("parent"); @@ -44,7 +52,8 @@ public void testNonDirectorySubPathAsPath() throws Exception { assertEquals("file content", contentOfCached(target)); } - public void testDirectorySubPathAsPath() throws Exception { + @Test + public void directorySubPathAsPath() throws Exception { wsRootHasFile("parent/subdir/subfile1", "subfile1 content"); wsRootHasFile("parent/subdir/subfile2", "subfile2 content"); Source parent = Source.underWsroot("parent"); @@ -60,7 +69,8 @@ public void testDirectorySubPathAsPath() throws Exception { * SubPath used to copy but it was unnecessary. This tests no copying * happens. */ - public void testCachedPathPointsDirectlyUnderOriginal() { + @Test + public void cachedPathPointsDirectlyUnderOriginal() { Source source = Source.underWsroot("source"); assertEquals(wsRoot + "/source", ctx.cached(source).getAbsolutePath()); assertEquals(wsRoot + "/source/subdir", @@ -72,7 +82,8 @@ public void testCachedPathPointsDirectlyUnderOriginal() { * This is important since no copying happens: the parent must not be * deleted when refreshing a subpath of it. */ - public void testDeletionOfCachedFileIsNotRequested() { + @Test + public void deletionOfCachedFileIsNotRequested() { assertFalse(new SubPath("s", Source.underWsroot("parent"), "sub") .expectsCachedTargetMissingBeforeRefresh()); } diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeFormatterPolicyTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeFormatterPolicyTest.java index 2401b606..b62b19a3 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeFormatterPolicyTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeFormatterPolicyTest.java @@ -1,20 +1,21 @@ package org.fluentjava.iwant.api.javamodules; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.fluentjava.iwant.api.javamodules.CodeFormatterPolicy.FormatterSettingsListener; import org.fluentjava.iwant.api.javamodules.CodeFormatterPolicy.TabulationCharValue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.google.common.testing.EqualsTester; -import junit.framework.TestCase; - -public class CodeFormatterPolicyTest extends TestCase - implements FormatterSettingsListener { +public class CodeFormatterPolicyTest implements FormatterSettingsListener { private Integer alignmentForEnumConstants; private TabulationCharValue tabulationChar; - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void before() throws Exception { alignmentForEnumConstants = null; tabulationChar = null; } @@ -31,7 +32,8 @@ public void tabulationChar(TabulationCharValue value) { // the tests - public void testWriteCallsListenerWithDefaultValues() { + @Test + public void writeCallsListenerWithDefaultValues() { CodeFormatterPolicy policy = new CodeFormatterPolicy(); policy.write(this); @@ -40,7 +42,8 @@ public void testWriteCallsListenerWithDefaultValues() { assertEquals(TabulationCharValue.TAB, tabulationChar); } - public void testWriteCallsListenerWithChangedValues() { + @Test + public void writeCallsListenerWithChangedValues() { CodeFormatterPolicy policy = new CodeFormatterPolicy(); policy.alignmentForEnumConstants = 48; policy.tabulationChar = TabulationCharValue.SPACE; @@ -51,7 +54,8 @@ public void testWriteCallsListenerWithChangedValues() { assertEquals(TabulationCharValue.SPACE, tabulationChar); } - public void testEqualsAndHashcode() { + @Test + public void equalsAndHashcode() { EqualsTester et = new EqualsTester(); et.addEqualityGroup(CodeFormatterPolicy.defaults(), CodeFormatterPolicy.defaults(), new CodeFormatterPolicy()); diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeStylePolicyTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeStylePolicyTest.java index 56178f4a..988a6791 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeStylePolicyTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/CodeStylePolicyTest.java @@ -1,10 +1,14 @@ package org.fluentjava.iwant.api.javamodules; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; -public class CodeStylePolicyTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testDefaults() { +public class CodeStylePolicyTest { + + @Test + public void defaults() { CodeStylePolicy policy = CodeStylePolicy.defaultsExcept().end(); assertEquals(CodeStyleValue.FAIL, @@ -16,7 +20,8 @@ public void testDefaults() { policy.valueOf(CodeStyle.NON_EXTERNALIZED_STRING_LITERAL)); } - public void testOverrides() { + @Test + public void overrides() { CodeStylePolicy policy = CodeStylePolicy.defaultsExcept() .ignore(CodeStyle.ASSERT_IDENTIFIER) .warn(CodeStyle.NON_EXTERNALIZED_STRING_LITERAL) @@ -33,12 +38,13 @@ public void testOverrides() { policy.valueOf(CodeStyle.DEPRECATION_IN_DEPRECATED_CODE)); } - public void testIteratingStylesFromDefaultGivesNonNullValues() { + @Test + public void iteratingStylesFromDefaultGivesNonNullValues() { CodeStylePolicy policy = CodeStylePolicy.defaultsExcept().end(); for (CodeStyle style : CodeStyle.values()) { CodeStyleValue value = policy.valueOf(style); - assertNotNull("Please define default for " + style, value); + assertNotNull(value, "Please define default for " + style); } } diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/DefaultTestClassNameFilterTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/DefaultTestClassNameFilterTest.java index d9e5bd45..e82c36b8 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/DefaultTestClassNameFilterTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/DefaultTestClassNameFilterTest.java @@ -1,24 +1,30 @@ package org.fluentjava.iwant.api.javamodules; -import org.fluentjava.iwant.api.model.StringFilter; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import junit.framework.TestCase; +import org.fluentjava.iwant.api.model.StringFilter; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class DefaultTestClassNameFilterTest extends TestCase { +public class DefaultTestClassNameFilterTest { private StringFilter filter; - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void before() throws Exception { filter = new DefaultTestClassNameFilter(); } - public void testPositives() { + @Test + public void positives() { assertTrue(filter.matches("com.example.NormalTest")); assertTrue(filter.matches("org.anotherexample.AnotherNormalTest")); } - public void testNegatives() { + @Test + public void negatives() { assertFalse(filter.matches("com.example.TestUtility")); assertFalse(filter.matches("com.example.ServiceMock")); assertFalse(filter.matches("com.example.NormalTest$1")); @@ -26,7 +32,8 @@ public void testNegatives() { assertFalse(filter.matches("com.example.AbstractUiTest")); } - public void testToStringIsConstantSoItCanBeUsedInTargetContentDefinition() { + @Test + public void toStringIsConstantSoItCanBeUsedInTargetContentDefinition() { assertEquals( "org.fluentjava.iwant.api.javamodules.DefaultTestClassNameFilter", filter.toString()); diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaBinModuleTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaBinModuleTest.java index 2106f131..5692a218 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaBinModuleTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaBinModuleTest.java @@ -1,5 +1,11 @@ package org.fluentjava.iwant.api.javamodules; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.fluentjava.iwant.api.core.HelloTarget; import org.fluentjava.iwant.api.javamodules.StandardCharacteristics.ProductionCode; import org.fluentjava.iwant.api.javamodules.StandardCharacteristics.ProductionConfiguration; @@ -8,12 +14,14 @@ import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class JavaBinModuleTest extends IwantTestCase { // provided by src module - public void testToStringOfProjectProvidedBinIsTheName() { + @Test + public void toStringOfProjectProvidedBinIsTheName() { JavaSrcModule libsModule = JavaSrcModule.with().name("libs").end(); JavaModule lib = JavaBinModule.named("lib.jar").inside(libsModule) .end(); @@ -22,7 +30,8 @@ public void testToStringOfProjectProvidedBinIsTheName() { } @SuppressWarnings("unlikely-arg-type") - public void testEqualsUsesNameAndClass() { + @Test + public void equalsUsesNameAndClass() { assertTrue(JavaBinModule.providing(Source.underWsroot("a")).end() .equals(JavaBinModule.providing(Source.underWsroot("a")) .end())); @@ -34,7 +43,8 @@ public void testEqualsUsesNameAndClass() { .end())); } - public void testHashCodeIsSameIfNameIsSame() { + @Test + public void hashCodeIsSameIfNameIsSame() { assertTrue(JavaBinModule.providing(Source.underWsroot("a")).end() .hashCode() == JavaBinModule.providing(Source.underWsroot("a")) .end().hashCode()); @@ -42,7 +52,8 @@ public void testHashCodeIsSameIfNameIsSame() { .hashCode() == JavaSrcModule.with().name("a").end().hashCode()); } - public void testMainArtifactOfBinModuleIsTheJarAsSource() { + @Test + public void mainArtifactOfBinModuleIsTheJarAsSource() { JavaSrcModule libsModule = JavaSrcModule.with().name("libs").end(); JavaModule lib = JavaBinModule.named("lib.jar").inside(libsModule) .end(); @@ -51,7 +62,8 @@ public void testMainArtifactOfBinModuleIsTheJarAsSource() { assertEquals("libs/lib.jar", artifact.name()); } - public void testEclipsePathsOfBinInsideLibProject() { + @Test + public void eclipsePathsOfBinInsideLibProject() { JavaSrcModule libsModule = JavaSrcModule.with().name("libs").end(); JavaBinModule lib = JavaBinModule.named("lib.jar").inside(libsModule) .end(); @@ -60,7 +72,8 @@ public void testEclipsePathsOfBinInsideLibProject() { assertEquals(null, lib.eclipseSourceReference(ctx)); } - public void testEclipsePathsOfBinInsideLibProjectAndWithSources() { + @Test + public void eclipsePathsOfBinInsideLibProjectAndWithSources() { JavaSrcModule libsModule = JavaSrcModule.with().name("libs").end(); JavaBinModule lib = JavaBinModule.named("lib2.jar") .source("lib2-src.zip").inside(libsModule).end(); @@ -69,7 +82,8 @@ public void testEclipsePathsOfBinInsideLibProjectAndWithSources() { assertEquals("/libs/lib2-src.zip", lib.eclipseSourceReference(ctx)); } - public void testSourceOfBinInsideProjectWhenGivenAndWhenNot() { + @Test + public void sourceOfBinInsideProjectWhenGivenAndWhenNot() { JavaSrcModule libsModule = JavaSrcModule.with().name("libs").end(); JavaBinModule lib = JavaBinModule.named("sourced.jar") .source("sourced-src.zip").inside(libsModule).end(); @@ -81,7 +95,8 @@ public void testSourceOfBinInsideProjectWhenGivenAndWhenNot() { .source()); } - public void testCharacteristicsForBinaryModuleInsideLibraryModule() { + @Test + public void characteristicsForBinaryModuleInsideLibraryModule() { JavaSrcModule libsModule = JavaSrcModule.with().name("libs").end(); JavaBinModule bin = JavaBinModule.named("mod.jar") .has(ProductionCode.class).inside(libsModule).end(); @@ -92,7 +107,8 @@ public void testCharacteristicsForBinaryModuleInsideLibraryModule() { assertTrue(bin.doesHave(ProductionRuntimeData.class)); } - public void testObservableDepsOfBinInsideLibraryModuleThatHasRuntimeDeps() { + @Test + public void observableDepsOfBinInsideLibraryModuleThatHasRuntimeDeps() { JavaBinModule dep1 = JavaBinModule .providing(Source.underWsroot("dep1.jar")).end(); JavaBinModule dep2 = JavaBinModule @@ -116,7 +132,8 @@ public void testObservableDepsOfBinInsideLibraryModuleThatHasRuntimeDeps() { assertEquals("[]", lib.effectivePathForTestRuntime().toString()); } - public void testModuleLikeABinUnderLibsIsReallyLikeIt() { + @Test + public void moduleLikeABinUnderLibsIsReallyLikeIt() { JavaSrcModule libs = JavaSrcModule.with().name("libs").end(); JavaBinModule m1 = JavaBinModule.named("bin.jar").has(TestUtility.class) .runtimeDeps(JavaBinModule @@ -136,7 +153,8 @@ public void testModuleLikeABinUnderLibsIsReallyLikeIt() { // path provider module - public void testToStringOfPathProviderBinIsTheName() { + @Test + public void toStringOfPathProviderBinIsTheName() { Target libJar = new HelloTarget("lib.jar", ""); JavaBinModule libJarModule = JavaBinModule.providing(libJar, null) .end(); @@ -144,7 +162,8 @@ public void testToStringOfPathProviderBinIsTheName() { assertEquals("lib.jar", libJarModule.toString()); } - public void testBinModuleThatProvidesAMainArtifactTarget() { + @Test + public void binModuleThatProvidesAMainArtifactTarget() { Target libJar = new HelloTarget("lib.jar", ""); JavaBinModule libJarModule = JavaBinModule.providing(libJar, null) .end(); @@ -153,7 +172,8 @@ public void testBinModuleThatProvidesAMainArtifactTarget() { assertSame(libJar, libJarModule.mainArtifact()); } - public void testEclipsePathsOfModuleThatProvidesAMainArtifactTarget() { + @Test + public void eclipsePathsOfModuleThatProvidesAMainArtifactTarget() { Target libJar = new HelloTarget("lib.jar", ""); JavaBinModule libJarModule = JavaBinModule.providing(libJar).end(); @@ -162,7 +182,8 @@ public void testEclipsePathsOfModuleThatProvidesAMainArtifactTarget() { assertEquals(null, libJarModule.eclipseSourceReference(ctx)); } - public void testEclipsePathsOfModuleThatProvidesAMainArtifactTargetWithSources() { + @Test + public void eclipsePathsOfModuleThatProvidesAMainArtifactTargetWithSources() { Target libJar = new HelloTarget("lib.jar", ""); Target libSrc = new HelloTarget("lib-src.zip", ""); JavaBinModule libJarModule = JavaBinModule.providing(libJar, libSrc) @@ -174,7 +195,8 @@ public void testEclipsePathsOfModuleThatProvidesAMainArtifactTargetWithSources() libJarModule.eclipseSourceReference(ctx)); } - public void testBinaryModulesDontHaveMainDepsForCompilation() { + @Test + public void binaryModulesDontHaveMainDepsForCompilation() { assertTrue(JavaBinModule.named("lib") .inside(JavaSrcModule.with().name("libs").end()).end() .mainDepsForCompilation().isEmpty()); @@ -183,7 +205,8 @@ public void testBinaryModulesDontHaveMainDepsForCompilation() { .mainDepsForCompilation().isEmpty()); } - public void testBinaryModulesDontHaveTestDepsOfAnyKind() { + @Test + public void binaryModulesDontHaveTestDepsOfAnyKind() { JavaBinModule binInsideLibs = JavaBinModule.named("lib") .inside(JavaSrcModule.with().name("libs").end()).end(); assertTrue(binInsideLibs.testDepsForCompilationExcludingMainDeps() @@ -206,14 +229,16 @@ public void testBinaryModulesDontHaveTestDepsOfAnyKind() { binInsideLibs.effectivePathForTestRuntime().toString()); } - public void testSourcesOfProviderModule() { + @Test + public void sourcesOfProviderModule() { Source src = Source.underWsroot("src"); assertSame(src, JavaBinModule.providing(Source.underWsroot("bin"), src) .end().source()); } - public void testCharacteristicsOfProviderModule() { + @Test + public void characteristicsOfProviderModule() { JavaBinModule mod = JavaBinModule .providing(new HelloTarget("lib.jar", ""), null) .has(ProductionConfiguration.class).end(); @@ -224,7 +249,8 @@ public void testCharacteristicsOfProviderModule() { assertTrue(mod.doesHave(ProductionRuntimeData.class)); } - public void testObservableDepsOfPathProviderModuleThatHasRuntimeDeps() { + @Test + public void observableDepsOfPathProviderModuleThatHasRuntimeDeps() { JavaBinModule dep1 = JavaBinModule .providing(Source.underWsroot("dep1.jar")).end(); JavaBinModule dep2 = JavaBinModule @@ -248,7 +274,8 @@ public void testObservableDepsOfPathProviderModuleThatHasRuntimeDeps() { assertEquals("[]", lib.effectivePathForTestRuntime().toString()); } - public void testModuleLikeAPathProviderIsReallyLikeIt() { + @Test + public void moduleLikeAPathProviderIsReallyLikeIt() { JavaBinModule m1 = JavaBinModule .providing(Source.underWsroot("lib.jar"), Source.underWsroot("lib-src.zip")) diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesAndSourcesTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesAndSourcesTest.java index 9e9f64c0..12d2469d 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesAndSourcesTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesAndSourcesTest.java @@ -1,12 +1,14 @@ package org.fluentjava.iwant.api.javamodules; -import org.fluentjava.iwant.api.model.Source; +import static org.junit.jupiter.api.Assertions.assertEquals; -import junit.framework.TestCase; +import org.fluentjava.iwant.api.model.Source; +import org.junit.jupiter.api.Test; -public class JavaClassesAndSourcesTest extends TestCase { +public class JavaClassesAndSourcesTest { - public void testNameIsThatOfClasses() { + @Test + public void nameIsThatOfClasses() { assertEquals("one", new JavaClassesAndSources(Source.underWsroot("one"), Source.underWsroot("irrelevant")).name()); assertEquals("two", new JavaClassesAndSources(Source.underWsroot("two"), diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesTest.java index 327fb2ad..5d3a6d36 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaClassesTest.java @@ -1,5 +1,10 @@ package org.fluentjava.iwant.api.javamodules; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -16,6 +21,7 @@ import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.entry.Iwant.IwantException; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.Test; public class JavaClassesTest extends IwantTestCase { @@ -24,7 +30,8 @@ protected boolean mustCaptureSystemOutAndErr() { return true; } - public void testSrcDirIsAnIgredient() { + @Test + public void srcDirIsAnIgredient() { Path src = Source.underWsroot("src"); Target target = JavaClasses.with().name("classes").srcDirs(src) .classLocations().end(); @@ -32,7 +39,8 @@ public void testSrcDirIsAnIgredient() { assertTrue(target.ingredients().contains(src)); } - public void testSrcDirsAreIgredients() { + @Test + public void srcDirsAreIgredients() { Path src1 = Source.underWsroot("src1"); Path src2 = Source.underWsroot("src1"); Target target = JavaClasses.with().name("classes").srcDirs(src1, src2) @@ -42,7 +50,8 @@ public void testSrcDirsAreIgredients() { assertTrue(target.ingredients().contains(src2)); } - public void testResourceDirsAreIgredients() { + @Test + public void resourceDirsAreIgredients() { Path res1 = Source.underWsroot("res1"); Path res2 = Source.underWsroot("res1"); Target target = JavaClasses.with().name("classes") @@ -52,7 +61,8 @@ public void testResourceDirsAreIgredients() { assertTrue(target.ingredients().contains(res2)); } - public void testSrcDirsCanBeEmptiedDuringSpecifyingJavaClasses() { + @Test + public void srcDirsCanBeEmptiedDuringSpecifyingJavaClasses() { Path src1 = Source.underWsroot("src1"); Path src2 = Source.underWsroot("src1"); JavaClassesSpex spex = JavaClasses.with().name("classes").srcDirs(src1) @@ -66,7 +76,8 @@ public void testSrcDirsCanBeEmptiedDuringSpecifyingJavaClasses() { assertTrue(target.ingredients().contains(src2)); } - public void testRelevantSettingsAreMentionedInContentDescriptor() { + @Test + public void relevantSettingsAreMentionedInContentDescriptor() { assertEquals("org.fluentjava.iwant.api.javamodules.JavaClasses\n" + "i:srcDirs:\n" + " src\n" + "i:resourceDirs:\n" + "i:classLocations:\n" + "p:javacOptions:\n" + " -Xlint\n" @@ -89,7 +100,8 @@ public void testRelevantSettingsAreMentionedInContentDescriptor() { .contentDescriptor()); } - public void testCrapToPathFails() throws Exception { + @Test + public void crapToPathFails() throws Exception { wsRootHasFile("src/Crap.java", "crap"); Source src = Source.underWsroot("src"); Target target = JavaClasses.with().name("crap").srcDirs(src) @@ -103,7 +115,8 @@ public void testCrapToPathFails() throws Exception { } } - public void testSourceCompliance1_7WarnsAboutMissingBootclasspath() + @Test + public void sourceCompliance1_7WarnsAboutMissingBootclasspath() throws Exception { wsRootHasFile("src/Valid.java", "class Valid {}"); Source src = Source.underWsroot("src"); @@ -125,7 +138,8 @@ public void testSourceCompliance1_7WarnsAboutMissingBootclasspath() * Without this we get warning: [options] system modules path not set in * conjunction with -source 11 */ - public void testJavacOptionsSourceAndTargetAreReplacedWithReleaseFromJava11On() { + @Test + public void javacOptionsSourceAndTargetAreReplacedWithReleaseFromJava11On() { Source src = Source.underWsroot("src"); assertEquals("[-Xlint, -Xlint:-serial, -source, 1.8]", @@ -144,7 +158,8 @@ public void testJavacOptionsSourceAndTargetAreReplacedWithReleaseFromJava11On() .end().javacOptions().toString()); } - public void testToPathCompilesFromMultiplePackages() throws Exception { + @Test + public void toPathCompilesFromMultiplePackages() throws Exception { wsRootHasFile("src/Caller.java", "class Caller {pak1.Callee1 callee1;pak2.Callee2 callee2;}"); wsRootHasFile("src/pak1/Callee1.java", @@ -162,7 +177,8 @@ public void testToPathCompilesFromMultiplePackages() throws Exception { assertTrue(new File(cached, "multiple/pak2/Callee2.class").exists()); } - public void testToPathCompilesFromMultipleSrcDirs() throws Exception { + @Test + public void toPathCompilesFromMultipleSrcDirs() throws Exception { File srcDir1 = new File(wsRoot, "src1"); Iwant.newTextFile(new File(srcDir1, "Caller.java"), "class Caller {pak1.Callee1 callee1;pak2.Callee2 callee2;}"); @@ -186,7 +202,8 @@ public void testToPathCompilesFromMultipleSrcDirs() throws Exception { assertTrue(new File(cached, "multiple/pak2/Callee2.class").exists()); } - public void testClassWithDepToClassesCompiles() throws Exception { + @Test + public void classWithDepToClassesCompiles() throws Exception { Class superClass = SuperClassForJavaClassesTestSubclass.class; File superClassFile = new File(getClass() .getResource(superClass.getSimpleName() + ".class").toURI()); @@ -206,7 +223,8 @@ public void testClassWithDepToClassesCompiles() throws Exception { assertTrue(new File(cached, "valid/Subclass.class").exists()); } - public void testDependenciesAreIgredients() { + @Test + public void dependenciesAreIgredients() { Target dep1 = new TargetMock("dep1"); Target dep2 = new TargetMock("dep2"); Target target = JavaClasses.with().name("valid") @@ -217,7 +235,8 @@ public void testDependenciesAreIgredients() { assertTrue(target.ingredients().contains(dep2)); } - public void testDependenciesAreInContentDescriptor() { + @Test + public void dependenciesAreInContentDescriptor() { Target dep1 = new TargetMock("dep1"); Target dep2 = new TargetMock("dep2"); Target target = JavaClasses.with().name("valid") @@ -232,8 +251,8 @@ public void testDependenciesAreInContentDescriptor() { target.contentDescriptor()); } - public void testEmptySourceDirectoryProducesEmptyClasses() - throws Exception { + @Test + public void emptySourceDirectoryProducesEmptyClasses() throws Exception { File srcDir = new File(wsRoot, "src"); Iwant.mkdirs(srcDir); Source src = Source.underWsroot("src"); @@ -245,7 +264,8 @@ public void testEmptySourceDirectoryProducesEmptyClasses() assertEquals("[]", Arrays.toString(new File(cached, "empty").list())); } - public void testSourceDirectoryWithJustDotKeepInItProducesEmptyClasses() + @Test + public void sourceDirectoryWithJustDotKeepInItProducesEmptyClasses() throws Exception { wsRootHasFile("src/.keep", ""); @@ -258,8 +278,8 @@ public void testSourceDirectoryWithJustDotKeepInItProducesEmptyClasses() assertEquals("[]", Arrays.toString(new File(cached, "empty").list())); } - public void testMissingSourceDirectoryCausesFriendlyError() - throws Exception { + @Test + public void missingSourceDirectoryCausesFriendlyError() throws Exception { Source src = Source.underWsroot("missing-src"); Target target = JavaClasses.with().name("missing").srcDirs(src) .classLocations().end(); @@ -273,7 +293,8 @@ public void testMissingSourceDirectoryCausesFriendlyError() } } - public void testUsingNonDirectoryAsSourceDirectoryCausesFriendlyError() + @Test + public void usingNonDirectoryAsSourceDirectoryCausesFriendlyError() throws Exception { Iwant.mkdirs(wsRoot); File srcFile = new File(wsRoot, "Valid.java"); @@ -291,7 +312,8 @@ public void testUsingNonDirectoryAsSourceDirectoryCausesFriendlyError() } } - public void testDebugInformationIsIncludedIffRequested() throws Exception { + @Test + public void debugInformationIsIncludedIffRequested() throws Exception { String srcDirName = "src"; Path src = Source.underWsroot(srcDirName); Iwant.newTextFile(new File(new File(wsRoot, srcDirName), "Foo.java"), @@ -319,13 +341,15 @@ public void testDebugInformationIsIncludedIffRequested() throws Exception { assertTrue(TestArea.bytesContain(debugContent, "greeting")); } - public void testResourceDirDefinitionAndGetter() { + @Test + public void resourceDirDefinitionAndGetter() { JavaClasses c = JavaClasses.with() .resourceDirs(Source.underWsroot("res")).end(); assertEquals("[res]", c.resourceDirs().toString()); } - public void testClearingResourceDirsAndSpecifyingManyOfThem() { + @Test + public void clearingResourceDirsAndSpecifyingManyOfThem() { JavaClasses c = JavaClasses.with() .resourceDirs(Source.underWsroot("to-be-removed")) .noResourceDirs().resourceDirs(Source.underWsroot("r1"), @@ -334,7 +358,8 @@ public void testClearingResourceDirsAndSpecifyingManyOfThem() { assertEquals("[r1, r2]", c.resourceDirs().toString()); } - public void testResourcesAreCopiedAlongsideCompilationFromTheOneDirectoryGiven() + @Test + public void resourcesAreCopiedAlongsideCompilationFromTheOneDirectoryGiven() throws Exception { wsRootHasFile("src/Foo.java", "public class Foo {}"); wsRootHasFile("res/res.txt", "res.txt content"); @@ -348,7 +373,8 @@ public void testResourcesAreCopiedAlongsideCompilationFromTheOneDirectoryGiven() assertEquals("res.txt content", contentOfCached(classes, "res.txt")); } - public void testMissingResourceDirectoryIsIgnoredWithWarningAndWithoutThrowing() + @Test + public void missingResourceDirectoryIsIgnoredWithWarningAndWithoutThrowing() throws Exception { wsRootHasFile("src/Foo.java", "public class Foo {}"); // wsroot does not have directory "res1" @@ -369,7 +395,8 @@ public void testMissingResourceDirectoryIsIgnoredWithWarningAndWithoutThrowing() err()); } - public void testTwoResourceDirsAndNoSrc() throws Exception { + @Test + public void twoResourceDirsAndNoSrc() throws Exception { Iwant.newTextFile(new File(wsRoot, "res1/pak1/res1.txt"), "res1.txt content"); Iwant.newTextFile(new File(wsRoot, "res2/pak2/res2.txt"), @@ -385,12 +412,14 @@ public void testTwoResourceDirsAndNoSrc() throws Exception { contentOfCached(classes, "pak2/res2.txt")); } - public void testDefaultCharsetIsUtf8() { + @Test + public void defaultCharsetIsUtf8() { assertEquals(StandardCharsets.UTF_8, JavaClasses.with().end().encoding()); } - public void testOverridingChracterEncoding() throws Exception { + @Test + public void overridingChracterEncoding() throws Exception { Charset differentCharset = Charset.forName("ISO-8859-1"); assertFalse(differentCharset.equals(Charset.defaultCharset())); @@ -415,7 +444,8 @@ public void testOverridingChracterEncoding() throws Exception { assertEquals("aumlaut:รค\n", out()); } - public void testDefaultJavacOptionsPassedToServices() throws Exception { + @Test + public void defaultJavacOptionsPassedToServices() throws Exception { wsRootHasDirectory("src"); wsRootHasFile("src/Whatever.java", "public class Whatever {}"); JavaClasses classes = JavaClasses.with().name("classes") @@ -427,7 +457,8 @@ public void testDefaultJavacOptionsPassedToServices() throws Exception { ctx.iwant().lastJavacOptions().toString()); } - public void testCustomArgs() throws Exception { + @Test + public void customArgs() throws Exception { wsRootHasDirectory("src"); wsRootHasFile("src/Whatever.java", "public class Whatever {}"); JavaClasses classes = JavaClasses.with().name("classes") @@ -440,7 +471,8 @@ public void testCustomArgs() throws Exception { ctx.iwant().lastJavacOptions().toString()); } - public void testDifferentJavacOptionsPassedToServices() throws Exception { + @Test + public void differentJavacOptionsPassedToServices() throws Exception { wsRootHasDirectory("src"); wsRootHasFile("src/Whatever.java", "public class Whatever {}"); JavaClasses classes = JavaClasses.with().name("classes") @@ -453,7 +485,8 @@ public void testDifferentJavacOptionsPassedToServices() throws Exception { ctx.iwant().lastJavacOptions().toString()); } - public void testJavacOptionsAreInDescriptor() { + @Test + public void javacOptionsAreInDescriptor() { assertTrue(JavaClasses.with().name("classes") .srcDirs(Source.underWsroot("src")).debug(true) .sourceVersion(JavaCompliance.JAVA_1_6).end() @@ -472,8 +505,8 @@ public void testJavacOptionsAreInDescriptor() { .contains(" --release\n 11\n -g")); } - public void testJava8CompilesWithWarningsAboutBootclasspath() - throws Exception { + @Test + public void java8CompilesWithWarningsAboutBootclasspath() throws Exception { wsRootHasFile("src/UsingJ8.java", "class UsingJ8 {" + " static {\n" + " java.util.Arrays.asList(\"1\")." + "forEach(s -> System.out.println(s));\n" + " }\n" + "}"); @@ -490,7 +523,8 @@ public void testJava8CompilesWithWarningsAboutBootclasspath() err()); } - public void testJava11CompilesWithoutWarnings() throws Exception { + @Test + public void java11CompilesWithoutWarnings() throws Exception { wsRootHasFile("src/UsingJ11.java", "class UsingJ11 {void s() {var s = \"\";System.out.println(s);}}"); Source src = Source.underWsroot("src"); @@ -503,7 +537,8 @@ public void testJava11CompilesWithoutWarnings() throws Exception { assertEquals("", err()); } - public void testJava17CompilesWithoutWarnings() throws Exception { + @Test + public void java17CompilesWithoutWarnings() throws Exception { wsRootHasFile("src/UsingJ17.java", "public record UsingJ17(String a, int b) {}"); Source src = Source.underWsroot("src"); diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaSrcModuleTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaSrcModuleTest.java index 8845bab0..8c7e7a01 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaSrcModuleTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/JavaSrcModuleTest.java @@ -1,5 +1,12 @@ package org.fluentjava.iwant.api.javamodules; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +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.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.List; @@ -18,18 +25,19 @@ import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.StringFilter; import org.fluentjava.iwant.api.model.Target; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class JavaSrcModuleTest extends TestCase { +public class JavaSrcModuleTest { - public void testToStringIsTheName() { + @Test + public void toStringIsTheName() { assertEquals("m1", JavaSrcModule.with().name("m1").end().toString()); assertEquals("m2", JavaSrcModule.with().name("m2").end().toString()); } @SuppressWarnings("unlikely-arg-type") - public void testEqualsUsesNameAndClass() { + @Test + public void equalsUsesNameAndClass() { assertTrue(JavaSrcModule.with().name("a").end() .equals(JavaSrcModule.with().name("a").end())); assertTrue(JavaSrcModule.with().name("a").end() @@ -41,7 +49,8 @@ public void testEqualsUsesNameAndClass() { .equals(JavaSrcModule.with().name("b").end())); } - public void testHashCodeIsSameIfNameIsSame() { + @Test + public void hashCodeIsSameIfNameIsSame() { assertTrue(JavaSrcModule.with().name("a").end() .hashCode() == JavaSrcModule.with().name("a").end().hashCode()); assertTrue( @@ -49,7 +58,8 @@ public void testHashCodeIsSameIfNameIsSame() { .providing(Source.underWsroot("a")).end().hashCode()); } - public void testParentDirectoryNormalizationAffectsLocationUnderWsRoot() { + @Test + public void parentDirectoryNormalizationAffectsLocationUnderWsRoot() { assertEquals("a", JavaSrcModule.with().name("a").end().locationUnderWsRoot()); assertEquals("a", JavaSrcModule.with().name("a").relativeParentDir("") @@ -60,7 +70,8 @@ public void testParentDirectoryNormalizationAffectsLocationUnderWsRoot() { .relativeParentDir("dir/").end().locationUnderWsRoot()); } - public void testParentDirectoryNormalizationAffectsWsrootRelativeParentDir() { + @Test + public void parentDirectoryNormalizationAffectsWsrootRelativeParentDir() { assertEquals("", JavaSrcModule.with().name("a").end().wsrootRelativeParentDir()); assertEquals("", JavaSrcModule.with().name("a").relativeParentDir("") @@ -76,7 +87,8 @@ public void testParentDirectoryNormalizationAffectsWsrootRelativeParentDir() { .wsrootRelativeParentDir()); } - public void testRelativeWsRoot() { + @Test + public void relativeWsRoot() { assertEquals("..", JavaSrcModule.with().name("a").end().relativeWsRoot()); assertEquals("../..", JavaSrcModule.with().name("a") @@ -85,7 +97,8 @@ public void testRelativeWsRoot() { .relativeParentDir("one/two").end().relativeWsRoot()); } - public void testLocationUnderWsRootFromParentAndName() { + @Test + public void locationUnderWsRootFromParentAndName() { assertEquals("simple", JavaSrcModule.with().name("simple").end() .locationUnderWsRoot()); assertEquals("one/nested", JavaSrcModule.with().name("nested") @@ -94,7 +107,8 @@ public void testLocationUnderWsRootFromParentAndName() { .relativeParentDir("one/two").end().locationUnderWsRoot()); } - public void testLocationThatDiffersFromName() { + @Test + public void locationThatDiffersFromName() { JavaSrcModule module = JavaSrcModule.with().name("module-name") .locationUnderWsRoot("parent/dir-name").end(); @@ -102,7 +116,8 @@ public void testLocationThatDiffersFromName() { assertEquals("parent/dir-name", module.locationUnderWsRoot()); } - public void testSettingBothParentAndLocationIsAnError() { + @Test + public void settingBothParentAndLocationIsAnError() { IwantSrcModuleSpex spex = JavaSrcModule.with().name("module-name") .relativeParentDir("parent") .locationUnderWsRoot("parent/dir-name"); @@ -118,12 +133,14 @@ public void testSettingBothParentAndLocationIsAnError() { // java classes - public void testMainJavasAsPathsFromSourcelessSrcModule() { + @Test + public void mainJavasAsPathsFromSourcelessSrcModule() { assertTrue(JavaSrcModule.with().name("srcless").end().mainJavasAsPaths() .isEmpty()); } - public void testMainJavasAsPathsFromNormalSrcModule() { + @Test + public void mainJavasAsPathsFromNormalSrcModule() { assertEquals("[simple/src]", JavaSrcModule.with().name("simple") .mainJava("src").end().mainJavasAsPaths().toString()); assertEquals("[parent/more-nesting/src/main/java]", @@ -132,7 +149,8 @@ public void testMainJavasAsPathsFromNormalSrcModule() { .end().mainJavasAsPaths().toString()); } - public void testMainJavasAsPathsFromCodeGenerationModule() { + @Test + public void mainJavasAsPathsFromCodeGenerationModule() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") @@ -148,20 +166,23 @@ public void testMainJavasAsPathsFromCodeGenerationModule() { assertSame(generatedSrc, mainJavas.get(0)); } - public void testTestJavaAsPathWithNullAndNonNull() { + @Test + public void testJavaAsPathWithNullAndNonNull() { assertTrue(JavaSrcModule.with().name("testless").end() .testJavasAsPaths().isEmpty()); assertEquals("[tested/test]", JavaSrcModule.with().name("tested") .testJava("test").end().testJavasAsPaths().toString()); } - public void testSourcelessSrcModuleHasNoMainArtifact() { + @Test + public void sourcelessSrcModuleHasNoMainArtifact() { JavaSrcModule module = JavaSrcModule.with().name("srcless").end(); assertNull(module.mainArtifact()); } - public void testMainArtifactOfCodeGenerationModule() { + @Test + public void mainArtifactOfCodeGenerationModule() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") @@ -176,7 +197,8 @@ public void testMainArtifactOfCodeGenerationModule() { assertSame(generatedClasses, mainArtifact); } - public void testMainArtifactOfMinimalSrcModuleIsJavaClassesCompiledFromSource() { + @Test + public void mainArtifactOfMinimalSrcModuleIsJavaClassesCompiledFromSource() { JavaSrcModule module = JavaSrcModule.with().name("simple") .mainJava("src").end(); @@ -186,7 +208,8 @@ public void testMainArtifactOfMinimalSrcModuleIsJavaClassesCompiledFromSource() assertEquals("[]", mainArtifact.classLocations().toString()); } - public void testMainArtifactOfOfSrcModuleThatHasDependencies() { + @Test + public void mainArtifactOfOfSrcModuleThatHasDependencies() { JavaSrcModule util1 = JavaSrcModule.with().name("util1") .mainJava("src/main/java").end(); JavaSrcModule util2 = JavaSrcModule.with().name("util2") @@ -202,7 +225,8 @@ public void testMainArtifactOfOfSrcModuleThatHasDependencies() { mainArtifact.classLocations().toString()); } - public void testMainArtifactOfOfSrcModuleThatHasManyMainJavas() { + @Test + public void mainArtifactOfOfSrcModuleThatHasManyMainJavas() { JavaSrcModule module = JavaSrcModule.with().name("dual-src") .mainJava("src1").mainJava("src2").mainDeps().end(); @@ -212,7 +236,8 @@ public void testMainArtifactOfOfSrcModuleThatHasManyMainJavas() { mainArtifact.srcDirs().toString()); } - public void testMainJavaCollectionCanBeEmptiedDuringSpecification() { + @Test + public void mainJavaCollectionCanBeEmptiedDuringSpecification() { JavaSrcModule module = JavaSrcModule.with().name("dual-src") .mainJava("src1").noMainJava().mainJava("src2").mainDeps() .end(); @@ -222,7 +247,8 @@ public void testMainJavaCollectionCanBeEmptiedDuringSpecification() { assertEquals("[dual-src/src2]", mainArtifact.srcDirs().toString()); } - public void testMainResourcesCollectionCanBeEmptiedDuringSpecification() { + @Test + public void mainResourcesCollectionCanBeEmptiedDuringSpecification() { JavaSrcModule module = JavaSrcModule.with().name("dual-res") .mainResources("res1").noMainResources().mainResources("res2") .mainDeps().end(); @@ -230,7 +256,8 @@ public void testMainResourcesCollectionCanBeEmptiedDuringSpecification() { assertEquals("[res2]", module.mainResources().toString()); } - public void testTestArtifactOfOfSrcModuleThatHasManyTestJavas() { + @Test + public void testArtifactOfOfSrcModuleThatHasManyTestJavas() { JavaSrcModule module = JavaSrcModule.with().name("dual-test") .testJava("test1").testJava("test2").mainDeps().end(); @@ -240,7 +267,8 @@ public void testTestArtifactOfOfSrcModuleThatHasManyTestJavas() { testArtifact.srcDirs().toString()); } - public void testTestJavaCollectionCanBeEmptiedDuringSpecification() { + @Test + public void testJavaCollectionCanBeEmptiedDuringSpecification() { JavaSrcModule module = JavaSrcModule.with().name("dual-test") .testJava("test1").noTestJava().testJava("test2").mainDeps() .end(); @@ -250,7 +278,8 @@ public void testTestJavaCollectionCanBeEmptiedDuringSpecification() { assertEquals("[dual-test/test2]", testArtifact.srcDirs().toString()); } - public void testTestResourcesCollectionCanBeEmptiedDuringSpecification() { + @Test + public void testResourcesCollectionCanBeEmptiedDuringSpecification() { JavaSrcModule module = JavaSrcModule.with().name("dual-res") .testResources("res1").noTestResources().testResources("res2") .mainDeps().end(); @@ -258,7 +287,8 @@ public void testTestResourcesCollectionCanBeEmptiedDuringSpecification() { assertEquals("[res2]", module.testResources().toString()); } - public void testMainResourcesArePassedToMainClassesWhileTestResourcesAreMissing() { + @Test + public void mainResourcesArePassedToMainClassesWhileTestResourcesAreMissing() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .mainResources("res").testJava("test").end(); @@ -271,7 +301,8 @@ public void testMainResourcesArePassedToMainClassesWhileTestResourcesAreMissing( assertEquals("[]", mod.testResourcesAsPaths().toString()); } - public void testTestResourcesArePassedToTestClassesWhileMainResourcesAreMissing() { + @Test + public void testResourcesArePassedToTestClassesWhileMainResourcesAreMissing() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .testJava("test").testResources("test-res").end(); @@ -284,7 +315,8 @@ public void testTestResourcesArePassedToTestClassesWhileMainResourcesAreMissing( assertEquals("[mod/test-res]", mod.testResourcesAsPaths().toString()); } - public void testModulesAreComparedByName() { + @Test + public void modulesAreComparedByName() { JavaModule srcA = JavaSrcModule.with().name("a").end(); JavaSrcModule libs = JavaSrcModule.with().name("libs").end(); JavaModule binA = JavaBinModule.named("a").inside(libs).end(); @@ -299,12 +331,14 @@ public void testModulesAreComparedByName() { assertTrue(libs.compareTo(binA) > 0); } - public void testTestArtifactIsNullWhenNoTests() { + @Test + public void testArtifactIsNullWhenNoTests() { assertNull(JavaSrcModule.with().name("testless").mainJava("src").end() .testArtifact()); } - public void testTestArtifactIsWhenThereAreTests() { + @Test + public void testArtifactIsWhenThereAreTests() { JavaClasses tests = (JavaClasses) JavaSrcModule.with().name("tested") .mainJava("src").testJava("test").end().testArtifact(); @@ -314,7 +348,8 @@ public void testTestArtifactIsWhenThereAreTests() { tests.classLocations().toString()); } - public void testTestArtifactWithMainAndTestDeps() { + @Test + public void testArtifactWithMainAndTestDeps() { JavaClasses tests = (JavaClasses) JavaSrcModule.with().name("tested2") .mainJava("src") .mainDeps(JavaBinModule @@ -332,7 +367,8 @@ public void testTestArtifactWithMainAndTestDeps() { tests.classLocations().toString()); } - public void testTestArtifactWhenNoMainJava() { + @Test + public void testArtifactWhenNoMainJava() { JavaClasses tests = (JavaClasses) JavaSrcModule.with() .name("only-tests").testJava("test").end().testArtifact(); @@ -341,7 +377,8 @@ public void testTestArtifactWhenNoMainJava() { assertEquals("[]", tests.classLocations().toString()); } - public void testTestedBySingleTestSuite() { + @Test + public void testedBySingleTestSuite() { StringFilter testNames = JavaSrcModule.with().name("suited") .testJava("test").testedBy("com.example.TestSuite").end() .testClassNameDefinition(); @@ -350,7 +387,8 @@ public void testTestedBySingleTestSuite() { assertFalse(testNames.matches("com.example.SomethingElse")); } - public void testTestedByManyTestsWithCustomNamingConvention() { + @Test + public void testedByManyTestsWithCustomNamingConvention() { StringFilter filter = new StringFilter() { @Override public boolean matches(String candidate) { @@ -366,12 +404,14 @@ public boolean matches(String candidate) { assertFalse(testNames.matches("b")); } - public void testDefaultEncodingIsUtf() { + @Test + public void defaultEncodingIsUtf() { assertEquals(StandardCharsets.UTF_8, JavaSrcModule.with().end().encoding()); } - public void testEncodingIsUsedToCompileMainAndTestClasses() { + @Test + public void encodingIsUsedToCompileMainAndTestClasses() { Charset encoding = Charset.forName("ISO-8859-1"); JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .testJava("test").encoding(encoding).end(); @@ -382,7 +422,8 @@ public void testEncodingIsUsedToCompileMainAndTestClasses() { assertSame(encoding, test.encoding()); } - public void testRawCompilerArgsAreUsedToCompileMainAndTestClasses() { + @Test + public void rawCompilerArgsAreUsedToCompileMainAndTestClasses() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .testJava("test") .rawCompilerArgs("-bootclasspath", "/mock/jdk-1.7").end(); @@ -397,12 +438,14 @@ public void testRawCompilerArgsAreUsedToCompileMainAndTestClasses() { test.javacOptions().toString()); } - public void testNoCharacteristicsByDefault() { + @Test + public void noCharacteristicsByDefault() { assertTrue(JavaSrcModule.with().name("mod").mainJava("src").end() .characteristics().isEmpty()); } - public void testCharacteristicsReturnsGivenStandardCharacteristics() { + @Test + public void characteristicsReturnsGivenStandardCharacteristics() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .has(ProductionConfiguration.class).has(ProductionCode.class) .end(); @@ -413,7 +456,8 @@ public void testCharacteristicsReturnsGivenStandardCharacteristics() { mod.characteristics().toString()); } - public void testDoesHaveTellsIfModuleHasTheAskedCharacteristicOrItsSubType() { + @Test + public void doesHaveTellsIfModuleHasTheAskedCharacteristicOrItsSubType() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .has(ProductionCode.class).end(); @@ -425,7 +469,8 @@ public void testDoesHaveTellsIfModuleHasTheAskedCharacteristicOrItsSubType() { assertFalse(mod.doesHave(TestUtility.class)); } - public void testHavingCharacteristicDoesNotImplyHavingItsSubType() { + @Test + public void havingCharacteristicDoesNotImplyHavingItsSubType() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .has(ProductionRuntimeData.class).end(); @@ -436,7 +481,8 @@ private interface CustomCharacteristic extends TestRuntimeData { // just a marker } - public void testCustomCharacteristic() { + @Test + public void customCharacteristic() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .has(CustomCharacteristic.class).has(BuildUtility.class).end(); @@ -451,7 +497,8 @@ public void testCustomCharacteristic() { assertFalse(mod.doesHave(TestCode.class)); } - public void testJavaSrcModuleLikeAnotherIsReallyLikeIt() { + @Test + public void javaSrcModuleLikeAnotherIsReallyLikeIt() { JavaSrcModule m1 = JavaSrcModule.with() .codeFormatter(new CodeFormatterPolicy()) .codeStyle(CodeStylePolicy.defaultsExcept() @@ -502,7 +549,8 @@ public void testJavaSrcModuleLikeAnotherIsReallyLikeIt() { // direct getters - public void testDirectDepGettersWhenModuleHasNoDeps() { + @Test + public void directDepGettersWhenModuleHasNoDeps() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .testJava("test").end(); @@ -515,7 +563,8 @@ public void testDirectDepGettersWhenModuleHasNoDeps() { mod.testDepsForRunOnlyExcludingMainDeps().toString()); } - public void testDirectDepGettersWhenModuleHasAllKindsOfDeps() { + @Test + public void directDepGettersWhenModuleHasAllKindsOfDeps() { JavaBinModule mainCompDep = JavaBinModule .providing(Source.underWsroot("mainCompDep.jar")).end(); JavaBinModule mainRuntimeDep = JavaBinModule @@ -543,7 +592,8 @@ public void testDirectDepGettersWhenModuleHasAllKindsOfDeps() { // non-cumulative cases - public void testEffectiveDepsWhenModuleHasOnlyCompileTimeDeps() { + @Test + public void effectiveDepsWhenModuleHasOnlyCompileTimeDeps() { JavaBinModule compDep = JavaBinModule .providing(Source.underWsroot("compDep.jar")).end(); @@ -560,7 +610,8 @@ public void testEffectiveDepsWhenModuleHasOnlyCompileTimeDeps() { mod.effectivePathForTestRuntime().toString()); } - public void testEffectiveDepsWhenModuleHasCompileAndRuntimeDeps() { + @Test + public void effectiveDepsWhenModuleHasCompileAndRuntimeDeps() { JavaBinModule compDep = JavaBinModule .providing(Source.underWsroot("compDep.jar")).end(); JavaBinModule runDep = JavaBinModule @@ -580,7 +631,8 @@ public void testEffectiveDepsWhenModuleHasCompileAndRuntimeDeps() { mod.effectivePathForTestRuntime().toString()); } - public void testEffectiveDepsWhenModuleHasOnlyTestCompileDeps() { + @Test + public void effectiveDepsWhenModuleHasOnlyTestCompileDeps() { JavaBinModule testCompDep = JavaBinModule .providing(Source.underWsroot("testCompDep.jar")).end(); @@ -595,7 +647,8 @@ public void testEffectiveDepsWhenModuleHasOnlyTestCompileDeps() { mod.effectivePathForTestRuntime().toString()); } - public void testEffectiveDepsWhenModuleHasOnlyTestCompileAndTestRuntimeDeps() { + @Test + public void effectiveDepsWhenModuleHasOnlyTestCompileAndTestRuntimeDeps() { JavaBinModule testCompDep = JavaBinModule .providing(Source.underWsroot("testCompDep.jar")).end(); JavaBinModule testtimeDep = JavaBinModule @@ -613,7 +666,8 @@ public void testEffectiveDepsWhenModuleHasOnlyTestCompileAndTestRuntimeDeps() { mod.effectivePathForTestRuntime().toString()); } - public void testEffectiveDepsWhenModuleHasAllKindsOfDeps() { + @Test + public void effectiveDepsWhenModuleHasAllKindsOfDeps() { JavaBinModule mainCompDep = JavaBinModule .providing(Source.underWsroot("mainCompDep.jar")).end(); JavaBinModule mainRuntimeDep = JavaBinModule @@ -643,7 +697,8 @@ public void testEffectiveDepsWhenModuleHasAllKindsOfDeps() { // main dep of main dep - public void testEffectiveDepsWithCompileDepOfCompileDep() { + @Test + public void effectiveDepsWithCompileDepOfCompileDep() { JavaBinModule utilOfProdUtilJar = JavaBinModule .providing(Source.underWsroot("utilOfProdUtil.jar")).end(); JavaSrcModule prodUtil = JavaSrcModule.with().name("prodUtil") @@ -663,7 +718,8 @@ public void testEffectiveDepsWithCompileDepOfCompileDep() { mod.effectivePathForTestRuntime().toString()); } - public void testEffectiveRuntimeDepsWithRuntimeDepOfCompileDep() { + @Test + public void effectiveRuntimeDepsWithRuntimeDepOfCompileDep() { JavaBinModule utilOfProdUtilJar = JavaBinModule .providing(Source.underWsroot("utilOfProdUtil.jar")).end(); JavaBinModule prodUtilJar = JavaBinModule @@ -685,7 +741,8 @@ public void testEffectiveRuntimeDepsWithRuntimeDepOfCompileDep() { // main dep of test dep - public void testEffectiveRuntimeDepsWithCompileDepOfTestCompileDep() { + @Test + public void effectiveRuntimeDepsWithCompileDepOfTestCompileDep() { JavaBinModule utilOfTestUtilJar = JavaBinModule .providing(Source.underWsroot("utilOfTestUtil.jar")).end(); JavaSrcModule testUtil = JavaSrcModule.with().name("testUtil") @@ -703,7 +760,8 @@ public void testEffectiveRuntimeDepsWithCompileDepOfTestCompileDep() { mod.effectivePathForTestRuntime().toString()); } - public void testEffectiveRuntimeDepsWithRuntimeDepOfTestCompileDep() { + @Test + public void effectiveRuntimeDepsWithRuntimeDepOfTestCompileDep() { JavaBinModule utilOfTestUtilJar = JavaBinModule .providing(Source.underWsroot("utilOfTestUtil.jar")).end(); JavaBinModule testUtilJar = JavaBinModule @@ -721,7 +779,8 @@ public void testEffectiveRuntimeDepsWithRuntimeDepOfTestCompileDep() { mod.effectivePathForTestRuntime().toString()); } - public void testMainClassesHaveDebugEnabledByDefault() { + @Test + public void mainClassesHaveDebugEnabledByDefault() { JavaSrcModule mod = JavaSrcModule.with().name("simple").mainJava("src") .end(); JavaClasses classes = (JavaClasses) mod.mainArtifact(); @@ -729,7 +788,8 @@ public void testMainClassesHaveDebugEnabledByDefault() { assertTrue(classes.debug()); } - public void testTestClassesHaveDebugEnabledByDefault() { + @Test + public void testClassesHaveDebugEnabledByDefault() { JavaSrcModule mod = JavaSrcModule.with().name("simple").mainJava("src") .testJava("test").end(); JavaClasses classes = (JavaClasses) mod.testArtifact(); @@ -737,7 +797,8 @@ public void testTestClassesHaveDebugEnabledByDefault() { assertTrue(classes.debug()); } - public void testModuleWithTestsHasDefaultTestClassNameFilter() { + @Test + public void moduleWithTestsHasDefaultTestClassNameFilter() { JavaSrcModule mod = JavaSrcModule.with().name("tested").mainJava("src") .testJava("test").end(); @@ -745,7 +806,8 @@ public void testModuleWithTestsHasDefaultTestClassNameFilter() { .testClassNameDefinition() instanceof DefaultTestClassNameFilter); } - public void testAlsoTestlessModuleHasDefaultTestClassNameFilter() { + @Test + public void alsoTestlessModuleHasDefaultTestClassNameFilter() { JavaSrcModule mod = JavaSrcModule.with().name("testless") .mainJava("src").end(); @@ -753,7 +815,8 @@ public void testAlsoTestlessModuleHasDefaultTestClassNameFilter() { .testClassNameDefinition() instanceof DefaultTestClassNameFilter); } - public void testTestlessModuleTestClassNameFilterCanBeExplicitlySetEvenIfItHasNoUse() { + @Test + public void testlessModuleTestClassNameFilterCanBeExplicitlySetEvenIfItHasNoUse() { StringFilter filter = new StringFilter() { @Override public boolean matches(String candidate) { @@ -766,7 +829,8 @@ public boolean matches(String candidate) { assertSame(filter, mod.testClassNameDefinition()); } - public void testTestClassNameDefinitionReturnsGivenFilter() { + @Test + public void testClassNameDefinitionReturnsGivenFilter() { StringFilter filter = new StringFilter() { @Override public boolean matches(String candidate) { @@ -779,7 +843,8 @@ public boolean matches(String candidate) { assertSame(filter, mod.testClassNameDefinition()); } - public void testSourceComplianceOfMainAndTestClassesIsTheJavaComplianceOfTheModule() { + @Test + public void sourceComplianceOfMainAndTestClassesIsTheJavaComplianceOfTheModule() { JavaCompliance nonDefaultCompliance = JavaCompliance.JAVA_1_6; // inner test: assertFalse(nonDefaultCompliance.equals( @@ -796,7 +861,8 @@ public void testSourceComplianceOfMainAndTestClassesIsTheJavaComplianceOfTheModu assertEquals(nonDefaultCompliance, testClasses.sourceCompliance()); } - public void testMainClassesHasCorrectKindOfClassesWhenScalaInUse() { + @Test + public void mainClassesHasCorrectKindOfClassesWhenScalaInUse() { ScalaVersion scala = ScalaVersion._2_11_7(); JavaModule dep = JavaBinModule.providing(Source.underWsroot("dep")) .end(); @@ -818,7 +884,8 @@ public void testMainClassesHasCorrectKindOfClassesWhenScalaInUse() { assertSame(scala, scalaClasses.scala()); } - public void testTestClassesHasCorrectKindOfClassesWhenScalaInUse() { + @Test + public void testClassesHasCorrectKindOfClassesWhenScalaInUse() { ScalaVersion scala = ScalaVersion._2_11_7(); JavaModule dep = JavaBinModule.providing(Source.underWsroot("dep")) .end(); @@ -842,7 +909,8 @@ public void testTestClassesHasCorrectKindOfClassesWhenScalaInUse() { assertSame(scala, scalaClasses.scala()); } - public void testMainClassesHasCorrectKindOfClassesWhenKotlinInUse() { + @Test + public void mainClassesHasCorrectKindOfClassesWhenKotlinInUse() { KotlinVersion kotlin = KotlinVersion._1_3_60(); JavaModule dep = JavaBinModule.providing(Source.underWsroot("dep")) @@ -860,7 +928,8 @@ public void testMainClassesHasCorrectKindOfClassesWhenKotlinInUse() { assertEquals("[dep]", mainClasses.classLocations().toString()); } - public void testTestClassesHasCorrectKindOfClassesWhenKotlinInUse() { + @Test + public void testClassesHasCorrectKindOfClassesWhenKotlinInUse() { KotlinVersion kotlin = KotlinVersion._1_3_60(); JavaModule dep = JavaBinModule.providing(Source.underWsroot("dep")) diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/KotlinAndJavaClassesTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/KotlinAndJavaClassesTest.java index ee44463c..40c669a3 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/KotlinAndJavaClassesTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/KotlinAndJavaClassesTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.api.javamodules; +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.util.Arrays; @@ -8,6 +12,7 @@ import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.entry.Iwant.IwantException; +import org.junit.jupiter.api.Test; public class KotlinAndJavaClassesTest extends IwantTestCase { @@ -25,7 +30,8 @@ protected void moreSetUp() throws Exception { KOTLIN.kotlinAntJar().path(ctx); } - public void testSrcDirsAreIgredients() { + @Test + public void srcDirsAreIgredients() { Path src1 = Source.underWsroot("src1"); Path src2 = Source.underWsroot("src1"); Target target = new KotlinAndJavaClasses("classes", KOTLIN, @@ -35,7 +41,8 @@ public void testSrcDirsAreIgredients() { assertTrue(target.ingredients().contains(src2)); } - public void testResourceDirsAreIgredients() { + @Test + public void resourceDirsAreIgredients() { Path res1 = Source.underWsroot("res1"); Path res2 = Source.underWsroot("res1"); Target target = new KotlinAndJavaClasses("classes", KOTLIN, @@ -45,7 +52,8 @@ public void testResourceDirsAreIgredients() { assertTrue(target.ingredients().contains(res2)); } - public void testCrapJavaToPathFails() throws Exception { + @Test + public void crapJavaToPathFails() throws Exception { wsRootHasFile("src/Crap.java", "crap"); Source src = Source.underWsroot("src"); Target target = new KotlinAndJavaClasses("classes", KOTLIN, @@ -61,7 +69,8 @@ public void testCrapJavaToPathFails() throws Exception { assertTrue(err().contains("crap")); } - public void testJavaOnlyCompiles() throws Exception { + @Test + public void javaOnlyCompiles() throws Exception { wsRootHasFile("src/Minimal.java", "class Minimal {}"); Source src = Source.underWsroot("src"); Target target = new KotlinAndJavaClasses("classes", KOTLIN, @@ -72,7 +81,8 @@ public void testJavaOnlyCompiles() throws Exception { assertTrue(new File(cached, "classes/Minimal.class").exists()); } - public void testMixedJavanAndKotlinCompile() throws Exception { + @Test + public void mixedJavanAndKotlinCompile() throws Exception { wsRootHasFile("src/MinimalJava.java", "class MinimalJava {}"); wsRootHasFile("src/MinimalKotlin.kt", "class MinimalKotlin {}"); Source src = Source.underWsroot("src"); @@ -89,7 +99,8 @@ public void testMixedJavanAndKotlinCompile() throws Exception { * Using AntRunner leaked memory. It is either kotlinc itself or its ant * adapter. Now we fork a new process via a shell script. */ - public void testTargetDoesRunOutOfMemoryWhenRepeated() throws Exception { + @Test + public void targetDoesRunOutOfMemoryWhenRepeated() throws Exception { if (true) { System.err .println("Not running the slow testTargetDoesNotLeakMemory" diff --git a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/ScalaClassesTest.java b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/ScalaClassesTest.java index b81818dd..f86625fb 100644 --- a/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/ScalaClassesTest.java +++ b/essential/iwant-api-javamodules/src/test/java/org/fluentjava/iwant/api/javamodules/ScalaClassesTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.api.javamodules; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.util.Arrays; @@ -8,6 +11,7 @@ import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.core.download.TestedIwantDependencies; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.Test; public class ScalaClassesTest extends IwantTestCase { @@ -24,7 +28,8 @@ protected void moreSetUp() throws Exception { TestedIwantDependencies.antLauncherJar().artifact().url()); } - public void testScalaAndJavaCompileAndRunWhenThereIsACrossDependencyBetweenTheLanguages() + @Test + public void scalaAndJavaCompileAndRunWhenThereIsACrossDependencyBetweenTheLanguages() throws Exception { wsRootHasDirectory("depsrc/deppak"); StringBuilder dep = new StringBuilder(); @@ -98,7 +103,8 @@ public void testScalaAndJavaCompileAndRunWhenThereIsACrossDependencyBetweenTheLa out()); } - public void testContentDescriptorAndIngredients() { + @Test + public void contentDescriptorAndIngredients() { Path dep = Source.underWsroot("dep"); ScalaClasses scalaClasses = ScalaClasses.with().name("scala-classes") .scala(SCALA) diff --git a/essential/iwant-api-model/src/test/java/org/fluentjava/iwant/api/model/SourceTest.java b/essential/iwant-api-model/src/test/java/org/fluentjava/iwant/api/model/SourceTest.java index 33b58966..91f7ffc4 100644 --- a/essential/iwant-api-model/src/test/java/org/fluentjava/iwant/api/model/SourceTest.java +++ b/essential/iwant-api-model/src/test/java/org/fluentjava/iwant/api/model/SourceTest.java @@ -1,19 +1,25 @@ package org.fluentjava.iwant.api.model; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class SourceTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testToString() { +public class SourceTest { + + @Test + public void toStringIsThePath() { assertEquals("a", Source.underWsroot("a").toString()); assertEquals("b", Source.underWsroot("b").toString()); } - public void testItHasNoIngredients() { + @Test + public void itHasNoIngredients() { assertTrue(Source.underWsroot("whatever").ingredients().isEmpty()); } - public void testWsrootRelativePath() { + @Test + public void wsrootRelativePath() { assertEquals("a", Source.underWsroot("a").wsRootRelativePath()); assertEquals("a/b", Source.underWsroot("a/b").wsRootRelativePath()); } diff --git a/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/JarTest.java b/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/JarTest.java index 0409f715..7dd9594e 100644 --- a/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/JarTest.java +++ b/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/JarTest.java @@ -1,11 +1,15 @@ package org.fluentjava.iwant.api.zip; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import org.fluentjava.iwant.api.model.ExternalSource; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class JarTest extends IwantTestCase { @@ -18,14 +22,16 @@ private void assertJarContainsTestStuff(File cachedJar) { assertTrue(new File(tmp, "META-INF/MANIFEST.MF").exists()); } - public void testIngredientsAndDescriptorOfSimpleJarOfClasses() { + @Test + public void ingredientsAndDescriptorOfSimpleJarOfClasses() { Jar jar = Jar.with().classes(Source.underWsroot("classes")).end(); assertEquals("[classes]", jar.ingredients().toString()); assertEquals("org.fluentjava.iwant.api.zip.Jar\n" + "i:classDirs:\n" + " classes\n" + "", jar.contentDescriptor()); } - public void testIngredientsAndDescriptorOfJarOfMultipleClassDirs() { + @Test + public void ingredientsAndDescriptorOfJarOfMultipleClassDirs() { Jar jar = Jar.with().classes(Source.underWsroot("classes")) .classes(Source.underWsroot("classes2")).end(); assertEquals("[classes, classes2]", jar.ingredients().toString()); @@ -35,7 +41,8 @@ public void testIngredientsAndDescriptorOfJarOfMultipleClassDirs() { jar.contentDescriptor()); } - public void testJarOfDirectory() throws Exception { + @Test + public void jarOfDirectory() throws Exception { File classes = new File(getClass() .getResource("/org/fluentjava/iwant/api/zip/dirtojar").toURI()); diff --git a/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/UnzippedTest.java b/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/UnzippedTest.java index efd5746e..18b4339a 100644 --- a/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/UnzippedTest.java +++ b/essential/iwant-api-zip/src/test/java/org/fluentjava/iwant/api/zip/UnzippedTest.java @@ -1,27 +1,34 @@ package org.fluentjava.iwant.api.zip; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import org.fluentjava.iwant.api.model.ExternalSource; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class UnzippedTest extends IwantTestCase { - public void testInregedients() { + @Test + public void inregedients() { assertEquals("[a.zip]", Unzipped.with().name("u").from(Source.underWsroot("a.zip")) .end().ingredients().toString()); } - public void testContentDescriptor() { + @Test + public void contentDescriptor() { assertEquals("org.fluentjava.iwant.api.zip.Unzipped:[a.zip]", Unzipped.with().name("u").from(Source.underWsroot("a.zip")) .end().contentDescriptor()); } - public void testUnzippedDirAndFileZip() throws Exception { + @Test + public void unzippedDirAndFileZip() throws Exception { File zipFile = new File( getClass().getResource("unzipped-test.zip").toURI()); diff --git a/essential/iwant-core-ant/src/test/java/org/fluentjava/iwant/core/ant/AntGeneratedTest.java b/essential/iwant-core-ant/src/test/java/org/fluentjava/iwant/core/ant/AntGeneratedTest.java index f05908c6..730b59d0 100644 --- a/essential/iwant-core-ant/src/test/java/org/fluentjava/iwant/core/ant/AntGeneratedTest.java +++ b/essential/iwant-core-ant/src/test/java/org/fluentjava/iwant/core/ant/AntGeneratedTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.core.ant; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import org.fluentjava.iwant.api.core.Concatenated; @@ -14,6 +17,7 @@ import org.fluentjava.iwant.embedded.AsEmbeddedIwantUser; import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.entry.Iwant.ExitCalledException; +import org.junit.jupiter.api.Test; public class AntGeneratedTest extends IwantTestCase { @@ -41,7 +45,8 @@ private Path antLauncherJar() { return downloaded(TestedIwantDependencies.antLauncherJar()); } - public void testContentDescriptor() { + @Test + public void contentDescriptor() { assertEquals("org.fluentjava.iwant.core.ant.AntGenerated\n" + "i:ant-jars:\n " + Iwant.IWANT_USER_DIR + "/cached/UnmodifiableUrl/https%3A/%2Frepo1.maven.org/maven2/org/apache/ant/ant/1.10.14/ant-1.10.14.jar\n" @@ -59,7 +64,8 @@ public void testContentDescriptor() { .contentDescriptor()); } - public void testIngredients() { + @Test + public void ingredients() { assertEquals("[" + antJar() + ", script]", AntGenerated.with().name("minimal").antJars(antJar()) .script(Source.underWsroot("script")).end() @@ -72,7 +78,8 @@ public void testIngredients() { .ingredients().toString()); } - public void testMinimalEcho() throws Exception { + @Test + public void minimalEcho() throws Exception { ConcatenatedBuilder scriptContent = Concatenated.named("script"); scriptContent.string("\n"); scriptContent.string(" \n"); @@ -90,7 +97,8 @@ public void testMinimalEcho() throws Exception { assertContains(err(), "hello message"); } - public void testMinimalFail() throws Exception { + @Test + public void minimalFail() throws Exception { ConcatenatedBuilder scriptContent = Concatenated.named("script"); scriptContent.string("\n"); scriptContent.string(" \n"); @@ -113,7 +121,8 @@ public void testMinimalFail() throws Exception { assertContains(err(), "fail message"); } - public void testEchoIwantOutFileProperty() throws Exception { + @Test + public void echoIwantOutFileProperty() throws Exception { ConcatenatedBuilder scriptContent = Concatenated.named("script"); scriptContent.string("\n"); scriptContent.string(" \n"); @@ -133,7 +142,8 @@ public void testEchoIwantOutFileProperty() throws Exception { } } - public void testFileGeneratingScriptWithIngredients() throws Exception { + @Test + public void fileGeneratingScriptWithIngredients() throws Exception { HelloTarget ingredient1 = new HelloTarget("ingredient1", "ingredient1 content"); ingredient1.path(ctx); diff --git a/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/DownloadedTest.java b/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/DownloadedTest.java index 1bfd38b1..f1a8706b 100644 --- a/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/DownloadedTest.java +++ b/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/DownloadedTest.java @@ -1,5 +1,10 @@ package org.fluentjava.iwant.core.download; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.net.URL; import java.util.LinkedHashMap; @@ -12,10 +17,10 @@ import org.fluentjava.iwant.apimocks.UrlString; import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class DownloadedTest extends TestCase { +public class DownloadedTest { private TestArea testArea; private CachesMock caches; @@ -24,8 +29,8 @@ public class DownloadedTest extends TestCase { private TargetEvaluationContextMock ctx; private File cached; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); wsRoot = testArea.newDir("wsroot"); caches = new CachesMock(wsRoot); @@ -34,12 +39,14 @@ public void setUp() { cached = new File(testArea.root(), "cachedDownload"); } - public void testThereAreNoIngredients() { + @Test + public void thereAreNoIngredients() { assertTrue(Downloaded.withName("any").url("http://localhost/any") .md5("any").ingredients().isEmpty()); } - public void testContentDescriptor() { + @Test + public void contentDescriptor() { assertEquals( "org.fluentjava.iwant.core.download.Downloaded\n" + "p:url:\n" + " http://localhost/url1\n" + "p:md5:\n" + " any\n" @@ -59,12 +66,14 @@ public void testContentDescriptor() { * simplest way to avoid failed downloads because of server refusing the * connection. */ - public void testParallelRefreshIsDisabled() { + @Test + public void parallelRefreshIsDisabled() { assertFalse(Downloaded.withName("any").url("http://any.com/file") .noCheck().supportsParallelism()); } - public void testDownloadSucceedsWithoutDigestCheck() throws Exception { + @Test + public void downloadSucceedsWithoutDigestCheck() throws Exception { URL url = Iwant.url("http://localhost"); caches.cachesUrlAt(url, cached); iwantMock.shallDownloadContent(url, "valid content"); @@ -77,7 +86,8 @@ public void testDownloadSucceedsWithoutDigestCheck() throws Exception { assertEquals("valid content", testArea.contentOf(cached)); } - public void testDownloadSucceedsWithCorrectMd5() throws Exception { + @Test + public void downloadSucceedsWithCorrectMd5() throws Exception { URL url = Iwant.url("http://localhost"); caches.cachesUrlAt(url, cached); iwantMock.shallDownloadContent(url, "valid content"); @@ -91,7 +101,8 @@ public void testDownloadSucceedsWithCorrectMd5() throws Exception { assertEquals("valid content", testArea.contentOf(cached)); } - public void testDownloadFailsAndCachedFileIsRenamedIfMd5Fails() + @Test + public void downloadFailsAndCachedFileIsRenamedIfMd5Fails() throws Exception { URL url = Iwant.url("http://localhost"); caches.cachesUrlAt(url, cached); diff --git a/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/FromRepositoryTest.java b/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/FromRepositoryTest.java index 1aee8ee5..cffe1769 100644 --- a/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/FromRepositoryTest.java +++ b/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/FromRepositoryTest.java @@ -1,10 +1,14 @@ package org.fluentjava.iwant.core.download; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; -public class FromRepositoryTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testFactsOfArtifactGivenWithSlashesInGroup() { +public class FromRepositoryTest { + + @Test + public void factsOfArtifactGivenWithSlashesInGroup() { GnvArtifact t = FromRepository.repo1MavenOrg() .group("org/apache/ant").name("ant").version("1.7.1").jar(); @@ -22,7 +26,8 @@ public void testFactsOfArtifactGivenWithSlashesInGroup() { assertNull(t.artifact().md5()); } - public void testFactsOfArtifactGivenWithDotsInGroup() { + @Test + public void factsOfArtifactGivenWithDotsInGroup() { GnvArtifact t = FromRepository.repo1MavenOrg() .group("com.google.code.findbugs").name("findbugs") .version("1.3.9").jar(); @@ -40,7 +45,8 @@ public void testFactsOfArtifactGivenWithDotsInGroup() { assertNull(t.artifact().md5()); } - public void testFactsOfSourceArtifact() { + @Test + public void factsOfSourceArtifact() { GnvArtifact t = FromRepository.repo1MavenOrg() .group("com.google.code.findbugs").name("findbugs") .version("1.3.9").sourcesJar(); @@ -58,7 +64,8 @@ public void testFactsOfSourceArtifact() { assertNull(t.artifact().md5()); } - public void testFactsOfTestArtifact() { + @Test + public void factsOfTestArtifact() { GnvArtifact t = FromRepository.repo1MavenOrg() .group("org.apache.kafka").name("kafka_2.11").version("2.0.1") .testJar(); @@ -76,7 +83,8 @@ public void testFactsOfTestArtifact() { assertNull(t.artifact().md5()); } - public void testFactsWithCustomUrlPrefix() { + @Test + public void factsWithCustomUrlPrefix() { GnvArtifact t = FromRepository .at("https://maven.google.com/").group("androidx.annotation") .name("annotation").version("1.1.0").jar(); diff --git a/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/TestedIwantDependenciesTest.java b/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/TestedIwantDependenciesTest.java index 19f4103e..46d18b37 100644 --- a/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/TestedIwantDependenciesTest.java +++ b/essential/iwant-core-download/src/test/java/org/fluentjava/iwant/core/download/TestedIwantDependenciesTest.java @@ -1,10 +1,13 @@ package org.fluentjava.iwant.core.download; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class TestedIwantDependenciesTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testNamesOfDownloadedTargets() { +public class TestedIwantDependenciesTest { + + @Test + public void namesOfDownloadedTargets() { // this documents the names, change when upgrading: assertEquals("ant-1.10.14.jar", TestedIwantDependencies.antJar().name()); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/ContentDefinitionsTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/ContentDefinitionsTest.java index 8b3de3ff..5ecedc4b 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/ContentDefinitionsTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/ContentDefinitionsTest.java @@ -2,7 +2,7 @@ import junit.framework.TestCase; -public class ContentDefinitionsTest extends TestCase { +public class ContentDefinitionsTest{ private String descr; @@ -21,14 +21,14 @@ private void descrChanged(Content content) { // the tests - public void testConstant() { + @Test public void constant() { Constant content = Constant.value("value"); descrChanged(content); content = Constant.value("some-other-value"); descrChanged(content); } - public void testJavaClasses() { + @Test public void javaClasses() { JavaClasses content = JavaClasses.compiledFrom(new Source("src")); descrChanged(content); content = JavaClasses.compiledFrom(new Source("other-src")); @@ -39,7 +39,7 @@ public void testJavaClasses() { descrChanged(content); } - public void testJunitResult() { + @Test public void junitResult() { JunitResult content = JunitResult.ofClass("ATest"); descrChanged(content); content = JunitResult.ofClass("SomeOtherTest"); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/EmbeddedUsageTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/EmbeddedUsageTest.java index fe2e1fde..7a94994e 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/EmbeddedUsageTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/EmbeddedUsageTest.java @@ -2,7 +2,7 @@ import junit.framework.TestCase; -public class EmbeddedUsageTest extends TestCase { +public class EmbeddedUsageTest{ private TestArea testArea; @@ -11,7 +11,7 @@ public void setUp() { testArea = TestArea.newEmpty(); } - public void testNonexistentTargetAsPath() { + @Test public void nonexistentTargetAsPath() { Workspace ws = Workspace.with().name("test").target("hello") .content(Concatenated.from().string("hello world").end()) .endWorkspace(); @@ -24,7 +24,7 @@ public void testNonexistentTargetAsPath() { } } - public void testSuccessfulHelloAsPath() throws Exception { + @Test public void successfulHelloAsPath() throws Exception { Workspace ws = Workspace.with().name("test").target("hello") .content(Concatenated.from().string("hello world").end()) .endWorkspace(); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/IwantTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/IwantTest.java index cf56c959..9ba02a60 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/IwantTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/IwantTest.java @@ -54,7 +54,7 @@ public void tearDown() { super.tearDown(); } - public void testMissingAsSomebodyIsAnInternalFailure() throws Exception { + @Test public void missingAsSomebodyIsAnInternalFailure() throws Exception { try { Iwant.main(new String[] { wsRoot() + "/as-x-developer", "", iwantLibs }); @@ -68,7 +68,7 @@ public void testMissingAsSomebodyIsAnInternalFailure() throws Exception { + "/as-x-developer/i-have\n", err()); } - public void testMissingIHaveIsAnInternalFailure() throws Exception { + @Test public void missingIHaveIsAnInternalFailure() throws Exception { directoryExists("as-x-developer"); try { Iwant.main(new String[] { wsRoot() + "/as-x-developer", "", @@ -83,7 +83,7 @@ public void testMissingIHaveIsAnInternalFailure() throws Exception { + "/as-x-developer/i-have\n", err()); } - public void testMissingIHaveWsInfoGetsCreatedThenBuildAborts() + @Test public void missingIHaveWsInfoGetsCreatedThenBuildAborts() throws Exception { directoryExists("as-x-developer/i-have"); try { @@ -104,7 +104,7 @@ public void testMissingIHaveWsInfoGetsCreatedThenBuildAborts() contentOf(wsRoot() + "/as-x-developer/i-have/ws-info.conf")); } - public void testMissingWsDefJavaGetsCreatedThenBuildAborts() + @Test public void missingWsDefJavaGetsCreatedThenBuildAborts() throws Exception { directoryExists("as-x-developer/i-have"); file("as-x-developer/i-have/ws-info.conf").withContent(); @@ -135,7 +135,7 @@ public void testMissingWsDefJavaGetsCreatedThenBuildAborts() .contains("class TestWorkspace implements WorkspaceDefinition {")); } - public void testEmptyWishCausesAHelpMessage() throws Exception { + @Test public void emptyWishCausesAHelpMessage() throws Exception { testMissingWsDefJavaGetsCreatedThenBuildAborts(); startOfOutAndErrCapture(); try { @@ -150,7 +150,7 @@ public void testEmptyWishCausesAHelpMessage() throws Exception { err().startsWith("perr:Please tell what you want.")); } - public void testEmptyWishAlsoGeneratesWishScripts() throws Exception { + @Test public void emptyWishAlsoGeneratesWishScripts() throws Exception { testEmptyWishCausesAHelpMessage(); // just a few examples asserted, descript tests more: assertEquals("#!/bin/bash\n" + "HERE=$(dirname \"$0\")\n" @@ -168,7 +168,7 @@ public void testEmptyWishAlsoGeneratesWishScripts() throws Exception { .canExecute()); } - public void testWishScriptsAreNotDeletedWhenTargetDetectionFails() + @Test public void wishScriptsAreNotDeletedWhenTargetDetectionFails() throws Exception { testEmptyWishAlsoGeneratesWishScripts(); file( @@ -198,7 +198,7 @@ public void testWishScriptsAreNotDeletedWhenTargetDetectionFails() .length() > 0); } - public void testListOfTargetsWorksAndRenamesWishScriptAfterTargetRename() + @Test public void listOfTargetsWorksAndRenamesWishScriptAfterTargetRename() throws Exception { testEmptyWishAlsoGeneratesWishScripts(); @@ -227,7 +227,7 @@ public void testListOfTargetsWorksAndRenamesWishScriptAfterTargetRename() .exists()); } - public void testListOfTargets() throws Exception { + @Test public void listOfTargets() throws Exception { testMissingWsDefJavaGetsCreatedThenBuildAborts(); startOfOutAndErrCapture(); @@ -237,7 +237,7 @@ public void testListOfTargets() throws Exception { assertEquals("", err()); } - public void testRefreshingNonExistentTargetCausesErrorMessage() + @Test public void refreshingNonExistentTargetCausesErrorMessage() throws Exception { testMissingWsDefJavaGetsCreatedThenBuildAborts(); startOfOutAndErrCapture(); @@ -254,7 +254,7 @@ public void testRefreshingNonExistentTargetCausesErrorMessage() err()); } - public void testRefreshingOfAConstant() throws Exception { + @Test public void refreshingOfAConstant() throws Exception { testMissingWsDefJavaGetsCreatedThenBuildAborts(); startOfOutAndErrCapture(); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/LocationsTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/LocationsTest.java index a3cff655..5bb98ab0 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/LocationsTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/LocationsTest.java @@ -5,9 +5,9 @@ import junit.framework.TestCase; -public class LocationsTest extends TestCase { +public class LocationsTest{ - public void testLocationsCreatedFromIhave() throws IOException { + @Test public void locationsCreatedFromIhave() throws IOException { Locations locations = Locations.from(new File("/wsRoot"), new File( "/as-x/i-have"), "wsName", new File( "/as-x/with/bash/iwant/cached/blah/iwant-lib")); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PathDiggerTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PathDiggerTest.java index 23a4205c..1cef1cdc 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PathDiggerTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PathDiggerTest.java @@ -2,30 +2,30 @@ import junit.framework.TestCase; -public class PathDiggerTest extends TestCase { +public class PathDiggerTest{ private static final Locations LOCATIONS = new Locations("wsRoot", "as-someone", "cacheDir", "iwant-libs"); - public void testEmptyListOfTargets() { + @Test public void emptyListOfTargets() { ContainerPath root = new EmptyWorkspace().wsRoot(LOCATIONS); assertEquals("[]", PathDigger.targets(root).toString()); } - public void testListOfTwoConstantTargetsAmongNonTargetMethods() { + @Test public void listOfTwoConstantTargetsAmongNonTargetMethods() { ContainerPath root = new WorkspaceWithTwoConstantTargetFiles() .wsRoot(LOCATIONS); assertEquals("[Target:constant2-container/constant2," + " Target:constantOne]", PathDigger.targets(root).toString()); } - public void testTargetByIllegalName() { + @Test public void targetByIllegalName() { ContainerPath root = new WorkspaceWithTwoConstantTargetFiles() .wsRoot(LOCATIONS); assertNull(PathDigger.target(root, "illegal")); } - public void testTargetByName() { + @Test public void targetByName() { ContainerPath root = new WorkspaceWithTwoConstantTargetFiles() .wsRoot(LOCATIONS); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PrintPrefixesTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PrintPrefixesTest.java index 6c00415c..4c1d756f 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PrintPrefixesTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/PrintPrefixesTest.java @@ -2,9 +2,9 @@ import junit.framework.TestCase; -public class PrintPrefixesTest extends TestCase { +public class PrintPrefixesTest{ - public void testNullPrefix() { + @Test public void nullPrefix() { PrintPrefixes p = PrintPrefixes.fromPrefix(null); assertEquals("", p.prefix()); assertEquals("", p.errPrefix()); @@ -12,7 +12,7 @@ public void testNullPrefix() { assertEquals("1\n2\n", p.multiLineErr("1\n2\n")); } - public void testEmptyPrefix() { + @Test public void emptyPrefix() { PrintPrefixes p = PrintPrefixes.fromPrefix(""); assertEquals("", p.prefix()); assertEquals("", p.errPrefix()); @@ -20,7 +20,7 @@ public void testEmptyPrefix() { assertEquals("1\n2\n", p.multiLineErr("1\n2\n")); } - public void testNonEmptyPrefix() { + @Test public void nonEmptyPrefix() { PrintPrefixes p = PrintPrefixes.fromPrefix(":iwant:"); assertEquals(":iwant:", p.prefix()); assertEquals(":iwant:err:", p.errPrefix()); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/RefresherTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/RefresherTest.java index c33d5ba9..4ac85a8f 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/RefresherTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/RefresherTest.java @@ -4,7 +4,7 @@ import junit.framework.TestCase; -public class RefresherTest extends TestCase { +public class RefresherTest{ private static final Locations LOCATIONS = new Locations("wsRoot", "as-someone", "cacheDir", "iwant-libs"); @@ -21,7 +21,7 @@ public void setUp() { content = new ContentMock(); } - public void testMissingTargetWithNoSrcIsRefreshed() throws Exception { + @Test public void missingTargetWithNoSrcIsRefreshed() throws Exception { ts.doesNotExist("cacheDir/target/missing"); Target target = new Target("missing", content); refresher.refresh(target); @@ -29,7 +29,7 @@ public void testMissingTargetWithNoSrcIsRefreshed() throws Exception { .refreshedDestinations().toString()); } - public void testMissingTargetWithSrcIsRefreshed() throws Exception { + @Test public void missingTargetWithSrcIsRefreshed() throws Exception { content.ingredients().add(new Source("src")); ts.modifiedAt("wsRoot/src", 1); ts.doesNotExist("cacheDir/target/classes"); @@ -39,7 +39,7 @@ public void testMissingTargetWithSrcIsRefreshed() throws Exception { .refreshedDestinations().toString()); } - public void testExistingTargetWithNoSrcAndUnchangedDescrIsNotRefreshed() + @Test public void existingTargetWithNoSrcAndUnchangedDescrIsNotRefreshed() throws Exception { ts.modifiedAt("cacheDir/target/constant", 1); Target target = new Target("constant", @@ -49,7 +49,7 @@ public void testExistingTargetWithNoSrcAndUnchangedDescrIsNotRefreshed() assertEquals("[]", content.refreshedDestinations().toString()); } - public void testExistingTargetWithNoSrcAndNoCachedDescrIsRefreshed() + @Test public void existingTargetWithNoSrcAndNoCachedDescrIsRefreshed() throws Exception { ts.modifiedAt("cacheDir/target/constant", 1); Target target = new Target("constant", @@ -59,7 +59,7 @@ public void testExistingTargetWithNoSrcAndNoCachedDescrIsRefreshed() .refreshedDestinations().toString()); } - public void testExistingTargetWithMissingSrcIsRefreshed() throws Exception { + @Test public void existingTargetWithMissingSrcIsRefreshed() throws Exception { content.ingredients().add(new Source("src")); ts.modifiedAt("cacheDir/target/classes", 1); ts.doesNotExist("wsRoot/src"); @@ -69,7 +69,7 @@ public void testExistingTargetWithMissingSrcIsRefreshed() throws Exception { .refreshedDestinations().toString()); } - public void testTargetOlderThanItsSourceIsRefreshed() throws Exception { + @Test public void targetOlderThanItsSourceIsRefreshed() throws Exception { content.ingredients().add(new Source("src")); ts.modifiedAt("cacheDir/target/classes", 1); ts.modifiedAt("wsRoot/src", 2); @@ -79,7 +79,7 @@ public void testTargetOlderThanItsSourceIsRefreshed() throws Exception { .refreshedDestinations().toString()); } - public void testTargetNotOlderThanItsSourceAndUnchangedContentDescriptionIsNotRefreshed() + @Test public void targetNotOlderThanItsSourceAndUnchangedContentDescriptionIsNotRefreshed() throws Exception { content.ingredients().add(new Source("src")); ts.modifiedAt("wsRoot/src", 1); @@ -91,7 +91,7 @@ public void testTargetNotOlderThanItsSourceAndUnchangedContentDescriptionIsNotRe assertEquals("[]", descrCache.recachedTargets().toString()); } - public void testTargetNotOlderThanItsSourceIsRefreshedIfItsContentDescriptionHasChanged() + @Test public void targetNotOlderThanItsSourceIsRefreshedIfItsContentDescriptionHasChanged() throws Exception { content.ingredients().add(new Source("src")); content.definitionDescription("new-description"); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderArgumentsTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderArgumentsTest.java index fdaa1865..47c1d224 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderArgumentsTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderArgumentsTest.java @@ -2,7 +2,7 @@ public class WorkspaceBuilderArgumentsTest extends WorkspaceBuilderTestBase { - public void testTooFewArguments() { + @Test public void tooFewArguments() { try { WorkspaceBuilder .build(new String[] { EmptyWorkspace.class.getName(), diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTest.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTest.java index 8afb688e..98c0b785 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTest.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTest.java @@ -11,20 +11,20 @@ @SuppressWarnings("resource") public class WorkspaceBuilderTest extends WorkspaceBuilderTestBase { - public void testListOfTargetsOfEmptyWs() { + @Test public void listOfTargetsOfEmptyWs() { at(EmptyWorkspace.class).iwant("list-of/targets"); assertEquals("", out()); assertEquals("", err()); } - public void testListOfTargetsWithTwoConstantTargetFiles() { + @Test public void listOfTargetsWithTwoConstantTargetFiles() { at(WorkspaceWithTwoConstantTargetFiles.class).iwant("list-of/targets"); assertEquals("pout:constant2-container/constant2\npout:constantOne\n", out()); assertEquals("", err()); } - public void testIllegalTargetAsPath() { + @Test public void illegalTargetAsPath() { try { at(WorkspaceWithTwoConstantTargetFiles.class).iwant( "target/illegal/as-path"); @@ -36,7 +36,7 @@ public void testIllegalTargetAsPath() { assertEquals("", err()); } - public void testConstantOneAsPathAndItsContent() throws IOException { + @Test public void constantOneAsPathAndItsContent() throws IOException { at(WorkspaceWithTwoConstantTargetFiles.class).iwant( "target/constantOne/as-path"); assertEquals(pathLine("constantOne"), out()); @@ -45,7 +45,7 @@ public void testConstantOneAsPathAndItsContent() throws IOException { assertEquals("constantOne content\n", cachedContent("constantOne")); } - public void testConstantTwoAsPathAndItsContent() throws IOException { + @Test public void constantTwoAsPathAndItsContent() throws IOException { at(WorkspaceWithTwoConstantTargetFiles.class).iwant( "target/constant2-container/constant2/as-path"); assertEquals(pathLine("constant2-container/constant2"), out()); @@ -85,7 +85,7 @@ public ContainerPath wsRoot(Locations locations) { /** * Further java compilation testing is done in the tutorial */ - public void testGeneratedJavaClassIsNonempty() throws Exception { + @Test public void generatedJavaClassIsNonempty() throws Exception { directoryExists("src"); file("src/Empty.java").withContent().line("public class Empty {}") .exists(); @@ -138,7 +138,7 @@ public ContainerPath wsRoot(Locations locations) { /** * Further java compilation testing is done in the tutorial */ - public void testClassWithDependencyCompiles() throws Exception { + @Test public void classWithDependencyCompiles() throws Exception { directoryExists("src1"); file("src1/Util.java").withContent().line("public class Util {}") .exists(); @@ -205,7 +205,7 @@ public ContainerPath wsRoot(Locations locations) { } - public void testJunitResultOfFailingTest() { + @Test public void junitResultOfFailingTest() { directoryExists("tests"); file("tests/ATest.java").withContent(); line("public class ATest extends junit.framework.TestCase {"); @@ -223,7 +223,7 @@ public void testJunitResultOfFailingTest() { assertEquals("perr:Test ATest FAILED\n", err()); } - public void testJunitResultOfPassingTest() throws Exception { + @Test public void junitResultOfPassingTest() throws Exception { new File(wsRoot() + "/tests").mkdir(); new FileWriter(wsRoot() + "/tests/ATest.java").append( "public class ATest extends junit.framework.TestCase {" @@ -242,7 +242,7 @@ public void testJunitResultOfPassingTest() throws Exception { /** * Let's test laziness when sources are directories like for javac */ - public void testJunitResultIsFailureEvenIfSourcesAreTouchedAfterSuccess() + @Test public void junitResultIsFailureEvenIfSourcesAreTouchedAfterSuccess() throws Exception { testJunitResultOfPassingTest(); sleep(); @@ -287,7 +287,7 @@ public ContainerPath wsRoot(Locations locations) { } - public void testDownloadFailsIfFileDoesNotExist() { + @Test public void downloadFailsIfFileDoesNotExist() { try { at(WorkspaceWithDownloadedContent.class).iwant( "target/aDownloadedFile/as-path"); @@ -299,7 +299,7 @@ public void testDownloadFailsIfFileDoesNotExist() { assertTrue(err().contains("Error getting")); } - public void testDownloadFailsIfDownloadedFileIsCorrupt() throws Exception { + @Test public void downloadFailsIfDownloadedFileIsCorrupt() throws Exception { new FileWriter(mockWeb() + "/aFileInTheWeb").append("corrupted\n") .close(); try { @@ -313,7 +313,7 @@ public void testDownloadFailsIfDownloadedFileIsCorrupt() throws Exception { assertTrue(err().contains("Checksum failed")); } - public void testDownloadFailsIfShaDoesNotMatch() throws Exception { + @Test public void downloadFailsIfShaDoesNotMatch() throws Exception { new FileWriter(mockWeb() + "/aFileInTheWeb").append("corrupted\n") .close(); try { @@ -327,7 +327,7 @@ public void testDownloadFailsIfShaDoesNotMatch() throws Exception { assertTrue(err().contains("Checksum failed")); } - public void testDownloadRetryWorksAfterFailedDownload() throws Exception { + @Test public void downloadRetryWorksAfterFailedDownload() throws Exception { testDownloadFailsIfDownloadedFileIsCorrupt(); new FileWriter(mockWeb() + "/aFileInTheWeb").append("correct\n") .close(); @@ -342,7 +342,7 @@ public void testDownloadRetryWorksAfterFailedDownload() throws Exception { * Custom cache invalidation logic needed to negate this feature, if needed * for the paranoid among us */ - public void testDownloadDoesNotFailIfAlreadyCachedFileIsCorrupt() + @Test public void downloadDoesNotFailIfAlreadyCachedFileIsCorrupt() throws Exception { testSuccessfulFirstDownload(); sleep(); @@ -355,7 +355,7 @@ public void testDownloadDoesNotFailIfAlreadyCachedFileIsCorrupt() assertEquals("corrupted\n", cachedContent("aDownloadedFile")); } - public void testSuccessfulFirstDownload() throws Exception { + @Test public void successfulFirstDownload() throws Exception { new FileWriter(mockWeb() + "/aFileInTheWeb").append("correct\n") .close(); at(WorkspaceWithDownloadedContent.class).iwant( @@ -365,7 +365,7 @@ public void testSuccessfulFirstDownload() throws Exception { assertEquals("correct\n", cachedContent("aDownloadedFile")); } - public void testSuccessfulFirstDownloadWithSha() throws Exception { + @Test public void successfulFirstDownloadWithSha() throws Exception { new FileWriter(mockWeb() + "/aFileInTheWeb").append("correct\n") .close(); at(WorkspaceWithDownloadedContent.class).iwant( @@ -375,7 +375,7 @@ public void testSuccessfulFirstDownloadWithSha() throws Exception { assertEquals("correct\n", cachedContent("aDownloadedFileWithSha")); } - public void testSuccessfulLazyDownloadWhenCorrectCachedFileExists() + @Test public void successfulLazyDownloadWhenCorrectCachedFileExists() throws Exception { testSuccessfulFirstDownload(); @@ -453,7 +453,7 @@ public ContainerPath wsRoot(Locations locations) { } - public void testEclipseProjectsFailsIfCompilationFails() throws IOException { + @Test public void eclipseProjectsFailsIfCompilationFails() throws IOException { ensureEmpty(wsRoot() + "/a/src"); ensureEmpty(wsRoot() + "/b/src"); new FileWriter(wsRoot() + "/b/src/B.java").append( @@ -467,7 +467,7 @@ public void testEclipseProjectsFailsIfCompilationFails() throws IOException { } } - public void testEclipseProjectsWithTwoMinimalProjectsWithDependency() + @Test public void eclipseProjectsWithTwoMinimalProjectsWithDependency() throws IOException { ensureEmpty(wsRoot() + "/a/src"); ensureEmpty(wsRoot() + "/b/src"); @@ -733,7 +733,7 @@ private static String phase2java() { return b.toString(); } - public void testListOfTargetsContainsPhase2Target() throws IOException { + @Test public void listOfTargetsContainsPhase2Target() throws IOException { ensureEmpty(wsRoot() + "/phase2/src/com/example/phasetwo"); new FileWriter(wsRoot() + "/phase2/src/com/example/phasetwo/Phase2.java").append( @@ -743,7 +743,7 @@ public void testListOfTargetsContainsPhase2Target() throws IOException { assertEquals("pout:phase2Classes\npout:targetInPhase2\n", out()); } - public void testPhase2TargetContent() throws IOException { + @Test public void phase2TargetContent() throws IOException { ensureEmpty(wsRoot() + "/phase2/src/com/example/phasetwo"); new FileWriter(wsRoot() + "/phase2/src/com/example/phasetwo/Phase2.java").append( @@ -842,7 +842,7 @@ public ContainerPath wsRoot(Locations locations) { } - public void testSuccessfulShellScript() throws IOException { + @Test public void successfulShellScript() throws IOException { at(WorkspaceWithShellScript.class).iwant( "target/successfulScriptOutput/as-path"); @@ -864,7 +864,7 @@ public void testSuccessfulShellScript() throws IOException { /** * A bug made the second run run the first script again. */ - public void testAnotherScriptAfterOneScript() throws IOException { + @Test public void anotherScriptAfterOneScript() throws IOException { testSuccessfulShellScript(); startOfOutAndErrCapture(); at(WorkspaceWithShellScript.class).iwant( @@ -877,7 +877,7 @@ public void testAnotherScriptAfterOneScript() throws IOException { cachedContent("anotherSuccessfulScriptOutput")); } - public void testFailingShellScript() { + @Test public void failingShellScript() { try { at(WorkspaceWithShellScript.class).iwant( "target/failingScriptOutput/as-path"); @@ -899,7 +899,7 @@ public void testFailingShellScript() { .exists()); } - public void testConcatenatedSrc() throws IOException { + @Test public void concatenatedSrc() throws IOException { new FileWriter(wsRoot() + "/src").append("src content\n").close(); at(WorkspaceWithConcatenatedContent.class).iwant( "target/copyOfSrc/as-path"); @@ -910,7 +910,7 @@ public void testConcatenatedSrc() throws IOException { assertEquals("src content\n", cachedContent("copyOfSrc")); } - public void testConcatenatedSrcAfterSrcChanges() throws IOException { + @Test public void concatenatedSrcAfterSrcChanges() throws IOException { testConcatenatedSrc(); sleep(); new FileWriter(wsRoot() + "/src").append("new src content\n").close(); @@ -923,7 +923,7 @@ public void testConcatenatedSrcAfterSrcChanges() throws IOException { assertEquals("new src content\n", cachedContent("copyOfSrc")); } - public void testAnotherTargetContentAndBytesConcatenated() + @Test public void anotherTargetContentAndBytesConcatenated() throws IOException { new FileWriter(wsRoot() + "/src").append("src content\n").close(); at(WorkspaceWithConcatenatedContent.class).iwant( @@ -937,7 +937,7 @@ public void testAnotherTargetContentAndBytesConcatenated() cachedContent("anotherTargetContentAndBytesConcatenated")); } - public void testAnotherTargetPathAndStringConcatenated() throws IOException { + @Test public void anotherTargetPathAndStringConcatenated() throws IOException { new FileWriter(wsRoot() + "/src").append("src content\n").close(); at(WorkspaceWithConcatenatedContent.class).iwant( "target/anotherTargetPathAndStringConcatenated/as-path"); @@ -954,7 +954,7 @@ public void testAnotherTargetPathAndStringConcatenated() throws IOException { * ensuring scripts get rerun when paths referenced in them have been * refreshed, because this way the scripts themselves get touched. */ - public void testAnotherTargetPathAndStringConcatenatedIsRefreshedWhenSrcChanges() + @Test public void anotherTargetPathAndStringConcatenatedIsRefreshedWhenSrcChanges() throws IOException, InterruptedException { testAnotherTargetPathAndStringConcatenated(); long firstModTime = new File( @@ -984,7 +984,7 @@ public void testAnotherTargetPathAndStringConcatenatedIsRefreshedWhenSrcChanges( /** * This tests iwant deletes the cached target before calling refresh */ - public void testScriptThatCreatesDirWorksTwice() throws IOException { + @Test public void scriptThatCreatesDirWorksTwice() throws IOException { file("mkdirScriptSource").withContent().line("1").exists(); at(WorkspaceWithShellScript.class).iwant( "target/mkdirScriptGeneratedContent/as-path"); @@ -1058,7 +1058,7 @@ public ContainerPath wsRoot(Locations locations) { } - public void testListOfTargetsFromExplicitCollectionWithDynamicTargets() { + @Test public void listOfTargetsFromExplicitCollectionWithDynamicTargets() { at(WorkspaceWithExplicitTargetCollection.class) .iwant("list-of/targets"); assertEquals( @@ -1067,7 +1067,7 @@ public void testListOfTargetsFromExplicitCollectionWithDynamicTargets() { assertEquals("", err()); } - public void testRefreshOfDynamicTarget() throws IOException { + @Test public void refreshOfDynamicTarget() throws IOException { at(WorkspaceWithExplicitTargetCollection.class).iwant( "target/dynamic-2/as-path"); @@ -1077,7 +1077,7 @@ public void testRefreshOfDynamicTarget() throws IOException { assertEquals("content of dynamic-2", cachedContent("dynamic-2")); } - public void testRefreshOfPublicMethodTargetFailsWhenItDoesNotBelongToExplicitCollection() { + @Test public void refreshOfPublicMethodTargetFailsWhenItDoesNotBelongToExplicitCollection() { try { at(WorkspaceWithExplicitTargetCollection.class).iwant( "target/invisible/as-path"); diff --git a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTestBase.java b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTestBase.java index ac9b8535..f750c45c 100644 --- a/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTestBase.java +++ b/essential/iwant-core/src/test/java/org/fluentjava/iwant/core/WorkspaceBuilderTestBase.java @@ -9,7 +9,7 @@ import junit.framework.TestCase; -public abstract class WorkspaceBuilderTestBase extends TestCase { +public abstract class WorkspaceBuilderTestBase{ private static final boolean SHOW_OUTPUT = false; diff --git a/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/FileUtilTest.java b/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/FileUtilTest.java index a81a5beb..984be3f4 100644 --- a/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/FileUtilTest.java +++ b/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/FileUtilTest.java @@ -1,15 +1,20 @@ package org.fluentjava.iwant.coreservices; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +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.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class FileUtilTest extends TestCase { +public class FileUtilTest { - public void testRelativePathFailsWithDifferentParent() { + @Test + public void relativePathFailsWithDifferentParent() { File parent = new File("/a"); try { FileUtil.relativePathOfFileUnderParent(new File("/b"), parent); @@ -19,7 +24,8 @@ public void testRelativePathFailsWithDifferentParent() { } } - public void testRelativePathFailsWithFileUnderDifferentParent() { + @Test + public void relativePathFailsWithFileUnderDifferentParent() { File parent = new File("/a"); try { FileUtil.relativePathOfFileUnderParent(new File("/b/c"), parent); @@ -29,7 +35,8 @@ public void testRelativePathFailsWithFileUnderDifferentParent() { } } - public void testRelativePathFailsWithRoot() { + @Test + public void relativePathFailsWithRoot() { File parent = new File("/a"); try { FileUtil.relativePathOfFileUnderParent(new File("/"), parent); @@ -39,7 +46,8 @@ public void testRelativePathFailsWithRoot() { } } - public void testRelativePathFailsWithNull() { + @Test + public void relativePathFailsWithNull() { File parent = new File("/a"); try { FileUtil.relativePathOfFileUnderParent(null, parent); @@ -49,31 +57,36 @@ public void testRelativePathFailsWithNull() { } } - public void testRelativePathIsEmptyForParentItself() { + @Test + public void relativePathIsEmptyForParentItself() { File parent = new File("/a"); assertEquals("", FileUtil.relativePathOfFileUnderParent(new File("/a"), parent)); } - public void testRelativePathIsEmptyForRoot() { + @Test + public void relativePathIsEmptyForRoot() { File parent = new File("/"); assertEquals("", FileUtil.relativePathOfFileUnderParent(new File("/"), parent)); } - public void testRelativePathIsBForAB() { + @Test + public void relativePathIsBForAB() { File parent = new File("/a"); assertEquals("b", FileUtil .relativePathOfFileUnderParent(new File("/a/b"), parent)); } - public void testRelativePathIsBCForABC() { + @Test + public void relativePathIsBCForABC() { File parent = new File("/a"); assertEquals("b/c", FileUtil .relativePathOfFileUnderParent(new File("/a/b/c"), parent)); } - public void testCopyMissingFilesExcludesSvnMetafiles() throws IOException { + @Test + public void copyMissingFilesExcludesSvnMetafiles() throws IOException { TestArea testArea = TestArea.forTest(this); File from = testArea.newDir("from"); testArea.newDir("from/.svn"); @@ -92,7 +105,8 @@ public void testCopyMissingFilesExcludesSvnMetafiles() throws IOException { assertTrue(new File(to, "b/B").exists()); } - public void testCopyRecursivelyIncludesSvnMetafilesIfToldSo() + @Test + public void copyRecursivelyIncludesSvnMetafilesIfToldSo() throws IOException { TestArea testArea = TestArea.forTest(this); File from = testArea.newDir("from"); @@ -112,7 +126,8 @@ public void testCopyRecursivelyIncludesSvnMetafilesIfToldSo() assertTrue(new File(to, "b/B").exists()); } - public void testCopyRecursivelyPreservedXFlag() throws IOException { + @Test + public void copyRecursivelyPreservedXFlag() throws IOException { TestArea testArea = TestArea.forTest(this); File from = testArea.newDir("from"); testArea.hasFile("from/x", "").setExecutable(true); diff --git a/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/IwantCoreServicesImplTest.java b/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/IwantCoreServicesImplTest.java index 366cc2e5..33e098ad 100755 --- a/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/IwantCoreServicesImplTest.java +++ b/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/IwantCoreServicesImplTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.coreservices; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.HashMap; import java.util.Map; @@ -7,10 +11,10 @@ import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class IwantCoreServicesImplTest extends TestCase { +public class IwantCoreServicesImplTest { private TestArea testArea; private Properties sysprops; @@ -18,8 +22,8 @@ public class IwantCoreServicesImplTest extends TestCase { private Iwant iwant; private IwantCoreServicesImpl services; - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void before() throws Exception { iwant = null; testArea = TestArea.forTest(this); sysprops = new Properties(); @@ -54,7 +58,8 @@ private void allWindowsBashesExist() { existingProgramFilesGitBash(); } - public void testWindowsBashExeIsNullOnLinux() { + @Test + public void windowsBashExeIsNullOnLinux() { sysprops.put("os.name", "Linux"); allWindowsBashesExist(); @@ -62,7 +67,8 @@ public void testWindowsBashExeIsNullOnLinux() { assertNull(services.windowsBashExe()); } - public void testWindosBashExeIsNullOnUnknownOs() { + @Test + public void windosBashExeIsNullOnUnknownOs() { sysprops.put("os.name", "SomethingExotic"); allWindowsBashesExist(); @@ -70,21 +76,24 @@ public void testWindosBashExeIsNullOnUnknownOs() { assertNull(services.windowsBashExe()); } - public void testCygwin64ExeIsFoundOnWindows7() { + @Test + public void cygwin64ExeIsFoundOnWindows7() { sysprops.put("os.name", "Windows 7"); File bashExe = existingCygwin64Bash(); assertEquals(bashExe, services.windowsBashExe()); } - public void testCygwinExeIsFoundOnWindows7() { + @Test + public void cygwinExeIsFoundOnWindows7() { sysprops.put("os.name", "Windows 7"); File bashExe = existingCygwinBash(); assertEquals(bashExe, services.windowsBashExe()); } - public void testHomeGitBashExeIsFoundOnWindows7() { + @Test + public void homeGitBashExeIsFoundOnWindows7() { sysprops.put("os.name", "Windows 7"); File bashExe = existingHomeGitBash(); @@ -92,7 +101,8 @@ public void testHomeGitBashExeIsFoundOnWindows7() { assertEquals(bashExe, services.windowsBashExe()); } - public void testProgramFilesGitBashExeIsFoundOnWindows7() { + @Test + public void programFilesGitBashExeIsFoundOnWindows7() { sysprops.put("os.name", "Windows 7"); File bashExe = existingProgramFilesGitBash(); @@ -100,7 +110,8 @@ public void testProgramFilesGitBashExeIsFoundOnWindows7() { assertEquals(bashExe, services.windowsBashExe()); } - public void testGitBashDeducedFromEnvIsPreferredOverExistingBashes() { + @Test + public void gitBashDeducedFromEnvIsPreferredOverExistingBashes() { File customBash = testArea.hasFile("custom/gitbash/bin/bash.exe", "ignored"); File customMingw = testArea.newDir("custom/gitbash/mingw"); @@ -115,7 +126,8 @@ public void testGitBashDeducedFromEnvIsPreferredOverExistingBashes() { assertEquals("/c/a/path", services.toNativeBashFormat("C:/a/path")); } - public void testEnvVariableShellIsIgnoredIfWeCannotDeduceItsNature() { + @Test + public void envVariableShellIsIgnoredIfWeCannotDeduceItsNature() { File customBash = testArea.hasFile("custom/gitbash/bin/bash.exe", "ignored"); sysprops.put("os.name", "Windows 7"); @@ -133,7 +145,8 @@ public void testEnvVariableShellIsIgnoredIfWeCannotDeduceItsNature() { services.toNativeBashFormat("C:/a/path")); } - public void testCygwin64IsPreferredOverCygwinAndGitBash() { + @Test + public void cygwin64IsPreferredOverCygwinAndGitBash() { sysprops.put("os.name", "Windows 7"); File bash64Exe = existingCygwin64Bash(); existingCygwinBash(); @@ -143,14 +156,16 @@ public void testCygwin64IsPreferredOverCygwinAndGitBash() { assertEquals(bash64Exe, services.windowsBashExe()); } - public void testCygwin64ExeIsFoundOnSomeUnknownFlavourOfWindows() { + @Test + public void cygwin64ExeIsFoundOnSomeUnknownFlavourOfWindows() { sysprops.put("os.name", "Windows the last one"); File bashExe = existingCygwin64Bash(); assertEquals(bashExe, services.windowsBashExe()); } - public void testMissingBashIsAnErrorOnWindows7() { + @Test + public void missingBashIsAnErrorOnWindows7() { sysprops.put("os.name", "Windows 7"); try { @@ -162,7 +177,8 @@ public void testMissingBashIsAnErrorOnWindows7() { } } - public void testNativeBashFormatIsTheOriginalOnNonWindows() { + @Test + public void nativeBashFormatIsTheOriginalOnNonWindows() { sysprops.put("os.name", "Anything but Windows"); assertEquals("C:\\this\\is\\fine", @@ -171,7 +187,8 @@ public void testNativeBashFormatIsTheOriginalOnNonWindows() { services.toNativeBashFormat("C:/also/fine")); } - public void testNativeBashFormatIsCygdriveFormatOnWindowsWithCygwin64() { + @Test + public void nativeBashFormatIsCygdriveFormatOnWindowsWithCygwin64() { sysprops.put("os.name", "Windows 7"); existingCygwin64Bash(); @@ -181,7 +198,8 @@ public void testNativeBashFormatIsCygdriveFormatOnWindowsWithCygwin64() { services.toNativeBashFormat("C:/some/path")); } - public void testNativeBashFormatIsCygdriveFormatOnWindowsWithCygwin() { + @Test + public void nativeBashFormatIsCygdriveFormatOnWindowsWithCygwin() { sysprops.put("os.name", "Windows 7"); existingCygwinBash(); @@ -191,7 +209,8 @@ public void testNativeBashFormatIsCygdriveFormatOnWindowsWithCygwin() { services.toNativeBashFormat("C:/some/path")); } - public void testNativeBashFormatIsSlashCFormatOnWindowsWithGitBash() { + @Test + public void nativeBashFormatIsSlashCFormatOnWindowsWithGitBash() { sysprops.put("os.name", "Windows 7"); existingHomeGitBash(); diff --git a/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/StreamUtilTest.java b/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/StreamUtilTest.java index f9dd14ce..57c95ee7 100644 --- a/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/StreamUtilTest.java +++ b/essential/iwant-coreservices/src/test/java/org/fluentjava/iwant/coreservices/StreamUtilTest.java @@ -1,12 +1,15 @@ package org.fluentjava.iwant.coreservices; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.ByteArrayInputStream; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class StreamUtilTest extends TestCase { +public class StreamUtilTest { - public void testEmptyStreamToString() { + @Test + public void emptyStreamToString() { assertEquals("", StreamUtil.toString(new ByteArrayInputStream(new byte[0]))); } diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotClasspathTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotClasspathTest.java index 5234b42c..741d4abc 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotClasspathTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotClasspathTest.java @@ -1,17 +1,21 @@ package org.fluentjava.iwant.eclipsesettings; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class DotClasspathTest extends TestCase { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DotClasspathTest { private StringBuilder out; - @Override - public void setUp() { + @BeforeEach + public void before() { out = new StringBuilder(); } - public void testMinimalWithoutEvenSrc() { + @Test + public void minimalWithoutEvenSrc() { DotClasspath dp = DotClasspath.with().end(); out.append("\n"); out.append("\n"); @@ -23,7 +27,8 @@ public void testMinimalWithoutEvenSrc() { assertEquals(out.toString(), dp.asFileContent()); } - public void testMinimalWithOnlySrc() { + @Test + public void minimalWithOnlySrc() { DotClasspath dp = DotClasspath.with().src("src").end(); out.append("\n"); out.append("\n"); @@ -58,7 +63,8 @@ public void test2SourceDirsAndProjectDepAndLibraryDep() { assertEquals(out.toString(), dp.asFileContent()); } - public void testLibraryDepWithSourceAttachment() { + @Test + public void libraryDepWithSourceAttachment() { DotClasspath dp = DotClasspath.with().src("src") .binDep("a.jar", "a-src.zip").end(); out.append("\n"); @@ -74,7 +80,8 @@ public void testLibraryDepWithSourceAttachment() { assertEquals(out.toString(), dp.asFileContent()); } - public void testKotlinContainer() { + @Test + public void kotlinContainer() { DotClasspath dp = DotClasspath.with().src("src").kotlinContainer() .end(); out.append("\n"); @@ -92,7 +99,8 @@ public void testKotlinContainer() { // code generation - public void testExportedClassesWithSourceAttachment() { + @Test + public void exportedClassesWithSourceAttachment() { DotClasspath dp = DotClasspath.with().src("src") .exportedClasses("a.jar", "a-src.zip").end(); out.append("\n"); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotProjectTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotProjectTest.java index 1aa3e2d8..095268ef 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotProjectTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/DotProjectTest.java @@ -1,17 +1,23 @@ package org.fluentjava.iwant.eclipsesettings; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class DotProjectTest extends TestCase { +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DotProjectTest { private StringBuilder expected; - @Override - public void setUp() { + @BeforeEach + public void before() { expected = new StringBuilder(); } - public void testMinimalProjectA() { + @Test + public void minimalProjectA() { DotProject dp = DotProject.named("a").end(); expected.append("\n"); expected.append("\n"); @@ -35,7 +41,8 @@ public void testMinimalProjectA() { assertEquals(expected.toString(), dp.asFileContent()); } - public void testMinimalProjectB() { + @Test + public void minimalProjectB() { DotProject dp = DotProject.named("b").end(); expected.append("\n"); expected.append("\n"); @@ -59,14 +66,16 @@ public void testMinimalProjectB() { assertEquals(expected.toString(), dp.asFileContent()); } - public void testHasExternalBuilder() { + @Test + public void hasExternalBuilder() { assertTrue(DotProject.named("codegen").hasExternalBuilder(true).end() .hasExternalBuilder()); assertFalse(DotProject.named("no-codegen").hasExternalBuilder(false) .end().hasExternalBuilder()); } - public void testExternalBuilderReferenceInContent() { + @Test + public void externalBuilderReferenceInContent() { DotProject dp = DotProject.named("codegen").hasExternalBuilder(true) .end(); expected.append("\n"); @@ -103,7 +112,8 @@ public void testExternalBuilderReferenceInContent() { assertEquals(expected.toString(), dp.asFileContent()); } - public void testScalaSupport() { + @Test + public void scalaSupport() { DotProject dp = DotProject.named("mixed").hasScalaSupport(true).end(); expected.append("\n"); expected.append("\n"); @@ -129,7 +139,8 @@ public void testScalaSupport() { assertEquals(expected.toString(), dp.asFileContent()); } - public void testKotlinSupport() { + @Test + public void kotlinSupport() { DotProject dp = DotProject.named("kotlin-project") .hasKotlinSupport(true).end(); expected.append("\n"); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseAntScriptTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseAntScriptTest.java index 5ebedfe1..2184e7f1 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseAntScriptTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseAntScriptTest.java @@ -1,10 +1,13 @@ package org.fluentjava.iwant.eclipsesettings; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class EclipseAntScriptTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testGetters() { +public class EclipseAntScriptTest { + + @Test + public void getters() { EclipseAntScript script = new EclipseAntScript("proj1", "../..", "parent1", "classes1", "src1", "as-proj1-developer"); @@ -16,7 +19,8 @@ public void testGetters() { assertEquals("as-proj1-developer", script.asSomeone()); } - public void testFileContent() { + @Test + public void fileContent() { EclipseAntScript script = new EclipseAntScript("proj2", "../..", "parent-dir", "classes2", "src2", "as-proj2-developer"); @@ -75,7 +79,8 @@ public void testFileContent() { assertEquals(expected.toString(), script.asFileContent()); } - public void testFileContentWithDifferentValues() { + @Test + public void fileContentWithDifferentValues() { EclipseAntScript script = new EclipseAntScript("directly-under-wsroot", "..", "", "classes3", "src3", "as-directly-under-wsroot-developer"); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseProjectTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseProjectTest.java index fa4e6c33..7cec9a13 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseProjectTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseProjectTest.java @@ -1,5 +1,10 @@ package org.fluentjava.iwant.eclipsesettings; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.fluentjava.iwant.api.core.Concatenated; import org.fluentjava.iwant.api.core.HelloTarget; import org.fluentjava.iwant.api.javamodules.CodeFormatterPolicy; @@ -14,10 +19,12 @@ import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.apimocks.TargetMock; +import org.junit.jupiter.api.Test; public class EclipseProjectTest extends IwantTestCase { - public void testSimpleSrcModuleDotProject() { + @Test + public void simpleSrcModuleDotProject() { JavaSrcModule module = JavaSrcModule.with().name("simple").end(); EclipseProject project = new EclipseProject(module, ctx); @@ -26,7 +33,8 @@ public void testSimpleSrcModuleDotProject() { assertEquals("simple", dotProject.name()); } - public void testMinimalDotClasspath() { + @Test + public void minimalDotClasspath() { JavaSrcModule module = JavaSrcModule.with().name("simple").end(); EclipseProject project = new EclipseProject(module, ctx); @@ -36,7 +44,8 @@ public void testMinimalDotClasspath() { assertEquals("[]", dotClasspath.deps().toString()); } - public void testDotClasspathWithMainJavaOnly() { + @Test + public void dotClasspathWithMainJavaOnly() { JavaSrcModule module = JavaSrcModule.with().name("simple") .mainJava("src").end(); EclipseProject project = new EclipseProject(module, ctx); @@ -48,7 +57,8 @@ public void testDotClasspathWithMainJavaOnly() { assertEquals("[]", dotClasspath.deps().toString()); } - public void testDotClasspathWithAllFourSrcs() { + @Test + public void dotClasspathWithAllFourSrcs() { JavaSrcModule module = JavaSrcModule.with().name("simple") .mainJava("src").mainResources("res").testJava("test") .testResources("testRes").end(); @@ -64,7 +74,8 @@ public void testDotClasspathWithAllFourSrcs() { assertEquals("[]", dotClasspath.deps().toString()); } - public void testDotClasspathWithMavenLayout() { + @Test + public void dotClasspathWithMavenLayout() { JavaSrcModule module = JavaSrcModule.with().name("simple").mavenLayout() .end(); EclipseProject project = new EclipseProject(module, ctx); @@ -81,7 +92,8 @@ public void testDotClasspathWithMavenLayout() { assertEquals("[]", dotClasspath.deps().toString()); } - public void testDotClasspathWithOneDepToOtherSrcModule() { + @Test + public void dotClasspathWithOneDepToOtherSrcModule() { JavaSrcModule util = JavaSrcModule.with().name("util").mainJava("src") .end(); JavaSrcModule module = JavaSrcModule.with().name("simple") @@ -95,7 +107,8 @@ public void testDotClasspathWithOneDepToOtherSrcModule() { dotClasspath.deps().toString()); } - public void testDotClasspathWithTwoSrcModulesAsMainDep() { + @Test + public void dotClasspathWithTwoSrcModulesAsMainDep() { JavaSrcModule util1 = JavaSrcModule.with().name("util1").mainJava("src") .end(); JavaSrcModule util2 = JavaSrcModule.with().name("util2").mainJava("src") @@ -113,7 +126,8 @@ public void testDotClasspathWithTwoSrcModulesAsMainDep() { dotClasspath.deps().toString()); } - public void testDotClasspathWithMainDepsAndTestDeps() { + @Test + public void dotClasspathWithMainDepsAndTestDeps() { JavaSrcModule mainUtil = JavaSrcModule.with().name("main-util") .mainJava("src").end(); JavaSrcModule testUtil = JavaSrcModule.with().name("test-util") @@ -131,7 +145,8 @@ public void testDotClasspathWithMainDepsAndTestDeps() { dotClasspath.deps().toString()); } - public void testModuleThatIsBothMainDepAndSrcDepIsOnlyOnceInDotClasspath() { + @Test + public void moduleThatIsBothMainDepAndSrcDepIsOnlyOnceInDotClasspath() { JavaSrcModule mainUtil = JavaSrcModule.with().name("main-util") .mainJava("src").end(); JavaSrcModule testUtil = JavaSrcModule.with().name("test-util") @@ -150,7 +165,8 @@ public void testModuleThatIsBothMainDepAndSrcDepIsOnlyOnceInDotClasspath() { dotClasspath.deps().toString()); } - public void testDotClasspathWithOneDepToBinModuleProvidedBySrcModule() { + @Test + public void dotClasspathWithOneDepToBinModuleProvidedBySrcModule() { JavaSrcModule libs = JavaSrcModule.with().name("libs").end(); JavaModule util = JavaBinModule.named("util.jar").inside(libs).end(); JavaSrcModule module = JavaSrcModule.with().name("simple") @@ -165,7 +181,8 @@ public void testDotClasspathWithOneDepToBinModuleProvidedBySrcModule() { dotClasspath.deps().toString()); } - public void testDotClasspathWithOneDepToBinModuleWithSourcesProvidedBySrcModule() { + @Test + public void dotClasspathWithOneDepToBinModuleWithSourcesProvidedBySrcModule() { JavaSrcModule libs = JavaSrcModule.with().name("libs").end(); JavaModule util = JavaBinModule.named("util.jar").source("util-src.zip") .inside(libs).end(); @@ -181,7 +198,8 @@ public void testDotClasspathWithOneDepToBinModuleWithSourcesProvidedBySrcModule( dotClasspath.deps().toString()); } - public void testDotClasspathIncludesRuntimeDepOfTestRuntimeBinaryDep() { + @Test + public void dotClasspathIncludesRuntimeDepOfTestRuntimeBinaryDep() { JavaBinModule depOfBinDep = JavaBinModule .providing(new TargetMock("depOfBinDep.jar")).end(); JavaBinModule binDep = JavaBinModule @@ -203,7 +221,8 @@ public void testDotClasspathIncludesRuntimeDepOfTestRuntimeBinaryDep() { // code generation - public void testDotProjectWithReferenceToCodeGenerator() { + @Test + public void dotProjectWithReferenceToCodeGenerator() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") @@ -219,7 +238,8 @@ public void testDotProjectWithReferenceToCodeGenerator() { assertTrue(dotProject.hasExternalBuilder()); } - public void testDotClasspathWithCodeGenerator() { + @Test + public void dotClasspathWithCodeGenerator() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") @@ -238,14 +258,16 @@ public void testDotClasspathWithCodeGenerator() { dotClasspath.deps().toString()); } - public void testProjectExternalBuilderLaunchIsNullWithoutCodeGeneration() { + @Test + public void projectExternalBuilderLaunchIsNullWithoutCodeGeneration() { JavaSrcModule module = JavaSrcModule.with().name("simple").end(); EclipseProject project = new EclipseProject(module, ctx); assertNull(project.externalBuilderLaunch()); } - public void testProjectExternalBuilderLaunchHasCorrectContent() { + @Test + public void projectExternalBuilderLaunchHasCorrectContent() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") @@ -263,7 +285,8 @@ public void testProjectExternalBuilderLaunchHasCorrectContent() { assertEquals("[]", launch.relativeInputPaths().toString()); } - public void testProjectExternalBuilderLaunchUsesGeneratorSourceAsRelativeInputPaths() { + @Test + public void projectExternalBuilderLaunchUsesGeneratorSourceAsRelativeInputPaths() { Source srcForGenerator = Source .underWsroot("gen-parent/gen-src-project/gen-src"); Target generatedSrc = Concatenated.named("generated-src") @@ -285,7 +308,8 @@ public void testProjectExternalBuilderLaunchUsesGeneratorSourceAsRelativeInputPa launch.relativeInputPaths().toString()); } - public void testProjectExternalBuilderLaunchUsesExplicitlyGivenRelativeInputPaths() { + @Test + public void projectExternalBuilderLaunchUsesExplicitlyGivenRelativeInputPaths() { Source generatorMainJava = Source .underWsroot("gen-parent/generator/src/main/java"); Source generatorMainResources = Source @@ -318,14 +342,16 @@ public void testProjectExternalBuilderLaunchUsesExplicitlyGivenRelativeInputPath launch.relativeInputPaths().toString()); } - public void testEclipseAntScriptIsNullWithoutCodeGeneration() { + @Test + public void eclipseAntScriptIsNullWithoutCodeGeneration() { JavaSrcModule module = JavaSrcModule.with().name("simple").end(); EclipseProject project = new EclipseProject(module, ctx); assertNull(project.eclipseAntScript("as-ws-developer")); } - public void testEclipseAntScriptHasCorrectContent() { + @Test + public void eclipseAntScriptHasCorrectContent() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") @@ -347,7 +373,8 @@ public void testEclipseAntScriptHasCorrectContent() { assertEquals("as-ws-developer", antScript.asSomeone()); } - public void testEclipseAntScriptHasCorrectBasedirAndParentDirWhenModuleIsNotDirectlyUnderWsRoot() { + @Test + public void eclipseAntScriptHasCorrectBasedirAndParentDirWhenModuleIsNotDirectlyUnderWsRoot() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") @@ -368,7 +395,8 @@ public void testEclipseAntScriptHasCorrectBasedirAndParentDirWhenModuleIsNotDire // compiler warnings - public void testDefaultCompilerSettings() { + @Test + public void defaultCompilerSettings() { JavaSrcModule module = JavaSrcModule.with().name("simple") .mainJava("src").end(); EclipseProject project = new EclipseProject(module, ctx); @@ -383,7 +411,8 @@ public void testDefaultCompilerSettings() { CodeStyle.NON_EXTERNALIZED_STRING_LITERAL)); } - public void testOverriddenCompilerSettings() { + @Test + public void overriddenCompilerSettings() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); policy.ignore(CodeStyle.DEAD_CODE); policy.warn(CodeStyle.NON_EXTERNALIZED_STRING_LITERAL); @@ -404,7 +433,8 @@ public void testOverriddenCompilerSettings() { // formatter - public void testDefaultFormatterSettings() { + @Test + public void defaultFormatterSettings() { JavaSrcModule module = JavaSrcModule.with().name("simple") .mainJava("src").end(); EclipseProject project = new EclipseProject(module, ctx); @@ -415,7 +445,8 @@ public void testDefaultFormatterSettings() { assertEquals(Integer.valueOf(0), policy.alignmentForEnumConstants); } - public void testOverriddenFormatterSettings() { + @Test + public void overriddenFormatterSettings() { CodeFormatterPolicy policy = new CodeFormatterPolicy(); policy.alignmentForEnumConstants = 48; @@ -432,7 +463,8 @@ public void testOverriddenFormatterSettings() { // formatter reference - public void testProjectGivesUiPrefs() { + @Test + public void projectGivesUiPrefs() { JavaSrcModule module = JavaSrcModule.with().name("simple") .mainJava("src").end(); EclipseProject project = new EclipseProject(module, ctx); @@ -442,7 +474,8 @@ public void testProjectGivesUiPrefs() { assertNotNull(uiPrefs); } - public void testDotProjectHasScalaSupportWhenEnabled() { + @Test + public void dotProjectHasScalaSupportWhenEnabled() { JavaSrcModule module = JavaSrcModule.with().name("mixed") .scalaVersion(ScalaVersion._2_11_7()).mainJava("src/main/java") .mainScala("src/main/scala").end(); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsTest.java index a9b191cc..e14e2223 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.eclipsesettings; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.util.Arrays; @@ -12,6 +16,7 @@ import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.apimocks.TargetMock; +import org.junit.jupiter.api.Test; public class EclipseSettingsTest extends IwantTestCase { @@ -43,7 +48,8 @@ private void assertFileContains(String filename, String fragment) { } } - public void testModulesCanBeAddedInManyPartsBothAsVarargsAndAsCollections() { + @Test + public void modulesCanBeAddedInManyPartsBothAsVarargsAndAsCollections() { JavaSrcModule m1 = JavaSrcModule.with().name("m1").end(); JavaSrcModule m2 = JavaSrcModule.with().name("m2").end(); JavaSrcModule m3 = JavaSrcModule.with().name("m3").end(); @@ -55,7 +61,8 @@ public void testModulesCanBeAddedInManyPartsBothAsVarargsAndAsCollections() { assertEquals("[m1, m2, m3, m4, m5]", es.modules().toString()); } - public void testModulesAreCollectedToSortedSetSoMultipleAddsAndWrongOrderDontAffectIt() { + @Test + public void modulesAreCollectedToSortedSetSoMultipleAddsAndWrongOrderDontAffectIt() { JavaSrcModule m1 = JavaSrcModule.with().name("m1").end(); JavaSrcModule m2 = JavaSrcModule.with().name("m2").end(); JavaSrcModule m3 = JavaSrcModule.with().name("m3").end(); @@ -67,7 +74,8 @@ public void testModulesAreCollectedToSortedSetSoMultipleAddsAndWrongOrderDontAff assertEquals("[m1, m2, m3, m4, m5]", es.modules().toString()); } - public void testMutationUsingWsdefdefAndWsdefAndAnotherModuleUsedByWsdef() { + @Test + public void mutationUsingWsdefdefAndWsdefAndAnotherModuleUsedByWsdef() { JavaModule iwantClasses = JavaBinModule .providing(TargetMock.ingredientless("iwant-classes"), TargetMock.ingredientless("combined-iwant-sources")) @@ -115,7 +123,8 @@ public void testMutationUsingWsdefdefAndWsdefAndAnotherModuleUsedByWsdef() { + " kind=\"src\" path=\"/test-wsdef-tools\"/>"); } - public void testNoSourcesMeansNoSources() { + @Test + public void noSourcesMeansNoSources() { JavaModule srcless = JavaSrcModule.with().name("any") .locationUnderWsRoot("any").end(); wsRootHasDirectory("any"); @@ -129,7 +138,8 @@ public void testNoSourcesMeansNoSources() { .contains(""); } - public void testSetOfAllMainAndTestDependencyBinaryClassesAndSourcesGetsRefreshedSoEclipseWontComplainAboutMissingRefs() { + @Test + public void setOfAllMainAndTestDependencyBinaryClassesAndSourcesGetsRefreshedSoEclipseWontComplainAboutMissingRefs() { // 2 modules depend on this, but it's mentioned only once in refs: JavaModule binWithoutSources = JavaBinModule .providing(TargetMock.ingredientless("binWithoutSources")) @@ -205,7 +216,8 @@ public void testSetOfAllMainAndTestDependencyBinaryClassesAndSourcesGetsRefreshe seCtx.targetsWantedAsPath().get(0).contentDescriptor()); } - public void testClasspathIsGeneratedButWithWarningIfRefreshOfDepsFails() { + @Test + public void classpathIsGeneratedButWithWarningIfRefreshOfDepsFails() { JavaModule util = JavaBinModule .providing(TargetMock.ingredientless("util"), TargetMock.ingredientless("util-src")) @@ -237,7 +249,8 @@ public void testClasspathIsGeneratedButWithWarningIfRefreshOfDepsFails() { + "", seCtx.err().toString()); } - public void testNameOfBinDepRefreshTarget() { + @Test + public void nameOfBinDepRefreshTarget() { JavaModule util = JavaBinModule .providing(TargetMock.ingredientless("util"), TargetMock.ingredientless("util-src")) @@ -257,7 +270,8 @@ public void testNameOfBinDepRefreshTarget() { assertEquals("es2.bin-refs", seCtx.targetsWantedAsPath().get(1).name()); } - public void testDefaultJavaComplianceIs11() { + @Test + public void defaultJavaComplianceIs11() { JavaModule mod = JavaSrcModule.with().name("mod") .locationUnderWsRoot("mod").mainJava("src").end(); @@ -271,7 +285,8 @@ public void testDefaultJavaComplianceIs11() { assertFileContains(corePrefs, "compiler.source=11"); } - public void testJavaComplianceCanBeDefinedAs17() { + @Test + public void javaComplianceCanBeDefinedAs17() { JavaModule mod = JavaSrcModule.with().name("mod") .javaCompliance(JavaCompliance.JAVA_1_7) .locationUnderWsRoot("mod").mainJava("src").end(); @@ -286,7 +301,8 @@ public void testJavaComplianceCanBeDefinedAs17() { assertFileContains(corePrefs, "compiler.source=1.7"); } - public void testJavaAndResourceDirsAreCreated() { + @Test + public void javaAndResourceDirsAreCreated() { JavaModule modWithAll = JavaSrcModule.with().name("mod-with-all") .locationUnderWsRoot("mod-with-all").mavenLayout().end(); JavaModule modWithNone = JavaSrcModule.with().name("mod-with-none") @@ -314,7 +330,8 @@ public void testJavaAndResourceDirsAreCreated() { new File(wsRoot, "mod-with-all/src/test/resources").exists()); } - public void testTestRuntimeDepenencyGoesToDotClasspath() { + @Test + public void testRuntimeDepenencyGoesToDotClasspath() { JavaModule rtBinTool = JavaBinModule .providing(TargetMock.ingredientless("rtBinTool"), TargetMock.ingredientless("rtBinTool-src")) @@ -340,7 +357,8 @@ public void testTestRuntimeDepenencyGoesToDotClasspath() { ""); } - public void testDotProjectHasScalaSupportIfEnabledByTheModule() { + @Test + public void dotProjectHasScalaSupportIfEnabledByTheModule() { JavaSrcModule mod = JavaSrcModule.with().name("mixed") .scalaVersion(ScalaVersion._2_11_7()).mainJava("src/main/java") .mainScala("src/main/scala").end(); @@ -356,7 +374,8 @@ public void testDotProjectHasScalaSupportIfEnabledByTheModule() { "org.scala-ide.sdt.core.scalanature"); } - public void testDotProjectHasKotlinSupportIfEnabledByTheModule() { + @Test + public void dotProjectHasKotlinSupportIfEnabledByTheModule() { JavaSrcModule mod = JavaSrcModule.with().name("mod") .kotlinVersion(KotlinVersion._1_3_60()) .mainJava("src/main/java").end(); @@ -372,7 +391,8 @@ public void testDotProjectHasKotlinSupportIfEnabledByTheModule() { "org.jetbrains.kotlin.core.kotlinNature"); } - public void testDotClasspathHasKotlinContainerIfEnabledByTheModule() { + @Test + public void dotClasspathHasKotlinContainerIfEnabledByTheModule() { JavaSrcModule mod = JavaSrcModule.with().name("mod") .kotlinVersion(KotlinVersion._1_3_60()) .mainJava("src/main/java").end(); @@ -386,7 +406,8 @@ public void testDotClasspathHasKotlinContainerIfEnabledByTheModule() { ""); } - public void testKotlinPreferencesExistIfAndOnlyIfModuleHasKotlinSupport() { + @Test + public void kotlinPreferencesExistIfAndOnlyIfModuleHasKotlinSupport() { JavaModule withKotlin = JavaSrcModule.with().name("with-kotlin") .kotlinVersion(KotlinVersion._1_3_60()).mainJava("src").end(); JavaModule withoutKotlin = JavaSrcModule.with().name("without-kotlin") @@ -405,7 +426,8 @@ public void testKotlinPreferencesExistIfAndOnlyIfModuleHasKotlinSupport() { .exists()); } - public void testEncodingIsUtf8() { + @Test + public void encodingIsUtf8() { JavaModule mod = JavaSrcModule.with().name("mod") .locationUnderWsRoot("mod").mainJava("src").end(); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsWriterTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsWriterTest.java index a49ad817..1a507027 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsWriterTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/EclipseSettingsWriterTest.java @@ -1,11 +1,14 @@ package org.fluentjava.iwant.eclipsesettings; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.fluentjava.iwant.api.core.Concatenated; import org.fluentjava.iwant.api.core.HelloTarget; import org.fluentjava.iwant.api.javamodules.JavaModule; import org.fluentjava.iwant.api.javamodules.JavaSrcModule; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class EclipseSettingsWriterTest extends IwantTestCase { @@ -14,7 +17,8 @@ protected void moreSetUp() { seCtx.wsInfo().hasRelativeAsSomeone("as-writer-test"); } - public void testMinimal() { + @Test + public void minimal() { JavaModule module = JavaSrcModule.with().name("minimal").end(); EclipseSettingsWriter.with().modules(module).context(seCtx).end() @@ -35,7 +39,8 @@ public void testMinimal() { .contains("=UTF-8")); } - public void testMinimalWithLocationThatDiffersFromName() { + @Test + public void minimalWithLocationThatDiffersFromName() { JavaModule module = JavaSrcModule.with().name("module-name") .locationUnderWsRoot("parent/dir-name").end(); @@ -58,7 +63,8 @@ public void testMinimalWithLocationThatDiffersFromName() { .contains("=UTF-8")); } - public void testCodeGeneration() { + @Test + public void codeGeneration() { Target generatedSrc = new HelloTarget("generated-src", "in reality this would be a src directory generated from src-for-generator"); Target generatedClasses = Concatenated.named("generated-classes") diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseCoreResourcesPrefsTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseCoreResourcesPrefsTest.java index d583a58c..2c74b525 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseCoreResourcesPrefsTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseCoreResourcesPrefsTest.java @@ -1,13 +1,16 @@ package org.fluentjava.iwant.eclipsesettings; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class OrgEclipseCoreResourcesPrefsTest extends TestCase { +import org.junit.jupiter.api.Test; + +public class OrgEclipseCoreResourcesPrefsTest { /** * No need to test more now that it's 100% constant */ - public void testSomePiecesOfOutput() { + @Test + public void somePiecesOfOutput() { OrgEclipseCoreResourcesPrefs p = OrgEclipseCoreResourcesPrefs .withDefaultValues(); String actual = p.asFileContent(); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtCorePrefsTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtCorePrefsTest.java index e836edbb..52289b3a 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtCorePrefsTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtCorePrefsTest.java @@ -1,17 +1,21 @@ package org.fluentjava.iwant.eclipsesettings; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.fluentjava.iwant.api.javamodules.CodeFormatterPolicy; import org.fluentjava.iwant.api.javamodules.CodeFormatterPolicy.TabulationCharValue; import org.fluentjava.iwant.api.javamodules.CodeStyle; import org.fluentjava.iwant.api.javamodules.CodeStylePolicy; import org.fluentjava.iwant.api.javamodules.CodeStylePolicy.CodeStylePolicySpex; import org.fluentjava.iwant.api.javamodules.JavaCompliance; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class OrgEclipseJdtCorePrefsTest extends TestCase { +public class OrgEclipseJdtCorePrefsTest { - public void testDefaultCodeStyle() { + @Test + public void defaultCodeStyle() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); CodeFormatterPolicy formatter = new CodeFormatterPolicy(); @@ -32,7 +36,8 @@ public void testDefaultCodeStyle() { CodeStyle.NON_EXTERNALIZED_STRING_LITERAL)); } - public void testOverriddenCodeStyle() { + @Test + public void overriddenCodeStyle() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); policy.ignore(CodeStyle.DEAD_CODE); policy.warn(CodeStyle.NON_EXTERNALIZED_STRING_LITERAL); @@ -55,7 +60,8 @@ public void testOverriddenCodeStyle() { CodeStyle.NON_EXTERNALIZED_STRING_LITERAL)); } - public void testAStyleThatIsOnlyDisabledOrEnabled() { + @Test + public void aStyleThatIsOnlyDisabledOrEnabled() { CodeStyle style = CodeStyle.MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION; CodeFormatterPolicy formatter = new CodeFormatterPolicy(); assertEquals("org.eclipse.jdt.core.compiler.problem." @@ -78,7 +84,8 @@ public void testAStyleThatIsOnlyDisabledOrEnabled() { .asPropertyLine(style)); } - public void testDefaultsAsFileContent() { + @Test + public void defaultsAsFileContent() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); CodeFormatterPolicy formatter = new CodeFormatterPolicy(); @@ -798,7 +805,8 @@ public void testDefaultsAsFileContent() { assertEquals(b.toString(), prefs.asFileContent()); } - public void testOverriddenCodeStylesAffectFileContent() { + @Test + public void overriddenCodeStylesAffectFileContent() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); policy.ignore(CodeStyle.DEAD_CODE); policy.warn(CodeStyle.NON_EXTERNALIZED_STRING_LITERAL); @@ -818,7 +826,8 @@ public void testOverriddenCodeStylesAffectFileContent() { } } - public void testOverriddenCodeFormatterAffectsFileContent() { + @Test + public void overriddenCodeFormatterAffectsFileContent() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); CodeFormatterPolicy formatter = new CodeFormatterPolicy(); formatter.alignmentForEnumConstants = 48; @@ -843,7 +852,8 @@ public void testOverriddenCodeFormatterAffectsFileContent() { assertTrue(fileContent.contains(lineSplitKey + "=120\n")); } - public void testJavaCompliance17() { + @Test + public void javaCompliance17() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); CodeFormatterPolicy formatter = new CodeFormatterPolicy(); @@ -867,7 +877,8 @@ public void testJavaCompliance17() { content.contains("org.eclipse.jdt.core.compiler.source=1.7\n")); } - public void testKotlinSupport() { + @Test + public void kotlinSupport() { CodeStylePolicySpex policy = CodeStylePolicy.defaultsExcept(); CodeFormatterPolicy formatter = new CodeFormatterPolicy(); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtUiPrefsTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtUiPrefsTest.java index a631f359..0f280169 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtUiPrefsTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgEclipseJdtUiPrefsTest.java @@ -1,13 +1,16 @@ package org.fluentjava.iwant.eclipsesettings; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class OrgEclipseJdtUiPrefsTest extends TestCase { +import org.junit.jupiter.api.Test; + +public class OrgEclipseJdtUiPrefsTest { /** * No need to test more now that it's 100% constant */ - public void testSomePiecesOfOutput() { + @Test + public void somePiecesOfOutput() { OrgEclipseJdtUiPrefs p = OrgEclipseJdtUiPrefs.withDefaultValues(); String actual = p.asFileContent(); assertTrue(actual.contains("eclipse.preferences.version=1\n")); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgJetbrainsKotlinCorePrefsTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgJetbrainsKotlinCorePrefsTest.java index 23199429..a67d00b0 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgJetbrainsKotlinCorePrefsTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/OrgJetbrainsKotlinCorePrefsTest.java @@ -1,13 +1,16 @@ package org.fluentjava.iwant.eclipsesettings; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class OrgJetbrainsKotlinCorePrefsTest extends TestCase { +import org.junit.jupiter.api.Test; + +public class OrgJetbrainsKotlinCorePrefsTest { /** * No need to test more now that it's 100% constant */ - public void testSomePiecesOfOutput() { + @Test + public void somePiecesOfOutput() { OrgJetbrainsKotlinCorePrefs p = OrgJetbrainsKotlinCorePrefs .withDefaultValues(); String actual = p.asFileContent(); diff --git a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/ProjectExternalBuilderLaunchTest.java b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/ProjectExternalBuilderLaunchTest.java index 6c93912e..4142b78d 100644 --- a/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/ProjectExternalBuilderLaunchTest.java +++ b/essential/iwant-eclipse-settings/src/test/java/org/fluentjava/iwant/eclipsesettings/ProjectExternalBuilderLaunchTest.java @@ -1,5 +1,7 @@ package org.fluentjava.iwant.eclipsesettings; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.Arrays; import org.fluentjava.iwant.api.core.Concatenated; @@ -7,12 +9,12 @@ import org.fluentjava.iwant.api.model.Path; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class ProjectExternalBuilderLaunchTest extends TestCase { +public class ProjectExternalBuilderLaunchTest { - public void testGettersOfMinimal() { + @Test + public void gettersOfMinimal() { Target generatedJava = new HelloTarget("genSrc", ""); ProjectExternalBuilderLaunch launch = new ProjectExternalBuilderLaunch( "project-name", generatedJava, Arrays. asList(), @@ -23,7 +25,8 @@ public void testGettersOfMinimal() { assertEquals("generator-out", launch.relativeOutputDirectory()); } - public void testSourceIngredientsOfGeneratedJavaAreUsedAsGeneratorInputs() { + @Test + public void sourceIngredientsOfGeneratedJavaAreUsedAsGeneratorInputs() { Path ingr1ForGenerator = new HelloTarget("target-ingr1", ""); Path ingr2ForGenerator = Source.underWsroot("src-ingr1"); Path ingr3ForGenerator = new HelloTarget("target-ingr2", ""); @@ -42,7 +45,8 @@ public void testSourceIngredientsOfGeneratedJavaAreUsedAsGeneratorInputs() { launch.relativeInputPaths().toString()); } - public void testSourceIngredientsOfGeneratedJavaAreUsedAsGeneratorInputsTogetherWithExplicitlyGivenInputs() { + @Test + public void sourceIngredientsOfGeneratedJavaAreUsedAsGeneratorInputsTogetherWithExplicitlyGivenInputs() { Source genSrc1 = Source.underWsroot("explicit-gen-src1"); Source genSrc2 = Source.underWsroot("explicit-gen-src2"); @@ -69,7 +73,8 @@ public void testSourceIngredientsOfGeneratedJavaAreUsedAsGeneratorInputsTogether * TODO this hasn't been tested in real life, and it most probably doesn't * even make sense so maybe we should require ingredients. */ - public void testFileContentOfLaunchWithNoSrcIngredients() { + @Test + public void fileContentOfLaunchWithNoSrcIngredients() { Concatenated generatedJava = Concatenated.named("genSrc") .string("no ingredients").end(); ProjectExternalBuilderLaunch launch = new ProjectExternalBuilderLaunch( @@ -116,7 +121,8 @@ public void testFileContentOfLaunchWithNoSrcIngredients() { assertEquals(expected.toString(), launch.asFileContent()); } - public void testFileContentOfLaunchWithManySrcIngredients() { + @Test + public void fileContentOfLaunchWithManySrcIngredients() { Concatenated generatedJava = Concatenated.named("genSrc") .contentOf(Source.underWsroot("module-a/src-for-generator")) .contentOf(Source.underWsroot("module-b/src-for-generator")) diff --git a/essential/iwant-embedded/src/test/java/org/fluentjava/iwant/embedded/AsEmbeddedIwantUserTest.java b/essential/iwant-embedded/src/test/java/org/fluentjava/iwant/embedded/AsEmbeddedIwantUserTest.java index f42156bb..48f74165 100644 --- a/essential/iwant-embedded/src/test/java/org/fluentjava/iwant/embedded/AsEmbeddedIwantUserTest.java +++ b/essential/iwant-embedded/src/test/java/org/fluentjava/iwant/embedded/AsEmbeddedIwantUserTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.embedded; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.concurrent.atomic.AtomicReference; @@ -11,17 +14,17 @@ import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.entry3.UserPrefs; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class AsEmbeddedIwantUserTest extends TestCase { +public class AsEmbeddedIwantUserTest { private TestArea testArea; private File cacheDir; private File wsRoot; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); wsRoot = testArea.newDir("wsRoot"); cacheDir = testArea.newDir("cached"); @@ -31,7 +34,8 @@ private static void assertFile(File expected, File actual) { assertEquals(expected.getAbsolutePath(), actual.getAbsolutePath()); } - public void testHelloAsPath() { + @Test + public void helloAsPath() { File cached = AsEmbeddedIwantUser.with().workspaceAt(wsRoot) .cacheAt(cacheDir).iwant() .target(new HelloTarget("hello", "hello message")).asPath(); @@ -40,7 +44,8 @@ public void testHelloAsPath() { assertEquals("hello message", testArea.contentOf(cached)); } - public void testCustomUserPrefs() { + @Test + public void customUserPrefs() { class ThreadDetector extends TargetBase { AtomicReference threadName = new AtomicReference<>(); diff --git a/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/FileFilterTest.java b/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/FileFilterTest.java index 3454c20a..096917ea 100644 --- a/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/FileFilterTest.java +++ b/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/FileFilterTest.java @@ -1,19 +1,22 @@ package org.fluentjava.iwant.entry2; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.util.Arrays; import java.util.Collection; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class FileFilterTest extends TestCase { +public class FileFilterTest { private TestArea testArea; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); } @@ -25,7 +28,8 @@ private static void assertResult(Collection actual, } } - public void testFilesRecursivelyUnderPlainFileIsJustFileItsef() { + @Test + public void filesRecursivelyUnderPlainFileIsJustFileItsef() { File plain = testArea.hasFile("file", "whatever"); Collection result = Iwant2 @@ -34,7 +38,8 @@ public void testFilesRecursivelyUnderPlainFileIsJustFileItsef() { assertResult(result, plain); } - public void testFilesRecursivelyUnderDir() { + @Test + public void filesRecursivelyUnderDir() { File classes = testArea.newDir("classes"); File pack1class1 = testArea.hasFile("classes/example/pack1/C1.class", "whatever"); @@ -49,7 +54,8 @@ public void testFilesRecursivelyUnderDir() { assertResult(result, pack1class1, pack1class2, pack2class); } - public void testFilesByName() { + @Test + public void filesByName() { File java = testArea.hasFile("A.java", "whatever"); File nonJava = testArea.hasFile("B.nonjava", "whatever"); diff --git a/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/Iwant2Test.java b/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/Iwant2Test.java index ceeb0221..d9791611 100644 --- a/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/Iwant2Test.java +++ b/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/Iwant2Test.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.entry2; +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.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; @@ -11,10 +15,11 @@ import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.iwantwsrootfinder.IwantWsRootFinder; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class Iwant2Test extends TestCase { +public class Iwant2Test { private static final String LINE_SEPARATOR_KEY = "line.separator"; @@ -45,8 +50,8 @@ public class Iwant2Test extends TestCase { /** * TODO a reusable main-method testing tools project */ - @Override - public void setUp() { + @BeforeEach + public void before() { assertRealIwant3IsNotInClasspath(); origSecman = System.getSecurityManager(); System.setSecurityManager(new ExitCatcher()); @@ -121,8 +126,8 @@ public void checkExit(int status) { } - @Override - public void tearDown() { + @AfterEach + public void after() { System.setSecurityManager(origSecman); System.setIn(originalIn); System.setOut(originalOut); @@ -140,7 +145,8 @@ private String err() { return err.toString(); } - public void testIwant2CompilesIwantAndCallsIwant3() throws Exception { + @Test + public void iwant2CompilesIwantAndCallsIwant3() throws Exception { File iwantEssential = IwantWsRootFinder.mockEssential(); network.cachesAt( new ClassesFromUnmodifiableIwantEssential(iwantEssential), @@ -154,7 +160,8 @@ public void testIwant2CompilesIwantAndCallsIwant3() throws Exception { + iwantEssential + ", args, to be, passed]\n", out()); } - public void testIwant2CallsIwant3UsingCorrectClasspath() throws Exception { + @Test + public void iwant2CallsIwant3UsingCorrectClasspath() throws Exception { File iwantEssential = IwantWsRootFinder.mockEssential(); network.cachesAt( new ClassesFromUnmodifiableIwantEssential(iwantEssential), @@ -178,7 +185,8 @@ public void testIwant2CallsIwant3UsingCorrectClasspath() throws Exception { "MockedAsEmbeddedIwantUser"); } - public void testIwant2CompilesIwantWithDebugInformation() throws Exception { + @Test + public void iwant2CompilesIwantWithDebugInformation() throws Exception { File iwantEssential = IwantWsRootFinder.mockEssential(); network.cachesAt( new ClassesFromUnmodifiableIwantEssential(iwantEssential), @@ -197,7 +205,8 @@ public void testIwant2CompilesIwantWithDebugInformation() throws Exception { assertTrue(contentOfClass.contains("localVariable")); } - public void testFindingJavaFilesUnderSrcDirThatContainsNonJavaAndSvnMetadata() { + @Test + public void findingJavaFilesUnderSrcDirThatContainsNonJavaAndSvnMetadata() { File src = testArea.newDir("src"); Iwant.mkdirs(new File(src, ".svn")); File aJava = Iwant.newTextFile(new File(src, "A.java"), ""); @@ -211,8 +220,8 @@ public void testFindingJavaFilesUnderSrcDirThatContainsNonJavaAndSvnMetadata() { Iwant2.javaFilesRecursivelyUnder(src).toString()); } - public void testIwant2CopiesApiBashResourcesToIwantClasses() - throws Exception { + @Test + public void iwant2CopiesApiBashResourcesToIwantClasses() throws Exception { File iwantEssential = IwantWsRootFinder.mockEssential(); network.cachesAt( new ClassesFromUnmodifiableIwantEssential(iwantEssential), diff --git a/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/TimestampHandlerTest.java b/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/TimestampHandlerTest.java index 2e29d33e..5e9c704e 100644 --- a/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/TimestampHandlerTest.java +++ b/essential/iwant-entry2/src/test/java/org/fluentjava/iwant/entry2/TimestampHandlerTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.entry2; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.util.Arrays; import java.util.SortedSet; @@ -7,15 +11,15 @@ import org.fluentjava.iwant.entry2.Iwant2.TimestampHandler; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class TimestampHandlerTest extends TestCase { +public class TimestampHandlerTest { private TestArea testArea; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); } @@ -35,7 +39,8 @@ private File fileHasContentAndTimestamp(String path, String content, // refresh is needed - public void testRefreshWhenCachedTargetWithNoSourcesIsMissing() { + @Test + public void refreshWhenCachedTargetWithNoSourcesIsMissing() { SortedSet sources = new TreeSet<>(); File cachedTarget = fileIsMissing("cachedTarget"); File sourceDescriptor = fileHasContentAndTimestamp("srcDescr", "", 1); @@ -50,7 +55,8 @@ public void testRefreshWhenCachedTargetWithNoSourcesIsMissing() { * Descriptor needs to be deleted anyway so let the handler do it instead of * its caller. */ - public void testExistingSourceDescriptorIsDeletedIfFileNeedsRefresh() { + @Test + public void existingSourceDescriptorIsDeletedIfFileNeedsRefresh() { SortedSet sources = new TreeSet<>(); File cachedTarget = fileIsMissing("cachedTarget"); File sourceDescriptor = fileHasContentAndTimestamp("srcDescr", "", 1); @@ -63,7 +69,8 @@ public void testExistingSourceDescriptorIsDeletedIfFileNeedsRefresh() { assertFalse(sourceDescriptor.exists()); } - public void testFileNeedsRefreshWhenSrcDescriptorOfNoSourcesIsMissing() { + @Test + public void fileNeedsRefreshWhenSrcDescriptorOfNoSourcesIsMissing() { SortedSet sources = new TreeSet<>(); File cachedTarget = fileHasContentAndTimestamp("cachedTarget", "cached content", 1); @@ -75,7 +82,8 @@ public void testFileNeedsRefreshWhenSrcDescriptorOfNoSourcesIsMissing() { assertTrue(timestampHandler.needsRefresh()); } - public void testFileNeedsRefreshWhenSrcDescriptorContentDiffersFromCurrentSources() { + @Test + public void fileNeedsRefreshWhenSrcDescriptorContentDiffersFromCurrentSources() { File src1 = fileHasContentAndTimestamp("src1", "whatever", 1); File src2 = fileHasContentAndTimestamp("src2", "whatever", 1); SortedSet sources = new TreeSet<>(Arrays.asList(src1, src2)); @@ -90,7 +98,8 @@ public void testFileNeedsRefreshWhenSrcDescriptorContentDiffersFromCurrentSource assertTrue(timestampHandler.needsRefresh()); } - public void testFileNeedsRefreshWhenOneSourceFileIsNewerThanSourceDescriptor() { + @Test + public void fileNeedsRefreshWhenOneSourceFileIsNewerThanSourceDescriptor() { File src1 = fileHasContentAndTimestamp("src1", "whatever", 11); File src2 = fileHasContentAndTimestamp("src2", "whatever", 1); SortedSet sources = new TreeSet<>(Arrays.asList(src1, src2)); @@ -107,7 +116,8 @@ public void testFileNeedsRefreshWhenOneSourceFileIsNewerThanSourceDescriptor() { // refresh is not needed - public void testExistingCachedFileThatDoesNotNeedRefresh() { + @Test + public void existingCachedFileThatDoesNotNeedRefresh() { File src1 = fileHasContentAndTimestamp("src1", "whatever", 1); File src2 = fileHasContentAndTimestamp("src2", "whatever", 1); SortedSet sources = new TreeSet<>(Arrays.asList(src1, src2)); @@ -125,7 +135,8 @@ public void testExistingCachedFileThatDoesNotNeedRefresh() { /** * Testrun does not produce any cacheable file so it uses null for it. */ - public void testNullCachedFileThatDoesNotNeedRefresh() { + @Test + public void nullCachedFileThatDoesNotNeedRefresh() { File src1 = fileHasContentAndTimestamp("src1", "whatever", 1); File src2 = fileHasContentAndTimestamp("src2", "whatever", 1); SortedSet sources = new TreeSet<>(Arrays.asList(src1, src2)); @@ -141,7 +152,8 @@ public void testNullCachedFileThatDoesNotNeedRefresh() { // tests of method markFresh - public void testMarkFreshWritesSortedSetOfSourceNamesToSourceDescriptor() { + @Test + public void markFreshWritesSortedSetOfSourceNamesToSourceDescriptor() { File src1 = fileHasContentAndTimestamp("src1", "whatever", 1); File src2 = fileHasContentAndTimestamp("src2", "whatever", 1); SortedSet sources = new TreeSet<>(Arrays.asList(src1, src2)); diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/CachesImplTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/CachesImplTest.java index fa434bde..24630246 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/CachesImplTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/CachesImplTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.io.IOException; import java.net.URL; @@ -13,10 +17,10 @@ import org.fluentjava.iwant.entry.Iwant.UnmodifiableUrl; import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class CachesImplTest extends TestCase { +public class CachesImplTest { private TestArea testArea; private File cacheDir; @@ -24,8 +28,8 @@ public class CachesImplTest extends TestCase { private File wsRoot; private IwantNetworkMock network; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); wsRoot = testArea.newDir("wsroot"); cacheDir = testArea.newDir("cacheDir"); @@ -37,32 +41,37 @@ private static void assertFile(File expected, File actual) { assertEquals(expected.getAbsolutePath(), actual.getAbsolutePath()); } - public void testAskedPathCacheIsNotCreated() { + @Test + public void askedPathCacheIsNotCreated() { File cached = caches.contentOf(new HelloTarget("hello", "whatever")); assertFalse(cached.exists()); assertFalse(cached.getParentFile().exists()); } - public void testSourceIsItsOwnCacheAndRelativeToWsRoot() { + @Test + public void sourceIsItsOwnCacheAndRelativeToWsRoot() { assertFile(new File(wsRoot, "src1"), caches.contentOf(Source.underWsroot("src1"))); assertFile(new File(wsRoot, "src/src2"), caches.contentOf(Source.underWsroot("src/src2"))); } - public void testExternalSourceIsItsOwnCache() { + @Test + public void externalSourceIsItsOwnCache() { File file = new File("/absolute/path"); assertFile(file, caches.contentOf(ExternalSource.at(file))); } - public void testHelloTargetIsCachedAtWorkspaceCache() { + @Test + public void helloTargetIsCachedAtWorkspaceCache() { assertFile(new File(cacheDir, "target/hello"), caches.contentOf(new HelloTarget("hello", "whatever"))); assertFile(new File(cacheDir, "target/hello2"), caches.contentOf(new HelloTarget("hello2", "whatever"))); } - public void testDownloadedIsCachedAtUnmodifiableUrlCache() { + @Test + public void downloadedIsCachedAtUnmodifiableUrlCache() { String urlString = "file:///an/url"; URL url = Iwant.url(urlString); File cached = testArea.newDir("cached-url"); @@ -72,7 +81,8 @@ public void testDownloadedIsCachedAtUnmodifiableUrlCache() { Downloaded.withName("downloaded").url(urlString).md5("any"))); } - public void testContentDescriptorOfNormalTarget() { + @Test + public void contentDescriptorOfNormalTarget() { assertFile(new File(cacheDir, "descriptor/h1"), caches.contentDescriptorOf(new HelloTarget("h1", ""))); assertFile(new File(cacheDir, "descriptor/h2"), @@ -83,7 +93,8 @@ public void testContentDescriptorOfNormalTarget() { * The target itself is inside workspace and so is its content descriptor, * even though the cached content is reused between workspaces. */ - public void testContentDescriptorOfDownloadedTarget() { + @Test + public void contentDescriptorOfDownloadedTarget() { assertFile(new File(cacheDir, "descriptor/dl1"), caches.contentDescriptorOf(Downloaded.withName("dl1") .url("file:///any").md5("any"))); @@ -92,13 +103,15 @@ public void testContentDescriptorOfDownloadedTarget() { .url("file:///any").md5("any"))); } - public void testRequestedTemporaryDirectoryExistsAndIsDirectory() { + @Test + public void requestedTemporaryDirectoryExistsAndIsDirectory() { File tmpDir = caches.temporaryDirectory("w"); assertTrue(tmpDir.exists()); assertTrue(tmpDir.isDirectory()); } - public void testRequestedTemporaryDirectoryIsSameIfAndOnlyIfSameWorkerNameUsed() { + @Test + public void requestedTemporaryDirectoryIsSameIfAndOnlyIfSameWorkerNameUsed() { File a1 = caches.temporaryDirectory("a"); File a2 = caches.temporaryDirectory("a"); File b = caches.temporaryDirectory("b"); @@ -107,7 +120,8 @@ public void testRequestedTemporaryDirectoryIsSameIfAndOnlyIfSameWorkerNameUsed() assertFalse(a1.equals(b)); } - public void testTemporaryDirectoryIsEmptiedAfterPreviousUse() + @Test + public void temporaryDirectoryIsEmptiedAfterPreviousUse() throws IOException { File tmpDir = caches.temporaryDirectory("w"); File fileCreatedByPreviousWorker = new File(tmpDir, diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/ExampleWsDefGeneratorTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/ExampleWsDefGeneratorTest.java index 54037895..8c1e90a8 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/ExampleWsDefGeneratorTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/ExampleWsDefGeneratorTest.java @@ -1,17 +1,20 @@ package org.fluentjava.iwant.entry3; -import org.fluentjava.iwant.testarea.TestArea; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -import junit.framework.TestCase; +import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class ExampleWsDefGeneratorTest extends TestCase { +public class ExampleWsDefGeneratorTest { private StringBuilder expectedWsdefdefStart; private StringBuilder expectedWsdefStart; private TestArea testArea; - @Override - public void setUp() { + @BeforeEach + public void before() { expectedWsdefdefStart = new StringBuilder(); expectedWsdefStart = new StringBuilder(); testArea = TestArea.forTest(this); @@ -44,12 +47,14 @@ private void assertChangeWsdefdefTo(String newPackage, String newName, String actualWsdefdef = ExampleWsDefGenerator.exampleWsdefdef( testArea.root(), newPackage, newName, wsDefSrc, wsdefClassName); - assertTrue("actual:\n" + actualWsdefdef, - actualWsdefdef.startsWith(expectedWsdefdefStart.toString())); - assertTrue("actual:\n" + actualWsdefdef, - actualWsdefdef.endsWith("\n}\n")); - assertTrue("actual:\n" + actualWsdefdef, actualWsdefdef - .contains("return \"" + wsdefClassName + "Factory\";")); + assertTrue(actualWsdefdef.startsWith(expectedWsdefdefStart.toString()), + "actual:\n" + actualWsdefdef); + assertTrue(actualWsdefdef.endsWith("\n}\n"), + "actual:\n" + actualWsdefdef); + assertTrue( + actualWsdefdef + .contains("return \"" + wsdefClassName + "Factory\";"), + "actual:\n" + actualWsdefdef); } private void assertChangeWsdefTo(String newPackage, String newName) { @@ -66,11 +71,11 @@ private void assertChangeWsdefTo(String newPackage, String newName) { String actualWsdef = ExampleWsDefGenerator.exampleWsdef(testArea.root(), newPackage, newName); - assertTrue("actual:\n" + actualWsdef, - actualWsdef.startsWith(expectedWsdefStart.toString())); - assertTrue("actual:\n" + actualWsdef, - actualWsdef.contains("return new " + newName + "(")); - assertTrue("actual:\n" + actualWsdef, actualWsdef.endsWith("\n}\n")); + assertTrue(actualWsdef.startsWith(expectedWsdefStart.toString()), + "actual:\n" + actualWsdef); + assertTrue(actualWsdef.contains("return new " + newName + "("), + "actual:\n" + actualWsdef); + assertTrue(actualWsdef.endsWith("\n}\n"), "actual:\n" + actualWsdef); } private void assertChangeWsTo(String newPackage, String newName) { @@ -83,12 +88,13 @@ private void assertChangeWsTo(String newPackage, String newName) { String actualWs = ExampleWsDefGenerator.exampleWs(testArea.root(), newPackage, newName); - assertTrue("actual:\n" + actualWs, - actualWs.startsWith(expectedWsdefStart.toString())); - assertTrue("actual:\n" + actualWs, actualWs.endsWith("\n}\n")); + assertTrue(actualWs.startsWith(expectedWsdefStart.toString()), + "actual:\n" + actualWs); + assertTrue(actualWs.endsWith("\n}\n"), "actual:\n" + actualWs); } - public void testWsdefdefName1() { + @Test + public void wsdefdefName1() { expectedWsdefdefStart.append("package new.package1;\n"); expectedWsdefdefStart.append( "public class Ws1 implements WorkspaceModuleProvider {\n"); @@ -103,7 +109,8 @@ public void testWsdefdefName1() { "new.wsdefpack.Wsdef"); } - public void testWsdefdefName2() { + @Test + public void wsdefdefName2() { expectedWsdefdefStart.append("package new.package2;\n"); expectedWsdefdefStart.append( "public class Ws2 implements WorkspaceModuleProvider {\n"); @@ -118,7 +125,8 @@ public void testWsdefdefName2() { "new.wsdefpak2.Wsdef2"); } - public void testWsdefName1() { + @Test + public void wsdefName1() { expectedWsdefStart.append("package new.package1;\n"); expectedWsdefStart .append("public class Ws1Factory implements WorkspaceFactory "); @@ -126,7 +134,8 @@ public void testWsdefName1() { assertChangeWsdefTo("new.package1", "Ws1"); } - public void testWsdefName2() { + @Test + public void wsdefName2() { expectedWsdefStart.append("package new.package2;\n"); expectedWsdefStart .append("public class Ws2Factory implements WorkspaceFactory "); @@ -134,21 +143,24 @@ public void testWsdefName2() { assertChangeWsdefTo("new.package2", "Ws2"); } - public void testWsName1() { + @Test + public void wsName1() { expectedWsdefStart.append("package new.package1;\n"); expectedWsdefStart.append("public class Ws1 implements Workspace "); assertChangeWsTo("new.package1", "Ws1"); } - public void testWsName2() { + @Test + public void wsName2() { expectedWsdefStart.append("package new.package2;\n"); expectedWsdefStart.append("public class Ws2 implements Workspace "); assertChangeWsTo("new.package2", "Ws2"); } - public void testProposedWsdefPackage() { + @Test + public void proposedWsdefPackage() { assertEquals("com.example.project.wsdef", ExampleWsDefGenerator .proposedWsdefPackage("com.example.project.wsdefdef")); assertEquals("org.oikarinen.reuhu.wsdef", ExampleWsDefGenerator @@ -158,7 +170,8 @@ public void testProposedWsdefPackage() { "net.esimerkki.nonwsdefdefpackage")); } - public void testProposedWsdefSimpleName() { + @Test + public void proposedWsdefSimpleName() { assertEquals("Ws0Workspace", ExampleWsDefGenerator.proposedWsdefSimpleName("ws0")); assertEquals("OthernameWorkspace", diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/IngredientCheckingTargetEvaluationContextTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/IngredientCheckingTargetEvaluationContextTest.java index edaa89ec..77a6264c 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/IngredientCheckingTargetEvaluationContextTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/IngredientCheckingTargetEvaluationContextTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import org.fluentjava.iwant.api.core.HelloTarget; @@ -14,10 +18,10 @@ import org.fluentjava.iwant.entry3.IngredientCheckingTargetEvaluationContext.ReferenceLegalityCheckCache; import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class IngredientCheckingTargetEvaluationContextTest extends TestCase { +public class IngredientCheckingTargetEvaluationContextTest { private Iwant iwant; private IwantNetwork network; @@ -27,8 +31,8 @@ public class IngredientCheckingTargetEvaluationContextTest extends TestCase { private TargetMock target; private IngredientCheckingTargetEvaluationContext ctx; - @Override - public void setUp() { + @BeforeEach + public void before() { TestArea testArea = TestArea.forTest(this); network = new IwantNetworkMock(testArea); iwant = Iwant.using(network); @@ -44,7 +48,8 @@ public void setUp() { refLegalityCheckCache); } - public void testReferenceToCachedSelfIsDelegated() { + @Test + public void referenceToCachedSelfIsDelegated() { target.hasNoIngredients(); assertEquals(delegate.cached(target), ctx.cached(target)); } @@ -53,7 +58,8 @@ public void testReferenceToCachedSelfIsDelegated() { * In some weird situation a target may refer to another instance of itself * so no ingredient check done here. */ - public void testReferenceToCopyOfCachedSelfIsDelegated() { + @Test + public void referenceToCopyOfCachedSelfIsDelegated() { target.hasNoIngredients(); assertEquals(delegate.cached(target), ctx.cached(new TargetMock("target"))); @@ -63,7 +69,8 @@ public void testReferenceToCopyOfCachedSelfIsDelegated() { * With current design it would be too much to require proper equals from * all Target implementations. */ - public void testComparisonUsesNameSoEvenADifferentPathWithSameNameIsInterpretedAsTargetItself() { + @Test + public void comparisonUsesNameSoEvenADifferentPathWithSameNameIsInterpretedAsTargetItself() { target.hasNoIngredients(); HelloTarget differentTargetImplWithSameName = new HelloTarget("target", @@ -77,13 +84,15 @@ public void testComparisonUsesNameSoEvenADifferentPathWithSameNameIsInterpretedA ctx.cached(sourceWithSameName)); } - public void testReferenceToIngredientIsDelegated() { + @Test + public void referenceToIngredientIsDelegated() { TargetMock ingredient = new TargetMock("ingredient"); target.hasIngredients(ingredient); assertEquals(delegate.cached(ingredient), ctx.cached(ingredient)); } - public void testReferenceToNonIngredientCausesAFailure() { + @Test + public void referenceToNonIngredientCausesAFailure() { target.hasNoIngredients(); try { ctx.cached(new TargetMock("implicit ingredient")); @@ -100,7 +109,8 @@ public void testReferenceToNonIngredientCausesAFailure() { * It's ok to use ingredients of ingredients, otherwise you would have to * declare everything recursively */ - public void testReferenceToIngredientOfIngredientIsDelegated() { + @Test + public void referenceToIngredientOfIngredientIsDelegated() { TargetMock ingredientOfIngredient = new TargetMock( "ingredient-of-ingredient"); ingredientOfIngredient.hasNoIngredients(); @@ -118,7 +128,8 @@ public void testReferenceToIngredientOfIngredientIsDelegated() { /** * See the other name related test for explanation */ - public void testIngredientOfIngredientIsAlsoComparedByNameNotEquality() { + @Test + public void ingredientOfIngredientIsAlsoComparedByNameNotEquality() { TargetMock ingredientOfIngredient = new TargetMock( "ingredient-of-ingredient"); ingredientOfIngredient.hasNoIngredients(); @@ -131,7 +142,8 @@ public void testIngredientOfIngredientIsAlsoComparedByNameNotEquality() { ctx.cached(ingredientOfIngredient)); } - public void testNullIngredientIsReportedAsFriendlyException() { + @Test + public void nullIngredientIsReportedAsFriendlyException() { TargetMock ingredient = new TargetMock("ingredient"); ingredient.hasIngredients(new Path[] { null }); target.hasIngredients(ingredient); @@ -144,7 +156,8 @@ public void testNullIngredientIsReportedAsFriendlyException() { } } - public void testOtherMethodsAreJustDelegated() { + @Test + public void otherMethodsAreJustDelegated() { assertSame(delegate.iwant(), ctx.iwant()); assertSame(delegate.wsRoot(), ctx.wsRoot()); assertSame(delegate.freshTemporaryDirectory(), diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/Iwant3Test.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/Iwant3Test.java index 306ad132..e7d55ecf 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/Iwant3Test.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/Iwant3Test.java @@ -1,5 +1,10 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; @@ -22,10 +27,11 @@ import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.iwantwsrootfinder.IwantWsRootFinder; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class Iwant3Test extends TestCase { +public class Iwant3Test { private static final String LINE_SEPARATOR_KEY = "line.separator"; private static final int NCPU = Runtime.getRuntime().availableProcessors(); @@ -42,8 +48,8 @@ public class Iwant3Test extends TestCase { private String originalLineSeparator; private File combinedIwantSrc; - @Override - public void setUp() throws Exception { + @BeforeEach + public void before() throws Exception { testArea = TestArea.forTest(this); String asSomeone = "wsroot/as-example-developer"; testArea.hasFile(asSomeone + "/with/bash/iwant/help.sh", @@ -118,8 +124,8 @@ private String errIgnoringDebugLog() { return err.toString().replaceAll("\\([^\n]*\n", ""); } - @Override - public void tearDown() { + @AfterEach + public void after() { System.setIn(originalIn); System.setOut(originalOut); System.setErr(originalErr); @@ -150,24 +156,28 @@ private void evaluateAndExpectFriendlyFailureAndExampleWsInfoCreation() "wsroot/as-example-developer/i-have/conf/ws-info")); } - public void testMissingAsSomeoneCausesFriendlyFailureAndExampleCreation() + @Test + public void missingAsSomeoneCausesFriendlyFailureAndExampleCreation() throws Exception { evaluateAndExpectFriendlyFailureAndExampleWsInfoCreation(); } - public void testMissingIHaveCausesFriendlyFailureAndExampleCreation() + @Test + public void missingIHaveCausesFriendlyFailureAndExampleCreation() throws Exception { testArea.newDir("as-example-developer"); evaluateAndExpectFriendlyFailureAndExampleWsInfoCreation(); } - public void testMissingWsInfoCausesFriendlyFailureAndExampleCreation() + @Test + public void missingWsInfoCausesFriendlyFailureAndExampleCreation() throws Exception { testArea.newDir("as-example-developer/i-have"); evaluateAndExpectFriendlyFailureAndExampleWsInfoCreation(); } - public void testInvalidWsInfoCausesFailure() throws Exception { + @Test + public void invalidWsInfoCausesFailure() throws Exception { testArea.hasFile("wsroot/as-example-developer/i-have/conf/ws-info", "invalid\n"); try { @@ -179,7 +189,8 @@ public void testInvalidWsInfoCausesFailure() throws Exception { } } - public void testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation() + @Test + public void missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation() throws Exception { testArea.hasFile("wsroot/as-example-developer/i-have/conf/ws-info", "WSNAME=example\n" + "WSROOT=../../..\n" @@ -235,9 +246,9 @@ private static void spendSomeTimeLikeARealUser() Thread.sleep(1000L); } - public void testIwant3AlsoCreatesWishScriptsForExampleWsDef() - throws Exception { - testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); + @Test + public void iwant3AlsoCreatesWishScriptsForExampleWsDef() throws Exception { + missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); // targets: assertTrue(testArea.contentOf( "wsroot/as-example-developer/with/bash/iwant/list-of/targets") @@ -254,9 +265,10 @@ public void testIwant3AlsoCreatesWishScriptsForExampleWsDef() .startsWith("#!/bin/bash\n")); } - public void testIwant3DoesNotLeaveOldWishScriptsWhenTargetWasRenamedAndThereAreNoSideEffectsAnyMore() + @Test + public void iwant3DoesNotLeaveOldWishScriptsWhenTargetWasRenamedAndThereAreNoSideEffectsAnyMore() throws Exception { - testIwant3AlsoCreatesWishScriptsForExampleWsDef(); + iwant3AlsoCreatesWishScriptsForExampleWsDef(); String wsdefRelpath = "wsroot/as-example-developer/i-have/wsdef/src/main/java/com/example/wsdef/ExampleWorkspace.java"; String wsdefContent = testArea.contentOf(wsdefRelpath); @@ -301,9 +313,10 @@ public void testIwant3DoesNotLeaveOldWishScriptsWhenTargetWasRenamedAndThereAreN .startsWith("#!/bin/bash\n")); } - public void testIwant3DoesNotLeaveOldWishScriptsWhenSideEffectWasRenamedAndThereAreNoTargetsAnyMore() + @Test + public void iwant3DoesNotLeaveOldWishScriptsWhenSideEffectWasRenamedAndThereAreNoTargetsAnyMore() throws Exception { - testIwant3AlsoCreatesWishScriptsForExampleWsDef(); + iwant3AlsoCreatesWishScriptsForExampleWsDef(); String wsdefRelpath = "wsroot/as-example-developer/i-have/wsdef/src/main/java/com/example/wsdef/ExampleWorkspace.java"; String wsdefContent = testArea.contentOf(wsdefRelpath); @@ -351,8 +364,9 @@ public void testIwant3DoesNotLeaveOldWishScriptsWhenSideEffectWasRenamedAndThere .startsWith("#!/bin/bash\n")); } - public void testListOfTargetsOfExampleWsDef() throws Exception { - testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); + @Test + public void listOfTargetsOfExampleWsDef() throws Exception { + missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); startOfOutAndErrCapture(); iwant3.evaluate(asTest, "list-of/targets"); @@ -361,8 +375,9 @@ public void testListOfTargetsOfExampleWsDef() throws Exception { assertEquals("", errIgnoringDebugLog()); } - public void testListOfSideEffectsOfExampleWsDef() throws Exception { - testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); + @Test + public void listOfSideEffectsOfExampleWsDef() throws Exception { + missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); startOfOutAndErrCapture(); iwant3.evaluate(asTest, "list-of/side-effects"); @@ -371,8 +386,9 @@ public void testListOfSideEffectsOfExampleWsDef() throws Exception { assertEquals("", errIgnoringDebugLog()); } - public void testIwant3CreatesCombinedSources() throws Exception { - testListOfSideEffectsOfExampleWsDef(); + @Test + public void iwant3CreatesCombinedSources() throws Exception { + listOfSideEffectsOfExampleWsDef(); assertTrue(combinedIwantSrc.exists()); assertTrue(new File(combinedIwantSrc, @@ -486,7 +502,8 @@ private static String exampleWsFactory() { return b.toString(); } - public void testListOfTargetsOfModifiedWsDef() throws Exception { + @Test + public void listOfTargetsOfModifiedWsDef() throws Exception { testArea.hasFile("wsroot/as-example-developer/i-have/conf/ws-info", "WSNAME=example\n" + "WSROOT=../../..\n" + "WSDEFDEF_MODULE=../wsdefdef\n" @@ -515,7 +532,8 @@ public void testListOfTargetsOfModifiedWsDef() throws Exception { * version-control where the original author commited it after generating * with the iwant wizard. */ - public void testEmptyWishCreatesWishScriptsEvenWhenWsdefdefAndWsdefExist() + @Test + public void emptyWishCreatesWishScriptsEvenWhenWsdefdefAndWsdefExist() throws Exception { testArea.hasFile("wsroot/as-example-developer/i-have/conf/ws-info", "WSNAME=example\n" + "WSROOT=../../..\n" @@ -560,9 +578,10 @@ public void testEmptyWishCreatesWishScriptsEvenWhenWsdefdefAndWsdefExist() .exists()); } - public void testListOfTargetsOfModifiedWsDefAlsoCreatesWishScripts() + @Test + public void listOfTargetsOfModifiedWsDefAlsoCreatesWishScripts() throws Exception { - testListOfTargetsOfModifiedWsDef(); + listOfTargetsOfModifiedWsDef(); assertTrue(testArea.contentOf( "wsroot/as-example-developer/with/bash/iwant/list-of/targets") @@ -579,8 +598,9 @@ public void testListOfTargetsOfModifiedWsDefAlsoCreatesWishScripts() .exists()); } - public void testTargetHelloAsPathOfExampleWsDef() throws Exception { - testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); + @Test + public void targetHelloAsPathOfExampleWsDef() throws Exception { + missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); startOfOutAndErrCapture(); iwant3.evaluate(asTest, "target/hello/as-path"); @@ -592,9 +612,10 @@ public void testTargetHelloAsPathOfExampleWsDef() throws Exception { assertEquals("hello from iwant\n", testArea.contentOf(cached)); } - public void testSideEffectEclipseSettingsEffectiveOfExampleWsDef() + @Test + public void sideEffectEclipseSettingsEffectiveOfExampleWsDef() throws Exception { - testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); + missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); startOfOutAndErrCapture(); iwant3.evaluate(asTest, "side-effect/eclipse-settings/effective"); @@ -641,8 +662,8 @@ public void testSideEffectEclipseSettingsEffectiveOfExampleWsDef() "formatter_profile=_iwant-generated\n"); } - public void testTargetModifiedHelloAsPathOfModifiedWsDef() - throws Exception { + @Test + public void targetModifiedHelloAsPathOfModifiedWsDef() throws Exception { testArea.hasFile("wsroot/as-example-developer/i-have/conf/ws-info", "WSNAME=example\n" + "WSROOT=../../..\n" + "WSDEFDEF_MODULE=../wsdefdef\n" @@ -669,8 +690,8 @@ public void testTargetModifiedHelloAsPathOfModifiedWsDef() assertEquals("content 1", testArea.contentOf(cached)); } - public void testListOfTargetsFailsIfWsDefdefDoesNotCompile() - throws Exception { + @Test + public void listOfTargetsFailsIfWsDefdefDoesNotCompile() throws Exception { testArea.hasFile("wsroot/as-example-developer/i-have/conf/ws-info", "WSNAME=example\n" + "WSROOT=../../..\n" + "WSDEFDEF_MODULE=../wsdefdef\n" @@ -696,7 +717,8 @@ public void testListOfTargetsFailsIfWsDefdefDoesNotCompile() * A learning test: the interface to cast to must come from the classloader * of the running class, not by loading it again. */ - public void testToLearnThatEvenTwoInstancesOfSameClassloaderLoadIncompatibleClasses() + @Test + public void toLearnThatEvenTwoInstancesOfSameClassloaderLoadIncompatibleClasses() throws Exception { Class exampleClass = Iwant3.class; File classes = new File(exampleClass @@ -718,8 +740,9 @@ public void testToLearnThatEvenTwoInstancesOfSameClassloaderLoadIncompatibleClas /** * Corresponds to calling help.sh once more */ - public void testEmptyWishAfterCreationOfExampleWsDef() throws Exception { - testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); + @Test + public void emptyWishAfterCreationOfExampleWsDef() throws Exception { + missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); startOfOutAndErrCapture(); spendSomeTimeLikeARealUser(); @@ -743,9 +766,10 @@ public void testEmptyWishAfterCreationOfExampleWsDef() throws Exception { /** * Corresponds to calling help.sh once more */ - public void testEmptyWishAfterCreationOfUserPreferencesFiles() + @Test + public void emptyWishAfterCreationOfUserPreferencesFiles() throws Exception { - testEmptyWishAfterCreationOfExampleWsDef(); + emptyWishAfterCreationOfExampleWsDef(); startOfOutAndErrCapture(); Iwant.newTextFile(new File(asTest, "i-have/conf/user-preferences"), @@ -771,7 +795,8 @@ public void testEmptyWishAfterCreationOfUserPreferencesFiles() * TODO extract class for this functionality and move these to its test, the * setup is very different from other tests here. */ - public void testWsdefRuntimeClasspathWhenWsdefClassesTargetDefinesNoExtra() { + @Test + public void wsdefRuntimeClasspathWhenWsdefClassesTargetDefinesNoExtra() { File wsRoot = testArea.newDir("wsroot"); CachesMock caches = new CachesMock(wsRoot); TargetEvaluationContextMock ctx = new TargetEvaluationContextMock( @@ -792,7 +817,8 @@ public void testWsdefRuntimeClasspathWhenWsdefClassesTargetDefinesNoExtra() { cp.toString()); } - public void testWsdefRuntimeClasspathWhenWsdefClassesTargetDefinesAnExternalLibrary() { + @Test + public void wsdefRuntimeClasspathWhenWsdefClassesTargetDefinesAnExternalLibrary() { File wsRoot = testArea.newDir("wsroot"); CachesMock caches = new CachesMock(wsRoot); TargetEvaluationContextMock ctx = new TargetEvaluationContextMock( @@ -816,9 +842,10 @@ public void testWsdefRuntimeClasspathWhenWsdefClassesTargetDefinesAnExternalLibr cp.toString()); } - public void testListOfSideEffectsOfExampleWsDefWorksFromUnderSymbolicLinkOfWorkspace() + @Test + public void listOfSideEffectsOfExampleWsDefWorksFromUnderSymbolicLinkOfWorkspace() throws Exception { - testMissingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); + missingWsdefdefCausesFriendlyFailureAndExampleWsdefdefAndWsdefAndWsCreation(); startOfOutAndErrCapture(); File symlinkToWsRoot = new File(testArea.root(), "symlink-to-wsroot"); @@ -831,11 +858,12 @@ public void testListOfSideEffectsOfExampleWsDefWorksFromUnderSymbolicLinkOfWorks assertEquals("", errIgnoringDebugLog()); } - public void testUsersWsClassesAreNotRecompiledIfNoIngredientHasChanged() + @Test + public void usersWsClassesAreNotRecompiledIfNoIngredientHasChanged() throws Exception { Iwant.fileLog( "Starting testUsersWsClassesAreNotRecompiledIfNoIngredientHasChanged"); - testEmptyWishAfterCreationOfExampleWsDef(); + emptyWishAfterCreationOfExampleWsDef(); File wsdefdefClasses = new File(asTest, ".i-cached/wsdefdef-classes"); long t1 = wsdefdefClasses.lastModified(); diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/PathDefinitionConflictCheckerTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/PathDefinitionConflictCheckerTest.java index 97f79b38..3ae0f4ad 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/PathDefinitionConflictCheckerTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/PathDefinitionConflictCheckerTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.Arrays; import org.fluentjava.iwant.api.core.Concatenated; @@ -8,10 +11,9 @@ import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.apimocks.TargetMock; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class PathDefinitionConflictCheckerTest extends TestCase { +public class PathDefinitionConflictCheckerTest { private static void assertError(String errorMessage, Path... paths) { try { @@ -28,11 +30,13 @@ private static void assertError(String errorMessage, Path... paths) { } } - public void testTwoIdenticalTargets() { + @Test + public void twoIdenticalTargets() { assertError(null, new HelloTarget("a", "a"), new HelloTarget("a", "a")); } - public void testTwoIdenticalTargetsWithIngredients() { + @Test + public void twoIdenticalTargetsWithIngredients() { Path p1 = Concatenated.named("a") .nativePathTo(Source.underWsroot("ingr")).end(); Path p2 = Concatenated.named("a") @@ -41,7 +45,8 @@ public void testTwoIdenticalTargetsWithIngredients() { assertError(null, p1, p2); } - public void testTwoRootTargetsWithDifferentClass() { + @Test + public void twoRootTargetsWithDifferentClass() { HelloTarget helloA = new HelloTarget("a", "a"); Concatenated concatenatedA = Concatenated.named("a").end(); @@ -53,7 +58,8 @@ public void testTwoRootTargetsWithDifferentClass() { helloA, concatenatedA); } - public void testPathIngredientOfTargetConflictsWithAnotherTarget() { + @Test + public void pathIngredientOfTargetConflictsWithAnotherTarget() { Path targetB = new HelloTarget("b", "b"); Path sourceB = Source.underWsroot("b"); Path a = Concatenated.named("a").nativePathTo(sourceB).end(); @@ -66,7 +72,8 @@ public void testPathIngredientOfTargetConflictsWithAnotherTarget() { a, targetB); } - public void testTwoConcatenatedsHaveIngredientsOfDifferentName() { + @Test + public void twoConcatenatedsHaveIngredientsOfDifferentName() { Path p1 = Concatenated.named("a") .nativePathTo(Source.underWsroot("ingr1")).end(); Path p2 = Concatenated.named("a") @@ -80,7 +87,8 @@ public void testTwoConcatenatedsHaveIngredientsOfDifferentName() { + "i:native-path:\n" + " ingr1\n" + "", p1, p2); } - public void testOneConcatenatedHasNullIngredientInsteadOfNotNull() { + @Test + public void oneConcatenatedHasNullIngredientInsteadOfNotNull() { Path p1 = Concatenated.named("a") .nativePathTo(Source.underWsroot("ingr1")).end(); Path p2 = Concatenated.named("a").nativePathTo(null).end(); @@ -96,7 +104,8 @@ public void testOneConcatenatedHasNullIngredientInsteadOfNotNull() { assertError("Null Path", p2, p1); } - public void testTwoConcatenatedsHaveDifferentNumberOfIngredients() { + @Test + public void twoConcatenatedsHaveDifferentNumberOfIngredients() { Path p1 = Concatenated.named("a") .nativePathTo(Source.underWsroot("common")).end(); Path p2 = Concatenated.named("a") @@ -112,7 +121,8 @@ public void testTwoConcatenatedsHaveDifferentNumberOfIngredients() { + "i:native-path:\n" + " common\n" + "", p1, p2); } - public void testBuggyTargetsThatGiveIdenticalDescriptorButDifferentIngredients() { + @Test + public void buggyTargetsThatGiveIdenticalDescriptorButDifferentIngredients() { TargetMock a1 = new TargetMock("a"); a1.hasContentDescriptor("a descriptor"); a1.hasIngredients(Source.underWsroot("ingr1")); @@ -125,7 +135,8 @@ public void testBuggyTargetsThatGiveIdenticalDescriptorButDifferentIngredients() + "while another has:\n" + " 'ingr1'\n", a1, a2); } - public void testBuggyTargetsThatGiveIdenticalDescriptorButDifferentNumberOfIngredients() { + @Test + public void buggyTargetsThatGiveIdenticalDescriptorButDifferentNumberOfIngredients() { TargetMock a1 = new TargetMock("a"); a1.hasContentDescriptor("a descriptor"); a1.hasIngredients(Source.underWsroot("ingr1")); @@ -140,7 +151,8 @@ public void testBuggyTargetsThatGiveIdenticalDescriptorButDifferentNumberOfIngre a1, a2); } - public void testBuggyTargetsThatGiveIdenticalDescriptorButAnotherGivesNullIngredient() { + @Test + public void buggyTargetsThatGiveIdenticalDescriptorButAnotherGivesNullIngredient() { TargetMock a1 = new TargetMock("a"); a1.hasContentDescriptor("a descriptor"); a1.hasIngredients(Source.underWsroot("ingr1")); @@ -153,7 +165,8 @@ public void testBuggyTargetsThatGiveIdenticalDescriptorButAnotherGivesNullIngred + "while another has:\n" + " 'ingr1'\n", a1, a2); } - public void testNullName() { + @Test + public void nullName() { Path path = new HelloTarget(null, ""); assertError("A Path of class " diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/TargetRefreshTaskTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/TargetRefreshTaskTest.java index 4e45fb6d..f31a111c 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/TargetRefreshTaskTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/TargetRefreshTaskTest.java @@ -1,5 +1,11 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +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 java.io.InputStream; @@ -28,10 +34,10 @@ import org.fluentjava.iwant.plannerapi.ResourcePool; import org.fluentjava.iwant.plannerapi.TaskDirtiness; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class TargetRefreshTaskTest extends TestCase { +public class TargetRefreshTaskTest { private TestArea testArea; private IwantNetwork network; @@ -42,8 +48,8 @@ public class TargetRefreshTaskTest extends TestCase { private CachesMock caches; private File wsRoot; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); network = new IwantNetworkMock(testArea); iwant = Iwant.using(network); @@ -81,7 +87,8 @@ private TargetRefreshTask task(Target target) { refLegalityCheckCache); } - public void testTaskNameIsTargetsName() { + @Test + public void taskNameIsTargetsName() { TargetMock t1 = new TargetMock("t1"); t1.hasNoIngredients(); TargetMock t2 = new TargetMock("t2"); @@ -91,7 +98,8 @@ public void testTaskNameIsTargetsName() { assertEquals("t2", task(t2).name()); } - public void testTaskToStringMentionsTargetsClassAndName() { + @Test + public void taskToStringMentionsTargetsClassAndName() { TargetMock t1 = new TargetMock("t1"); t1.hasNoIngredients(); TargetMock t2 = new TargetMock("t2"); @@ -106,7 +114,8 @@ public void testTaskToStringMentionsTargetsClassAndName() { task(hello).toString()); } - public void testEqualityAndHashcodeAreDeterminedByName() { + @Test + public void equalityAndHashcodeAreDeterminedByName() { TargetMock a1 = new TargetMock("a"); a1.hasNoIngredients(); TargetMock a2 = new TargetMock("a"); @@ -124,21 +133,24 @@ public void testEqualityAndHashcodeAreDeterminedByName() { assertFalse(a1Task.equals(bTask)); } - public void testTaskGetter() { + @Test + public void taskGetter() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); assertSame(target, task(target).target()); } - public void testTaskOfIngredientlessTargetHasNoDeps() { + @Test + public void taskOfIngredientlessTargetHasNoDeps() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); assertTrue(task(target).dependencies().isEmpty()); } - public void testTaskDependenciesAreRefreshTasksOfTargetIngredientsButNotSource() { + @Test + public void taskDependenciesAreRefreshTasksOfTargetIngredientsButNotSource() { Path srcIngredient = Source.underWsroot("src-ingredient"); TargetMock targetIngredient = new TargetMock("target-ingredient"); targetIngredient.hasNoIngredients(); @@ -154,7 +166,8 @@ public void testTaskDependenciesAreRefreshTasksOfTargetIngredientsButNotSource() assertSame(targetIngredient, depTask.target()); } - public void testTaskIsDirtyIfCachedTargetContentIsMissingEvenIfDescriptorDoes() { + @Test + public void taskIsDirtyIfCachedTargetContentIsMissingEvenIfDescriptorDoes() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); target.hasContentDescriptor("descr"); @@ -165,7 +178,8 @@ public void testTaskIsDirtyIfCachedTargetContentIsMissingEvenIfDescriptorDoes() task(target).dirtiness()); } - public void testIngredientlessTaskIsNotDirtyIfCachedTargetContentAndDescriptorExist() { + @Test + public void ingredientlessTaskIsNotDirtyIfCachedTargetContentAndDescriptorExist() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); target.hasContentDescriptor("descr"); @@ -175,14 +189,16 @@ public void testIngredientlessTaskIsNotDirtyIfCachedTargetContentAndDescriptorEx assertEquals(TaskDirtiness.NOT_DIRTY, task(target).dirtiness()); } - public void testNoResourcesRequiredIfTargetDoesNotRequireThem() { + @Test + public void noResourcesRequiredIfTargetDoesNotRequireThem() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); assertTrue(task(target).requiredResources().isEmpty()); } - public void testRefreshWritesCachedContent() { + @Test + public void refreshWritesCachedContent() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); target.hasContent("target content"); @@ -193,7 +209,8 @@ public void testRefreshWritesCachedContent() { assertEquals("target content", testArea.contentOf("cached/target")); } - public void testRefreshWritesCachedContentDescriptor() { + @Test + public void refreshWritesCachedContentDescriptor() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); target.hasContent("target content"); @@ -205,7 +222,8 @@ public void testRefreshWritesCachedContentDescriptor() { testArea.contentOf("cached-descriptor/target")); } - public void testTaskIsDirtyIfDescriptorChanged() { + @Test + public void taskIsDirtyIfDescriptorChanged() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); target.hasContentDescriptor("new-descriptor"); @@ -216,7 +234,8 @@ public void testTaskIsDirtyIfDescriptorChanged() { task(target).dirtiness()); } - public void testTaskIsDirtyIfCachedDescriptorIsMissing() { + @Test + public void taskIsDirtyIfCachedDescriptorIsMissing() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); target.hasContentDescriptor("new-descriptor"); @@ -227,7 +246,8 @@ public void testTaskIsDirtyIfCachedDescriptorIsMissing() { task(target).dirtiness()); } - public void testTaskIsNotDirtyIfDescriptorNotChanged() { + @Test + public void taskIsNotDirtyIfDescriptorNotChanged() { TargetMock target = new TargetMock("target"); target.hasNoIngredients(); target.hasContentDescriptor("current"); @@ -237,7 +257,8 @@ public void testTaskIsNotDirtyIfDescriptorNotChanged() { assertEquals(TaskDirtiness.NOT_DIRTY, task(target).dirtiness()); } - public void testTaskIsDirtyIfFileUnderSourceDirWasModifiedAfterDescriptor() { + @Test + public void taskIsDirtyIfFileUnderSourceDirWasModifiedAfterDescriptor() { File srcDir = testArea.newDir("src"); File srcFile = testArea.hasFile("src/src-file", "src-content"); srcFile.setLastModified(System.currentTimeMillis() + 2000); @@ -254,7 +275,8 @@ public void testTaskIsDirtyIfFileUnderSourceDirWasModifiedAfterDescriptor() { task(target).dirtiness()); } - public void testTaskIsDirtyIfFileUnderSourceDirWasModifiedAtTheSameTimeAsDescriptor() { + @Test + public void taskIsDirtyIfFileUnderSourceDirWasModifiedAtTheSameTimeAsDescriptor() { File srcDir = testArea.newDir("src"); File srcFile = testArea.hasFile("src/src-file", "src-content"); @@ -269,7 +291,8 @@ public void testTaskIsDirtyIfFileUnderSourceDirWasModifiedAtTheSameTimeAsDescrip task(target).dirtiness()); } - public void testTaskIsDirtyIfSourceIngredientIsMissing() { + @Test + public void taskIsDirtyIfSourceIngredientIsMissing() { File srcDir = new File(testArea.root(), "non-existent"); TargetMock target = new TargetMock("target"); @@ -282,7 +305,8 @@ public void testTaskIsDirtyIfSourceIngredientIsMissing() { task(target).dirtiness()); } - public void testCleanTaskWithSourceIngredient() { + @Test + public void cleanTaskWithSourceIngredient() { File srcDir = testArea.newDir("src"); File srcFile = testArea.hasFile("src/src-file", "src-content"); srcFile.setLastModified(System.currentTimeMillis() - 2000); @@ -297,7 +321,8 @@ public void testCleanTaskWithSourceIngredient() { assertEquals(TaskDirtiness.NOT_DIRTY, task(target).dirtiness()); } - public void testTargetIsDirtyIfIngredientDescriptorIsNewer() { + @Test + public void targetIsDirtyIfIngredientDescriptorIsNewer() { TargetMock ingredient = new TargetMock("ingredient"); ingredient.hasNoIngredients(); ingredient.hasContent("current"); @@ -323,7 +348,8 @@ public void testTargetIsDirtyIfIngredientDescriptorIsNewer() { /** * Often refresh is so fast that we want to optimize like this */ - public void testTargetIsCleanIfIngredientDescriptorIsAsNewAsTargetsOwnDescriptor() { + @Test + public void targetIsCleanIfIngredientDescriptorIsAsNewAsTargetsOwnDescriptor() { TargetMock ingredient = new TargetMock("ingredient"); ingredient.hasNoIngredients(); ingredient.hasContent("current"); @@ -345,7 +371,8 @@ public void testTargetIsCleanIfIngredientDescriptorIsAsNewAsTargetsOwnDescriptor assertEquals(TaskDirtiness.NOT_DIRTY, task(target).dirtiness()); } - public void testTargetIsDirtyIfIngredientDescriptorIsMissing() { + @Test + public void targetIsDirtyIfIngredientDescriptorIsMissing() { TargetMock ingredient = new TargetMock("ingredient"); ingredient.hasNoIngredients(); ingredient.hasContent("current"); @@ -366,7 +393,8 @@ public void testTargetIsDirtyIfIngredientDescriptorIsMissing() { task(target).dirtiness()); } - public void testCleanTaskWithTargetIngredient() { + @Test + public void cleanTaskWithTargetIngredient() { TargetMock ingredient = new TargetMock("ingredient"); ingredient.hasNoIngredients(); ingredient.hasContent("current"); @@ -384,7 +412,8 @@ public void testCleanTaskWithTargetIngredient() { assertEquals(TaskDirtiness.NOT_DIRTY, task(target).dirtiness()); } - public void testTaskSupportsParallelismIffTargetSupportsIt() { + @Test + public void taskSupportsParallelismIffTargetSupportsIt() { TargetMock nonPar = new TargetMock("nonpar"); nonPar.hasNoIngredients(); nonPar.doesNotSupportParallelism(); @@ -470,7 +499,8 @@ public synchronized void willVerifyCachedTargetExistence() { } - public void testExistingCachedContentIsDeletedBeforeRefresh() { + @Test + public void existingCachedContentIsDeletedBeforeRefresh() { TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory target = new TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory( "target"); target.expectsCachedTargetMissingBeforeRefresh(true); @@ -493,7 +523,8 @@ public void testExistingCachedContentIsDeletedBeforeRefresh() { assertFalse(new File(cachedTarget, "target/f1").exists()); } - public void testExistingCachedContentIsNotDeletedBeforeRefreshIfTargetSaysSo() { + @Test + public void existingCachedContentIsNotDeletedBeforeRefreshIfTargetSaysSo() { TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory target = new TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory( "target"); target.expectsCachedTargetMissingBeforeRefresh(false); @@ -516,7 +547,8 @@ public void testExistingCachedContentIsNotDeletedBeforeRefreshIfTargetSaysSo() { assertEquals(TaskDirtiness.NOT_DIRTY, task(target).dirtiness()); } - public void testParentOfCachedContentIsCreatedBeforeRefreshWhenCachedTargetIsNotDeleted() { + @Test + public void parentOfCachedContentIsCreatedBeforeRefreshWhenCachedTargetIsNotDeleted() { TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory target = new TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory( "parent/target"); target.expectsCachedTargetMissingBeforeRefresh(false); @@ -527,7 +559,8 @@ public void testParentOfCachedContentIsCreatedBeforeRefreshWhenCachedTargetIsNot assertEquals("f content", testArea.contentOf("cached/parent/target/f")); } - public void testParentOfCachedContentIsCreatedBeforeRefreshAlsoWhenCachedTargetIsDeleted() { + @Test + public void parentOfCachedContentIsCreatedBeforeRefreshAlsoWhenCachedTargetIsDeleted() { TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory target = new TargetThatVerifiesDirectoryExistenceAndThenCreatesADirectory( "parent/target"); target.expectsCachedTargetMissingBeforeRefresh(true); @@ -538,7 +571,8 @@ public void testParentOfCachedContentIsCreatedBeforeRefreshAlsoWhenCachedTargetI assertEquals("f content", testArea.contentOf("cached/parent/target/f")); } - public void testDownloadedTriesDownloadIfDescriptorIsMissingButNoRealDownloadIsExecutedBecauseCachedFileIsNotDeletedBeforeRefresh() + @Test + public void downloadedTriesDownloadIfDescriptorIsMissingButNoRealDownloadIsExecutedBecauseCachedFileIsNotDeletedBeforeRefresh() throws IOException { URL urlThatShallNotBeContacted = Iwant.url("http://localhost:9999"); try { diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/UserPrefsImplTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/UserPrefsImplTest.java index edaa1ae5..5291a6df 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/UserPrefsImplTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/UserPrefsImplTest.java @@ -1,16 +1,19 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.Properties; import org.fluentjava.iwant.entry.Iwant.IwantException; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class UserPrefsImplTest extends TestCase { +public class UserPrefsImplTest { @SuppressWarnings("unused") - public void testMissingWorkerCount() { + @Test + public void missingWorkerCount() { File file = new File("any"); Properties p = new Properties(); try { @@ -25,7 +28,8 @@ public void testMissingWorkerCount() { } @SuppressWarnings("unused") - public void testNonIntegerWorkerCount() { + @Test + public void nonIntegerWorkerCount() { File file = new File("any"); Properties p = new Properties(); p.put("workerCount", "1.1"); @@ -41,7 +45,8 @@ public void testNonIntegerWorkerCount() { } @SuppressWarnings("unused") - public void testZeroWorkerCount() { + @Test + public void zeroWorkerCount() { File file = new File("any"); Properties p = new Properties(); p.put("workerCount", "0"); @@ -56,7 +61,8 @@ public void testZeroWorkerCount() { } - public void testValidWorkerCount() { + @Test + public void validWorkerCount() { File file = new File("any"); Properties p = new Properties(); p.put("workerCount", "4"); diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishEvaluatorTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishEvaluatorTest.java index 8b0f5277..e0e124da 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishEvaluatorTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishEvaluatorTest.java @@ -1,8 +1,13 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +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.ByteArrayOutputStream; import java.io.File; -import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.util.ArrayList; @@ -41,10 +46,11 @@ import org.fluentjava.iwant.entry.Iwant.IwantException; import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class WishEvaluatorTest extends TestCase { +public class WishEvaluatorTest { private TestArea testArea; private File asSomeone; @@ -68,8 +74,8 @@ public class WishEvaluatorTest extends TestCase { private JavaModule wsdefdefModule; private File cachedIwantSrcRoot; - @Override - public void setUp() throws IOException { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); network = new IwantNetworkMock(testArea); iwant = Iwant.using(network); @@ -107,8 +113,8 @@ private String err() { return err.toString(); } - @Override - public void tearDown() { + @AfterEach + public void after() { System.setIn(originalIn); System.setOut(originalOut); System.setErr(originalErr); @@ -162,7 +168,8 @@ public List sideEffects( } - public void testIllegalWishFromHello() { + @Test + public void illegalWishFromHello() { Workspace hello = new Hello(); try { evaluator.iwant("illegal/wish", hello); @@ -174,13 +181,15 @@ public void testIllegalWishFromHello() { assertEquals("", out.toString()); } - public void testListOfTargetsFromHello() { + @Test + public void listOfTargetsFromHello() { Workspace hello = new Hello(); evaluator.iwant("list-of/targets", hello); assertEquals("hello\n", out.toString()); } - public void testTargetHelloAsPathFromHello() { + @Test + public void targetHelloAsPathFromHello() { Workspace hello = new Hello(); evaluator.iwant("target/hello/as-path", hello); @@ -190,19 +199,22 @@ public void testTargetHelloAsPathFromHello() { assertEquals("hello content", testArea.contentOf(cached)); } - public void testTargetHelloContentFromHello() { + @Test + public void targetHelloContentFromHello() { Workspace hello = new Hello(); evaluator.iwant("target/hello/content", hello); assertEquals("hello content", out.toString()); } - public void testListOfTargetsFromTwoHellos() { + @Test + public void listOfTargetsFromTwoHellos() { Workspace hellos = new TwoHellos(); evaluator.iwant("list-of/targets", hellos); assertEquals("hello1\nhello2\n", out.toString()); } - public void testTargetHello1AsPathFromTwoHellos() { + @Test + public void targetHello1AsPathFromTwoHellos() { Workspace hellos = new TwoHellos(); evaluator.iwant("target/hello1/as-path", hellos); @@ -212,13 +224,15 @@ public void testTargetHello1AsPathFromTwoHellos() { assertEquals("content 1", testArea.contentOf(cached)); } - public void testTargetHello1ContentFromTwoHellos() { + @Test + public void targetHello1ContentFromTwoHellos() { Workspace hellos = new TwoHellos(); evaluator.iwant("target/hello1/content", hellos); assertEquals("content 1", out.toString()); } - public void testTargetHello2AsPathFromTwoHellos() { + @Test + public void targetHello2AsPathFromTwoHellos() { Workspace hellos = new TwoHellos(); evaluator.iwant("target/hello2/as-path", hellos); @@ -228,7 +242,8 @@ public void testTargetHello2AsPathFromTwoHellos() { assertEquals("content 2", testArea.contentOf(cached)); } - public void testTargetHello2ContentFromTwoHellos() { + @Test + public void targetHello2ContentFromTwoHellos() { Workspace hellos = new TwoHellos(); evaluator.iwant("target/hello2/content", hellos); assertEquals("content 2", out.toString()); @@ -236,7 +251,8 @@ public void testTargetHello2ContentFromTwoHellos() { // target without a wsdef - public void testStandaloneHelloTargetContent() { + @Test + public void standaloneHelloTargetContent() { Target target = new HelloTarget("standalone", "Hello from standalone target\n"); evaluator.content(target); @@ -245,7 +261,8 @@ public void testStandaloneHelloTargetContent() { // another target as ingredient - public void testStreamOfTargetThatUsesAnotherTargetStreamAsIngredient() { + @Test + public void streamOfTargetThatUsesAnotherTargetStreamAsIngredient() { Target ingredient = new HelloTarget("ingredient", "ingredient content"); Target target = new TargetThatNeedsAnotherAsStream("target", ingredient); @@ -254,7 +271,8 @@ public void testStreamOfTargetThatUsesAnotherTargetStreamAsIngredient() { out.toString()); } - public void testPathToTargetThatUsesAnotherTargetStreamAsIngredient() { + @Test + public void pathToTargetThatUsesAnotherTargetStreamAsIngredient() { Target ingredient = new HelloTarget("ingredient", "ingredient content"); Target target = new TargetThatNeedsAnotherAsStream("target", ingredient); @@ -267,7 +285,8 @@ public void testPathToTargetThatUsesAnotherTargetStreamAsIngredient() { testArea.contentOf(cached)); } - public void testStreamOfTargetThatUsesAnotherTargetPathAsIngredient() { + @Test + public void streamOfTargetThatUsesAnotherTargetPathAsIngredient() { Target ingredient = new HelloTarget("ingredient", "ingredient content"); Target target = new TargetThatNeedsAnotherAsPath("target", ingredient); evaluator.content(target); @@ -275,7 +294,8 @@ public void testStreamOfTargetThatUsesAnotherTargetPathAsIngredient() { out.toString()); } - public void testPathToTargetThatUsesAnotherTargetPathAsIngredient() { + @Test + public void pathToTargetThatUsesAnotherTargetPathAsIngredient() { Target ingredient = new HelloTarget("ingredient", "ingredient content"); Target target = new TargetThatNeedsAnotherAsPath("target", ingredient); @@ -289,7 +309,8 @@ public void testPathToTargetThatUsesAnotherTargetPathAsIngredient() { // source as ingredient - public void testStreamOfTargetThatUsesASourceStreamAsIngredient() { + @Test + public void streamOfTargetThatUsesASourceStreamAsIngredient() { testArea.hasFile("wsroot/src", "src content"); Path ingredient = Source.underWsroot("src"); Target target = new TargetThatNeedsAnotherAsStream("target", @@ -299,7 +320,8 @@ public void testStreamOfTargetThatUsesASourceStreamAsIngredient() { out.toString()); } - public void testStreamOfTargetThatUsesASourcePathAsIngredient() { + @Test + public void streamOfTargetThatUsesASourcePathAsIngredient() { testArea.hasFile("wsroot/src", "src content"); Path ingredient = Source.underWsroot("src"); Target target = new TargetThatNeedsAnotherAsPath("target", ingredient); @@ -310,7 +332,8 @@ public void testStreamOfTargetThatUsesASourcePathAsIngredient() { // ... - public void testTargetIsRefreshedIfDescriptorOfIngredientsIngredientChanged() { + @Test + public void targetIsRefreshedIfDescriptorOfIngredientsIngredientChanged() { TargetMock t1 = new TargetMock("t1"); t1.hasNoIngredients(); t1.hasContent("t1 content 1"); @@ -372,25 +395,29 @@ public List sideEffects( } - public void testEmptyListOfSideEffects() { + @Test + public void emptyListOfSideEffects() { Workspace hellos = new TwoHellos(); evaluator.iwant("list-of/side-effects", hellos); assertEquals("", out.toString()); } - public void testListOfSideEffectsOfOnlyEclipseSettingsAsSideEffect() { + @Test + public void listOfSideEffectsOfOnlyEclipseSettingsAsSideEffect() { Workspace hellos = new OnlyEclipseSettingsAsSideEffect(); evaluator.iwant("list-of/side-effects", hellos); assertEquals("eclipse-settings\n", out.toString()); } - public void testListOfSideEffectsOfTwoSideEffects() { + @Test + public void listOfSideEffectsOfTwoSideEffects() { Workspace hellos = new TwoSideEffects(); evaluator.iwant("list-of/side-effects", hellos); assertEquals("hello-1\nhello-2\n", out.toString()); } - public void testHello1EffectiveOfTwoSideEffects() { + @Test + public void hello1EffectiveOfTwoSideEffects() { Workspace hellos = new TwoSideEffects(); evaluator.iwant("side-effect/hello-1/effective", hellos); @@ -398,7 +425,8 @@ public void testHello1EffectiveOfTwoSideEffects() { assertEquals("hello-1 mutating.\n", err.toString()); } - public void testHello2EffectiveOfTwoSideEffects() { + @Test + public void hello2EffectiveOfTwoSideEffects() { Workspace hellos = new TwoSideEffects(); evaluator.iwant("side-effect/hello-2/effective", hellos); @@ -406,7 +434,8 @@ public void testHello2EffectiveOfTwoSideEffects() { assertEquals("hello-2 mutating.\n", err.toString()); } - public void testDeletionOfJavaFileIsDetectedAndCompilationIsRetriedAndFailed() { + @Test + public void deletionOfJavaFileIsDetectedAndCompilationIsRetriedAndFailed() { File srcDir = new File(wsRoot, "src"); Iwant.newTextFile(new File(srcDir, "pak1/Caller.java"), "package pak1;\npublic class Caller {pak2.Callee callee;}"); @@ -439,7 +468,8 @@ public void testDeletionOfJavaFileIsDetectedAndCompilationIsRetriedAndFailed() { .exists()); } - public void testTwoTargetsReferToSamePathButOnlyTheOneThatDeclaresItAsIngredientSucceeds() { + @Test + public void twoTargetsReferToSamePathButOnlyTheOneThatDeclaresItAsIngredientSucceeds() { Path src = new HelloTarget("src", "src content"); ConcatenatedBuilder correctSpex = Concatenated.named("correct"); @@ -473,7 +503,8 @@ public void testTwoTargetsReferToSamePathButOnlyTheOneThatDeclaresItAsIngredient * synchronize too much, preventing concurrency from working properly * end-to-end */ - public void testConcurrencyWorksEndToEnd() throws InterruptedException { + @Test + public void concurrencyWorksEndToEnd() throws InterruptedException { final int workerCount = 2; evaluator = new WishEvaluator(out, err, wsRoot, iwant, wsInfo, caches, workerCount, wsdefdefJavaModule, wsdefJavaModule, wsdefCtx); @@ -543,7 +574,8 @@ public void run() { new File(asSomeone, ".i-cached/target/listOfParts"))); } - public void testContextUsesThreadNameToMakeSureAllWorkersGetOwnTemporaryDirectory() + @Test + public void contextUsesThreadNameToMakeSureAllWorkersGetOwnTemporaryDirectory() throws InterruptedException { final List results = Collections .synchronizedList(new ArrayList()); @@ -568,7 +600,8 @@ public void run() { results.get(1)); } - public void testScriptsWorkCorrectlyInParallel() { + @Test + public void scriptsWorkCorrectlyInParallel() { final int workerCount = 8; evaluator = new WishEvaluator(out, err, wsRoot, iwant, wsInfo, caches, workerCount, wsdefdefJavaModule, wsdefJavaModule, wsdefCtx); @@ -598,7 +631,8 @@ public void testScriptsWorkCorrectlyInParallel() { } } - public void testSideEffectDefinitionContextPassesIwantApiClasses() { + @Test + public void sideEffectDefinitionContextPassesIwantApiClasses() { final AtomicReference> fromCtx = new AtomicReference<>(); Workspace ws = new Workspace() { @@ -620,7 +654,8 @@ public List sideEffects( assertSame(iwantApiModules, fromCtx.get()); } - public void testSameNameOnPathAndTargetCausesErrorAtListOfOrAsPath() { + @Test + public void sameNameOnPathAndTargetCausesErrorAtListOfOrAsPath() { Workspace ws = new Workspace() { @Override @@ -668,7 +703,8 @@ public List sideEffects( * it's not retried because no source ingredients are newer than the cached * descriptor, only cached target files. */ - public void testTargetWithNonFreshTargetIngredientAndExistingCachedDescriptorStaysNonFreshEvenIfItFails() { + @Test + public void targetWithNonFreshTargetIngredientAndExistingCachedDescriptorStaysNonFreshEvenIfItFails() { TargetMock ingredient = new TargetMock("ingredient"); ingredient.hasContentDescriptor("ingredient descr 1"); ingredient.hasContent("ingredient content"); @@ -702,7 +738,8 @@ public List sideEffects( evaluateAndFail("target/failing/as-path", ws, "Simulated failure"); } - public void testTargetRefreshIsRetriedEvenIfReasonWasDirtinessOfIngredientAndItsRefreshWasInterruptedEarlier() { + @Test + public void targetRefreshIsRetriedEvenIfReasonWasDirtinessOfIngredientAndItsRefreshWasInterruptedEarlier() { TargetMock a = new TargetMock("a"); a.hasContentDescriptor("a descr 1"); a.hasContent("a content"); @@ -753,7 +790,8 @@ public List sideEffects( * Before the fix this failed, because only source timestamps were checked, * target dirtiness relied on refreshing them during the same run. */ - public void testTargetIsRefreshedEvenIfATargetIngredientWasRefreshedDuringEarlierRun() + @Test + public void targetIsRefreshedEvenIfATargetIngredientWasRefreshedDuringEarlierRun() throws InterruptedException { TargetMock a = new TargetMock("a"); a.hasContentDescriptor("a descr 1"); @@ -803,7 +841,8 @@ public List sideEffects( assertEquals(2, c.timesPathWasCalled()); } - public void testSideEffectThatWantsAndUsesTargetsAsPaths() { + @Test + public void sideEffectThatWantsAndUsesTargetsAsPaths() { final Target target1 = new HelloTarget("target1", "target1 content"); final Target target2 = Concatenated.named("target2") .string("target2 using ").contentOf(target1).end(); @@ -879,7 +918,8 @@ public List sideEffects( } - public void testSideEffectThatReferencesIwantPlugin() { + @Test + public void sideEffectThatReferencesIwantPlugin() { Workspace hellos = new IwantPluginReferenceInSideEffectDefinition(); evaluator.iwant("side-effect/ant-plugin-print/effective", hellos); @@ -914,7 +954,8 @@ public List sideEffects( /** * More cases are tested in TargetNameCheckerTest */ - public void testIllegalTargetNameCausesFailure() { + @Test + public void illegalTargetNameCausesFailure() { WorkspaceWithTarget ws = new WorkspaceWithTarget( new HelloTarget("a::b", "")); try { @@ -932,7 +973,8 @@ public void testIllegalTargetNameCausesFailure() { * happens. It also tests the already cached parent is not deleted before * refreshing the SubPath. */ - public void testSubPathPointsToUnderParentAndItHasCorrectCachedContent() + @Test + public void subPathPointsToUnderParentAndItHasCorrectCachedContent() throws Exception { Target hello = new HelloTarget("hello", "hello content"); Directory parent = Directory.named("parent").dir("sub").copyOf(hello) diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishScriptGeneratorTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishScriptGeneratorTest.java index bae8b053..328fc8ba 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishScriptGeneratorTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WishScriptGeneratorTest.java @@ -1,17 +1,21 @@ package org.fluentjava.iwant.entry3; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertEquals; -public class WishScriptGeneratorTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testListOfTargets() { +public class WishScriptGeneratorTest { + + @Test + public void listOfTargets() { assertEquals( "#!/bin/bash\n" + "HERE=$(dirname \"$0\")\n" + "exec \"$HERE/../help.sh\" \"list-of/targets\"\n", WishScriptGenerator.wishScriptContent("list-of/targets")); } - public void testTargetHelloAsPath() { + @Test + public void targetHelloAsPath() { assertEquals("#!/bin/bash\n" + "HERE=$(dirname \"$0\")\n" + "exec \"$HERE/../../help.sh\" \"target/hello/as-path\"\n", WishScriptGenerator.wishScriptContent("target/hello/as-path")); diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WorkspaceDefinitionContextImplTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WorkspaceDefinitionContextImplTest.java index d5852924..eba9f0b1 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WorkspaceDefinitionContextImplTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WorkspaceDefinitionContextImplTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + import java.io.File; import java.util.Iterator; import java.util.LinkedHashSet; @@ -13,10 +16,10 @@ import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.wsdef.WorkspaceModuleContext; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class WorkspaceDefinitionContextImplTest extends TestCase { +public class WorkspaceDefinitionContextImplTest { private Set apiModules; private WorkspaceModuleContext ctx; @@ -26,8 +29,8 @@ public class WorkspaceDefinitionContextImplTest extends TestCase { private TestArea testArea; private File cachedIwantSrcRoot; - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void before() throws Exception { iwantApiModule1 = JavaBinModule .providing(Source.underWsroot("iwant-api-1")).end(); iwantApiModule2 = JavaBinModule @@ -45,15 +48,18 @@ protected void setUp() throws Exception { wsdefdefModule); } - public void testApiModulesIsGivenAsSuch() { + @Test + public void apiModulesIsGivenAsSuch() { assertSame(apiModules, ctx.iwantApiModules()); } - public void testWsdefdefModuleIsGivenAsSuch() { + @Test + public void wsdefdefModuleIsGivenAsSuch() { assertSame(wsdefdefModule, ctx.wsdefdefModule()); } - public void testIwantPluginAntWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginAntWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().ant().withDependencies(); assertEquals(5, mods.size()); @@ -66,7 +72,8 @@ public void testIwantPluginAntWithDependenciesContainsCorrectModules() { assertEquals("ant-launcher-1.10.14.jar", iterator.next().name()); } - public void testIwantPluginAntMainClassesHasCorrectCompilationClasspath() { + @Test + public void iwantPluginAntMainClassesHasCorrectCompilationClasspath() { Set mods = ctx.iwantPlugin().ant().withDependencies(); JavaBinModule antPlugin = (JavaBinModule) mods.iterator().next(); @@ -78,7 +85,8 @@ public void testIwantPluginAntMainClassesHasCorrectCompilationClasspath() { assertEquals("ant-1.10.14.jar", iterator.next().name()); } - public void testIwantPluginAntMainJavaIsASubdirectoryUnderIwantSources() { + @Test + public void iwantPluginAntMainJavaIsASubdirectoryUnderIwantSources() { Set mods = ctx.iwantPlugin().ant().withDependencies(); JavaBinModule antPlugin = (JavaBinModule) mods.iterator().next(); @@ -92,7 +100,8 @@ public void testIwantPluginAntMainJavaIsASubdirectoryUnderIwantSources() { java.name()); } - public void testIwantPluginPmdWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginPmdWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().pmd().withDependencies(); assertEquals("[iwant-plugin-pmd, iwant-api-1, iwant-api-2," @@ -100,7 +109,8 @@ public void testIwantPluginPmdWithDependenciesContainsCorrectModules() { + " jaxen-1.1.4.jar, pmd-4.3.jar]", mods.toString()); } - public void testIwantPluginFindbugsWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginFindbugsWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().findbugs().withDependencies(); assertEquals("[iwant-plugin-findbugs, iwant-api-1, iwant-api-2," @@ -108,7 +118,8 @@ public void testIwantPluginFindbugsWithDependenciesContainsCorrectModules() { + " ant-launcher-1.10.14.jar]", mods.toString()); } - public void testIwantPluginGithubWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginGithubWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().github().withDependencies(); assertEquals( @@ -118,7 +129,8 @@ public void testIwantPluginGithubWithDependenciesContainsCorrectModules() { mods.toString()); } - public void testIwantPluginWarWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginWarWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().war().withDependencies(); assertEquals( @@ -126,7 +138,8 @@ public void testIwantPluginWarWithDependenciesContainsCorrectModules() { mods.toString()); } - public void testIwantPluginJacocoWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginJacocoWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().jacoco().withDependencies(); assertEquals( @@ -136,7 +149,8 @@ public void testIwantPluginJacocoWithDependenciesContainsCorrectModules() { mods.toString()); } - public void testIwantPluginJunit5runnerWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginJunit5runnerWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().junit5runner() .withDependencies(); @@ -149,7 +163,8 @@ public void testIwantPluginJunit5runnerWithDependenciesContainsCorrectModules() + " opentest4j-1.3.0.jar]", mods.toString()); } - public void testIwantPluginTestngWithDependenciesContainsCorrectModules() { + @Test + public void iwantPluginTestngWithDependenciesContainsCorrectModules() { Set mods = ctx.iwantPlugin().testng().withDependencies(); assertEquals( diff --git a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WsInfoTest.java b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WsInfoTest.java index 03d42a64..f49781d6 100644 --- a/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WsInfoTest.java +++ b/essential/iwant-entry3/src/test/java/org/fluentjava/iwant/entry3/WsInfoTest.java @@ -1,21 +1,24 @@ package org.fluentjava.iwant.entry3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.io.IOException; import java.io.StringReader; import org.fluentjava.iwant.api.model.WsInfo; import org.fluentjava.iwant.entry.Iwant.IwantException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class WsInfoTest extends TestCase { +public class WsInfoTest { private StringBuilder in; private File asSomeone; - @Override - public void setUp() { + @BeforeEach + public void before() { in = new StringBuilder(); asSomeone = new File("/project/as-test"); } @@ -25,7 +28,8 @@ private WsInfo newWsInfo() throws IOException { new File("/project/as-test/i-have/conf/wsinfo"), asSomeone); } - public void testEmpty() throws IOException { + @Test + public void empty() throws IOException { // empty in try { @@ -39,7 +43,8 @@ public void testEmpty() throws IOException { } - public void testMissingWsname() throws IOException { + @Test + public void missingWsname() throws IOException { in.append("WSROOT=../../..\n"); in.append("WSDEFDEF_MODULE=../wsdef\n"); in.append( @@ -56,7 +61,8 @@ public void testMissingWsname() throws IOException { } - public void testMissingWsroot() throws IOException { + @Test + public void missingWsroot() throws IOException { in.append("WSNAME=example\n"); in.append("WSDEFDEF_MODULE=../wsdef\n"); in.append( @@ -73,7 +79,8 @@ public void testMissingWsroot() throws IOException { } - public void testMissingWsdefdefModule() throws IOException { + @Test + public void missingWsdefdefModule() throws IOException { in.append("WSNAME=example\n"); in.append("WSROOT=../../..\n"); in.append( @@ -90,7 +97,8 @@ public void testMissingWsdefdefModule() throws IOException { } - public void testMissingWsdefdefClass() throws IOException { + @Test + public void missingWsdefdefClass() throws IOException { in.append("WSNAME=example\n"); in.append("WSROOT=../../..\n"); in.append("WSDEFDEF_MODULE=../wsdef\n"); @@ -106,7 +114,8 @@ public void testMissingWsdefdefClass() throws IOException { } - public void testAsSomeoneOutsideWsrootIsAnError() throws IOException { + @Test + public void asSomeoneOutsideWsrootIsAnError() throws IOException { in.append("WSNAME=example\n"); in.append("WSROOT=../../..\n"); in.append("WSDEFDEF_MODULE=../wsdef\n"); @@ -124,7 +133,8 @@ public void testAsSomeoneOutsideWsrootIsAnError() throws IOException { } } - public void testValid() throws IOException { + @Test + public void valid() throws IOException { in.append("WSNAME=example\n"); in.append("WSROOT=../../..\n"); in.append("WSDEFDEF_MODULE=../wsdef\n"); @@ -151,7 +161,8 @@ public void testValid() throws IOException { assertEquals("as-test", wsInfo.relativeAsSomeone()); } - public void testValidWithDifferentValues() throws IOException { + @Test + public void validWithDifferentValues() throws IOException { asSomeone = new File("/project/wsroot/as-test2"); in.append("WSNAME=example2\n"); in.append("WSROOT=../../../wsroot\n"); diff --git a/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java b/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java index 9072d0bc..7485063d 100644 --- a/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java +++ b/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java @@ -1,15 +1,17 @@ package org.fluentjava.iwant.iwantwsrootfinder; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class IwantWsRootFinderTest extends TestCase { +public class IwantWsRootFinderTest { - public void testKnownFileIsFoundUnderWsRoot() throws IOException { + @Test + public void knownFileIsFoundUnderWsRoot() throws IOException { File wsInfo = new File(IwantWsRootFinder.essential().getParentFile(), "as-iwant-developer/i-have/conf/ws-info"); @@ -18,7 +20,8 @@ public void testKnownFileIsFoundUnderWsRoot() throws IOException { FileUtils.readFileToString(wsInfo).contains("WSNAME=iwant\n")); } - public void testKnownFileIsFoundUnderMockEssential() throws IOException { + @Test + public void knownFileIsFoundUnderMockEssential() throws IOException { File mockedApiWsdef = new File(IwantWsRootFinder.mockEssential(), "iwant-api-wsdef/src/main/java/" + "org/fluentjava/iwant/api/wsdef/MockedApiWsdef.java"); diff --git a/essential/iwant-planner-api/src/test/java/org/fluentjava/iwant/plannerapi/TaskDirtinessTest.java b/essential/iwant-planner-api/src/test/java/org/fluentjava/iwant/plannerapi/TaskDirtinessTest.java index f371b9da..6e16ec81 100644 --- a/essential/iwant-planner-api/src/test/java/org/fluentjava/iwant/plannerapi/TaskDirtinessTest.java +++ b/essential/iwant-planner-api/src/test/java/org/fluentjava/iwant/plannerapi/TaskDirtinessTest.java @@ -1,10 +1,14 @@ package org.fluentjava.iwant.plannerapi; -import junit.framework.TestCase; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class TaskDirtinessTest extends TestCase { +import org.junit.jupiter.api.Test; - public void testDirtinessBoolean() { +public class TaskDirtinessTest { + + @Test + public void dirtinessBoolean() { assertFalse(TaskDirtiness.NOT_DIRTY.isDirty()); assertTrue(TaskDirtiness.DIRTY_DESCRIPTOR_CHANGED.isDirty()); assertTrue(TaskDirtiness.DIRTY_CACHED_CONTENT_MISSING.isDirty()); diff --git a/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/PlannerTest.java b/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/PlannerTest.java index 725c9f24..79ad5bb8 100644 --- a/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/PlannerTest.java +++ b/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/PlannerTest.java @@ -1,20 +1,23 @@ package org.fluentjava.iwant.planner; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.Arrays; import org.fluentjava.iwant.plannerapi.Task; import org.fluentjava.iwant.plannerapi.TaskDirtiness; import org.fluentjava.iwant.plannermocks.ResourceMock; import org.fluentjava.iwant.plannermocks.TaskMock; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class PlannerTest extends TestCase { +public class PlannerTest { Planner planner; - @Override - public void setUp() { + @BeforeEach + public void before() { planner = null; } @@ -46,7 +49,8 @@ private void buildEndsWithFailure(String message) { // ingredientless - public void testIngredientlessCleanTask() { + @Test + public void ingredientlessCleanTask() { TaskMock root = TaskMock.named("root").clean().noDeps(); ensureFresh(root, 2); @@ -54,7 +58,8 @@ public void testIngredientlessCleanTask() { buildEndsSuccessfully(); } - public void testIngredientlessDirtyTask() { + @Test + public void ingredientlessDirtyTask() { TaskMock root = TaskMock.named("root").dirty().noDeps(); ensureFresh(root, 2); @@ -66,7 +71,8 @@ public void testIngredientlessDirtyTask() { // one ingredient - public void testCleanTaskWithCleanDep() { + @Test + public void cleanTaskWithCleanDep() { TaskMock dep = TaskMock.named("dep").clean().noDeps(); TaskMock root = TaskMock.named("root").clean().deps(dep); @@ -75,7 +81,8 @@ public void testCleanTaskWithCleanDep() { buildEndsSuccessfully(); } - public void testDirtyTaskWithCleanDep() { + @Test + public void dirtyTaskWithCleanDep() { TaskMock dep = TaskMock.named("dep").clean().noDeps(); TaskMock root = TaskMock.named("root").dirty().deps(dep); @@ -86,7 +93,8 @@ public void testDirtyTaskWithCleanDep() { buildEndsSuccessfully(); } - public void testCleanTaskWithDirtyDep() { + @Test + public void cleanTaskWithDirtyDep() { TaskMock dep = TaskMock.named("dep").dirty().noDeps(); TaskMock root = TaskMock.named("root").clean().deps(dep); @@ -102,7 +110,8 @@ public void testCleanTaskWithDirtyDep() { // 2 ingredients - public void testCleanTaskWith2DirtyDeps() { + @Test + public void cleanTaskWith2DirtyDeps() { TaskMock dep1 = TaskMock.named("dep1").dirty().noDeps(); TaskMock dep2 = TaskMock.named("dep2").dirty().noDeps(); TaskMock root = TaskMock.named("root").clean().deps(dep1, dep2); @@ -121,7 +130,8 @@ public void testCleanTaskWith2DirtyDeps() { buildEndsSuccessfully(); } - public void testCleanTaskWith2DirtyDepsAndFirstDepRefreshFails() { + @Test + public void cleanTaskWith2DirtyDepsAndFirstDepRefreshFails() { TaskMock dep1 = TaskMock.named("dep1").dirty().noDeps(); TaskMock dep2 = TaskMock.named("dep2").dirty().noDeps(); TaskMock root = TaskMock.named("root").clean().deps(dep1, dep2); @@ -137,7 +147,8 @@ public void testCleanTaskWith2DirtyDepsAndFirstDepRefreshFails() { buildEndsWithFailure("dep1 failure"); } - public void testTwoDirtyTasksUsingSameResourcePoolOfOne() { + @Test + public void twoDirtyTasksUsingSameResourcePoolOfOne() { ResourceMock resource = ResourceMock.named("r"); ResourcePoolMock pool = ResourcePoolMock.of(resource); TaskMock dep1 = TaskMock.named("dep1").dirty().uses(pool).noDeps(); @@ -158,7 +169,8 @@ public void testTwoDirtyTasksUsingSameResourcePoolOfOne() { buildEndsSuccessfully(); } - public void testTwoDirtyTasksUsingSameResourcePoolOfTwo() { + @Test + public void twoDirtyTasksUsingSameResourcePoolOfTwo() { ResourceMock resource1 = ResourceMock.named("r1"); ResourceMock resource2 = ResourceMock.named("r2"); ResourcePoolMock pool = ResourcePoolMock.of(resource1, resource2); @@ -179,7 +191,8 @@ public void testTwoDirtyTasksUsingSameResourcePoolOfTwo() { buildEndsSuccessfully(); } - public void testNonParallelTaskDoesNotStartRefreshIfAnotherIsRunning() { + @Test + public void nonParallelTaskDoesNotStartRefreshIfAnotherIsRunning() { TaskMock dep1 = TaskMock.named("dep1").dirty() .doesNotSupportParallelism().noDeps(); TaskMock dep2 = TaskMock.named("dep2").dirty().noDeps(); @@ -201,7 +214,8 @@ public void testNonParallelTaskDoesNotStartRefreshIfAnotherIsRunning() { buildEndsSuccessfully(); } - public void testNormalTaskDoesNotStartRefreshIfNonParallelTaskIsRunning() { + @Test + public void normalTaskDoesNotStartRefreshIfNonParallelTaskIsRunning() { TaskMock dep1 = TaskMock.named("dep1").dirty().noDeps(); TaskMock dep2 = TaskMock.named("dep2").dirty() .doesNotSupportParallelism().noDeps(); @@ -223,7 +237,8 @@ public void testNormalTaskDoesNotStartRefreshIfNonParallelTaskIsRunning() { buildEndsSuccessfully(); } - public void testTaskStartLogMessage() { + @Test + public void taskStartLogMessage() { // in practice targets whose dependency target is dirty is clean but // still refreshed and this is what it looks like in the log: TaskMock clean = TaskMock.named("task1").clean().noDeps(); @@ -237,7 +252,8 @@ public void testTaskStartLogMessage() { planner.taskStartMessage(2, 1, dirty)); } - public void testTaskStartLogMessageDoesNotReEvaluateDirtinessForPerformanceReasons() { + @Test + public void taskStartLogMessageDoesNotReEvaluateDirtinessForPerformanceReasons() { TaskMock dirty = TaskMock.named("task2").dirty().noDeps(); planner = new Planner(dirty, 1); assertEquals("(2/1 S~ TaskMock:task2)", @@ -249,7 +265,8 @@ public void testTaskStartLogMessageDoesNotReEvaluateDirtinessForPerformanceReaso planner.taskStartMessage(2, 1, dirty)); } - public void testDirtinessStringForLogMessage() { + @Test + public void dirtinessStringForLogMessage() { assertEquals(" ", Planner.dirtinessToString(TaskDirtiness.NOT_DIRTY)); assertEquals("D~", Planner .dirtinessToString(TaskDirtiness.DIRTY_DESCRIPTOR_CHANGED)); diff --git a/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/TaskQueueTest.java b/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/TaskQueueTest.java index 12dbb0bc..417a3b2f 100644 --- a/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/TaskQueueTest.java +++ b/essential/iwant-planner/src/test/java/org/fluentjava/iwant/planner/TaskQueueTest.java @@ -1,19 +1,25 @@ package org.fluentjava.iwant.planner; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import org.fluentjava.iwant.plannerapi.Task; import org.fluentjava.iwant.plannermocks.ResourceMock; import org.fluentjava.iwant.plannermocks.TaskMock; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class TaskQueueTest extends TestCase { +public class TaskQueueTest { private TaskQueue queue; - @Override - public void setUp() { + @BeforeEach + public void before() { queue = null; } @@ -41,7 +47,8 @@ private void done(TaskAllocation allocation) { queue.markDone(allocation); } - public void testObservableStateOfDeplessClean() { + @Test + public void observableStateOfDeplessClean() { Task root = TaskMock.named("clean").clean().noDeps(); queue = new TaskQueue(root); @@ -49,7 +56,8 @@ public void testObservableStateOfDeplessClean() { assertNull(queue.next()); } - public void testOneDeplessDirty() { + @Test + public void oneDeplessDirty() { TaskMock root = TaskMock.named("dirty").dirty().noDeps(); queue = new TaskQueue(root); @@ -61,7 +69,8 @@ public void testOneDeplessDirty() { queueIsEmpty(); } - public void testCleanTaskWithTwoDirtyDeps() { + @Test + public void cleanTaskWithTwoDirtyDeps() { TaskMock dep1 = TaskMock.named("dep1").dirty().noDeps(); TaskMock dep2 = TaskMock.named("dep2").dirty().noDeps(); TaskMock root = TaskMock.named("root").clean().deps(dep1, dep2); @@ -84,7 +93,8 @@ public void testCleanTaskWithTwoDirtyDeps() { // resources - public void testOnlyOneTaskRunsAtATimeWhenUsingTheSameSingletonResource() { + @Test + public void onlyOneTaskRunsAtATimeWhenUsingTheSameSingletonResource() { ResourceMock res = ResourceMock.named("r"); ResourcePoolMock pool = ResourcePoolMock.of(res); TaskMock dep1 = TaskMock.named("dep1").dirty().uses(pool).noDeps(); @@ -105,7 +115,8 @@ public void testOnlyOneTaskRunsAtATimeWhenUsingTheSameSingletonResource() { // and so on } - public void testTwoTasksRunsInParallelWhenTheirCommonPoolIsBigEnough() { + @Test + public void twoTasksRunsInParallelWhenTheirCommonPoolIsBigEnough() { ResourceMock res1 = ResourceMock.named("r1"); ResourceMock res2 = ResourceMock.named("r2"); ResourcePoolMock pool = ResourcePoolMock.of(res1, res2); @@ -126,7 +137,8 @@ public void testTwoTasksRunsInParallelWhenTheirCommonPoolIsBigEnough() { // and so on } - public void testTaskDoesNotReserveAnyResourcesIfItCantGetAll() { + @Test + public void taskDoesNotReserveAnyResourcesIfItCantGetAll() { ResourceMock pool1res = ResourceMock.named("p1r"); ResourceMock pool2res = ResourceMock.named("p2r"); ResourcePoolMock pool1 = ResourcePoolMock.of(pool1res); @@ -158,7 +170,8 @@ public void testTaskDoesNotReserveAnyResourcesIfItCantGetAll() { // non-parallel task - public void testNonParallelTaskDoesNotStartRefreshIfAnotherIsRunning() { + @Test + public void nonParallelTaskDoesNotStartRefreshIfAnotherIsRunning() { TaskMock dep1 = TaskMock.named("dep1").dirty() .doesNotSupportParallelism().noDeps(); TaskMock dep2 = TaskMock.named("dep2").dirty().noDeps(); @@ -179,7 +192,8 @@ public void testNonParallelTaskDoesNotStartRefreshIfAnotherIsRunning() { queueIsEmpty(); } - public void testNormalTaskDoesNotStartRefreshIfNonParallelTaskIsRunning() { + @Test + public void normalTaskDoesNotStartRefreshIfNonParallelTaskIsRunning() { TaskMock dep1 = TaskMock.named("dep1").dirty().noDeps(); TaskMock dep2 = TaskMock.named("dep2").dirty() .doesNotSupportParallelism().noDeps(); @@ -202,7 +216,8 @@ public void testNormalTaskDoesNotStartRefreshIfNonParallelTaskIsRunning() { // other - public void testManyInstancesOfTheSameTargetAreHandledAsOne() { + @Test + public void manyInstancesOfTheSameTargetAreHandledAsOne() { TaskMock utilCopy1 = TaskMock.named("util").dirty().noDeps(); TaskMock utilCopy2 = TaskMock.named("util").dirty().noDeps(); diff --git a/optional/iwant-plugin-ant/src/test/java/org/fluentjava/iwant/plugin/ant/UntarredTest.java b/optional/iwant-plugin-ant/src/test/java/org/fluentjava/iwant/plugin/ant/UntarredTest.java index 348e79c6..875ed778 100644 --- a/optional/iwant-plugin-ant/src/test/java/org/fluentjava/iwant/plugin/ant/UntarredTest.java +++ b/optional/iwant-plugin-ant/src/test/java/org/fluentjava/iwant/plugin/ant/UntarredTest.java @@ -1,15 +1,20 @@ package org.fluentjava.iwant.plugin.ant; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import org.fluentjava.iwant.api.model.ExternalSource; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.apimocks.IwantTestCase; +import org.junit.jupiter.api.Test; public class UntarredTest extends IwantTestCase { - public void testInregedients() { + @Test + public void inregedients() { assertEquals("[a.tar]", Untarred.with().name("u").from(Source.underWsroot("a.tar")) .end().ingredients().toString()); @@ -18,7 +23,8 @@ public void testInregedients() { .gzCompression().end().ingredients().toString()); } - public void testContentDescriptor() { + @Test + public void contentDescriptor() { assertEquals( "org.fluentjava.iwant.plugin.ant.Untarred:" + "compression=null:[a.tar]", @@ -31,7 +37,8 @@ public void testContentDescriptor() { .gzCompression().end().contentDescriptor()); } - public void testSuccessfullyUntarringDirAndFileTar() throws Exception { + @Test + public void successfullyUntarringDirAndFileTar() throws Exception { File tarFile = new File(getClass().getResource( "/org/fluentjava/iwant/testresources/untarred/dir-and-file.tar") .toURI()); @@ -44,7 +51,8 @@ public void testSuccessfullyUntarringDirAndFileTar() throws Exception { assertEquals("file content\n", contentOfCached(untarred, "dir/file")); } - public void testSuccessfullyUntarringDirAndFileTarGz() throws Exception { + @Test + public void successfullyUntarringDirAndFileTarGz() throws Exception { File tarFile = new File(getClass().getResource( "/org/fluentjava/iwant/testresources/untarred/dir-and-file.tar.gz") .toURI()); diff --git a/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsDistributionTest.java b/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsDistributionTest.java index e31783d1..14ae49c3 100644 --- a/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsDistributionTest.java +++ b/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsDistributionTest.java @@ -1,11 +1,15 @@ package org.fluentjava.iwant.plugin.findbugs; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.io.IOException; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.core.download.Downloaded; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.Test; public class FindbugsDistributionTest extends IwantTestCase { @@ -14,7 +18,8 @@ protected void moreSetUp() { caches.cachesUrlAt(distroToTest().tarGz().url(), cachedFindbugsTarGz()); } - public void testTarGzIsADownloadedTargetWithCorrectUrlAndNameAndSum() { + @Test + public void tarGzIsADownloadedTargetWithCorrectUrlAndNameAndSum() { FindbugsDistribution distro300 = FindbugsDistribution._4_7_3; Downloaded tarGz300 = distro300.tarGz(); @@ -46,21 +51,24 @@ private static File cachedFindbugsTarGz() { .downloaded(distroToTest().tarGz().url()); } - public void testRealCachedFindbugs301TarGzExistsAndHasCorrectSize() { + @Test + public void realCachedFindbugs301TarGzExistsAndHasCorrectSize() { File cachedFindbugsJar = cachedFindbugsTarGz(); assertTrue(cachedFindbugsJar.exists()); assertEquals(16035999, cachedFindbugsJar.length()); } - public void testTarGzIsAnIngredientAndMentionedInDescriptor() { + @Test + public void tarGzIsAnIngredientAndMentionedInDescriptor() { FindbugsDistribution distro = FindbugsDistribution._4_7_3; assertTrue(distro.ingredients().contains(distro.tarGz())); assertTrue(distro.contentDescriptor().contains(distro.tarGz().name())); } - public void testFindbugsHomeDirectoryUnderCachedUntarredDistro() + @Test + public void findbugsHomeDirectoryUnderCachedUntarredDistro() throws IOException { FindbugsDistribution distro300 = FindbugsDistribution .ofVersion("anotherVersion", "whatever-hash"); @@ -76,7 +84,8 @@ public void testFindbugsHomeDirectoryUnderCachedUntarredDistro() distro301.homeDirectory(ctx).getCanonicalPath()); } - public void testFilesWithCorrectNameAreFoundInsideTheRealDistroHomeDir() + @Test + public void filesWithCorrectNameAreFoundInsideTheRealDistroHomeDir() throws Exception { FindbugsDistribution distro = distroToTest(); diff --git a/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java b/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java index 8c7b62d1..3eee252f 100644 --- a/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java +++ b/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java @@ -1,5 +1,10 @@ package org.fluentjava.iwant.plugin.findbugs; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.io.IOException; @@ -17,6 +22,7 @@ import org.fluentjava.iwant.embedded.AsEmbeddedIwantUser; import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.plugin.findbugs.FindbugsReport.FindbugsReportSpex; +import org.junit.jupiter.api.Test; public class FindbugsReportTest extends IwantTestCase { @@ -87,7 +93,8 @@ protected void srcDirHasFindbugsFodder(File srcDir, // the tests // ----------------------------------------------------- - public void testDistroMustBeGiven() { + @Test + public void distroMustBeGiven() { wsRootHasDirectory("empty-src"); wsRootHasDirectory("empty-classes"); Path emptySrc = Source.underWsroot("empty-src"); @@ -105,7 +112,8 @@ public void testDistroMustBeGiven() { } } - public void testIngredientsAndContentDescriptor() { + @Test + public void ingredientsAndContentDescriptor() { Path emptySrc = Source.underWsroot("empty-src"); Path emptyClasses = Source.underWsroot("empty-classes"); Path bin = Source.underWsroot("bin.jar"); @@ -136,7 +144,8 @@ public void testIngredientsAndContentDescriptor() { .contains("i:excludeFile:\n" + " exclude.xml\n")); } - public void testExplicitHtmlOutputFormat() { + @Test + public void explicitHtmlOutputFormat() { Path emptySrc = Source.underWsroot("empty-src"); Path emptyClasses = Source.underWsroot("empty-classes"); Target report = FindbugsReport.with().name("fb-empty") @@ -150,7 +159,8 @@ public void testExplicitHtmlOutputFormat() { report.contentDescriptor().contains("output-format:\n html")); } - public void testContentDescriptorWithXmlOutputFormat() { + @Test + public void contentDescriptorWithXmlOutputFormat() { Path emptySrc = Source.underWsroot("empty-src"); Path emptyClasses = Source.underWsroot("empty-classes"); Target report = FindbugsReport.with().name("fb-empty") @@ -168,7 +178,8 @@ public void testContentDescriptorWithXmlOutputFormat() { + " xml\n" + "", report.contentDescriptor()); } - public void testDefaultReportFromEmptyClasses() throws Exception { + @Test + public void defaultReportFromEmptyClasses() throws Exception { wsRootHasDirectory("empty-src"); wsRootHasDirectory("empty-classes"); Path emptySrc = Source.underWsroot("empty-src"); @@ -188,7 +199,8 @@ public void testDefaultReportFromEmptyClasses() throws Exception { assertEquals("", htmlReportContent); } - public void testReportMentionsIssuesFromTheGivenClassButOnlyIfNotFiltered() + @Test + public void reportMentionsIssuesFromTheGivenClassButOnlyIfNotFiltered() throws Exception { File srcDir = new File(wsRoot, "src"); srcDirHasFindbugsFodder(srcDir, "testfodder", @@ -230,7 +242,8 @@ public void testReportMentionsIssuesFromTheGivenClassButOnlyIfNotFiltered() htmlReportContent(filteredReport).contains(npeWarningSnippet)); } - public void testReportDoesNotDetectProblemIfDependencyNotInAuxclasses() + @Test + public void reportDoesNotDetectProblemIfDependencyNotInAuxclasses() throws Exception { File src1Dir = new File(wsRoot, "src1"); srcDirHasFindbugsFodder(src1Dir, "testfodder", @@ -267,7 +280,8 @@ private static final String warningAboutBugUsingBinaryDependency() { + "nullReferenceOfValueFromBinaryDependency()"; } - public void testReportDetectsProblemIfDependencyIsInAuxclasses() + @Test + public void reportDetectsProblemIfDependencyIsInAuxclasses() throws Exception { File src1Dir = new File(wsRoot, "src1"); srcDirHasFindbugsFodder(src1Dir, "testfodder", @@ -297,8 +311,8 @@ public void testReportDetectsProblemIfDependencyIsInAuxclasses() .contains(warningAboutBugUsingBinaryDependency())); } - public void testReportUsesXmlFormatWhenExplicitlyRequested() - throws Exception { + @Test + public void reportUsesXmlFormatWhenExplicitlyRequested() throws Exception { File srcDir = new File(wsRoot, "src"); srcDirHasFindbugsFodder(srcDir, "testfodder", "ClassWithFindbugsIssues"); @@ -323,8 +337,8 @@ public void testReportUsesXmlFormatWhenExplicitlyRequested() + " name=\"nullReference\"")); } - public void testReportUsesTextFormatWhenExplicitlyRequested() - throws Exception { + @Test + public void reportUsesTextFormatWhenExplicitlyRequested() throws Exception { File srcDir = new File(wsRoot, "src"); srcDirHasFindbugsFodder(srcDir, "testfodder", "ClassWithFindbugsIssues"); @@ -351,7 +365,8 @@ public void testReportUsesTextFormatWhenExplicitlyRequested() + " Dereferenced at ClassWithFindbugsIssues.java:[line 7]\n")); } - public void testModulesToAnalyzeMeansSrcsAnalyzedUsingBins() { + @Test + public void modulesToAnalyzeMeansSrcsAnalyzedUsingBins() { JavaBinModule bin1 = JavaBinModule.providing(Source.underWsroot("bin1")) .end(); diff --git a/optional/iwant-plugin-github/src/test/java/org/fluentjava/iwant/plugin/github/FromGithubTest.java b/optional/iwant-plugin-github/src/test/java/org/fluentjava/iwant/plugin/github/FromGithubTest.java index 10201a8f..1cbedcfe 100644 --- a/optional/iwant-plugin-github/src/test/java/org/fluentjava/iwant/plugin/github/FromGithubTest.java +++ b/optional/iwant-plugin-github/src/test/java/org/fluentjava/iwant/plugin/github/FromGithubTest.java @@ -1,15 +1,17 @@ package org.fluentjava.iwant.plugin.github; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.fluentjava.iwant.api.core.SubPath; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.api.zip.Unzipped; import org.fluentjava.iwant.core.download.Downloaded; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class FromGithubTest extends TestCase { +public class FromGithubTest { - public void testItIsASubPathOfUnzippedDownloaded() { + @Test + public void itIsASubPathOfUnzippedDownloaded() { Target target = FromGithub.user("aUser").project("aProject") .commit("ff"); diff --git a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverageTest.java b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverageTest.java index d3cbf800..429ec216 100644 --- a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverageTest.java +++ b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverageTest.java @@ -1,5 +1,11 @@ package org.fluentjava.iwant.plugin.jacoco; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.List; @@ -11,10 +17,12 @@ import org.fluentjava.iwant.api.model.SystemEnv; import org.fluentjava.iwant.api.model.Target; import org.fluentjava.iwant.entry.Iwant.ExitCalledException; +import org.junit.jupiter.api.Test; public class JacocoCoverageTest extends JacocoTestBase { - public void testParallelismIsDisabledUntilProvenByPracticeItDoesNotCauseProblems() { + @Test + public void parallelismIsDisabledUntilProvenByPracticeItDoesNotCauseProblems() { Path classes = Source.underWsroot("classes"); JacocoInstrumentation instr = JacocoInstrumentation.of(classes) .using(jacoco(), antJar(), antLauncherJar()); @@ -26,7 +34,8 @@ public void testParallelismIsDisabledUntilProvenByPracticeItDoesNotCauseProblems assertFalse(coverage.supportsParallelism()); } - public void testIngredientsAndDescriptorWithMainClassArgsGivenAsStrings() + @Test + public void ingredientsAndDescriptorWithMainClassArgsGivenAsStrings() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Main"); @@ -52,7 +61,8 @@ public void testIngredientsAndDescriptorWithMainClassArgsGivenAsStrings() + "p:jvmargs:\n", coverage.contentDescriptor()); } - public void testIngredientsAndDescriptorWithMainClassArgsGivenAsPath() + @Test + public void ingredientsAndDescriptorWithMainClassArgsGivenAsPath() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Main"); @@ -81,7 +91,8 @@ public void testIngredientsAndDescriptorWithMainClassArgsGivenAsPath() coverage.contentDescriptor()); } - public void testIngredientsAndDescriptorWithJvmArgs() throws Exception { + @Test + public void ingredientsAndDescriptorWithJvmArgs() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Main"); JacocoInstrumentation instr = JacocoInstrumentation @@ -106,7 +117,8 @@ public void testIngredientsAndDescriptorWithJvmArgs() throws Exception { + "p:jvmargs:\n" + " -Xmx1G\n", coverage.contentDescriptor()); } - public void testItProducesTheRequestedExecFile() throws Exception { + @Test + public void itProducesTheRequestedExecFile() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Hello"); JacocoInstrumentation instr = JacocoInstrumentation @@ -128,7 +140,8 @@ public void testItProducesTheRequestedExecFile() throws Exception { /** * We cannot we assert err() because jacoco forks a new jvm process */ - public void testItCallsGivenClassWithArgsGivenAsStrings() throws Exception { + @Test + public void itCallsGivenClassWithArgsGivenAsStrings() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "ArgChecker", "if(!\"[a0, a1]\".equals(" + "java.util.Arrays.toString(args))) System.exit(1);"); @@ -150,7 +163,8 @@ public void testItCallsGivenClassWithArgsGivenAsStrings() throws Exception { /** * We cannot we assert err() because jacoco forks a new jvm process */ - public void testItCallsGivenClassWithArgsGivenAsPath() throws Exception { + @Test + public void itCallsGivenClassWithArgsGivenAsPath() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "ArgChecker", "if(!\"[fa0, fa1]\".equals(" + "java.util.Arrays.toString(args))) System.exit(1);"); @@ -171,7 +185,8 @@ public void testItCallsGivenClassWithArgsGivenAsPath() throws Exception { assertTrue(new File(cached, "coverage.exec").exists()); } - public void testItFailsIfMainClassMakeNonZeroExit() throws Exception { + @Test + public void itFailsIfMainClassMakeNonZeroExit() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Failer", "System.exit(1);"); JacocoInstrumentation instr = JacocoInstrumentation @@ -193,7 +208,8 @@ public void testItFailsIfMainClassMakeNonZeroExit() throws Exception { } - public void testAllClasspathItemsBothInstrumentedAndNonInstrumentedGoToClasspathInTheSpecifiedOrder() + @Test + public void allClasspathItemsBothInstrumentedAndNonInstrumentedGoToClasspathInTheSpecifiedOrder() throws Exception { Path classes1 = Source.underWsroot("classes1"); @@ -221,8 +237,8 @@ public void testAllClasspathItemsBothInstrumentedAndNonInstrumentedGoToClasspath classpath.toString()); } - public void testJvmArgsContainsSaneDefaultsIfNotSpecified() - throws Exception { + @Test + public void jvmArgsContainsSaneDefaultsIfNotSpecified() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Hello"); JacocoInstrumentation instr = JacocoInstrumentation @@ -238,7 +254,8 @@ public void testJvmArgsContainsSaneDefaultsIfNotSpecified() assertEquals("[]", coverage.jvmargs().toString()); } - public void testJvmArgsCanBeCleared() throws Exception { + @Test + public void jvmArgsCanBeCleared() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Hello"); JacocoInstrumentation instr = JacocoInstrumentation @@ -254,7 +271,8 @@ public void testJvmArgsCanBeCleared() throws Exception { assertEquals("[]", coverage.jvmargs().toString()); } - public void testJvmArgsCanBeDefined() throws Exception { + @Test + public void jvmArgsCanBeDefined() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Hello"); JacocoInstrumentation instr = JacocoInstrumentation @@ -270,7 +288,8 @@ public void testJvmArgsCanBeDefined() throws Exception { assertEquals("[jvmarg0, jvmarg1]", coverage.jvmargs().toString()); } - public void testJvmArgsAreUsedInTheAntScriptUnderTmpDir() throws Exception { + @Test + public void jvmArgsAreUsedInTheAntScriptUnderTmpDir() throws Exception { JavaClassesAndSources classesAndSources = newJavaClassesAndSources( "instrtest", "Hello"); JacocoInstrumentation instr = JacocoInstrumentation @@ -298,7 +317,8 @@ public void testJvmArgsAreUsedInTheAntScriptUnderTmpDir() throws Exception { /** * We cannot we assert err() because jacoco forks a new jvm process */ - public void testItCallsGivenClassWithGivenEnvVariables() throws Exception { + @Test + public void itCallsGivenClassWithGivenEnvVariables() throws Exception { Path src = Source.underWsroot("aSrc"); JavaClassesAndSources classesAndSources = newJavaClassesAndSources( @@ -323,7 +343,8 @@ public void testItCallsGivenClassWithGivenEnvVariables() throws Exception { assertTrue(new File(cached, "coverage.exec").exists()); } - public void testEnvIsUsedAsIngredientsAndParameters() { + @Test + public void envIsUsedAsIngredientsAndParameters() { Path pathForEnv = Source.underWsroot("aSrc"); Path classesToInstrument = Source.underWsroot("classes"); diff --git a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoDistributionTest.java b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoDistributionTest.java index f6eb1e5e..05386b89 100644 --- a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoDistributionTest.java +++ b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoDistributionTest.java @@ -1,10 +1,14 @@ package org.fluentjava.iwant.plugin.jacoco; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.core.download.Downloaded; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.Test; public class JacocoDistributionTest extends IwantTestCase { @@ -13,7 +17,8 @@ protected void moreSetUp() { caches.cachesUrlAt(distroToTest().zip().url(), cachedJacocoZip()); } - public void testZipIsADownloadedTargetWithCorrectUrlAndName() { + @Test + public void zipIsADownloadedTargetWithCorrectUrlAndName() { JacocoDistribution distroNewest = distroToTest(); Downloaded zipNewest = distroNewest.zip(); @@ -41,14 +46,16 @@ private static File cachedJacocoZip() { return Iwant.usingRealNetwork().downloaded(distroToTest().zip().url()); } - public void testRealCachedZipExistsAndHasCorrectSize() { + @Test + public void realCachedZipExistsAndHasCorrectSize() { File cachedZip = cachedJacocoZip(); assertTrue(cachedZip.exists()); assertEquals(4007987, cachedZip.length()); } - public void testZipIsAnIngredientAndMentionedInDescriptor() { + @Test + public void zipIsAnIngredientAndMentionedInDescriptor() { JacocoDistribution distro = JacocoDistribution.ofVersion("something"); assertTrue(distro.ingredients().contains(distro.zip())); @@ -60,7 +67,8 @@ private static void assertJarNameAndExistence(String name, File jar) { assertTrue(jar.exists()); } - public void testJarFilesWithCorrectNameAreFoundInsideTheRealDistro() + @Test + public void jarFilesWithCorrectNameAreFoundInsideTheRealDistro() throws Exception { JacocoDistribution distro = distroToTest(); diff --git a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoInstrumentationTest.java b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoInstrumentationTest.java index e851b0d0..0328d295 100644 --- a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoInstrumentationTest.java +++ b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoInstrumentationTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.plugin.jacoco; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import org.apache.commons.io.FileUtils; @@ -7,10 +11,12 @@ import org.fluentjava.iwant.api.javamodules.JavaSrcModule; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.model.Target; +import org.junit.jupiter.api.Test; public class JacocoInstrumentationTest extends JacocoTestBase { - public void testNameIsDerivedFromTheNameOfJavaClassesAndSourcesPair() { + @Test + public void nameIsDerivedFromTheNameOfJavaClassesAndSourcesPair() { assertEquals("one.jacoco-instr", JacocoInstrumentation.of(Source.underWsroot("one")) .using(jacoco(), antJar(), antLauncherJar()).name()); @@ -19,7 +25,8 @@ public void testNameIsDerivedFromTheNameOfJavaClassesAndSourcesPair() { .using(jacoco(), antJar(), antLauncherJar()).name()); } - public void testIngredients() { + @Test + public void ingredients() { assertEquals( "[" + jacoco() + ", " + antJar() + ", " + antLauncherJar() + ", classes]", @@ -28,7 +35,8 @@ public void testIngredients() { .ingredients().toString()); } - public void testContentDescriptor() { + @Test + public void contentDescriptor() { assertEquals( "org.fluentjava.iwant.plugin.jacoco.JacocoInstrumentation\n" + "i:jacoco:\n" + " jacoco-0.8.10\n" + "i:antJars:\n" @@ -39,7 +47,8 @@ public void testContentDescriptor() { .contentDescriptor()); } - public void testInstrumentationCreatesAModifiedClass() throws Exception { + @Test + public void instrumentationCreatesAModifiedClass() throws Exception { wsRootHasFile("src/pak/Foo.java", "package pak;\npublic class Foo {}\n"); JavaClasses classes = JavaClasses.with().name("classes") @@ -58,7 +67,8 @@ public void testInstrumentationCreatesAModifiedClass() throws Exception { assertFalse(FileUtils.contentEquals(originalClass, instrClass)); } - public void testInstrumentationCreatesAModifiedClassAndCopiesResource() + @Test + public void instrumentationCreatesAModifiedClassAndCopiesResource() throws Exception { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .mainResources("res").end(); diff --git a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoReportTest.java b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoReportTest.java index 4add8c51..75323eb9 100644 --- a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoReportTest.java +++ b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoReportTest.java @@ -1,14 +1,19 @@ package org.fluentjava.iwant.plugin.jacoco; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import org.fluentjava.iwant.api.javamodules.JavaClassesAndSources; import org.fluentjava.iwant.api.model.Path; import org.fluentjava.iwant.api.model.Source; +import org.junit.jupiter.api.Test; public class JacocoReportTest extends JacocoTestBase { - public void testIngredientsAndContentDescriptor() { + @Test + public void ingredientsAndContentDescriptor() { Path classes = Source.underWsroot("theclasses"); Path sources = Source.underWsroot("thesources"); JacocoCoverage coverage = JacocoCoverage.with().name("thecoverage") @@ -30,8 +35,8 @@ public void testIngredientsAndContentDescriptor() { report.contentDescriptor()); } - public void testReportWithNoncoveredAndPartlyCoveredModule() - throws Exception { + @Test + public void reportWithNoncoveredAndPartlyCoveredModule() throws Exception { JavaClassesAndSources badTest = newJavaClassesAndSources("badtest", "BadTest", "System.err.println(\"This test covers nothing.\");"); diff --git a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoTargetsOfJavaModulesTest.java b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoTargetsOfJavaModulesTest.java index 7f63a282..3673ea02 100644 --- a/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoTargetsOfJavaModulesTest.java +++ b/optional/iwant-plugin-jacoco/src/test/java/org/fluentjava/iwant/plugin/jacoco/JacocoTargetsOfJavaModulesTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.plugin.jacoco; +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 java.io.File; import org.fluentjava.iwant.api.core.ClassNameList; @@ -10,10 +14,12 @@ import org.fluentjava.iwant.api.model.StringFilter; import org.fluentjava.iwant.api.model.SystemEnv; import org.fluentjava.iwant.api.model.Target; +import org.junit.jupiter.api.Test; public class JacocoTargetsOfJavaModulesTest extends JacocoTestBase { - public void testTargetsFromOneMinimalTestlessModule() { + @Test + public void targetsFromOneMinimalTestlessModule() { JavaSrcModule mod = JavaSrcModule.with().name("mod").mainJava("src") .end(); @@ -42,7 +48,8 @@ public void testTargetsFromOneMinimalTestlessModule() { report.contentDescriptor()); } - public void testReportName() { + @Test + public void reportName() { JavaSrcModule mod = JavaSrcModule.with().name("mod").end(); JacocoTargetsOfJavaModules jacocoTargets = JacocoTargetsOfJavaModules .with().jacoco(jacoco()).antJars(antJar(), antLauncherJar()) @@ -52,7 +59,8 @@ public void testReportName() { assertEquals("name2", jacocoTargets.jacocoReport("name2").name()); } - public void testTargetsFromOneMinimalCodelessModule() { + @Test + public void targetsFromOneMinimalCodelessModule() { JavaSrcModule mod = JavaSrcModule.with().name("mod").end(); JacocoTargetsOfJavaModules jacocoTargets = JacocoTargetsOfJavaModules @@ -71,7 +79,8 @@ public void testTargetsFromOneMinimalCodelessModule() { report.contentDescriptor()); } - public void testTargetsFromOneMinimalTestOnlyModule() { + @Test + public void targetsFromOneMinimalTestOnlyModule() { JavaSrcModule mod = JavaSrcModule.with().name("mod").testJava("test") .end(); @@ -100,7 +109,8 @@ public void testTargetsFromOneMinimalTestOnlyModule() { + "i:sources:\n" + "", report.contentDescriptor()); } - public void testTargetsFromOneBinaryModule() { + @Test + public void targetsFromOneBinaryModule() { JavaBinModule mod = JavaBinModule.providing(Source.underWsroot("lib")) .end(); @@ -120,7 +130,8 @@ public void testTargetsFromOneBinaryModule() { report.contentDescriptor()); } - public void testCoverageArgsForJunitIsClassNameListUnlessOnlyOneTestDefined() { + @Test + public void coverageArgsForJunitIsClassNameListUnlessOnlyOneTestDefined() { JavaSrcModule testedByOneClass = JavaSrcModule.with() .name("testedByOneClass").testJava("test") .testedBy("custom.Test").end(); @@ -165,7 +176,8 @@ public String toString() { testNames.contentDescriptor()); } - public void testCoverageOfJavaSrcModuleWithCumulativeDeps() { + @Test + public void coverageOfJavaSrcModuleWithCumulativeDeps() { JavaBinModule bin1 = JavaBinModule.providing(Source.underWsroot("bin1")) .end(); JavaSrcModule src1 = JavaSrcModule.with().name("src1").mainJava("src") @@ -196,7 +208,8 @@ public void testCoverageOfJavaSrcModuleWithCumulativeDeps() { coverage.classLocations().toString()); } - public void testCoverageOfSubsetOfSrcModulesWithDepToModuleOutsideTheSubset() + @Test + public void coverageOfSubsetOfSrcModulesWithDepToModuleOutsideTheSubset() throws Exception { JavaSrcModule uninteresting = JavaSrcModule.with().name("uninteresting") .mainJava("src").end(); @@ -248,7 +261,8 @@ public void testCoverageOfSubsetOfSrcModulesWithDepToModuleOutsideTheSubset() contentOf(new File(ctx.cached(report), "report.csv"))); } - public void testJacocoCoverageUsesModulesTestEnv() { + @Test + public void jacocoCoverageUsesModulesTestEnv() { SystemEnv env = SystemEnv.with().string("a", "a1") .path("b", Source.underWsroot("b")).end(); JavaSrcModule mod = JavaSrcModule.with().name("mod").testJava("test") @@ -263,7 +277,8 @@ public void testJacocoCoverageUsesModulesTestEnv() { assertSame(env, coverage.env()); } - public void testOwnJunitRunnerIsUsedForCoverageByDefault() { + @Test + public void ownJunitRunnerIsUsedForCoverageByDefault() { JavaSrcModule mod = JavaSrcModule.with().name("mod").testJava("test") .end(); @@ -276,7 +291,8 @@ public void testOwnJunitRunnerIsUsedForCoverageByDefault() { coverage.mainClassName()); } - public void testCustomTestRunnerIsUsedForCoverage() { + @Test + public void customTestRunnerIsUsedForCoverage() { class CustomRunner implements TestRunner { @Override public String mainClassName() { diff --git a/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/CopyPasteReportTest.java b/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/CopyPasteReportTest.java index 5b862150..0fedb386 100644 --- a/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/CopyPasteReportTest.java +++ b/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/CopyPasteReportTest.java @@ -1,15 +1,22 @@ package org.fluentjava.iwant.plugin.pmd; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import org.fluentjava.iwant.api.model.Path; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.entry.Iwant.IwantException; +import org.junit.jupiter.api.Test; public class CopyPasteReportTest extends PmdTestBase { - public void testSourceDirectoriesAreIngredients() { + @Test + public void sourceDirectoriesAreIngredients() { Path src1 = Source.underWsroot("src1"); Path src2 = Source.underWsroot("src2"); @@ -20,7 +27,8 @@ public void testSourceDirectoriesAreIngredients() { assertTrue(report.ingredients().contains(src2)); } - public void testSourceDirectoriesAreInContentDescriptor() { + @Test + public void sourceDirectoriesAreInContentDescriptor() { Path src1 = Source.underWsroot("src-one"); Path src2 = Source.underWsroot("src-two"); @@ -31,7 +39,8 @@ public void testSourceDirectoriesAreInContentDescriptor() { assertTrue(report.contentDescriptor().contains(src2.name())); } - public void testMinimumTokenCountIsInContentDescriptor() { + @Test + public void minimumTokenCountIsInContentDescriptor() { Path src = Source.underWsroot("src"); assertTrue(CopyPasteReport.with().name("report-10").from(src).end() @@ -41,7 +50,8 @@ public void testMinimumTokenCountIsInContentDescriptor() { .contains("minimumTokenCount:\n 150\n")); } - public void testReportOfZeroSrcDirectoriesIsAnError() throws Exception { + @Test + public void reportOfZeroSrcDirectoriesIsAnError() throws Exception { File srcDir = new File(wsRoot, "src"); Iwant.mkdirs(srcDir); @@ -57,7 +67,8 @@ public void testReportOfZeroSrcDirectoriesIsAnError() throws Exception { assertNull(txtReportContent(report)); } - public void testReportOfEmptySrcDirectoryDoesProducesAnEmptyReportFile() + @Test + public void reportOfEmptySrcDirectoryDoesProducesAnEmptyReportFile() throws Exception { File srcDir = new File(wsRoot, "src"); Iwant.mkdirs(srcDir); @@ -69,7 +80,8 @@ public void testReportOfEmptySrcDirectoryDoesProducesAnEmptyReportFile() assertEquals("", txtReportContent(report)); } - public void testReportOfTwoSrcDirectoriesIsEmptyWhenMinimumTokenCountIsUndefined() + @Test + public void reportOfTwoSrcDirectoriesIsEmptyWhenMinimumTokenCountIsUndefined() throws Exception { File src1 = new File(wsRoot, "src1"); srcDirHasPmdFodder(src1, "testfodder", "ClassWithPmdIssues"); @@ -86,7 +98,8 @@ public void testReportOfTwoSrcDirectoriesIsEmptyWhenMinimumTokenCountIsUndefined assertEquals("", txtReportContent); } - public void testReportOfTwoSrcDirectoriesMentionsRedundancyWhenMinimumTokenCountIsLow() + @Test + public void reportOfTwoSrcDirectoriesMentionsRedundancyWhenMinimumTokenCountIsLow() throws Exception { File src1 = new File(wsRoot, "src1"); srcDirHasPmdFodder(src1, "testfodder", "ClassWithPmdIssues"); @@ -104,7 +117,8 @@ public void testReportOfTwoSrcDirectoriesMentionsRedundancyWhenMinimumTokenCount .contains("Found a 9 line (14 tokens) duplication")); } - public void testReportOfTwoSrcDirectoriesIsEmptyWhenMinimumTokenCountIsHigh() + @Test + public void reportOfTwoSrcDirectoriesIsEmptyWhenMinimumTokenCountIsHigh() throws Exception { File src1 = new File(wsRoot, "src1"); srcDirHasPmdFodder(src1, "testfodder", "ClassWithPmdIssues"); diff --git a/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdReportTest.java b/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdReportTest.java index 363fca6e..67543317 100644 --- a/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdReportTest.java +++ b/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdReportTest.java @@ -1,5 +1,9 @@ package org.fluentjava.iwant.plugin.pmd; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.File; import java.io.IOException; @@ -7,6 +11,7 @@ import org.fluentjava.iwant.api.model.Path; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.Test; public class PmdReportTest extends PmdTestBase { @@ -18,7 +23,8 @@ private String htmlReportContent(PmdReport report) throws IOException { // the tests // ----------------------------------------------------- - public void testSourceDirectoriesAreIngredients() { + @Test + public void sourceDirectoriesAreIngredients() { Path src1 = Source.underWsroot("src1"); Path src2 = Source.underWsroot("src2"); @@ -29,7 +35,8 @@ public void testSourceDirectoriesAreIngredients() { assertTrue(report.ingredients().contains(src2)); } - public void testSourceDirectoriesAreInContentDescriptor() { + @Test + public void sourceDirectoriesAreInContentDescriptor() { Path src1 = Source.underWsroot("src-one"); Path src2 = Source.underWsroot("src-two"); @@ -40,7 +47,8 @@ public void testSourceDirectoriesAreInContentDescriptor() { assertTrue(report.contentDescriptor().contains(src2.name())); } - public void testRulesetIsInIngredientsIffDefined() { + @Test + public void rulesetIsInIngredientsIffDefined() { Path src = Source.underWsroot("src"); Path rules = Source.underWsroot("rules.xml"); @@ -51,7 +59,8 @@ public void testRulesetIsInIngredientsIffDefined() { .ingredients().toString()); } - public void testReportOfZeroSrcDirectoriesProducesReportFiles() + @Test + public void reportOfZeroSrcDirectoriesProducesReportFiles() throws Exception { File srcDir = new File(wsRoot, "src"); Iwant.mkdirs(srcDir); @@ -63,7 +72,8 @@ public void testReportOfZeroSrcDirectoriesProducesReportFiles() assertTrue(txtReportContent(report).length() == 0); } - public void testReportOfEmptySrcDirectoryProducesReportFiles() + @Test + public void reportOfEmptySrcDirectoryProducesReportFiles() throws Exception { File srcDir = new File(wsRoot, "src"); Iwant.mkdirs(srcDir); @@ -76,7 +86,8 @@ public void testReportOfEmptySrcDirectoryProducesReportFiles() assertTrue(txtReportContent(report).length() == 0); } - public void testAllReportFormatsOfOneClassesDirWithOneClassWithIssues() + @Test + public void allReportFormatsOfOneClassesDirWithOneClassWithIssues() throws Exception { File srcDir = new File(wsRoot, "src"); srcDirHasPmdFodder(srcDir, "testfodder", "ClassWithPmdIssues"); @@ -112,7 +123,8 @@ public void testAllReportFormatsOfOneClassesDirWithOneClassWithIssues() + " method=\"methodThatWritesParameter\"")); } - public void testReportOnlyContainsIssuesDefinedInGivenRulesPath() + @Test + public void reportOnlyContainsIssuesDefinedInGivenRulesPath() throws Exception { File srcDir = new File(wsRoot, "src"); srcDirHasPmdFodder(srcDir, "testfodder", "ClassWithPmdIssues"); diff --git a/optional/iwant-plugin-war/src/test/java/org/fluentjava/iwant/plugin/war/WarTest.java b/optional/iwant-plugin-war/src/test/java/org/fluentjava/iwant/plugin/war/WarTest.java index e0f6ca2b..7a5d947a 100644 --- a/optional/iwant-plugin-war/src/test/java/org/fluentjava/iwant/plugin/war/WarTest.java +++ b/optional/iwant-plugin-war/src/test/java/org/fluentjava/iwant/plugin/war/WarTest.java @@ -1,11 +1,15 @@ package org.fluentjava.iwant.plugin.war; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + import java.io.File; import org.fluentjava.iwant.api.model.Source; import org.fluentjava.iwant.api.zip.Unzipped; import org.fluentjava.iwant.apimocks.IwantTestCase; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.Test; public class WarTest extends IwantTestCase { @@ -26,7 +30,8 @@ private Source sourceWithContent(String path, String content) { // the tests // ------------------ - public void testIngredientsAndDescriptorOfMinimalWar() { + @Test + public void ingredientsAndDescriptorOfMinimalWar() { War war = War.with().name("test.war") .basedir(Source.underWsroot("empty-basedir")) .webXml(Source.underWsroot("web.xml")).end(); @@ -39,7 +44,8 @@ public void testIngredientsAndDescriptorOfMinimalWar() { assertEquals("[empty-basedir, web.xml]", war.ingredients().toString()); } - public void testIngredientsAndDescriptorOfWarWithFullFeatures() { + @Test + public void ingredientsAndDescriptorOfWarWithFullFeatures() { War war = War.with().name("test.war") .basedir(Source.underWsroot("empty-basedir")) .exclude("exclude1", "exclude2") @@ -64,7 +70,8 @@ public void testIngredientsAndDescriptorOfWarWithFullFeatures() { war.ingredients().toString()); } - public void testExplicitWebXml() throws Exception { + @Test + public void explicitWebXml() throws Exception { Source webXml = sourceWithContent("constant-web.xml", "web.xml content"); File baseDir = new File(wsRoot, "empty-basedir"); @@ -81,7 +88,8 @@ public void testExplicitWebXml() throws Exception { contentOf(new File(tmp, "WEB-INF/web.xml"))); } - public void testWebXmlUnderGivenDirectory() throws Exception { + @Test + public void webXmlUnderGivenDirectory() throws Exception { File generatedConfs = new File(wsRoot, "generated-confs"); Iwant.mkdirs(generatedConfs); Iwant.newTextFile(new File(generatedConfs, "generated-web.xml"), @@ -102,7 +110,8 @@ public void testWebXmlUnderGivenDirectory() throws Exception { contentOf(new File(tmp, "WEB-INF/web.xml"))); } - public void testNonEmptyBasedirWithFilesToExclude() throws Exception { + @Test + public void nonEmptyBasedirWithFilesToExclude() throws Exception { File web = new File(wsRoot, "web"); Iwant.mkdirs(web); Iwant.newTextFile(new File(web, "index.html"), "index.html content"); @@ -135,7 +144,8 @@ public void testNonEmptyBasedirWithFilesToExclude() throws Exception { assertFalse(new File(tmp, "subdir/another-file-to-exclude").exists()); } - public void testWarWithClassesLibsAndResources() throws Exception { + @Test + public void warWithClassesLibsAndResources() throws Exception { File baseDir = new File(wsRoot, "basedir"); Iwant.mkdirs(baseDir); Source webXml = sourceWithContent("web.xml", "web.xml content"); diff --git a/private/iwant-apimocks/src/main/java/org/fluentjava/iwant/apimocks/IwantTestCase.java b/private/iwant-apimocks/src/main/java/org/fluentjava/iwant/apimocks/IwantTestCase.java index 90ef17ca..959e80a2 100644 --- a/private/iwant-apimocks/src/main/java/org/fluentjava/iwant/apimocks/IwantTestCase.java +++ b/private/iwant-apimocks/src/main/java/org/fluentjava/iwant/apimocks/IwantTestCase.java @@ -13,10 +13,10 @@ import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; -import junit.framework.TestCase; - -public abstract class IwantTestCase extends TestCase { +public abstract class IwantTestCase { private IwantMockEnvironment e; private TestArea testArea; @@ -31,8 +31,8 @@ public abstract class IwantTestCase extends TestCase { private Iwant iwant; private IwantCoreServices realCoreServices; - @Override - public final void setUp() throws Exception { + @BeforeEach + public final void before() throws Exception { e = IwantMockEnvironment.forTest(this).end(); testArea = e.testArea(); wsRoot = e.wsRoot(); @@ -56,7 +56,7 @@ protected void moreSetUp() throws Exception { // override if needed } - @Override + @AfterEach public final void tearDown() throws Exception { if (captureOn) { restoreSystemOutAndErr(); diff --git a/private/iwant-docs/backlog.txt b/private/iwant-docs/backlog.txt index 9168fddf..466a2f17 100644 --- a/private/iwant-docs/backlog.txt +++ b/private/iwant-docs/backlog.txt @@ -6,9 +6,9 @@ - change each mod eclipse conf (manually) to run with junit5, convert at least 1 test to 5 - 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 + + convert all tests to junit 5 + 4 - - 3 + + 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 diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/DownloadingTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/DownloadingTest.java index 66145467..76fba23d 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/DownloadingTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/DownloadingTest.java @@ -1,5 +1,7 @@ package org.fluentjava.iwant.entry.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.File; import java.net.URL; @@ -7,17 +9,17 @@ import org.fluentjava.iwant.entry.Iwant.UnmodifiableUrl; import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class DownloadingTest extends TestCase { +public class DownloadingTest { private TestArea testArea; private IwantNetworkMock network; private Iwant iwant; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); network = new IwantNetworkMock(testArea); iwant = Iwant.using(network); @@ -35,7 +37,8 @@ private File remoteFileContains(String path, String content) { return remoteFile; } - public void testCachedFileIsReturnedWithoutDownloadingIfItExists() { + @Test + public void cachedFileIsReturnedWithoutDownloadingIfItExists() { URL url = Iwant.fileToUrl(new File(testArea.root(), "non-existent-so-impossible-to-download")); network.cachesUrlAt(url, "url"); @@ -46,7 +49,8 @@ public void testCachedFileIsReturnedWithoutDownloadingIfItExists() { assertEquals("cached-content", testArea.contentOf(cached)); } - public void testFileIsDownloadedToCacheDoesNotExist() { + @Test + public void fileIsDownloadedToCacheDoesNotExist() { File remoteFile = remoteFileContains("remote", "remote-content"); URL remoteUrl = Iwant.fileToUrl(remoteFile); network.cachesUrlAt(remoteUrl, "cached-remote"); @@ -56,7 +60,8 @@ public void testFileIsDownloadedToCacheDoesNotExist() { assertEquals("remote-content", testArea.contentOf(cached)); } - public void testFileIsSuccessfullyDownloadedEvenIfCacheParentDirDoesNotExist() { + @Test + public void fileIsSuccessfullyDownloadedEvenIfCacheParentDirDoesNotExist() { File remoteFile = remoteFileContains("remote", "remote-content"); URL remoteUrl = Iwant.fileToUrl(remoteFile); network.cachesUrlAt(remoteUrl, "cached/remote"); diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/FilenameEscapingTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/FilenameEscapingTest.java index cb0f4d37..ad8950d5 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/FilenameEscapingTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/FilenameEscapingTest.java @@ -1,25 +1,26 @@ package org.fluentjava.iwant.entry.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.File; import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class FilenameEscapingTest extends TestCase { +public class FilenameEscapingTest { private String origSeparator; - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void before() throws Exception { origSeparator = File.separator; } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void after() throws Exception { setSeparator(origSeparator); - super.tearDown(); } private static void setSeparator(String separator) { @@ -38,29 +39,34 @@ private static void escapeCase(String orig, String onUnix, assertEquals(onWindows, Iwant.toSafeFilename(orig)); } - public void testTrivialCases() { + @Test + public void trivialCases() { escapeCase("", ""); escapeCase("abc", "abc"); escapeCase("A1", "A1"); } - public void testCharsThatDefinitelyNeedEscaping() { + @Test + public void charsThatDefinitelyNeedEscaping() { escapeCase("a:b", "a%3Ab"); } - public void testCharsThatAreMoreRobustEscaped() { + @Test + public void charsThatAreMoreRobustEscaped() { escapeCase("a b", "a+b"); escapeCase("a+b", "a%2Bb"); escapeCase("a'b", "a%27b"); escapeCase("a\"b", "a%22b"); } - public void testLoneSlashWithoutParentDirRefIsNotEscaped() { + @Test + public void loneSlashWithoutParentDirRefIsNotEscaped() { escapeCase("a/b", "a/b", "a\\b"); escapeCase("abc/def/gef", "abc/def/gef", "abc\\def\\gef"); } - public void testLoneBackslashWithoutParentDirRefIsNotEscaped() { + @Test + public void loneBackslashWithoutParentDirRefIsNotEscaped() { escapeCase("a\\b", "a%5Cb", "a\\b"); escapeCase("abc\\def\\gef", "abc%5Cdef%5Cgef", "abc\\def\\gef"); } @@ -69,23 +75,27 @@ public void testLoneBackslashWithoutParentDirRefIsNotEscaped() { * Some safety agains accidents (build tools are omnipotent so no real * security tried here) */ - public void testParentDirRefIsEscaped() { + @Test + public void parentDirRefIsEscaped() { escapeCase("../b", "..%2Fb"); escapeCase("a/..", "a%2F.."); escapeCase("a/../b", "a%2F..%2Fb"); } - public void testStartingSlashIsEscaped() { + @Test + public void startingSlashIsEscaped() { escapeCase("/a", "%2Fa"); escapeCase("//a", "%2F/a", "%2F\\a"); } - public void testStartingBackslashIsEscapedButDifferentlyOnWindows() { + @Test + public void startingBackslashIsEscapedButDifferentlyOnWindows() { escapeCase("\\a", "%5Ca", "%2Fa"); escapeCase("\\\\a", "%5C%5Ca", "%2F\\a"); } - public void testTwoOrMoreSlashesAreEscaped() { + @Test + public void twoOrMoreSlashesAreEscaped() { escapeCase("a//b", "a/%2Fb", "a\\%2Fb"); escapeCase("a\\\\b", "a%5C%5Cb", "a\\%2Fb"); @@ -96,18 +106,21 @@ public void testTwoOrMoreSlashesAreEscaped() { escapeCase("a\\\\\\\\b", "a%5C%5C%5C%5Cb", "a\\%2F\\%2Fb"); } - public void testNontrivialCharsThatAreSafeAndMoreReadableToLeaveUnescaped() { + @Test + public void nontrivialCharsThatAreSafeAndMoreReadableToLeaveUnescaped() { escapeCase("a-b", "a-b"); escapeCase("a?b", "a?b"); } - public void testARealisticWindowsPathExample() { + @Test + public void aRealisticWindowsPathExample() { escapeCase("c:\\Documents and Settings\\slave", "c%3A%5CDocuments+and+Settings%5Cslave", "c%3A\\Documents+and+Settings\\slave"); } - public void testARealisticWindowsMingwPathExampleWithMixedSeparators() { + @Test + public void aRealisticWindowsMingwPathExampleWithMixedSeparators() { escapeCase("c:\\Documents and Settings\\and/forward/slashes", "c%3A%5CDocuments+and+Settings%5Cand/forward/slashes", "c%3A\\Documents+and+Settings\\and\\forward\\slashes"); diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/HttpProxyInitializationTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/HttpProxyInitializationTest.java index 5c1dab2b..41d161c3 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/HttpProxyInitializationTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/HttpProxyInitializationTest.java @@ -1,10 +1,14 @@ package org.fluentjava.iwant.entry.tests; -import org.fluentjava.iwant.entry.Iwant; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; -import junit.framework.TestCase; +import org.fluentjava.iwant.entry.Iwant; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class HttpProxyInitializationTest extends TestCase { +public class HttpProxyInitializationTest { private static final String H_KEY = "http.proxyHost"; private static final String P_KEY = "http.proxyPort"; @@ -16,16 +20,16 @@ public class HttpProxyInitializationTest extends TestCase { private String originalSH; private String originalSP; - @Override - public void setUp() { + @BeforeEach + public void before() { originalH = System.getProperty(H_KEY); originalP = System.getProperty(P_KEY); originalSH = System.getProperty(SH_KEY); originalSP = System.getProperty(SP_KEY); } - @Override - public void tearDown() { + @AfterEach + public void after() { restore(H_KEY, originalH); restore(P_KEY, originalP); restore(SH_KEY, originalSH); @@ -51,17 +55,20 @@ private static void assertJavaSettings(String httpProxyHost, // the tests - public void testNullValues() { + @Test + public void nullValues() { Iwant.unixHttpProxyToJavaHttpProxy(null, null); assertJavaSettings(null, null, null, null); } - public void testEmptyValues() { + @Test + public void emptyValues() { Iwant.unixHttpProxyToJavaHttpProxy("", ""); assertJavaSettings(null, null, null, null); } - public void testHttpProxyThatIsInvalidUrlOnlyAHostName() { + @Test + public void httpProxyThatIsInvalidUrlOnlyAHostName() { try { Iwant.unixHttpProxyToJavaHttpProxy("http-proxy-host", ""); fail(); @@ -70,23 +77,27 @@ public void testHttpProxyThatIsInvalidUrlOnlyAHostName() { } } - public void testHttpProxyHost() { + @Test + public void httpProxyHost() { Iwant.unixHttpProxyToJavaHttpProxy("http://http-proxy-host", ""); assertJavaSettings("http-proxy-host", null, null, null); } - public void testHttpProxyHostAndPort() { + @Test + public void httpProxyHostAndPort() { Iwant.unixHttpProxyToJavaHttpProxy("http://http-proxy-host:8080", ""); assertJavaSettings("http-proxy-host", "8080", null, null); } - public void testHttpProxyHostAndPortAndHttpsProxyHost() { + @Test + public void httpProxyHostAndPortAndHttpsProxyHost() { Iwant.unixHttpProxyToJavaHttpProxy("http://http-proxy-host:8080", "http://https-proxy-host"); assertJavaSettings("http-proxy-host", "8080", "https-proxy-host", null); } - public void testHttpProxyHostAndPortAndHttpsProxyHostAndPort() { + @Test + public void httpProxyHostAndPortAndHttpsProxyHostAndPort() { Iwant.unixHttpProxyToJavaHttpProxy("http://http-proxy-host:8080", "http://https-proxy-host:8081"); assertJavaSettings("http-proxy-host", "8080", "https-proxy-host", diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/IwantTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/IwantTest.java index 5b8b2f14..7e36812e 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/IwantTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/IwantTest.java @@ -1,5 +1,10 @@ package org.fluentjava.iwant.entry.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -16,10 +21,11 @@ import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.iwantwsrootfinder.IwantWsRootFinder; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class IwantTest extends TestCase { +public class IwantTest { private static final String LINE_SEPARATOR_KEY = "line.separator"; @@ -42,8 +48,8 @@ public class IwantTest extends TestCase { /** * TODO a reusable main-method testing tools project */ - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); origSecman = System.getSecurityManager(); System.setSecurityManager(new ExitCatcher()); @@ -90,8 +96,8 @@ public void checkExit(int status) { } - @Override - public void tearDown() { + @AfterEach + public void after() { System.setSecurityManager(origSecman); System.setIn(originalIn); System.setOut(originalOut); @@ -129,7 +135,8 @@ private File mockWsRootZip() { } } - public void testMainFailsAndExitsIfGivenZeroArguments() throws Exception { + @Test + public void mainFailsAndExitsIfGivenZeroArguments() throws Exception { try { Iwant.main(new String[] {}); fail(); @@ -142,7 +149,8 @@ public void testMainFailsAndExitsIfGivenZeroArguments() throws Exception { err()); } - public void testMainFailsAndExitsIfGivenAsSomeoneDoesNotExist() + @Test + public void mainFailsAndExitsIfGivenAsSomeoneDoesNotExist() throws Exception { try { Iwant.main(new String[] { testArea.root() + "/as-missing" }); @@ -155,7 +163,8 @@ public void testMainFailsAndExitsIfGivenAsSomeoneDoesNotExist() + "/as-missing\n", err()); } - public void testMainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist() + @Test + public void mainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist() throws Exception { File asSomeone = testArea.newDir("as-test"); try { @@ -176,7 +185,8 @@ public void testMainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist() testArea.contentOf("as-test/i-have/conf/iwant-from")); } - public void testMainCreatesIwantFromAndPrintsHelpIfIwantFromDoesNotExist() + @Test + public void mainCreatesIwantFromAndPrintsHelpIfIwantFromDoesNotExist() throws Exception { File asSomeone = testArea.newDir("as-test"); testArea.newDir("as-test/i-have"); @@ -198,9 +208,10 @@ public void testMainCreatesIwantFromAndPrintsHelpIfIwantFromDoesNotExist() testArea.contentOf("as-test/i-have/conf/iwant-from")); } - public void testUserGetsFriendlyErrorIfRerunsIwantWithoutEditingIwantFrom() + @Test + public void userGetsFriendlyErrorIfRerunsIwantWithoutEditingIwantFrom() throws Exception { - testMainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist(); + mainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist(); startOfOutAndErrCapture(); File asSomeone = testArea.newDir("as-test"); @@ -216,9 +227,10 @@ public void testUserGetsFriendlyErrorIfRerunsIwantWithoutEditingIwantFrom() + Iwant.EXAMPLE_IWANT_FROM_CONTENT + "\n", err()); } - public void testUserGetsFriendlyErrorIfIwantFromFileDoesNotSpecifyIwantFrom() + @Test + public void userGetsFriendlyErrorIfIwantFromFileDoesNotSpecifyIwantFrom() throws Exception { - testMainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist(); + mainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist(); startOfOutAndErrCapture(); File asSomeone = testArea.newDir("as-test"); @@ -236,9 +248,10 @@ public void testUserGetsFriendlyErrorIfIwantFromFileDoesNotSpecifyIwantFrom() + Iwant.EXAMPLE_IWANT_FROM_CONTENT + "\n", err()); } - public void testUserGetsFriendlyErrorIfIwantFromFileContainsInvalidIwantFromUrl() + @Test + public void userGetsFriendlyErrorIfIwantFromFileContainsInvalidIwantFromUrl() throws Exception { - testMainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist(); + mainCreatesIwantFromAndPrintsHelpIfIHaveDoesNotExist(); startOfOutAndErrCapture(); File asSomeone = testArea.newDir("as-test"); @@ -257,7 +270,8 @@ public void testUserGetsFriendlyErrorIfIwantFromFileContainsInvalidIwantFromUrl( + Iwant.EXAMPLE_IWANT_FROM_CONTENT + "\n", err()); } - public void testIwantSourceZipIsAcquiredWhenItDoesntExist() { + @Test + public void iwantSourceZipIsAcquiredWhenItDoesntExist() { File asSomeone = testArea.newDir("as-test"); File iHaveConf = testArea.newDir("as-test/i-have/conf"); File iwantZip = mockWsRootZip(); @@ -275,7 +289,8 @@ public void testIwantSourceZipIsAcquiredWhenItDoesntExist() { testArea.contentOf(cachedIwantZip)); } - public void testIwantSourceIsAcquiredWhenItDoesntExist() { + @Test + public void iwantSourceIsAcquiredWhenItDoesntExist() { File asSomeone = testArea.newDir("as-test"); File iHaveConf = testArea.newDir("as-test/i-have/conf"); File iwantZip = mockWsRootZip(); @@ -301,7 +316,8 @@ public void testIwantSourceIsAcquiredWhenItDoesntExist() { new File(cachedIwantSrc, "essential/iwant-api-bash").exists()); } - public void testIwantBootstrapsWhenNothingHasBeenDownloadedAndJustIwantFromFileIsGiven() + @Test + public void iwantBootstrapsWhenNothingHasBeenDownloadedAndJustIwantFromFileIsGiven() throws Exception { File asSomeone = testArea.newDir("as-test"); File iHaveConf = testArea.newDir("as-test/i-have/conf"); @@ -333,7 +349,8 @@ public void testIwantBootstrapsWhenNothingHasBeenDownloadedAndJustIwantFromFileI assertTrue(err().endsWith("And syserr message from mocked entry2\n")); } - public void testTrailingSlashRemoval() { + @Test + public void trailingSlashRemoval() { assertEquals("", Iwant.withoutTrailingSlash("")); assertEquals("", Iwant.withoutTrailingSlash("/")); assertEquals("a", Iwant.withoutTrailingSlash("a")); @@ -346,7 +363,8 @@ public void testTrailingSlashRemoval() { * File to uri to url ends with slash iff dir exists so it's too random for * us */ - public void testFileToUrlNeverEndsInSlashRegardlessOfExistenceOfFile() { + @Test + public void fileToUrlNeverEndsInSlashRegardlessOfExistenceOfFile() { File dir = new File(testArea.root(), "dir"); UnmodifiableIwantBootstrapperClassesFromIwantWsRoot without = new UnmodifiableIwantBootstrapperClassesFromIwantWsRoot( dir); @@ -360,7 +378,8 @@ public void testFileToUrlNeverEndsInSlashRegardlessOfExistenceOfFile() { /** * This happens when JRE is used instead of JDK */ - public void testIwantGivesNiceErrorMessageIfSystemJavaCompilerIsNotFound() + @Test + public void iwantGivesNiceErrorMessageIfSystemJavaCompilerIsNotFound() throws Exception { File asSomeone = testArea.newDir("as-test"); File iHaveConf = testArea.newDir("as-test/i-have/conf"); @@ -394,7 +413,8 @@ public void testIwantGivesNiceErrorMessageIfSystemJavaCompilerIsNotFound() } } - public void testBootstrapperIsNotCompiledIfNotNecessary() throws Exception { + @Test + public void bootstrapperIsNotCompiledIfNotNecessary() throws Exception { Iwant.fileLog("Starting testBootstrapperIsNotCompiledIfNotNecessary"); File asSomeone = testArea.newDir("as-test"); File iHaveConf = testArea.newDir("as-test/i-have/conf"); @@ -434,7 +454,8 @@ public void testBootstrapperIsNotCompiledIfNotNecessary() throws Exception { assertEquals(t1, t2); } - public void testMkdirsCreatesDirectoryWithParent() { + @Test + public void mkdirsCreatesDirectoryWithParent() { File dir = new File(testArea.root(), "a/b"); Iwant.mkdirs(dir); @@ -442,7 +463,8 @@ public void testMkdirsCreatesDirectoryWithParent() { assertTrue(dir.isDirectory()); } - public void testMkdirsIsOkForExistentDirectory() { + @Test + public void mkdirsIsOkForExistentDirectory() { File dir = new File(testArea.root(), "a/b"); Iwant.mkdirs(dir); Iwant.mkdirs(dir); @@ -451,7 +473,8 @@ public void testMkdirsIsOkForExistentDirectory() { assertTrue(dir.isDirectory()); } - public void testMkdirsThrowsAndRefusesToTouchExistingNonDir() { + @Test + public void mkdirsThrowsAndRefusesToTouchExistingNonDir() { File nondir = testArea.hasFile("nondir", "anything"); try { @@ -464,7 +487,8 @@ public void testMkdirsThrowsAndRefusesToTouchExistingNonDir() { } } - public void testMkdirsThrowsIfNoPermissions() { + @Test + public void mkdirsThrowsIfNoPermissions() { File parent = testArea.newDir("parent"); File dir = new File(parent, "a/b"); @@ -482,7 +506,8 @@ public void testMkdirsThrowsIfNoPermissions() { } } - public void testDelDeletesEvenANonEmptyDirectory() { + @Test + public void delDeletesEvenANonEmptyDirectory() { File dirToDelete = testArea.newDir("dir"); testArea.hasFile("dir/file", "anything"); @@ -491,7 +516,8 @@ public void testDelDeletesEvenANonEmptyDirectory() { assertFalse(dirToDelete.exists()); } - public void testDelDoesNotComplainAboutNonexistentFile() { + @Test + public void delDoesNotComplainAboutNonexistentFile() { File nonexistent = new File(testArea.root(), "nonexistent"); assertFalse(nonexistent.exists()); @@ -500,7 +526,8 @@ public void testDelDoesNotComplainAboutNonexistentFile() { assertFalse(nonexistent.exists()); } - public void testDelThrowsIfNoPermissions() { + @Test + public void delThrowsIfNoPermissions() { File parent = testArea.newDir("parent"); File fileToDelete = new File(parent, "file"); testArea.fileHasContent(fileToDelete, "anything"); @@ -519,7 +546,8 @@ public void testDelThrowsIfNoPermissions() { } } - public void testDelWorksEvenWithBrokenSymlinkUnderDirToDelete() + @Test + public void delWorksEvenWithBrokenSymlinkUnderDirToDelete() throws IOException, InterruptedException { File parent = testArea.newDir("parent"); ScriptGenerated.execute(parent, Arrays.asList("ln", "-s", diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/JavaUrlLearningTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/JavaUrlLearningTest.java index c0d574f4..feb64237 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/JavaUrlLearningTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/JavaUrlLearningTest.java @@ -1,13 +1,17 @@ package org.fluentjava.iwant.entry.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.net.MalformedURLException; import java.net.URL; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; -public class JavaUrlLearningTest extends TestCase { +public class JavaUrlLearningTest { - public void testUrlAppendForLearning() throws MalformedURLException { + @Test + public void urlAppendForLearning() throws MalformedURLException { URL base = new URL("http://localhost/base"); // it replaces the path: assertEquals("http://localhost/sub", @@ -17,7 +21,8 @@ public void testUrlAppendForLearning() throws MalformedURLException { new URL(base + "/sub").toExternalForm()); } - public void testInvalidUrlForTestingErrors() { + @Test + public void invalidUrlForTestingErrors() { try { @SuppressWarnings("unused") URL url = new URL("crap"); diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/LocationsTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/LocationsTest.java index 50b478ae..172c3470 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/LocationsTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/LocationsTest.java @@ -1,5 +1,8 @@ package org.fluentjava.iwant.entry.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + import java.net.MalformedURLException; import java.net.URL; @@ -8,12 +11,12 @@ import org.fluentjava.iwant.entry.Iwant.UnmodifiableUrl; import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class LocationsTest extends TestCase { +public class LocationsTest { - public void testNetworkGetter() { + @Test + public void networkGetter() { TestArea testArea = TestArea.forTest(this); IwantNetwork network = new IwantNetworkMock(testArea); Iwant iwant = Iwant.using(network); @@ -21,7 +24,8 @@ public void testNetworkGetter() { assertSame(network, iwant.network()); } - public void testRealCacheLocationEscapesUrl() throws MalformedURLException { + @Test + public void realCacheLocationEscapesUrl() throws MalformedURLException { URL nastyUrl = new URL( "http://localhost/very/../nasty?url&needs=\"escaping"); assertEquals( diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/TheSoleChildOfTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/TheSoleChildOfTest.java index fe268d8a..154b1051 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/TheSoleChildOfTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/TheSoleChildOfTest.java @@ -1,23 +1,27 @@ package org.fluentjava.iwant.entry.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import org.fluentjava.iwant.entry.Iwant; import org.fluentjava.iwant.entry.Iwant.IwantException; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class TheSoleChildOfTest extends TestCase { +public class TheSoleChildOfTest { private TestArea testArea; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); } - public void testNonDirectoryIsError() { + @Test + public void nonDirectoryIsError() { File nondir = testArea.hasFile("nondir", "anything"); try { @@ -29,7 +33,8 @@ public void testNonDirectoryIsError() { } } - public void testEmptyDirectoryIsError() { + @Test + public void emptyDirectoryIsError() { File dir = testArea.newDir("empty"); try { @@ -41,7 +46,8 @@ public void testEmptyDirectoryIsError() { } } - public void testDirectoryWith2ChildrenIsError() { + @Test + public void directoryWith2ChildrenIsError() { File dir = testArea.newDir("dir"); testArea.hasFile("dir/1", "1"); testArea.hasFile("dir/2", "2"); @@ -55,7 +61,8 @@ public void testDirectoryWith2ChildrenIsError() { } } - public void testSoleChildOfDirIsReturned() { + @Test + public void soleChildOfDirIsReturned() { File dir = testArea.newDir("dir"); File theone = testArea.hasFile("dir/theone", "theone"); diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnmodifiableSourceTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnmodifiableSourceTest.java index 5a5bffdc..8bdc00e7 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnmodifiableSourceTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnmodifiableSourceTest.java @@ -6,15 +6,14 @@ import org.fluentjava.iwant.entry.Iwant.UnmodifiableSource; import org.fluentjava.iwant.entry.Iwant.UnmodifiableUrl; import org.fluentjava.iwant.entry.Iwant.UnmodifiableZip; +import org.junit.jupiter.api.Test; import com.google.common.testing.EqualsTester; -import junit.framework.TestCase; +public class UnmodifiableSourceTest { -public class UnmodifiableSourceTest extends TestCase { - - public void testEqualsComparesTypeAndLocation() - throws MalformedURLException { + @Test + public void equalsComparesTypeAndLocation() throws MalformedURLException { UnmodifiableSource url1a = new UnmodifiableUrl( new URL("http://localhost/one")); UnmodifiableSource url1b = new UnmodifiableUrl(url1a.location()); diff --git a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnzippingTest.java b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnzippingTest.java index 2594941d..89564d41 100644 --- a/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnzippingTest.java +++ b/private/iwant-entry-tests/src/test/java/org/fluentjava/iwant/entry/tests/UnzippingTest.java @@ -1,5 +1,10 @@ package org.fluentjava.iwant.entry.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -11,17 +16,17 @@ import org.fluentjava.iwant.entry.Iwant.UnmodifiableZip; import org.fluentjava.iwant.entrymocks.IwantNetworkMock; import org.fluentjava.iwant.testarea.TestArea; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class UnzippingTest extends TestCase { +public class UnzippingTest { private TestArea testArea; private IwantNetworkMock network; private Iwant iwant; - @Override - public void setUp() { + @BeforeEach + public void before() { testArea = TestArea.forTest(this); network = new IwantNetworkMock(testArea); iwant = Iwant.using(network); @@ -31,7 +36,8 @@ private URL dirContainingAAndBZip() { return getClass().getResource("dir-containing-a-and-b.zip"); } - public void testStreamIsCorrectlyUnzippedToCacheWhenCacheDoesNotExist() + @Test + public void streamIsCorrectlyUnzippedToCacheWhenCacheDoesNotExist() throws FileNotFoundException, IOException { URL url = dirContainingAAndBZip(); UnmodifiableZip src = new UnmodifiableZip(url); @@ -48,7 +54,8 @@ public void testStreamIsCorrectlyUnzippedToCacheWhenCacheDoesNotExist() assertEquals("b\n", testArea.contentOf(new File(unzipped, "dir/b"))); } - public void testCacheIsReturnedWithoutUnzippingWhenCacheExists() { + @Test + public void cacheIsReturnedWithoutUnzippingWhenCacheExists() { URL zip = Iwant .fileToUrl(new File(testArea.root(), "not-to-be-accessed")); File unzipped = network.cachesZipAt(zip, "unzipped"); @@ -62,7 +69,8 @@ public void testCacheIsReturnedWithoutUnzippingWhenCacheExists() { assertEquals("unzipped content", testArea.contentOf("unzipped/file")); } - public void testUnzipHandlesSubDirectoriesToo() + @Test + public void unzipHandlesSubDirectoriesToo() throws FileNotFoundException, IOException { URL url = getClass().getResource("zip-with-subdir.zip"); UnmodifiableZip src = new UnmodifiableZip(url); @@ -83,7 +91,8 @@ public void testUnzipHandlesSubDirectoriesToo() /** * This way the error message will be seen again on later runs */ - public void testUnzipLeavesNoResultIfUnzipFails() throws IOException { + @Test + public void unzipLeavesNoResultIfUnzipFails() throws IOException { File zip = new File(testArea.root(), "zip"); UnmodifiableZip src = new UnmodifiableZip(zip.toURI().toURL()); File cachedZip = network.cachesAt(src, "unzipped");