diff --git a/common.gradle b/common.gradle index 042d88e3b5..273691d718 100644 --- a/common.gradle +++ b/common.gradle @@ -38,9 +38,12 @@ repositories { dependencies { // Adding dependencies here will add the dependencies to each subproject. - testImplementation libs.junit4 + testImplementation platform(libs.junit.bom) + testImplementation libs.junit.jupiter testImplementation libs.mokito.core + testImplementation libs.mokito.junit.jupiter testImplementation libs.groovy.test + testRuntimeOnly libs.junit.platform.launcher } // Uncomment if you want to see the status of every test that is run and @@ -76,6 +79,7 @@ javadoc { } test { + useJUnitPlatform() testLogging { exceptionFormat = 'full' } @@ -227,4 +231,4 @@ tasks.withType(Checkstyle) { html.required.set(true) } include("**/com/jme3/renderer/**/*.java") -} \ No newline at end of file +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3ac3ad8371..39040320da 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,7 +21,9 @@ jbullet = "com.github.stephengold:jbullet:1.0.3" jinput = "net.java.jinput:jinput:2.0.9" jna = "net.java.dev.jna:jna:5.10.0" jnaerator-runtime = "com.nativelibs4java:jnaerator-runtime:0.12" -junit4 = "junit:junit:4.13.2" +junit-bom = "org.junit:junit-bom:5.13.4" +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } lwjgl2 = "org.jmonkeyengine:lwjgl:2.9.5" lwjgl3-awt = "org.jmonkeyengine:lwjgl3-awt:0.2.4" @@ -35,6 +37,7 @@ lwjgl3-opengl = { module = "org.lwjgl:lwjgl-opengl", version.ref = "lwjgl3" lwjgl3-sdl = { module = "org.lwjgl:lwjgl-sdl", version.ref = "lwjgl3" } mokito-core = "org.mockito:mockito-core:3.12.4" +mokito-junit-jupiter = "org.mockito:mockito-junit-jupiter:3.12.4" nifty = { module = "com.github.nifty-gui:nifty", version.ref = "nifty" } nifty-default-controls = { module = "com.github.nifty-gui:nifty-default-controls", version.ref = "nifty" } diff --git a/jme3-android-examples/src/test/java/org/jmonkeyengine/jme3androidexamples/ExampleUnitTest.java b/jme3-android-examples/src/test/java/org/jmonkeyengine/jme3androidexamples/ExampleUnitTest.java index 3c2dcb42b7..0d59740d8f 100644 --- a/jme3-android-examples/src/test/java/org/jmonkeyengine/jme3androidexamples/ExampleUnitTest.java +++ b/jme3-android-examples/src/test/java/org/jmonkeyengine/jme3androidexamples/ExampleUnitTest.java @@ -1,8 +1,8 @@ package org.jmonkeyengine.jme3androidexamples; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * To work on unit tests, switch the Test Artifact in the Build Variants view. diff --git a/jme3-core/src/test/java/com/jme3/SetupTest.java b/jme3-core/src/test/java/com/jme3/SetupTest.java index fdf35dbf34..2b8af96076 100644 --- a/jme3-core/src/test/java/com/jme3/SetupTest.java +++ b/jme3-core/src/test/java/com/jme3/SetupTest.java @@ -31,7 +31,9 @@ */ package com.jme3; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @@ -39,8 +41,10 @@ */ public class SetupTest { - @Test(expected=AssertionError.class) + @Test public void testAssertionEnabled() { - assert false; + assertThrows(AssertionError.class, () -> { + assert false; + }); } } diff --git a/jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java b/jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java index 4813747695..1fa35f02be 100644 --- a/jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java +++ b/jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java @@ -35,8 +35,11 @@ import com.jme3.util.clone.Cloner; import java.util.Set; import java.util.TreeSet; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Remy Van Doosselaer @@ -47,16 +50,16 @@ public class AnimComposerTest { public void testGetAnimClips() { AnimComposer composer = new AnimComposer(); - Assert.assertNotNull(composer.getAnimClips()); - Assert.assertEquals(0, composer.getAnimClips().size()); + assertNotNull(composer.getAnimClips()); + assertEquals(0, composer.getAnimClips().size()); } @Test public void testGetAnimClipsNames() { AnimComposer composer = new AnimComposer(); - Assert.assertNotNull(composer.getAnimClipsNames()); - Assert.assertEquals(0, composer.getAnimClipsNames().size()); + assertNotNull(composer.getAnimClipsNames()); + assertEquals(0, composer.getAnimClipsNames().size()); } @Test @@ -71,8 +74,8 @@ public void testMakeLayer() { layers.add("Default"); layers.add(layerName); - Assert.assertNotNull(composer.getLayer(layerName)); - Assert.assertEquals(layers, composer.getLayerNames()); + assertNotNull(composer.getLayer(layerName)); + assertEquals(layers, composer.getLayerNames()); } @Test @@ -86,21 +89,23 @@ public void testMakeAction() { final Action action = composer.makeAction(animName); - Assert.assertNotNull(action); + assertNotNull(action); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testGetAnimClipsIsNotModifiable() { AnimComposer composer = new AnimComposer(); - composer.getAnimClips().add(new AnimClip("test")); + assertThrows(UnsupportedOperationException.class, + () -> composer.getAnimClips().add(new AnimClip("test"))); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testGetAnimClipsNamesIsNotModifiable() { AnimComposer composer = new AnimComposer(); - composer.getAnimClipsNames().add("test"); + assertThrows(UnsupportedOperationException.class, + () -> composer.getAnimClipsNames().add("test")); } @Test @@ -108,7 +113,7 @@ public void testHasDefaultLayer() { AnimComposer composer = new AnimComposer(); AnimLayer defaultLayer = composer.getLayer("Default"); - Assert.assertNotNull(defaultLayer); + assertNotNull(defaultLayer); } @Test @@ -122,7 +127,7 @@ public void testMissingDefaultLayerIssue2341() { AnimComposer clone = (AnimComposer) composer.jmeClone(); clone.cloneFields(new Cloner(), composer); - Assert.assertNotNull(clone.getLayer(AnimComposer.DEFAULT_LAYER)); + assertNotNull(clone.getLayer(AnimComposer.DEFAULT_LAYER)); } } diff --git a/jme3-core/src/test/java/com/jme3/anim/ArmatureMaskTest.java b/jme3-core/src/test/java/com/jme3/anim/ArmatureMaskTest.java index e68a56c95f..90512699c9 100644 --- a/jme3-core/src/test/java/com/jme3/anim/ArmatureMaskTest.java +++ b/jme3-core/src/test/java/com/jme3/anim/ArmatureMaskTest.java @@ -31,8 +31,8 @@ */ package com.jme3.anim; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test constructors and modification methods of the ArmatureMask class. @@ -81,7 +81,7 @@ public void testMaskAll() { for (ArmatureMask testMask : maskArray) { for (Joint testJoint : jointList) { - Assert.assertTrue(testMask.contains(testJoint)); + Assertions.assertTrue(testMask.contains(testJoint)); } } } @@ -104,7 +104,7 @@ public void testMaskNone() { for (ArmatureMask testMask : maskArray) { for (Joint testJoint : jointList) { - Assert.assertFalse(testMask.contains(testJoint)); + Assertions.assertFalse(testMask.contains(testJoint)); } } } @@ -132,9 +132,9 @@ public void testMask12() { for (ArmatureMask testMask : maskArray) { for (Joint testJoint : jointList) { if (testJoint == j1 || testJoint == j2) { - Assert.assertTrue(testMask.contains(testJoint)); + Assertions.assertTrue(testMask.contains(testJoint)); } else { - Assert.assertFalse(testMask.contains(testJoint)); + Assertions.assertFalse(testMask.contains(testJoint)); } } } diff --git a/jme3-core/src/test/java/com/jme3/anim/JointCloneTest.java b/jme3-core/src/test/java/com/jme3/anim/JointCloneTest.java index 34d6a3a677..5a04a513bf 100644 --- a/jme3-core/src/test/java/com/jme3/anim/JointCloneTest.java +++ b/jme3-core/src/test/java/com/jme3/anim/JointCloneTest.java @@ -32,8 +32,8 @@ package com.jme3.anim; import com.jme3.util.clone.Cloner; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test cloning a Joint. @@ -49,11 +49,11 @@ public class JointCloneTest { @Test public void testInitialTransform() { Joint testJoint = new Joint("testJoint"); - Assert.assertTrue(testJoint.getInitialTransform().isIdentity()); + Assertions.assertTrue(testJoint.getInitialTransform().isIdentity()); Joint clone = Cloner.deepClone(testJoint); clone.getInitialTransform().setScale(2f); - Assert.assertTrue(testJoint.getInitialTransform().isIdentity()); + Assertions.assertTrue(testJoint.getInitialTransform().isIdentity()); } } diff --git a/jme3-core/src/test/java/com/jme3/anim/tween/action/ClipActionTest.java b/jme3-core/src/test/java/com/jme3/anim/tween/action/ClipActionTest.java index cbcdc416ea..3dc20d2175 100644 --- a/jme3-core/src/test/java/com/jme3/anim/tween/action/ClipActionTest.java +++ b/jme3-core/src/test/java/com/jme3/anim/tween/action/ClipActionTest.java @@ -32,9 +32,9 @@ package com.jme3.anim.tween.action; import com.jme3.anim.AnimClip; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Test for ClipAction. diff --git a/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java b/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java index e4f3e57a8b..fd52fb7aa3 100644 --- a/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java +++ b/jme3-core/src/test/java/com/jme3/asset/LoadShaderSourceTest.java @@ -35,7 +35,7 @@ import com.jme3.shader.plugins.GLSLLoader; import com.jme3.system.JmeSystem; import com.jme3.system.MockJmeSystemDelegate; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LoadShaderSourceTest { diff --git a/jme3-core/src/test/java/com/jme3/asset/TestLocators.java b/jme3-core/src/test/java/com/jme3/asset/TestLocators.java index ae2e1996c0..a3355f1cee 100644 --- a/jme3-core/src/test/java/com/jme3/asset/TestLocators.java +++ b/jme3-core/src/test/java/com/jme3/asset/TestLocators.java @@ -7,8 +7,10 @@ import com.jme3.audio.plugins.WAVLoader; import com.jme3.system.JmeSystem; import com.jme3.texture.plugins.AWTLoader; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestLocators { @@ -19,8 +21,8 @@ public void testAbsoluteLocators() { am.registerLoader(WAVLoader.class, "wav"); am.registerLoader(AWTLoader.class, "jpg"); - Assert.assertNotNull(am.loadAudio("Sound/Effects/Gun.wav")); - Assert.assertNotNull(am.loadTexture("Textures/Terrain/Pond/Pond.jpg")); + assertNotNull(am.loadAudio("Sound/Effects/Gun.wav")); + assertNotNull(am.loadTexture("Textures/Terrain/Pond/Pond.jpg")); } /** @@ -32,7 +34,7 @@ public void testCustomLoader() { am.registerLocator("/", ClasspathLocator.class); am.registerLoader(TextLoader.class, "fnt"); String result = (String)am.loadAsset("Interface/Fonts/Console.fnt"); - Assert.assertTrue(result.startsWith("info face=\"Lucida Console\" size=11 bold=0 italic=0 charset=\"\" unicode=1" + + assertTrue(result.startsWith("info face=\"Lucida Console\" size=11 bold=0 italic=0 charset=\"\" unicode=1" + " stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 outline=0")); } @@ -50,19 +52,19 @@ public void testManyLocators() { am.registerLocator("/", ClasspathLocator.class); // Try loading from jme3-core resources using the ClasspathLocator. - Assert.assertNotNull("Failed to load from classpath", - am.locateAsset(new AssetKey<>("Interface/Fonts/Default.fnt"))); + assertNotNull(am.locateAsset(new AssetKey<>("Interface/Fonts/Default.fnt")), + "Failed to load from classpath"); // Try loading from the "town.zip" file using the ZipLocator. - Assert.assertNotNull("Failed to load from town.zip file", - am.locateAsset(new ModelKey("casaamarela.jpg"))); + assertNotNull(am.locateAsset(new ModelKey("casaamarela.jpg")), + "Failed to load from town.zip file"); // Try loading from the Google Code Archive website using the HttpZipLocator. - Assert.assertNotNull("Failed to load from wildhouse.zip on googleapis.com", - am.locateAsset(new ModelKey("glasstile2.png"))); + assertNotNull(am.locateAsset(new ModelKey("glasstile2.png")), + "Failed to load from wildhouse.zip on googleapis.com"); // Try loading from the GitHub website using the UrlLocator. - Assert.assertNotNull("Failed to load from HTTP", - am.locateAsset(new TextureKey("beginner-physics.png"))); + assertNotNull(am.locateAsset(new TextureKey("beginner-physics.png")), + "Failed to load from HTTP"); } } diff --git a/jme3-core/src/test/java/com/jme3/audio/AudioFilterTest.java b/jme3-core/src/test/java/com/jme3/audio/AudioFilterTest.java index 5ccf79d6c0..5f49922c1d 100644 --- a/jme3-core/src/test/java/com/jme3/audio/AudioFilterTest.java +++ b/jme3-core/src/test/java/com/jme3/audio/AudioFilterTest.java @@ -3,8 +3,8 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the Filter class. @@ -24,8 +24,8 @@ public void testSaveAndLoad_LowPassFilter() { LowPassFilter copy = BinaryExporter.saveAndLoad(assetManager, f); float delta = 0.001f; - Assert.assertEquals(f.getVolume(), copy.getVolume(), delta); - Assert.assertEquals(f.getHighFreqVolume(), copy.getHighFreqVolume(), delta); + Assertions.assertEquals(f.getVolume(), copy.getVolume(), delta); + Assertions.assertEquals(f.getHighFreqVolume(), copy.getHighFreqVolume(), delta); } /** @@ -39,8 +39,8 @@ public void testSaveAndLoad_HighPassFilter() { HighPassFilter copy = BinaryExporter.saveAndLoad(assetManager, f); float delta = 0.001f; - Assert.assertEquals(f.getVolume(), copy.getVolume(), delta); - Assert.assertEquals(f.getLowFreqVolume(), copy.getLowFreqVolume(), delta); + Assertions.assertEquals(f.getVolume(), copy.getVolume(), delta); + Assertions.assertEquals(f.getLowFreqVolume(), copy.getLowFreqVolume(), delta); } /** @@ -54,9 +54,9 @@ public void testSaveAndLoad_BandPassFilter() { BandPassFilter copy = BinaryExporter.saveAndLoad(assetManager, f); float delta = 0.001f; - Assert.assertEquals(f.getVolume(), copy.getVolume(), delta); - Assert.assertEquals(f.getHighFreqVolume(), copy.getHighFreqVolume(), delta); - Assert.assertEquals(f.getLowFreqVolume(), copy.getLowFreqVolume(), delta); + Assertions.assertEquals(f.getVolume(), copy.getVolume(), delta); + Assertions.assertEquals(f.getHighFreqVolume(), copy.getHighFreqVolume(), delta); + Assertions.assertEquals(f.getLowFreqVolume(), copy.getLowFreqVolume(), delta); } } diff --git a/jme3-core/src/test/java/com/jme3/audio/AudioNodeTest.java b/jme3-core/src/test/java/com/jme3/audio/AudioNodeTest.java index e7e32012f8..a34f3091df 100644 --- a/jme3-core/src/test/java/com/jme3/audio/AudioNodeTest.java +++ b/jme3-core/src/test/java/com/jme3/audio/AudioNodeTest.java @@ -3,8 +3,8 @@ import com.jme3.asset.AssetManager; import com.jme3.math.Vector3f; import com.jme3.system.JmeSystem; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code AudioNode} class. @@ -26,23 +26,23 @@ public void testAudioNodeClone() { AudioNode clone = audio.clone(); - Assert.assertNotNull(clone.previousWorldTranslation); - Assert.assertNotSame(audio.previousWorldTranslation, clone.previousWorldTranslation); - Assert.assertEquals(audio.previousWorldTranslation, clone.previousWorldTranslation); + Assertions.assertNotNull(clone.previousWorldTranslation); + Assertions.assertNotSame(audio.previousWorldTranslation, clone.previousWorldTranslation); + Assertions.assertEquals(audio.previousWorldTranslation, clone.previousWorldTranslation); - Assert.assertNotNull(clone.getDirection()); - Assert.assertNotSame(audio.getDirection(), clone.getDirection()); - Assert.assertEquals(audio.getDirection(), clone.getDirection()); + Assertions.assertNotNull(clone.getDirection()); + Assertions.assertNotSame(audio.getDirection(), clone.getDirection()); + Assertions.assertEquals(audio.getDirection(), clone.getDirection()); - Assert.assertNotNull(clone.getVelocity()); - Assert.assertNotSame(audio.getVelocity(), clone.getVelocity()); - Assert.assertEquals(audio.getVelocity(), clone.getVelocity()); + Assertions.assertNotNull(clone.getVelocity()); + Assertions.assertNotSame(audio.getVelocity(), clone.getVelocity()); + Assertions.assertEquals(audio.getVelocity(), clone.getVelocity()); - Assert.assertNotNull(clone.getDryFilter()); - Assert.assertNotSame(audio.getDryFilter(), clone.getDryFilter()); + Assertions.assertNotNull(clone.getDryFilter()); + Assertions.assertNotSame(audio.getDryFilter(), clone.getDryFilter()); - Assert.assertNotNull(clone.getReverbFilter()); - Assert.assertNotSame(audio.getReverbFilter(), clone.getReverbFilter()); + Assertions.assertNotNull(clone.getReverbFilter()); + Assertions.assertNotSame(audio.getReverbFilter(), clone.getReverbFilter()); } } diff --git a/jme3-core/src/test/java/com/jme3/bounding/TestBoundingBox.java b/jme3-core/src/test/java/com/jme3/bounding/TestBoundingBox.java index ed0c7c3408..199eaab7dd 100644 --- a/jme3-core/src/test/java/com/jme3/bounding/TestBoundingBox.java +++ b/jme3-core/src/test/java/com/jme3/bounding/TestBoundingBox.java @@ -32,8 +32,8 @@ package com.jme3.bounding; import com.jme3.math.Vector3f; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test cases for the BoundingBox class. @@ -59,16 +59,16 @@ public void testEquals() { bb6.setCheckPlane(1); // Clones are equal to their base instances: - Assert.assertEquals(bb1, bb1.clone()); - Assert.assertEquals(bb2, bb2.clone()); - Assert.assertEquals(bb3, bb3.clone()); - Assert.assertEquals(bb4, bb4.clone()); - Assert.assertEquals(bb5, bb5.clone()); - Assert.assertEquals(bb6, bb6.clone()); - - Assert.assertNotEquals(bb1, bb2); // because their extents differ - Assert.assertNotEquals(bb3, bb4); // because their centers differ - Assert.assertEquals(bb5, bb6); // because check planes are ignored + Assertions.assertEquals(bb1, bb1.clone()); + Assertions.assertEquals(bb2, bb2.clone()); + Assertions.assertEquals(bb3, bb3.clone()); + Assertions.assertEquals(bb4, bb4.clone()); + Assertions.assertEquals(bb5, bb5.clone()); + Assertions.assertEquals(bb6, bb6.clone()); + + Assertions.assertNotEquals(bb1, bb2); // because their extents differ + Assertions.assertNotEquals(bb3, bb4); // because their centers differ + Assertions.assertEquals(bb5, bb6); // because check planes are ignored } /** @@ -86,10 +86,10 @@ public void testMergeModifiesReceiver() { BoundingVolume result = bb1.merge(bb2); // merge() delegates to mergeLocal(), so bb1 IS modified. - Assert.assertNotEquals(bb1Before, bb1); + Assertions.assertNotEquals(bb1Before, bb1); // The result is the same object as bb1. - Assert.assertSame(bb1, result); + Assertions.assertSame(bb1, result); } /** @@ -107,16 +107,16 @@ public void testMergeWithDoesNotModifyReceiver() { BoundingVolume result = bb1.mergeWith(bb2); // bb1 must be unmodified. - Assert.assertEquals(bb1Before, bb1); + Assertions.assertEquals(bb1Before, bb1); // The result must be a different object than bb1. - Assert.assertNotSame(bb1, result); + Assertions.assertNotSame(bb1, result); // The result must contain both inputs' centers. - Assert.assertTrue(result instanceof BoundingBox); + Assertions.assertTrue(result instanceof BoundingBox); BoundingBox merged = (BoundingBox) result; - Assert.assertTrue(merged.contains(bb2.getCenter())); - Assert.assertTrue(merged.contains(bb1.getCenter())); + Assertions.assertTrue(merged.contains(bb2.getCenter())); + Assertions.assertTrue(merged.contains(bb1.getCenter())); } /** @@ -136,12 +136,12 @@ public void testIsSimilar() { BoundingBox bb6 = (BoundingBox) bb5.clone(); bb6.setCheckPlane(1); - Assert.assertFalse(bb1.isSimilar(bb2, 0.09999f)); - Assert.assertTrue(bb1.isSimilar(bb2, 0.10001f)); + Assertions.assertFalse(bb1.isSimilar(bb2, 0.09999f)); + Assertions.assertTrue(bb1.isSimilar(bb2, 0.10001f)); - Assert.assertFalse(bb3.isSimilar(bb4, 0.09999f)); - Assert.assertTrue(bb3.isSimilar(bb4, 0.10001f)); + Assertions.assertFalse(bb3.isSimilar(bb4, 0.09999f)); + Assertions.assertTrue(bb3.isSimilar(bb4, 0.10001f)); - Assert.assertTrue(bb5.isSimilar(bb6, 0f)); // check planes are ignored + Assertions.assertTrue(bb5.isSimilar(bb6, 0f)); // check planes are ignored } } diff --git a/jme3-core/src/test/java/com/jme3/bounding/TestBoundingSphere.java b/jme3-core/src/test/java/com/jme3/bounding/TestBoundingSphere.java index 4c0e760bc2..59fa2dfc4b 100644 --- a/jme3-core/src/test/java/com/jme3/bounding/TestBoundingSphere.java +++ b/jme3-core/src/test/java/com/jme3/bounding/TestBoundingSphere.java @@ -32,8 +32,8 @@ package com.jme3.bounding; import com.jme3.math.Vector3f; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test cases for the BoundingSphere class. @@ -57,16 +57,16 @@ public void testEquals() { bs6.setCheckPlane(1); // Clones are equal to their base instances: - Assert.assertEquals(bs1, bs1.clone()); - Assert.assertEquals(bs2, bs2.clone()); - Assert.assertEquals(bs3, bs3.clone()); - Assert.assertEquals(bs4, bs4.clone()); - Assert.assertEquals(bs5, bs5.clone()); - Assert.assertEquals(bs6, bs6.clone()); - - Assert.assertNotEquals(bs1, bs2); // because their radii differ - Assert.assertNotEquals(bs3, bs4); // because their centers differ - Assert.assertEquals(bs5, bs6); // because check planes are ignored + Assertions.assertEquals(bs1, bs1.clone()); + Assertions.assertEquals(bs2, bs2.clone()); + Assertions.assertEquals(bs3, bs3.clone()); + Assertions.assertEquals(bs4, bs4.clone()); + Assertions.assertEquals(bs5, bs5.clone()); + Assertions.assertEquals(bs6, bs6.clone()); + + Assertions.assertNotEquals(bs1, bs2); // because their radii differ + Assertions.assertNotEquals(bs3, bs4); // because their centers differ + Assertions.assertEquals(bs5, bs6); // because check planes are ignored } /** @@ -84,13 +84,13 @@ public void testIsSimilar() { BoundingSphere bs6 = (BoundingSphere) bs5.clone(); bs6.setCheckPlane(1); - Assert.assertFalse(bs1.isSimilar(bs2, 0.09999f)); - Assert.assertTrue(bs1.isSimilar(bs2, 0.10001f)); + Assertions.assertFalse(bs1.isSimilar(bs2, 0.09999f)); + Assertions.assertTrue(bs1.isSimilar(bs2, 0.10001f)); - Assert.assertFalse(bs3.isSimilar(bs4, 0.09999f)); - Assert.assertTrue(bs3.isSimilar(bs4, 0.10001f)); + Assertions.assertFalse(bs3.isSimilar(bs4, 0.09999f)); + Assertions.assertTrue(bs3.isSimilar(bs4, 0.10001f)); - Assert.assertTrue(bs5.isSimilar(bs6, 0f)); // check planes are ignored + Assertions.assertTrue(bs5.isSimilar(bs6, 0f)); // check planes are ignored } /** @@ -112,6 +112,6 @@ public void testIssue1459() { Vector3f copyCenter = new Vector3f(); boundingSphere.getCenter(copyCenter); - Assert.assertTrue(Vector3f.isValidVector(copyCenter)); + Assertions.assertTrue(Vector3f.isValidVector(copyCenter)); } } diff --git a/jme3-core/src/test/java/com/jme3/cinematic/CinematicTest.java b/jme3-core/src/test/java/com/jme3/cinematic/CinematicTest.java index 400dbaa9f9..45d020217b 100644 --- a/jme3-core/src/test/java/com/jme3/cinematic/CinematicTest.java +++ b/jme3-core/src/test/java/com/jme3/cinematic/CinematicTest.java @@ -35,7 +35,7 @@ import com.jme3.animation.Animation; import com.jme3.cinematic.events.AnimationEvent; import com.jme3.scene.Node; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * diff --git a/jme3-core/src/test/java/com/jme3/cinematic/MotionPathTest.java b/jme3-core/src/test/java/com/jme3/cinematic/MotionPathTest.java index 7fa2c71f58..5faec718c3 100644 --- a/jme3-core/src/test/java/com/jme3/cinematic/MotionPathTest.java +++ b/jme3-core/src/test/java/com/jme3/cinematic/MotionPathTest.java @@ -33,8 +33,8 @@ import com.jme3.math.Vector3f; import com.jme3.util.clone.Cloner; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Verifies that the {@link MotionPath} class works. @@ -59,17 +59,17 @@ public void cloneMotionPath() { MotionPath clone = Cloner.deepClone(original); // Verify that the clone is non-null and distinct from the original: - Assert.assertNotNull(clone); - Assert.assertTrue(clone != original); + Assertions.assertNotNull(clone); + Assertions.assertTrue(clone != original); // Compare the return values of various getters: - Assert.assertEquals( + Assertions.assertEquals( clone.getCurveTension(), original.getCurveTension(), 0f); - Assert.assertEquals(clone.getLength(), original.getLength(), 0f); - Assert.assertEquals(clone.getNbWayPoints(), original.getNbWayPoints()); - Assert.assertEquals( + Assertions.assertEquals(clone.getLength(), original.getLength(), 0f); + Assertions.assertEquals(clone.getNbWayPoints(), original.getNbWayPoints()); + Assertions.assertEquals( clone.getPathSplineType(), original.getPathSplineType()); - Assert.assertEquals(clone.getWayPoint(0), original.getWayPoint(0)); - Assert.assertEquals(clone.isCycle(), original.isCycle()); + Assertions.assertEquals(clone.getWayPoint(0), original.getWayPoint(0)); + Assertions.assertEquals(clone.isCycle(), original.isCycle()); } } diff --git a/jme3-core/src/test/java/com/jme3/collision/BoundingCollisionTest.java b/jme3-core/src/test/java/com/jme3/collision/BoundingCollisionTest.java index 033b673100..32b86dbf26 100644 --- a/jme3-core/src/test/java/com/jme3/collision/BoundingCollisionTest.java +++ b/jme3-core/src/test/java/com/jme3/collision/BoundingCollisionTest.java @@ -40,7 +40,7 @@ import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Quad; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests collision detection between bounding volumes. diff --git a/jme3-core/src/test/java/com/jme3/collision/CollideIgnoreTransformTest.java b/jme3-core/src/test/java/com/jme3/collision/CollideIgnoreTransformTest.java index 0a4a04249d..9f9b918a95 100644 --- a/jme3-core/src/test/java/com/jme3/collision/CollideIgnoreTransformTest.java +++ b/jme3-core/src/test/java/com/jme3/collision/CollideIgnoreTransformTest.java @@ -44,7 +44,7 @@ import com.jme3.scene.shape.Quad; import com.jme3.system.JmeSystem; import com.jme3.system.MockJmeSystemDelegate; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Verify that collideWith() works with ignoreTransforms. This was issue #744 at diff --git a/jme3-core/src/test/java/com/jme3/effect/influencers/ParticleInfluencerTest.java b/jme3-core/src/test/java/com/jme3/effect/influencers/ParticleInfluencerTest.java index 1e98da6e57..348230ae3d 100644 --- a/jme3-core/src/test/java/com/jme3/effect/influencers/ParticleInfluencerTest.java +++ b/jme3-core/src/test/java/com/jme3/effect/influencers/ParticleInfluencerTest.java @@ -4,8 +4,8 @@ import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; import com.jme3.math.Vector3f; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code ParticleInfluencer} class. @@ -30,18 +30,18 @@ public void testNewtonianParticleInfluencer() { NewtonianParticleInfluencer clone = (NewtonianParticleInfluencer) inf.clone(); assertEquals(inf, clone); - Assert.assertNotSame(inf.temp, clone.temp); + Assertions.assertNotSame(inf.temp, clone.temp); NewtonianParticleInfluencer copy = BinaryExporter.saveAndLoad(assetManager, inf); assertEquals(inf, copy); } private void assertEquals(NewtonianParticleInfluencer inf, NewtonianParticleInfluencer clone) { - Assert.assertEquals(inf.getNormalVelocity(), clone.getNormalVelocity(), 0.001f); - Assert.assertEquals(inf.getSurfaceTangentFactor(), clone.getSurfaceTangentFactor(), 0.001f); - Assert.assertEquals(inf.getSurfaceTangentRotation(), clone.getSurfaceTangentRotation(), 0.001f); - Assert.assertEquals(inf.getInitialVelocity(), clone.getInitialVelocity()); - Assert.assertEquals(inf.getVelocityVariation(), clone.getVelocityVariation(), 0.001f); + Assertions.assertEquals(inf.getNormalVelocity(), clone.getNormalVelocity(), 0.001f); + Assertions.assertEquals(inf.getSurfaceTangentFactor(), clone.getSurfaceTangentFactor(), 0.001f); + Assertions.assertEquals(inf.getSurfaceTangentRotation(), clone.getSurfaceTangentRotation(), 0.001f); + Assertions.assertEquals(inf.getInitialVelocity(), clone.getInitialVelocity()); + Assertions.assertEquals(inf.getVelocityVariation(), clone.getVelocityVariation(), 0.001f); } /** @@ -60,19 +60,19 @@ public void testRadialParticleInfluencer() { RadialParticleInfluencer clone = (RadialParticleInfluencer) inf.clone(); assertEquals(inf, clone); - Assert.assertNotSame(inf.temp, clone.temp); - Assert.assertNotSame(inf.getOrigin(), clone.getOrigin()); + Assertions.assertNotSame(inf.temp, clone.temp); + Assertions.assertNotSame(inf.getOrigin(), clone.getOrigin()); RadialParticleInfluencer copy = BinaryExporter.saveAndLoad(assetManager, inf); assertEquals(inf, copy); } private void assertEquals(RadialParticleInfluencer inf, RadialParticleInfluencer clone) { - Assert.assertEquals(inf.isHorizontal(), clone.isHorizontal()); - Assert.assertEquals(inf.getOrigin(), clone.getOrigin()); - Assert.assertEquals(inf.getRadialVelocity(), clone.getRadialVelocity(), 0.001f); - Assert.assertEquals(inf.getInitialVelocity(), clone.getInitialVelocity()); - Assert.assertEquals(inf.getVelocityVariation(), clone.getVelocityVariation(), 0.001f); + Assertions.assertEquals(inf.isHorizontal(), clone.isHorizontal()); + Assertions.assertEquals(inf.getOrigin(), clone.getOrigin()); + Assertions.assertEquals(inf.getRadialVelocity(), clone.getRadialVelocity(), 0.001f); + Assertions.assertEquals(inf.getInitialVelocity(), clone.getInitialVelocity()); + Assertions.assertEquals(inf.getVelocityVariation(), clone.getVelocityVariation(), 0.001f); } } diff --git a/jme3-core/src/test/java/com/jme3/light/LightFilterTest.java b/jme3-core/src/test/java/com/jme3/light/LightFilterTest.java index 80c75f0b7b..206fb5e712 100644 --- a/jme3-core/src/test/java/com/jme3/light/LightFilterTest.java +++ b/jme3-core/src/test/java/com/jme3/light/LightFilterTest.java @@ -38,8 +38,8 @@ import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; import com.jme3.util.TempVars; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test light filtering for various light types. @@ -61,7 +61,7 @@ private void checkFilteredLights(int expected) { assert list.size() == expected; } - @Before + @BeforeEach public void setUp() { filter = new DefaultLightFilter(); diff --git a/jme3-core/src/test/java/com/jme3/light/LightSortTest.java b/jme3-core/src/test/java/com/jme3/light/LightSortTest.java index 1be8305bc8..63ccb96c58 100644 --- a/jme3-core/src/test/java/com/jme3/light/LightSortTest.java +++ b/jme3-core/src/test/java/com/jme3/light/LightSortTest.java @@ -35,7 +35,7 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.jme3.scene.Node; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test light sorting (in the scene graph) for various light types. diff --git a/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java b/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java index 9b572e8e93..594f8dfba5 100644 --- a/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java +++ b/jme3-core/src/test/java/com/jme3/material/MaterialMatParamTest.java @@ -42,8 +42,8 @@ import com.jme3.shader.VarType; import java.util.Arrays; import java.util.HashSet; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import static com.jme3.scene.MPOTestUtils.*; import com.jme3.scene.Node; @@ -54,8 +54,8 @@ import com.jme3.texture.Texture; import com.jme3.texture.Texture2D; import java.util.ArrayList; -import static org.junit.Assert.assertEquals; -import org.junit.Before; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; /** * Validates {@link MatParam}s. @@ -432,7 +432,7 @@ public String toString() { private final Node root = new Node("Root Node"); private final LightList lightList = new LightList(geometry); - @Before + @BeforeEach public void setUp() { root.attachChild(geometry); } @@ -524,18 +524,18 @@ private void material(String path) { } private void evaluateTechniqueDef() { - Assert.assertFalse(evaluated); + Assertions.assertFalse(evaluated); Material mat = geometry.getMaterial(); mat.render(geometry, lightList, renderManager); - Assert.assertTrue(evaluated); + Assertions.assertTrue(evaluated); } private void outTextures(Texture... textures) { for (int i = 0; i < usedTextures.length; i++) { if (i < textures.length) { - Assert.assertSame(textures[i], usedTextures[i]); + Assertions.assertSame(textures[i], usedTextures[i]); } else { - Assert.assertNull(usedTextures[i]); + Assertions.assertNull(usedTextures[i]); } } } @@ -578,7 +578,7 @@ private void outUniforms(Uniform... uniforms) { HashSet expectedUniforms = new HashSet<>(Arrays.asList(uniforms)); if (!expectedUniforms.equals(actualUniforms)) { - Assert.fail("Uniform lists must match: " + expectedUniforms + " != " + actualUniforms); + Assertions.fail("Uniform lists must match: " + expectedUniforms + " != " + actualUniforms); } } } diff --git a/jme3-core/src/test/java/com/jme3/material/MaterialTest.java b/jme3-core/src/test/java/com/jme3/material/MaterialTest.java index 6edd3ed34a..97ab7f3209 100644 --- a/jme3-core/src/test/java/com/jme3/material/MaterialTest.java +++ b/jme3-core/src/test/java/com/jme3/material/MaterialTest.java @@ -47,12 +47,12 @@ import java.util.Arrays; import java.util.EnumSet; -import static org.junit.Assert.*; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(MockitoJUnitRunner.class) public class MaterialTest { private Material material; @@ -65,16 +65,18 @@ public EnumSet getCaps() { } }); - @Test(expected = IllegalArgumentException.class) + @Test public void testSelectNonExistentTechnique() { material("Common/MatDefs/Gui/Gui.j3md"); - material.selectTechnique("Doesn't Exist", renderManager); + assertThrows(IllegalArgumentException.class, + () -> material.selectTechnique("Doesn't Exist", renderManager)); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testSelectDefaultTechnique_NoCaps() { material("Common/MatDefs/Gui/Gui.j3md"); - material.selectTechnique("Default", renderManager); + assertThrows(UnsupportedOperationException.class, + () -> material.selectTechnique("Default", renderManager)); } @Test diff --git a/jme3-core/src/test/java/com/jme3/material/RenderStateTest.java b/jme3-core/src/test/java/com/jme3/material/RenderStateTest.java index e3c13eba52..0ebcc2aa19 100644 --- a/jme3-core/src/test/java/com/jme3/material/RenderStateTest.java +++ b/jme3-core/src/test/java/com/jme3/material/RenderStateTest.java @@ -34,8 +34,10 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * Test cloning/saving/loading a RenderState. Related issues include #1718 and @@ -66,42 +68,42 @@ public void testHashInvalidation() { // Test setFrontStencilMask invalidates hash state.setFrontStencilMask(0x12345678); int hash2 = state.contentHashCode(); - Assert.assertNotEquals("setFrontStencilMask should invalidate hash", hash1, hash2); + assertNotEquals(hash1, hash2, "setFrontStencilMask should invalidate hash"); // Test setBackStencilMask invalidates hash hash1 = state.contentHashCode(); state.setBackStencilMask(0x87654321); hash2 = state.contentHashCode(); - Assert.assertNotEquals("setBackStencilMask should invalidate hash", hash1, hash2); + assertNotEquals(hash1, hash2, "setBackStencilMask should invalidate hash"); // Test setFrontStencilReference invalidates hash hash1 = state.contentHashCode(); state.setFrontStencilReference(42); hash2 = state.contentHashCode(); - Assert.assertNotEquals("setFrontStencilReference should invalidate hash", hash1, hash2); + assertNotEquals(hash1, hash2, "setFrontStencilReference should invalidate hash"); // Test setBackStencilReference invalidates hash hash1 = state.contentHashCode(); state.setBackStencilReference(99); hash2 = state.contentHashCode(); - Assert.assertNotEquals("setBackStencilReference should invalidate hash", hash1, hash2); + assertNotEquals(hash1, hash2, "setBackStencilReference should invalidate hash"); // Test flipFaceCull invalidates hash state.setFaceCullMode(RenderState.FaceCullMode.Back); hash1 = state.contentHashCode(); state.flipFaceCull(); hash2 = state.contentHashCode(); - Assert.assertNotEquals("flipFaceCull should invalidate hash", hash1, hash2); - Assert.assertEquals("flipFaceCull should flip Back to Front", - RenderState.FaceCullMode.Front, state.getFaceCullMode()); + assertNotEquals(hash1, hash2, "flipFaceCull should invalidate hash"); + assertEquals(RenderState.FaceCullMode.Front, state.getFaceCullMode(), + "flipFaceCull should flip Back to Front"); // Test flipFaceCull again (Front to Back) hash1 = state.contentHashCode(); state.flipFaceCull(); hash2 = state.contentHashCode(); - Assert.assertNotEquals("flipFaceCull should invalidate hash (Front to Back)", hash1, hash2); - Assert.assertEquals("flipFaceCull should flip Front to Back", - RenderState.FaceCullMode.Back, state.getFaceCullMode()); + assertNotEquals(hash1, hash2, "flipFaceCull should invalidate hash (Front to Back)"); + assertEquals(RenderState.FaceCullMode.Back, state.getFaceCullMode(), + "flipFaceCull should flip Front to Back"); } @Test @@ -175,14 +177,14 @@ private static void test() { * Test a clone for equality. */ RenderState clone = testObject.clone(); - Assert.assertEquals(testObject, clone); + assertEquals(testObject, clone); if (testSerialization) { /* * Test a save-and-load copy for equality. */ RenderState copy = BinaryExporter.saveAndLoad(assetManager, testObject); - Assert.assertEquals(testObject, copy); + assertEquals(testObject, copy); } } diff --git a/jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java b/jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java index 7126d94fa8..c1c330d226 100644 --- a/jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java +++ b/jme3-core/src/test/java/com/jme3/material/plugins/J3MLoaderTest.java @@ -12,23 +12,23 @@ import com.jme3.texture.Texture; import java.io.IOException; import java.util.EnumSet; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.verify; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.verify; /** * @author Daniel Johansson * @since 2015-07-20 */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class J3MLoaderTest { private J3MLoader j3MLoader; @@ -45,13 +45,13 @@ public class J3MLoaderTest { @Mock private MaterialDef materialDef; - @Before + @BeforeEach @SuppressWarnings("unchecked") public void setUp() throws Exception { when(assetKey.getExtension()).thenReturn(".j3m"); when(assetInfo.getManager()).thenReturn(assetManager); when(assetInfo.getKey()).thenReturn(assetKey); - when(assetManager.loadAsset(any(AssetKey.class))).thenReturn(materialDef); + Mockito.lenient().when(assetManager.loadAsset(any(AssetKey.class))).thenReturn(materialDef); j3MLoader = new J3MLoader(); } diff --git a/jme3-core/src/test/java/com/jme3/material/plugins/LoadJ3mdTest.java b/jme3-core/src/test/java/com/jme3/material/plugins/LoadJ3mdTest.java index 2d35362a15..4696a5b521 100644 --- a/jme3-core/src/test/java/com/jme3/material/plugins/LoadJ3mdTest.java +++ b/jme3-core/src/test/java/com/jme3/material/plugins/LoadJ3mdTest.java @@ -39,12 +39,11 @@ import com.jme3.shader.Shader; import com.jme3.system.*; import java.util.*; -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; -@RunWith(MockitoJUnitRunner.class) public class LoadJ3mdTest { private Material material; @@ -57,22 +56,22 @@ public EnumSet getCaps() { } }); - @Test(expected = IllegalArgumentException.class) + @Test public void testBadBooleans1() { supportGlsl(100); - material("bad-booleans1.j3md"); // DepthTest yes + assertThrows(IllegalArgumentException.class, () -> material("bad-booleans1.j3md")); // DepthTest yes } - @Test(expected = IllegalArgumentException.class) + @Test public void testBadBooleans2() { supportGlsl(100); - material("bad-booleans2.j3md"); // DepthWrite on + assertThrows(IllegalArgumentException.class, () -> material("bad-booleans2.j3md")); // DepthWrite on } - @Test(expected = IllegalArgumentException.class) + @Test public void testBadBooleans3() { supportGlsl(100); - material("bad-booleans3.j3md"); // Wireframe true + assertThrows(IllegalArgumentException.class, () -> material("bad-booleans3.j3md")); // Wireframe true } @Test diff --git a/jme3-core/src/test/java/com/jme3/math/ColorRGBATest.java b/jme3-core/src/test/java/com/jme3/math/ColorRGBATest.java index 914ef61c14..ff5b276e09 100644 --- a/jme3-core/src/test/java/com/jme3/math/ColorRGBATest.java +++ b/jme3-core/src/test/java/com/jme3/math/ColorRGBATest.java @@ -1,7 +1,7 @@ package com.jme3.math; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author capdevon @@ -16,15 +16,15 @@ public void testIntColor() { int abgr = color.asIntABGR(); int argb = color.asIntARGB(); - Assert.assertEquals(-13395508, rgba); - Assert.assertEquals(-862374913, abgr); - Assert.assertEquals(-855690343, argb); + Assertions.assertEquals(-13395508, rgba); + Assertions.assertEquals(-862374913, abgr); + Assertions.assertEquals(-855690343, argb); ColorRGBA copy = new ColorRGBA(); - Assert.assertEquals(color, copy.fromIntRGBA(rgba)); - Assert.assertEquals(color, copy.fromIntABGR(abgr)); - Assert.assertEquals(color, copy.fromIntARGB(argb)); + Assertions.assertEquals(color, copy.fromIntRGBA(rgba)); + Assertions.assertEquals(color, copy.fromIntABGR(abgr)); + Assertions.assertEquals(color, copy.fromIntARGB(argb)); } } diff --git a/jme3-core/src/test/java/com/jme3/math/FastMathTest.java b/jme3-core/src/test/java/com/jme3/math/FastMathTest.java index b99f5836eb..ee732f2989 100644 --- a/jme3-core/src/test/java/com/jme3/math/FastMathTest.java +++ b/jme3-core/src/test/java/com/jme3/math/FastMathTest.java @@ -31,15 +31,12 @@ */ package com.jme3.math; -import org.junit.Test; - -import static org.junit.Assert.*; -import org.junit.Ignore; - import java.lang.Math; -import org.junit.Rule; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * Verifies that algorithms in {@link FastMath} are working correctly. @@ -47,8 +44,6 @@ * @author Kirill Vainer */ public class FastMathTest { - - @Rule public ExpectedException thrown = ExpectedException.none(); private int nearestPowerOfTwoSlow(int number) { return (int) Math.pow(2, Math.ceil(Math.log(number) / Math.log(2))); @@ -77,7 +72,7 @@ private static Vector2f randomVector() { FastMath.nextRandomFloat()); } - @Ignore + @Disabled @Test public void testCounterClockwise() { for (int i = 0; i < 100; i++) { @@ -344,8 +339,7 @@ public void testComputeNormal2() { @Test public void testConvertFloatToHalfUnsupportedOperationException() { - thrown.expect(UnsupportedOperationException.class); - FastMath.convertFloatToHalf(Float.NaN); + assertThrows(UnsupportedOperationException.class, () -> FastMath.convertFloatToHalf(Float.NaN)); } @Test diff --git a/jme3-core/src/test/java/com/jme3/math/QuaternionTest.java b/jme3-core/src/test/java/com/jme3/math/QuaternionTest.java index a81074de70..a209edaffa 100644 --- a/jme3-core/src/test/java/com/jme3/math/QuaternionTest.java +++ b/jme3-core/src/test/java/com/jme3/math/QuaternionTest.java @@ -31,19 +31,23 @@ */ package com.jme3.math; -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Verifies that the {@link Quaternion} class works correctly. * * @author Richard Tingle (aka Richtea) */ -public class QuaternionTest extends TestCase{ +public class QuaternionTest { /** * Verify that the {@link Quaternion#isValidQuaternion(com.jme3.math.Quaternion)} method works correctly. Testing * for NaNs and infinities (which are not "valid") */ + @Test public void testIsValidQuaternion(){ assertFalse(Quaternion.isValidQuaternion(new Quaternion(Float.NaN, 2.1f, 3.0f, 1.5f))); assertFalse(Quaternion.isValidQuaternion(new Quaternion(1f, Float.NaN, 3.0f, 1.5f))); @@ -56,4 +60,4 @@ public void testIsValidQuaternion(){ assertTrue(Quaternion.isValidQuaternion(new Quaternion())); assertTrue(Quaternion.isValidQuaternion(new Quaternion(1.5f, -5.7f, 8.2f, 3.0f))); } -} \ No newline at end of file +} diff --git a/jme3-core/src/test/java/com/jme3/math/SplineTest.java b/jme3-core/src/test/java/com/jme3/math/SplineTest.java index 447bf1d7bb..9717e18428 100644 --- a/jme3-core/src/test/java/com/jme3/math/SplineTest.java +++ b/jme3-core/src/test/java/com/jme3/math/SplineTest.java @@ -37,8 +37,8 @@ import com.jme3.util.clone.Cloner; import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Verifies that the {@link Spline} class works correctly. @@ -146,16 +146,16 @@ public void saveAndLoadSplines() { private static void assertListEquals(List a1, List a2) { if (a1 == null || a2 == null) { // If either list is null, verify that both are null: - Assert.assertNull(a1); - Assert.assertNull(a2); + Assertions.assertNull(a1); + Assertions.assertNull(a2); } else { // Verify that the lists are distinct and and of equal length: - Assert.assertTrue(a1 != a2); - Assert.assertEquals(a1.size(), a2.size()); + Assertions.assertTrue(a1 != a2); + Assertions.assertEquals(a1.size(), a2.size()); for (int i = 0; i < a1.size(); ++i) { - Assert.assertEquals(a1.get(i), a2.get(i)); + Assertions.assertEquals(a1.get(i), a2.get(i)); } } } @@ -167,25 +167,25 @@ private static void assertListEquals(List a1, List a2) { * @param s2 the 2nd split to compare (not null, unaffected) */ private static void assertSplineEquals(Spline s1, Spline s2) { - Assert.assertEquals(s1.getType(), s2.getType()); - Assert.assertEquals(s1.isCycle(), s2.isCycle()); + Assertions.assertEquals(s1.getType(), s2.getType()); + Assertions.assertEquals(s1.isCycle(), s2.isCycle()); - Assert.assertEquals( + Assertions.assertEquals( s1.getBasisFunctionDegree(), s2.getBasisFunctionDegree()); assertListEquals(s1.getControlPoints(), s2.getControlPoints()); - Assert.assertEquals(s1.getCurveTension(), s2.getCurveTension(), 0f); + Assertions.assertEquals(s1.getCurveTension(), s2.getCurveTension(), 0f); assertListEquals(s1.getKnots(), s2.getKnots()); if (s1.getType() == Spline.SplineType.Nurb) { // These methods throw NPEs on non-NURB splines. - Assert.assertEquals(s1.getMaxNurbKnot(), s2.getMaxNurbKnot(), 0f); - Assert.assertEquals(s1.getMinNurbKnot(), s2.getMinNurbKnot(), 0f); + Assertions.assertEquals(s1.getMaxNurbKnot(), s2.getMaxNurbKnot(), 0f); + Assertions.assertEquals(s1.getMinNurbKnot(), s2.getMinNurbKnot(), 0f); } assertListEquals(s1.getSegmentsLength(), s2.getSegmentsLength()); - Assert.assertEquals( + Assertions.assertEquals( s1.getTotalLength(), s2.getTotalLength(), 0f); - Assert.assertArrayEquals(s1.getWeights(), s2.getWeights(), 0f); + Assertions.assertArrayEquals(s1.getWeights(), s2.getWeights(), 0f); } /** diff --git a/jme3-core/src/test/java/com/jme3/math/TestIssue1388.java b/jme3-core/src/test/java/com/jme3/math/TestIssue1388.java index 23fe86168a..fb19077c1f 100644 --- a/jme3-core/src/test/java/com/jme3/math/TestIssue1388.java +++ b/jme3-core/src/test/java/com/jme3/math/TestIssue1388.java @@ -31,8 +31,8 @@ */ package com.jme3.math; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Verify the order in which Tait-Bryan angles are applied by the Quaternion @@ -112,15 +112,15 @@ public void testIssue1388() { private void assertEquals(float[] expected, float[] actual, float tolerance) { - Assert.assertEquals(expected[0], actual[0], tolerance); - Assert.assertEquals(expected[1], actual[1], tolerance); - Assert.assertEquals(expected[2], actual[2], tolerance); + Assertions.assertEquals(expected[0], actual[0], tolerance); + Assertions.assertEquals(expected[1], actual[1], tolerance); + Assertions.assertEquals(expected[2], actual[2], tolerance); } private void assertEquals(Vector3f expected, Vector3f actual, float tolerance) { - Assert.assertEquals(expected.x, actual.x, tolerance); - Assert.assertEquals(expected.y, actual.y, tolerance); - Assert.assertEquals(expected.z, actual.z, tolerance); + Assertions.assertEquals(expected.x, actual.x, tolerance); + Assertions.assertEquals(expected.y, actual.y, tolerance); + Assertions.assertEquals(expected.z, actual.z, tolerance); } } diff --git a/jme3-core/src/test/java/com/jme3/math/TestIssue2023.java b/jme3-core/src/test/java/com/jme3/math/TestIssue2023.java index e50ab207d9..fee5449a8c 100644 --- a/jme3-core/src/test/java/com/jme3/math/TestIssue2023.java +++ b/jme3-core/src/test/java/com/jme3/math/TestIssue2023.java @@ -31,8 +31,8 @@ */ package com.jme3.math; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Verify that getRotationColumn() returns correct values for non-normalized @@ -50,35 +50,35 @@ public void testIssue2023() { Quaternion test1 = new Quaternion(2f, 0.5f, 1f, -0.3f); Vector3f col0 = test1.getRotationColumn(0); - Assert.assertEquals(0.5318352f, col0.x, 1e-6f); - Assert.assertEquals(0.26217228f, col0.y, 1e-6f); - Assert.assertEquals(0.80524343f, col0.z, 1e-6f); + Assertions.assertEquals(0.5318352f, col0.x, 1e-6f); + Assertions.assertEquals(0.26217228f, col0.y, 1e-6f); + Assertions.assertEquals(0.80524343f, col0.z, 1e-6f); Vector3f col1 = test1.getRotationColumn(1); - Assert.assertEquals(0.4868914f, col1.x, 1e-6f); - Assert.assertEquals(-0.8726592f, col1.y, 1e-6f); - Assert.assertEquals(-0.03745319f, col1.z, 1e-6f); + Assertions.assertEquals(0.4868914f, col1.x, 1e-6f); + Assertions.assertEquals(-0.8726592f, col1.y, 1e-6f); + Assertions.assertEquals(-0.03745319f, col1.z, 1e-6f); Vector3f col2 = test1.getRotationColumn(2); - Assert.assertEquals(0.6928839f, col2.x, 1e-6f); - Assert.assertEquals(0.41198504f, col2.y, 1e-6f); - Assert.assertEquals(-0.5917603f, col2.z, 1e-6f); + Assertions.assertEquals(0.6928839f, col2.x, 1e-6f); + Assertions.assertEquals(0.41198504f, col2.y, 1e-6f); + Assertions.assertEquals(-0.5917603f, col2.z, 1e-6f); Quaternion test2 = new Quaternion(0f, -0.2f, 0f, 0.6f); col0 = test2.getRotationColumn(0); - Assert.assertEquals(0.8f, col0.x, 1e-6f); - Assert.assertEquals(0f, col0.y, 1e-6f); - Assert.assertEquals(0.6f, col0.z, 1e-6f); + Assertions.assertEquals(0.8f, col0.x, 1e-6f); + Assertions.assertEquals(0f, col0.y, 1e-6f); + Assertions.assertEquals(0.6f, col0.z, 1e-6f); col1 = test2.getRotationColumn(1); - Assert.assertEquals(0f, col1.x, 1e-6f); - Assert.assertEquals(1f, col1.y, 1e-6f); - Assert.assertEquals(0f, col1.z, 1e-6f); + Assertions.assertEquals(0f, col1.x, 1e-6f); + Assertions.assertEquals(1f, col1.y, 1e-6f); + Assertions.assertEquals(0f, col1.z, 1e-6f); col2 = test2.getRotationColumn(2); - Assert.assertEquals(-0.6f, col2.x, 1e-6f); - Assert.assertEquals(0f, col2.y, 1e-6f); - Assert.assertEquals(0.8f, col2.z, 1e-6f); + Assertions.assertEquals(-0.6f, col2.x, 1e-6f); + Assertions.assertEquals(0f, col2.y, 1e-6f); + Assertions.assertEquals(0.8f, col2.z, 1e-6f); } } diff --git a/jme3-core/src/test/java/com/jme3/math/TestIssue957.java b/jme3-core/src/test/java/com/jme3/math/TestIssue957.java index 16cca641e0..11eff83834 100644 --- a/jme3-core/src/test/java/com/jme3/math/TestIssue957.java +++ b/jme3-core/src/test/java/com/jme3/math/TestIssue957.java @@ -31,7 +31,7 @@ */ package com.jme3.math; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Verify that a Triangle center and normal get recomputed after a change. This diff --git a/jme3-core/src/test/java/com/jme3/math/TestToString.java b/jme3-core/src/test/java/com/jme3/math/TestToString.java index c30c1e45ed..76036564c2 100644 --- a/jme3-core/src/test/java/com/jme3/math/TestToString.java +++ b/jme3-core/src/test/java/com/jme3/math/TestToString.java @@ -31,8 +31,8 @@ */ package com.jme3.math; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test various toString() methods using JUnit. See also @@ -71,16 +71,16 @@ public void testToString() { String triangleString = triangle.toString(); // Verify that the results match the javadoc: - Assert.assertEquals( + Assertions.assertEquals( "Line [Origin: (1.0, 0.0, 0.0) Direction: (0.0, 1.0, 0.0)]", lineString); - Assert.assertEquals( + Assertions.assertEquals( "LineSegment [Origin: (1.0, 0.0, 0.0) Direction: (0.0, 1.0, 0.0) Extent: 1.0]", segmentString); - Assert.assertEquals( + Assertions.assertEquals( "Rectangle [A: (1.0, 0.0, 0.0) B: (2.0, 0.0, 0.0) C: (1.0, 2.0, 0.0)]", rectangleString); - Assert.assertEquals( + Assertions.assertEquals( "Triangle [V1: (1.0, 0.0, 0.0) V2: (0.0, 1.0, 0.0) V3: (0.0, 0.0, 1.0)]", triangleString); } diff --git a/jme3-core/src/test/java/com/jme3/math/TestTransform.java b/jme3-core/src/test/java/com/jme3/math/TestTransform.java index c3f80f8822..1885a24efb 100644 --- a/jme3-core/src/test/java/com/jme3/math/TestTransform.java +++ b/jme3-core/src/test/java/com/jme3/math/TestTransform.java @@ -33,8 +33,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test the Transform class using JUnit. @@ -66,18 +66,18 @@ public void testTransformToString() { ); Matcher matcher = pattern.matcher(result); boolean valid = matcher.matches(); - Assert.assertTrue(valid); + Assertions.assertTrue(valid); String txText = matcher.group(1); float tx = Float.parseFloat(txText); - Assert.assertEquals(12f, tx, 1e-5f); + Assertions.assertEquals(12f, tx, 1e-5f); String rzText = matcher.group(6); float rz = Float.parseFloat(rzText); - Assert.assertEquals(-0.8f, rz, 1e-6f); + Assertions.assertEquals(-0.8f, rz, 1e-6f); String szText = matcher.group(10); float sz = Float.parseFloat(szText); - Assert.assertEquals(1.7f, sz, 2e-6f); + Assertions.assertEquals(1.7f, sz, 2e-6f); } } diff --git a/jme3-core/src/test/java/com/jme3/math/TriangleTest.java b/jme3-core/src/test/java/com/jme3/math/TriangleTest.java index 02066f4cf3..95c1c15f6b 100644 --- a/jme3-core/src/test/java/com/jme3/math/TriangleTest.java +++ b/jme3-core/src/test/java/com/jme3/math/TriangleTest.java @@ -31,8 +31,8 @@ */ package com.jme3.math; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Verifies that the {@link Triangle} class works correctly. @@ -53,38 +53,38 @@ public void test1() { // Verify that centroid and normal are calculated correctly. Vector3f c1 = triangle1.getCenter(); - Assert.assertEquals(4f, c1.x, 1e-6f); - Assert.assertEquals(5f, c1.y, 1e-6f); - Assert.assertEquals(3f, c1.z, 1e-6f); + Assertions.assertEquals(4f, c1.x, 1e-6f); + Assertions.assertEquals(5f, c1.y, 1e-6f); + Assertions.assertEquals(3f, c1.z, 1e-6f); Vector3f n1 = triangle1.getNormal(); - Assert.assertEquals(-0.408248, n1.x, 1e-6f); - Assert.assertEquals(0.408248, n1.y, 1e-6f); - Assert.assertEquals(0.816497, n1.z, 1e-6f); + Assertions.assertEquals(-0.408248, n1.x, 1e-6f); + Assertions.assertEquals(0.408248, n1.y, 1e-6f); + Assertions.assertEquals(0.816497, n1.z, 1e-6f); // Clone triangle1 and verify its vertices. Triangle triangle2 = triangle1.clone(); - Assert.assertTrue(triangle1 != triangle2); - Assert.assertEquals(triangle1.get1(), triangle2.get1()); - Assert.assertEquals(triangle1.get2(), triangle2.get2()); - Assert.assertEquals(triangle1.get3(), triangle2.get3()); + Assertions.assertTrue(triangle1 != triangle2); + Assertions.assertEquals(triangle1.get1(), triangle2.get1()); + Assertions.assertEquals(triangle1.get2(), triangle2.get2()); + Assertions.assertEquals(triangle1.get3(), triangle2.get3()); // Modify triangle1 and verify its new centroid. triangle1.set1(new Vector3f(-2f, -1f, 0f)); c1 = triangle1.getCenter(); - Assert.assertEquals(3f, c1.x, 1e-6f); - Assert.assertEquals(4f, c1.y, 1e-6f); - Assert.assertEquals(2f, c1.z, 1e-6f); + Assertions.assertEquals(3f, c1.x, 1e-6f); + Assertions.assertEquals(4f, c1.y, 1e-6f); + Assertions.assertEquals(2f, c1.z, 1e-6f); // Verify that triangle2's centroid and normal are (still) correct. Vector3f c2 = triangle2.getCenter(); - Assert.assertEquals(4f, c2.x, 1e-6f); - Assert.assertEquals(5f, c2.y, 1e-6f); - Assert.assertEquals(3f, c2.z, 1e-6f); + Assertions.assertEquals(4f, c2.x, 1e-6f); + Assertions.assertEquals(5f, c2.y, 1e-6f); + Assertions.assertEquals(3f, c2.z, 1e-6f); Vector3f n2 = triangle2.getNormal(); - Assert.assertEquals(-0.408248, n2.x, 1e-6f); - Assert.assertEquals(0.408248, n2.y, 1e-6f); - Assert.assertEquals(0.816497, n2.z, 1e-6f); + Assertions.assertEquals(-0.408248, n2.x, 1e-6f); + Assertions.assertEquals(0.408248, n2.y, 1e-6f); + Assertions.assertEquals(0.816497, n2.z, 1e-6f); } } diff --git a/jme3-core/src/test/java/com/jme3/math/Vector3fTest.java b/jme3-core/src/test/java/com/jme3/math/Vector3fTest.java index c03719746e..3230fa9149 100644 --- a/jme3-core/src/test/java/com/jme3/math/Vector3fTest.java +++ b/jme3-core/src/test/java/com/jme3/math/Vector3fTest.java @@ -31,16 +31,12 @@ */ package com.jme3.math; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; -import org.junit.Rule; -import org.junit.rules.ExpectedException; +import static org.junit.jupiter.api.Assertions.*; public class Vector3fTest { - @Rule public ExpectedException thrown = ExpectedException.none(); - @Test public void testAdd() { final Vector3f target = new Vector3f(1.0f, Float.NaN, 5.36f); @@ -81,11 +77,10 @@ public void testAdd3() { @Test public void testAdd4() { - thrown.expect(NullPointerException.class); final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); final Vector3f other = new Vector3f(1.42f, 7.52f, 1.1f); final Vector3f result = null; - target.add(other, result); + assertThrows(NullPointerException.class, () -> target.add(other, result)); } @@ -448,8 +443,8 @@ public void testGenerateOrthonormalBasis4() { @Test public void testGet_illegalArgumentException() { - thrown.expect(IllegalArgumentException.class); - new Vector3f(0.0f, 0.0f, 0.0f).get(536_870_914); + assertThrows(IllegalArgumentException.class, + () -> new Vector3f(0.0f, 0.0f, 0.0f).get(536_870_914)); } @Test @@ -957,8 +952,8 @@ public void testScaleAdd2() { @Test public void testSet_OutputIllegalArgumentException() { - thrown.expect(IllegalArgumentException.class); - new Vector3f(1.5f, 2.3f, 4.7f).set(5, 1.5f); + assertThrows(IllegalArgumentException.class, + () -> new Vector3f(1.5f, 2.3f, 4.7f).set(5, 1.5f)); } @Test diff --git a/jme3-core/src/test/java/com/jme3/renderer/Issue2333Test.java b/jme3-core/src/test/java/com/jme3/renderer/Issue2333Test.java index ca553a6137..cd39973541 100644 --- a/jme3-core/src/test/java/com/jme3/renderer/Issue2333Test.java +++ b/jme3-core/src/test/java/com/jme3/renderer/Issue2333Test.java @@ -31,8 +31,10 @@ */ package com.jme3.renderer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Automated tests for "Camera Viewport Dimensions not Checked" (issue #2333 at @@ -50,10 +52,10 @@ public void testIssue2333() { Camera c = new Camera(1, 1); // Verify some Camera defaults: - Assert.assertEquals(0f, c.getViewPortBottom(), 0f); - Assert.assertEquals(0f, c.getViewPortLeft(), 0f); - Assert.assertEquals(1f, c.getViewPortRight(), 0f); - Assert.assertEquals(1f, c.getViewPortTop(), 0f); + assertEquals(0f, c.getViewPortBottom(), 0f); + assertEquals(0f, c.getViewPortLeft(), 0f); + assertEquals(1f, c.getViewPortRight(), 0f); + assertEquals(1f, c.getViewPortTop(), 0f); // Try some valid settings: new Camera(1, 1).setViewPort(0.5f, 0.7f, 0.1f, 0.3f); @@ -67,175 +69,183 @@ public void testIssue2333() { * Verifies that setViewPort() with left = right throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase01() { - new Camera(1, 1).setViewPort(0.5f, 0.5f, 0f, 1f); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(0.5f, 0.5f, 0f, 1f)); } /** * Verifies that setViewPort() with left > right throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase02() { - new Camera(1, 1).setViewPort(0.7f, 0.5f, 0f, 1f); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(0.7f, 0.5f, 0f, 1f)); } /** * Verifies that setViewPortLeft() resulting in left = right throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase03() { - new Camera(1, 1).setViewPortLeft(1f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortLeft(1f)); } /** * Verifies that setViewPortLeft() resulting in left > right throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase04() { - new Camera(1, 1).setViewPortLeft(1.1f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortLeft(1.1f)); } /** * Verifies that setViewPortRight() resulting in left = right throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase05() { - new Camera(1, 1).setViewPortRight(0f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortRight(0f)); } /** * Verifies that setViewPortRight() resulting in left > right throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase06() { - new Camera(1, 1).setViewPortRight(-0.1f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortRight(-0.1f)); } /** * Verifies that setViewPort() with bottom = top throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase07() { - new Camera(1, 1).setViewPort(0f, 1f, 0.5f, 0.5f); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(0f, 1f, 0.5f, 0.5f)); } /** * Verifies that setViewPort() with bottom > top throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase08() { - new Camera(1, 1).setViewPort(0f, 1f, 0.7f, 0.6f); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(0f, 1f, 0.7f, 0.6f)); } /** * Verifies that setViewPortBottom() resulting in bottom = top throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase09() { - new Camera(1, 1).setViewPortBottom(1f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortBottom(1f)); } /** * Verifies that setViewPortBottom() resulting in bottom > top throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase10() { - new Camera(1, 1).setViewPortBottom(2f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortBottom(2f)); } /** * Verifies that setViewPortTop() resulting in bottom = top throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase11() { - new Camera(1, 1).setViewPortTop(0f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortTop(0f)); } /** * Verifies that setViewPortTop() resulting in bottom > top throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase12() { - new Camera(1, 1).setViewPortTop(-1f); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortTop(-1f)); } /** * Verifies that setViewPort() with left = NaN throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase13() { - new Camera(1, 1).setViewPort(Float.NaN, 1f, 0f, 1f); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(Float.NaN, 1f, 0f, 1f)); } /** * Verifies that setViewPort() with right = NaN throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase14() { - new Camera(1, 1).setViewPort(0f, Float.NaN, 0f, 1f); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(0f, Float.NaN, 0f, 1f)); } /** * Verifies that setViewPort() with bottom = NaN throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase15() { - new Camera(1, 1).setViewPort(0f, 1f, Float.NaN, 1f); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(0f, 1f, Float.NaN, 1f)); } /** * Verifies that setViewPort() with top = NaN throws an * IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase16() { - new Camera(1, 1).setViewPort(0f, 1f, 0f, Float.NaN); + assertThrows(IllegalArgumentException.class, + () -> new Camera(1, 1).setViewPort(0f, 1f, 0f, Float.NaN)); } /** * Verifies that setViewPortBottom(NaN) throws an IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase17() { - new Camera(1, 1).setViewPortBottom(Float.NaN); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortBottom(Float.NaN)); } /** * Verifies that setViewPortLeft(NaN) throws an IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase18() { - new Camera(1, 1).setViewPortLeft(Float.NaN); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortLeft(Float.NaN)); } /** * Verifies that setViewPortRight(NaN) throws an IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase19() { - new Camera(1, 1).setViewPortRight(Float.NaN); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortRight(Float.NaN)); } /** * Verifies that setViewPortTop(NaN) throws an IllegalArgumentException. */ - @Test(expected = IllegalArgumentException.class) + @Test public void iaeCase20() { - new Camera(1, 1).setViewPortTop(Float.NaN); + assertThrows(IllegalArgumentException.class, () -> new Camera(1, 1).setViewPortTop(Float.NaN)); } } diff --git a/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java b/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java index 929281819e..07244bf28a 100644 --- a/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java +++ b/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java @@ -50,8 +50,10 @@ import java.nio.ByteBuffer; import java.util.HashSet; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class OpaqueComparatorTest { @@ -61,7 +63,7 @@ public class OpaqueComparatorTest { private AssetManager assetManager; final private OpaqueComparator comparator = new OpaqueComparator(); - @Before + @BeforeEach public void setUp() { assetManager = TestUtil.createAssetManager(); renderManager = TestUtil.createRenderManager(); @@ -174,7 +176,7 @@ public void testSortByTechnique() { lightingMatDefault, lightingPostShadow); } - @Test(expected = AssertionError.class) + @Test public void testNoSortByParam() { Material sameMat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); Material sameMat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); @@ -185,7 +187,7 @@ public void testNoSortByParam() { sameMat2.setName("MatBlue"); sameMat2.setColor("Color", ColorRGBA.Blue); - testSort(sameMat1, sameMat2); + assertThrows(AssertionError.class, () -> testSort(sameMat1, sameMat2)); } private Texture createTexture(String name) { diff --git a/jme3-core/src/test/java/com/jme3/scene/MPOTestUtils.java b/jme3-core/src/test/java/com/jme3/scene/MPOTestUtils.java index d78703e500..dd7a0945da 100644 --- a/jme3-core/src/test/java/com/jme3/scene/MPOTestUtils.java +++ b/jme3-core/src/test/java/com/jme3/scene/MPOTestUtils.java @@ -39,7 +39,7 @@ import java.lang.reflect.Field; import java.util.HashSet; import java.util.Set; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MPOTestUtils { @@ -75,7 +75,7 @@ private static void validateSubScene(Spatial scene) { current = current.getParent(); } - assertEquals("For " + scene, expectedOverrides, actualOverrides); + assertEquals(expectedOverrides, actualOverrides, "For " + scene); } public static void validateScene(Spatial scene) { diff --git a/jme3-core/src/test/java/com/jme3/scene/PhantomTrianglesTest.java b/jme3-core/src/test/java/com/jme3/scene/PhantomTrianglesTest.java index e7f1013f62..53cc6e804c 100644 --- a/jme3-core/src/test/java/com/jme3/scene/PhantomTrianglesTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/PhantomTrianglesTest.java @@ -43,7 +43,7 @@ import com.jme3.scene.shape.Quad; import com.jme3.system.JmeSystem; import com.jme3.system.MockJmeSystemDelegate; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Verify that collideWith() doesn't report collisions with phantom triangles. diff --git a/jme3-core/src/test/java/com/jme3/scene/SceneGraphTraversalTest.java b/jme3-core/src/test/java/com/jme3/scene/SceneGraphTraversalTest.java index 6327df4881..2108d20304 100644 --- a/jme3-core/src/test/java/com/jme3/scene/SceneGraphTraversalTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/SceneGraphTraversalTest.java @@ -36,8 +36,8 @@ import java.util.Collections; import java.util.List; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.jupiter.api.Test; /** * Tests for traversal order when using SceneGraphVisitor diff --git a/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java b/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java index fb8a60aa7f..d94142587a 100644 --- a/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java @@ -34,10 +34,10 @@ import com.jme3.asset.AssetManager; import com.jme3.export.binary.BinaryExporter; import com.jme3.material.MatParamOverride; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static com.jme3.scene.MPOTestUtils.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import com.jme3.system.TestUtil; import java.util.List; diff --git a/jme3-core/src/test/java/com/jme3/scene/ShapeGeometryTest.java b/jme3-core/src/test/java/com/jme3/scene/ShapeGeometryTest.java index af20a134de..8f2bbf3d8f 100644 --- a/jme3-core/src/test/java/com/jme3/scene/ShapeGeometryTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/ShapeGeometryTest.java @@ -37,7 +37,7 @@ import com.jme3.math.Vector3f; import com.jme3.scene.shape.Cylinder; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Ensures that geometries behave correctly, by casting rays and ensure they don't break. diff --git a/jme3-core/src/test/java/com/jme3/scene/SpatialTest.java b/jme3-core/src/test/java/com/jme3/scene/SpatialTest.java index 48c9147920..4de2a7a303 100644 --- a/jme3-core/src/test/java/com/jme3/scene/SpatialTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/SpatialTest.java @@ -31,12 +31,16 @@ */ package com.jme3.scene; -import com.jme3.math.FastMath; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; -import com.jme3.scene.control.UpdateControl; -import org.junit.Assert; -import org.junit.Test; +import com.jme3.math.FastMath; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; +import com.jme3.scene.control.UpdateControl; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests selected methods of the Spatial class. @@ -48,42 +52,42 @@ public class SpatialTest { /** * Tests addControlAt() with a duplicate Control. */ - @Test(expected = IllegalStateException.class) - public void addControlAtDuplicate() { - Spatial testSpatial = new Node("testSpatial"); - UpdateControl control1 = new UpdateControl(); - testSpatial.addControlAt(0, control1); - testSpatial.addControlAt(1, control1); - } + @Test + public void addControlAtDuplicate() { + Spatial testSpatial = new Node("testSpatial"); + UpdateControl control1 = new UpdateControl(); + testSpatial.addControlAt(0, control1); + assertThrows(IllegalStateException.class, () -> testSpatial.addControlAt(1, control1)); + } /** * Tests addControlAt() with a negative index. */ - @Test(expected = IndexOutOfBoundsException.class) - public void addControlAtNegativeIndex() { - Spatial testSpatial = new Node("testSpatial"); - UpdateControl control1 = new UpdateControl(); - testSpatial.addControlAt(-1, control1); - } + @Test + public void addControlAtNegativeIndex() { + Spatial testSpatial = new Node("testSpatial"); + UpdateControl control1 = new UpdateControl(); + assertThrows(IndexOutOfBoundsException.class, () -> testSpatial.addControlAt(-1, control1)); + } /** * Tests addControlAt() with a null argument. */ - @Test(expected = IllegalArgumentException.class) - public void addControlAtNullControl() { - Spatial testSpatial = new Node("testSpatial"); - testSpatial.addControlAt(0, null); - } + @Test + public void addControlAtNullControl() { + Spatial testSpatial = new Node("testSpatial"); + assertThrows(IllegalArgumentException.class, () -> testSpatial.addControlAt(0, null)); + } /** * Tests addControlAt() with an out-of-range positive index. */ - @Test(expected = IndexOutOfBoundsException.class) - public void addControlAtOutOfRange() { - Spatial testSpatial = new Node("testSpatial"); - UpdateControl control1 = new UpdateControl(); - testSpatial.addControlAt(1, control1); - } + @Test + public void addControlAtOutOfRange() { + Spatial testSpatial = new Node("testSpatial"); + UpdateControl control1 = new UpdateControl(); + assertThrows(IndexOutOfBoundsException.class, () -> testSpatial.addControlAt(1, control1)); + } /** * Tests typical uses of addControlAt(). @@ -96,31 +100,31 @@ public void testAddControlAt() { UpdateControl control1 = new UpdateControl(); testSpatial.addControlAt(0, control1); - Assert.assertEquals(1, testSpatial.getNumControls()); - Assert.assertEquals(control1, testSpatial.getControl(0)); - Assert.assertEquals(testSpatial, control1.getSpatial()); + assertEquals(1, testSpatial.getNumControls()); + assertEquals(control1, testSpatial.getControl(0)); + assertEquals(testSpatial, control1.getSpatial()); // Add at the end of a non-empty list. UpdateControl control2 = new UpdateControl(); testSpatial.addControlAt(1, control2); - Assert.assertEquals(2, testSpatial.getNumControls()); - Assert.assertEquals(control1, testSpatial.getControl(0)); - Assert.assertEquals(control2, testSpatial.getControl(1)); - Assert.assertEquals(testSpatial, control1.getSpatial()); - Assert.assertEquals(testSpatial, control2.getSpatial()); + assertEquals(2, testSpatial.getNumControls()); + assertEquals(control1, testSpatial.getControl(0)); + assertEquals(control2, testSpatial.getControl(1)); + assertEquals(testSpatial, control1.getSpatial()); + assertEquals(testSpatial, control2.getSpatial()); // Add at the beginning of a non-empty list. UpdateControl control0 = new UpdateControl(); testSpatial.addControlAt(0, control0); - Assert.assertEquals(3, testSpatial.getNumControls()); - Assert.assertEquals(control0, testSpatial.getControl(0)); - Assert.assertEquals(control1, testSpatial.getControl(1)); - Assert.assertEquals(control2, testSpatial.getControl(2)); - Assert.assertEquals(testSpatial, control0.getSpatial()); - Assert.assertEquals(testSpatial, control1.getSpatial()); - Assert.assertEquals(testSpatial, control2.getSpatial()); + assertEquals(3, testSpatial.getNumControls()); + assertEquals(control0, testSpatial.getControl(0)); + assertEquals(control1, testSpatial.getControl(1)); + assertEquals(control2, testSpatial.getControl(2)); + assertEquals(testSpatial, control0.getSpatial()); + assertEquals(testSpatial, control1.getSpatial()); + assertEquals(testSpatial, control2.getSpatial()); } @Test @@ -136,19 +140,19 @@ public void testTransferToOtherNode(){ Vector3f worldTranslation = testNode.getWorldTranslation().clone(); Quaternion worldRotation = testNode.getWorldRotation().clone(); - Assert.assertTrue(worldTranslation.isSimilar(testNode.getWorldTranslation(),1e-6f)); - Assert.assertTrue(worldRotation.isSimilar(testNode.getWorldRotation(),1e-6f)); + assertTrue(worldTranslation.isSimilar(testNode.getWorldTranslation(),1e-6f)); + assertTrue(worldRotation.isSimilar(testNode.getWorldRotation(),1e-6f)); nodeB.attachChild(testNode); - Assert.assertFalse(worldTranslation.isSimilar(testNode.getWorldTranslation(),1e-6f)); - Assert.assertFalse(worldRotation.isSimilar(testNode.getWorldRotation(),1e-6f)); + assertFalse(worldTranslation.isSimilar(testNode.getWorldTranslation(),1e-6f)); + assertFalse(worldRotation.isSimilar(testNode.getWorldRotation(),1e-6f)); testNode.setLocalTranslation(nodeB.worldToLocal(worldTranslation,null)); - Assert.assertTrue(worldTranslation.isSimilar(testNode.getWorldTranslation(),1e-6f)); + assertTrue(worldTranslation.isSimilar(testNode.getWorldTranslation(),1e-6f)); testNode.setLocalRotation(nodeB.worldToLocal(worldRotation,null)); System.out.println(testNode.getWorldRotation()); - Assert.assertTrue(worldRotation.isSimilar(testNode.getWorldRotation(),1e-6f)); - } -} + assertTrue(worldRotation.isSimilar(testNode.getWorldRotation(),1e-6f)); + } +} diff --git a/jme3-core/src/test/java/com/jme3/scene/TestIssue954.java b/jme3-core/src/test/java/com/jme3/scene/TestIssue954.java index 6b94da6641..57ffa1a435 100644 --- a/jme3-core/src/test/java/com/jme3/scene/TestIssue954.java +++ b/jme3-core/src/test/java/com/jme3/scene/TestIssue954.java @@ -31,7 +31,7 @@ */ package com.jme3.scene; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Verify that an empty Node gets a valid bounding volume. This was issue #954 diff --git a/jme3-core/src/test/java/com/jme3/scene/TestUserData.java b/jme3-core/src/test/java/com/jme3/scene/TestUserData.java index afd9d70e2b..360acc0eba 100644 --- a/jme3-core/src/test/java/com/jme3/scene/TestUserData.java +++ b/jme3-core/src/test/java/com/jme3/scene/TestUserData.java @@ -31,15 +31,17 @@ */ package com.jme3.scene; -import junit.framework.TestCase; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class TestUserData extends TestCase { +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class TestUserData { public static void userDataTest(Spatial sp, Object v) { sp.setUserData("test", v); - assertTrue("UserData is null", sp.getUserData("test") != null); - assertEquals("UserData value is different than input value", sp.getUserData("test"), v); + assertNotNull(sp.getUserData("test"), "UserData is null"); + assertEquals(v, sp.getUserData("test"), "UserData value is different than input value"); sp.setUserData("test", null); } diff --git a/jme3-core/src/test/java/com/jme3/scene/debug/TestCloneMesh.java b/jme3-core/src/test/java/com/jme3/scene/debug/TestCloneMesh.java index b2a9a7704b..651c213fd8 100644 --- a/jme3-core/src/test/java/com/jme3/scene/debug/TestCloneMesh.java +++ b/jme3-core/src/test/java/com/jme3/scene/debug/TestCloneMesh.java @@ -40,8 +40,8 @@ import com.jme3.util.clone.Cloner; import java.util.HashMap; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test cloning/saving/loading debug meshes of various types. @@ -60,13 +60,13 @@ public void testCloneArrow() { Arrow arrow = new Arrow(new Vector3f(1f, 1f, 1f)); Arrow deepClone = Cloner.deepClone(arrow); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, arrow); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, arrow); AssetManager assetManager = new DesktopAssetManager(); Arrow saveAndLoad = BinaryExporter.saveAndLoad(assetManager, arrow); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -77,13 +77,13 @@ public void testCloneGrid() { Grid grid = new Grid(5, 5, 1f); Grid deepClone = Cloner.deepClone(grid); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, grid); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, grid); AssetManager assetManager = new DesktopAssetManager(); Grid saveAndLoad = BinaryExporter.saveAndLoad(assetManager, grid); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -101,14 +101,14 @@ public void testCloneSkeletonDebugger() { = new SkeletonDebugger("sd", skeleton); SkeletonDebugger deepClone = Cloner.deepClone(skeletonDebugger); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, skeletonDebugger); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, skeletonDebugger); AssetManager assetManager = new DesktopAssetManager(); SkeletonDebugger saveAndLoad = BinaryExporter.saveAndLoad(assetManager, skeletonDebugger); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -129,14 +129,14 @@ public void testCloneSkeletonInterBoneWire() { = new SkeletonInterBoneWire(skeleton, boneLengths); SkeletonInterBoneWire deepClone = Cloner.deepClone(sibw); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, sibw); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, sibw); AssetManager assetManager = new DesktopAssetManager(); SkeletonInterBoneWire saveAndLoad = BinaryExporter.saveAndLoad(assetManager, sibw); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -153,14 +153,14 @@ public void testCloneSkeletonPoints() { SkeletonPoints skeletonPoints = new SkeletonPoints(skeleton); SkeletonPoints deepClone = Cloner.deepClone(skeletonPoints); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, skeletonPoints); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, skeletonPoints); AssetManager assetManager = new DesktopAssetManager(); SkeletonPoints saveAndLoad = BinaryExporter.saveAndLoad(assetManager, skeletonPoints); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -176,14 +176,14 @@ public void testCloneSkeletonWire() { SkeletonWire skeletonWire = new SkeletonWire(skeleton); SkeletonWire deepClone = Cloner.deepClone(skeletonWire); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, skeletonWire); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, skeletonWire); AssetManager assetManager = new DesktopAssetManager(); SkeletonWire saveAndLoad = BinaryExporter.saveAndLoad(assetManager, skeletonWire); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -194,13 +194,13 @@ public void testCloneWireBox() { WireBox box = new WireBox(0.5f, 0.5f, 0.5f); WireBox deepClone = Cloner.deepClone(box); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, box); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, box); AssetManager assetManager = new DesktopAssetManager(); WireBox saveAndLoad = BinaryExporter.saveAndLoad(assetManager, box); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -211,14 +211,14 @@ public void testCloneWireSphere() { WireSphere sphere = new WireSphere(1f); WireSphere deepClone = Cloner.deepClone(sphere); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, sphere); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, sphere); AssetManager assetManager = new DesktopAssetManager(); WireSphere saveAndLoad = BinaryExporter.saveAndLoad(assetManager, sphere); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } /** @@ -232,13 +232,13 @@ public void testIssue1462() { } WireFrustum wireFrustum = new WireFrustum(vertices); WireFrustum deepClone = Cloner.deepClone(wireFrustum); - Assert.assertNotNull(deepClone); - Assert.assertNotEquals(deepClone, wireFrustum); + Assertions.assertNotNull(deepClone); + Assertions.assertNotEquals(deepClone, wireFrustum); AssetManager assetManager = new DesktopAssetManager(); WireFrustum saveAndLoad = BinaryExporter.saveAndLoad(assetManager, wireFrustum); - Assert.assertNotNull(saveAndLoad); - Assert.assertNotEquals(deepClone, saveAndLoad); + Assertions.assertNotNull(saveAndLoad); + Assertions.assertNotEquals(deepClone, saveAndLoad); } } diff --git a/jme3-core/src/test/java/com/jme3/scene/instancing/InstancedNodeTest.java b/jme3-core/src/test/java/com/jme3/scene/instancing/InstancedNodeTest.java index 057a93a4bd..dde37c9d32 100644 --- a/jme3-core/src/test/java/com/jme3/scene/instancing/InstancedNodeTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/instancing/InstancedNodeTest.java @@ -34,8 +34,10 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Verifies that the {@link InstancedNode} class works correctly. @@ -55,18 +57,18 @@ public void testSerializationPreservesControl() throws Exception { InstancedNode instancedNode = new InstancedNode("test_instanced_node"); // Verify the control exists before serialization - Assert.assertEquals("InstancedNode should have 1 control before serialization", - 1, instancedNode.getNumControls()); + assertEquals(1, instancedNode.getNumControls(), + "InstancedNode should have 1 control before serialization"); // Serialize and deserialize InstancedNode loaded = (InstancedNode) BinaryExporter.saveAndLoad(assetManager, instancedNode); // Verify the control exists after deserialization - Assert.assertNotNull("Loaded InstancedNode should not be null", loaded); - Assert.assertEquals("InstancedNode should have 1 control after deserialization", - 1, loaded.getNumControls()); + assertNotNull(loaded, "Loaded InstancedNode should not be null"); + assertEquals(1, loaded.getNumControls(), + "InstancedNode should have 1 control after deserialization"); // Verify the control is the right type - Assert.assertNotNull("Control should not be null", loaded.getControl(0)); + assertNotNull(loaded.getControl(0), "Control should not be null"); } } diff --git a/jme3-core/src/test/java/com/jme3/scene/mesh/MeshTest.java b/jme3-core/src/test/java/com/jme3/scene/mesh/MeshTest.java index 27f0cda591..030f545f2b 100644 --- a/jme3-core/src/test/java/com/jme3/scene/mesh/MeshTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/mesh/MeshTest.java @@ -32,9 +32,9 @@ package com.jme3.scene.mesh; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.jme3.scene.Mesh; diff --git a/jme3-core/src/test/java/com/jme3/scene/mesh/VirtualIndexBufferTest.java b/jme3-core/src/test/java/com/jme3/scene/mesh/VirtualIndexBufferTest.java index a81ed9f5aa..e8f0fa40bf 100644 --- a/jme3-core/src/test/java/com/jme3/scene/mesh/VirtualIndexBufferTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/mesh/VirtualIndexBufferTest.java @@ -1,23 +1,18 @@ package com.jme3.scene.mesh; import com.jme3.scene.Mesh.Mode; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - import java.nio.IntBuffer; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class VirtualIndexBufferTest { - @Rule public ExpectedException thrown = ExpectedException.none(); - @Test public void testHybrid() { - thrown.expect(UnsupportedOperationException.class); - new VirtualIndexBuffer(8, Mode.Hybrid); + assertThrows(UnsupportedOperationException.class, () -> new VirtualIndexBuffer(8, Mode.Hybrid)); } @Test @@ -224,8 +219,7 @@ public void testGet() { @Test public void testGet_Patch() { final VirtualIndexBuffer bufferPatch = new VirtualIndexBuffer(27, Mode.Patch); - thrown.expect(UnsupportedOperationException.class); - bufferPatch.get(); + assertThrows(UnsupportedOperationException.class, bufferPatch::get); } @Test diff --git a/jme3-core/src/test/java/com/jme3/scene/plugins/OBJLoaderTest.java b/jme3-core/src/test/java/com/jme3/scene/plugins/OBJLoaderTest.java index 8fadbedae5..4fb7e325f2 100644 --- a/jme3-core/src/test/java/com/jme3/scene/plugins/OBJLoaderTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/plugins/OBJLoaderTest.java @@ -40,15 +40,15 @@ import com.jme3.scene.Spatial; import com.jme3.system.TestUtil; import com.jme3.texture.Image; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class OBJLoaderTest { private AssetManager assetManager; - @Before + @BeforeEach public void init() { assetManager = TestUtil.createAssetManager(); // texture loaders are outside of core, so creating stub diff --git a/jme3-core/src/test/java/com/jme3/scene/shape/ShapeBoundsTest.java b/jme3-core/src/test/java/com/jme3/scene/shape/ShapeBoundsTest.java index dc923f6f46..b953c7ce10 100644 --- a/jme3-core/src/test/java/com/jme3/scene/shape/ShapeBoundsTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/shape/ShapeBoundsTest.java @@ -37,8 +37,10 @@ import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.VertexBuffer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests that all shapes have had a world bound calculated, and that vertices are within those bounds. Test @@ -103,7 +105,7 @@ public void testQuad() { BoundingVolume bv = geometry.getWorldBound(); BoundingBox bb = (BoundingBox) bv; //Quad z extent 0 is normal, so not using testBounds() here. - Assert.assertTrue(bb.getXExtent() > 0 && bb.getYExtent() > 0); + assertTrue(bb.getXExtent() > 0 && bb.getYExtent() > 0); testVertices(geometry); } @@ -133,10 +135,10 @@ private void testBounds(Geometry geometry) { if (bv instanceof BoundingBox) { BoundingBox bb = (BoundingBox) bv; - Assert.assertTrue(bb.getXExtent() > 0 && bb.getYExtent() > 0 && bb.getZExtent() > 0); + assertTrue(bb.getXExtent() > 0 && bb.getYExtent() > 0 && bb.getZExtent() > 0); } else if (bv instanceof BoundingSphere) { BoundingSphere bs = (BoundingSphere) bv; - Assert.assertTrue(bs.getRadius() > 1f); + assertTrue(bs.getRadius() > 1f); } testVertices(geometry); @@ -144,14 +146,14 @@ private void testBounds(Geometry geometry) { private void testVertices(Geometry geometry) { BoundingVolume bv = geometry.getWorldBound(); - Assert.assertNotNull(bv); + assertNotNull(bv); for (int e = 0; e < geometry.getVertexCount(); e++) { float x = (Float) geometry.getMesh().getBuffer(VertexBuffer.Type.Position).getElementComponent(e, 0); float y = (Float) geometry.getMesh().getBuffer(VertexBuffer.Type.Position).getElementComponent(e, 1); float z = (Float) geometry.getMesh().getBuffer(VertexBuffer.Type.Position).getElementComponent(e, 2); Vector3f vertex = new Vector3f(x, y, z); - Assert.assertTrue("Vertex outside world bound: " + vertex, bv.intersects(vertex)); + assertTrue(bv.intersects(vertex), "Vertex outside world bound: " + vertex); } } } diff --git a/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenGeometryExtendedTest.java b/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenGeometryExtendedTest.java index 3b264a4177..541a1294a5 100644 --- a/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenGeometryExtendedTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenGeometryExtendedTest.java @@ -5,40 +5,34 @@ import com.jme3.scene.Mesh; import com.jme3.scene.Node; import com.jme3.scene.shape.Box; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.mockito.Mockito; - -import java.util.Arrays; -import java.util.Collection; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; import java.util.function.Consumer; +import java.util.stream.Stream; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mockito; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Parameterized tests for SceneGraphThreadWarden class with Geometry objects. * These tests verify that various scene graph mutations are properly checked for thread safety. */ -@RunWith(Parameterized.class) public class SceneGraphThreadWardenGeometryExtendedTest { private static ExecutorService executorService; - private final String testName; - private final Consumer action; - @SuppressWarnings({"ReassignedVariable", "AssertWithSideEffects"}) - @BeforeClass + @BeforeAll public static void setupClass() { // Make sure assertions are enabled boolean assertsEnabled = false; @@ -48,70 +42,46 @@ public static void setupClass() { } } - @Before + @BeforeEach public void setup() { executorService = newSingleThreadDaemonExecutor(); } - @After + @AfterEach public void tearDown() { executorService.shutdown(); SceneGraphThreadWarden.reset(); } - /** - * Constructor for the parameterized test. - * - * @param testName A descriptive name for the test - * @param action The action to perform on the spatial - */ - public SceneGraphThreadWardenGeometryExtendedTest(String testName, Consumer action) { - this.testName = testName; - this.action = action; - } - /** * Define the parameters for the test. * Each parameter is a pair of (test name, action to perform on spatial). */ - @Parameterized.Parameters(name = "{0}") - public static Collection data() { + static Stream data() { Material mockMaterial = Mockito.mock(Material.class); Box box = new Box(1, 1, 1); - return Arrays.asList(new Object[][] { - { - "setMaterial", - (Consumer) spatial -> spatial.setMaterial(mockMaterial) - }, - { - "setMesh", - (Consumer) spatial -> spatial.setMesh(box) - }, - { - "setLodLevel", - (Consumer) spatial -> { - // Need to set a mesh with LOD levels first + return Stream.of( + Arguments.of("setMaterial", (Consumer) spatial -> spatial.setMaterial(mockMaterial)), + Arguments.of("setMesh", (Consumer) spatial -> spatial.setMesh(box)), + Arguments.of("setLodLevel", (Consumer) spatial -> { Mesh mesh = new Box(1, 1, 1); mesh.setLodLevels(new com.jme3.scene.VertexBuffer[]{ - mesh.getBuffer(com.jme3.scene.VertexBuffer.Type.Index) + mesh.getBuffer(com.jme3.scene.VertexBuffer.Type.Index) }); spatial.setMesh(mesh); spatial.setLodLevel(0); - } - }, - { - "removeFromParent", - (Consumer) Geometry::removeFromParent - } - }); + }), + Arguments.of("removeFromParent", (Consumer) Geometry::removeFromParent) + ); } /** * Test that scene graph mutation is fine on the main thread when the object is attached to the root. */ - @Test - public void testMutationOnMainThreadOnAttachedObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnMainThreadOnAttachedObject(String testName, Consumer action) { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -126,8 +96,9 @@ public void testMutationOnMainThreadOnAttachedObject() { /** * Test that scene graph mutation is fine on the main thread when the object is not attached to the root. */ - @Test - public void testMutationOnMainThreadOnDetachedObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnMainThreadOnDetachedObject(String testName, Consumer action) { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -141,8 +112,10 @@ public void testMutationOnMainThreadOnDetachedObject() { /** * Test that scene graph mutation is fine on a non-main thread when the object is not attached to the root. */ - @Test - public void testMutationOnNonMainThreadOnDetachedObject() throws ExecutionException, InterruptedException { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnNonMainThreadOnDetachedObject(String testName, Consumer action) + throws ExecutionException, InterruptedException { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -162,8 +135,10 @@ public void testMutationOnNonMainThreadOnDetachedObject() throws ExecutionExcept /** * Test that scene graph mutation is not allowed on a non-main thread when the object is attached to the root. */ - @Test - public void testMutationOnNonMainThreadOnAttachedObject() throws InterruptedException { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnNonMainThreadOnAttachedObject(String testName, Consumer action) + throws InterruptedException { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -182,8 +157,8 @@ public void testMutationOnNonMainThreadOnAttachedObject() throws InterruptedExce fail("Expected an IllegalThreadSceneGraphMutation exception"); } catch (ExecutionException e) { // This is expected - verify it's the right exception type - assertTrue("Expected IllegalThreadSceneGraphMutation, got: " + e.getCause().getClass().getName(), - e.getCause() instanceof IllegalThreadSceneGraphMutation); + assertTrue(e.getCause() instanceof IllegalThreadSceneGraphMutation, + "Expected IllegalThreadSceneGraphMutation, got: " + e.getCause().getClass().getName()); } } @@ -204,4 +179,4 @@ private static ThreadFactory daemonThreadFactory() { return t; }; } -} \ No newline at end of file +} diff --git a/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenNodeExtendedTest.java b/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenNodeExtendedTest.java index 7c36f07bcd..3b56c21391 100644 --- a/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenNodeExtendedTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenNodeExtendedTest.java @@ -5,40 +5,34 @@ import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.shader.VarType; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.mockito.Mockito; - -import java.util.Arrays; -import java.util.Collection; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; import java.util.function.Consumer; +import java.util.stream.Stream; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mockito; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Parameterized tests for SceneGraphThreadWarden class. * These tests verify that various scene graph mutations are properly checked for thread safety. */ -@RunWith(Parameterized.class) public class SceneGraphThreadWardenNodeExtendedTest { private static ExecutorService executorService; - private final String testName; - private final Consumer action; - @SuppressWarnings({"ReassignedVariable", "AssertWithSideEffects"}) - @BeforeClass + @BeforeAll public static void setupClass() { // Make sure assertions are enabled boolean assertsEnabled = false; @@ -48,66 +42,40 @@ public static void setupClass() { } } - @Before + @BeforeEach public void setup() { executorService = newSingleThreadDaemonExecutor(); } - @After + @AfterEach public void tearDown() { executorService.shutdown(); SceneGraphThreadWarden.reset(); } - /** - * Constructor for the parameterized test. - * - * @param testName A descriptive name for the test - * @param action The action to perform on the spatial - */ - public SceneGraphThreadWardenNodeExtendedTest(String testName, Consumer action) { - this.testName = testName; - this.action = action; - } - /** * Define the parameters for the test. * Each parameter is a pair of (test name, action to perform on spatial). */ - @Parameterized.Parameters(name = "{0}") - public static Collection data() { + static Stream data() { Material mockMaterial = Mockito.mock(Material.class); MatParamOverride override = new MatParamOverride(VarType.Float, "TestParam", 1.0f); - return Arrays.asList(new Object[][] { - { - "setMaterial", - (Consumer) spatial -> spatial.setMaterial(mockMaterial) - }, - { - "setLodLevel", - (Consumer) spatial -> spatial.setLodLevel(1) - }, - { - "addMatParamOverride", - (Consumer) spatial -> spatial.addMatParamOverride(override) - }, - { - "removeMatParamOverride", - (Consumer) spatial -> spatial.removeMatParamOverride(override) - }, - { - "clearMatParamOverrides", - (Consumer) Spatial::clearMatParamOverrides - } - }); + return Stream.of( + Arguments.of("setMaterial", (Consumer) spatial -> spatial.setMaterial(mockMaterial)), + Arguments.of("setLodLevel", (Consumer) spatial -> spatial.setLodLevel(1)), + Arguments.of("addMatParamOverride", (Consumer) spatial -> spatial.addMatParamOverride(override)), + Arguments.of("removeMatParamOverride", (Consumer) spatial -> spatial.removeMatParamOverride(override)), + Arguments.of("clearMatParamOverrides", (Consumer) Spatial::clearMatParamOverrides) + ); } /** * Test that scene graph mutation is fine on the main thread when the object is attached to the root. */ - @Test - public void testMutationOnMainThreadOnAttachedObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnMainThreadOnAttachedObject(String testName, Consumer action) { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -122,8 +90,9 @@ public void testMutationOnMainThreadOnAttachedObject() { /** * Test that scene graph mutation is fine on the main thread when the object is not attached to the root. */ - @Test - public void testMutationOnMainThreadOnDetachedObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnMainThreadOnDetachedObject(String testName, Consumer action) { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -137,8 +106,10 @@ public void testMutationOnMainThreadOnDetachedObject() { /** * Test that scene graph mutation is fine on a non-main thread when the object is not attached to the root. */ - @Test - public void testMutationOnNonMainThreadOnDetachedObject() throws ExecutionException, InterruptedException { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnNonMainThreadOnDetachedObject(String testName, Consumer action) + throws ExecutionException, InterruptedException { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -158,8 +129,10 @@ public void testMutationOnNonMainThreadOnDetachedObject() throws ExecutionExcept /** * Test that scene graph mutation is not allowed on a non-main thread when the object is attached to the root. */ - @Test - public void testMutationOnNonMainThreadOnAttachedObject() throws InterruptedException { + @ParameterizedTest(name = "{0}") + @MethodSource("data") + public void testMutationOnNonMainThreadOnAttachedObject(String testName, Consumer action) + throws InterruptedException { Node rootNode = new Node("root"); SceneGraphThreadWarden.setup(rootNode); @@ -178,8 +151,8 @@ public void testMutationOnNonMainThreadOnAttachedObject() throws InterruptedExce fail("Expected an IllegalThreadSceneGraphMutation exception"); } catch (ExecutionException e) { // This is expected - verify it's the right exception type - assertTrue("Expected IllegalThreadSceneGraphMutation, got: " + e.getCause().getClass().getName(), - e.getCause() instanceof IllegalThreadSceneGraphMutation); + assertTrue(e.getCause() instanceof IllegalThreadSceneGraphMutation, + "Expected IllegalThreadSceneGraphMutation, got: " + e.getCause().getClass().getName()); } } diff --git a/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenTest.java b/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenTest.java index b06c4cc8cc..64fe3495c9 100644 --- a/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/threadwarden/SceneGraphThreadWardenTest.java @@ -1,10 +1,10 @@ package com.jme3.scene.threadwarden; import com.jme3.scene.Node; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -12,8 +12,8 @@ import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests for SceneGraphThreadWarden class. @@ -29,7 +29,7 @@ public class SceneGraphThreadWardenTest { private static ExecutorService executorService2; @SuppressWarnings({"ReassignedVariable", "AssertWithSideEffects"}) - @BeforeClass + @BeforeAll public static void setupClass() { // Make sure assertions are enabled boolean assertsEnabled = false; @@ -40,13 +40,13 @@ public static void setupClass() { } } - @Before + @BeforeEach public void setup() { executorService = newSingleThreadDaemonExecutor(); executorService2 = newSingleThreadDaemonExecutor(); } - @After + @AfterEach public void tearDown() { executorService.shutdown(); executorService2.shutdown(); @@ -85,8 +85,8 @@ public void restrictingTheSameRootNodeToTwoThreadsIsIllegal() throws ExecutionEx fail("Expected an IllegalThreadSceneGraphMutation exception"); } catch (ExecutionException e) { // This is expected - verify it's the right exception type - assertTrue("Expected IllegalStateException, got: " + e.getCause().getClass().getName(), - e.getCause() instanceof IllegalStateException); + assertTrue(e.getCause() instanceof IllegalStateException, + "Expected IllegalStateException, got: " + e.getCause().getClass().getName()); } } @@ -416,8 +416,8 @@ private void expectSceneGraphException(Future future){ fail("Expected an IllegalThreadSceneGraphMutation exception"); } catch (ExecutionException e) { // This is expected - verify it's the right exception type - assertTrue("Expected IllegalThreadSceneGraphMutation, got: " + e.getCause().getClass().getName(), - e.getCause() instanceof IllegalThreadSceneGraphMutation); + assertTrue(e.getCause() instanceof IllegalThreadSceneGraphMutation, + "Expected IllegalThreadSceneGraphMutation, got: " + e.getCause().getClass().getName()); } catch (InterruptedException e){ fail("Unexpected InterruptedException"); } diff --git a/jme3-core/src/test/java/com/jme3/shader/DefineListTest.java b/jme3-core/src/test/java/com/jme3/shader/DefineListTest.java index ac3ada832b..8b2fc17f22 100644 --- a/jme3-core/src/test/java/com/jme3/shader/DefineListTest.java +++ b/jme3-core/src/test/java/com/jme3/shader/DefineListTest.java @@ -35,9 +35,9 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DefineListTest { diff --git a/jme3-core/src/test/java/com/jme3/shader/GLSLPreprocessorTest.java b/jme3-core/src/test/java/com/jme3/shader/GLSLPreprocessorTest.java index 5ba4ecd2c7..f33326fa06 100644 --- a/jme3-core/src/test/java/com/jme3/shader/GLSLPreprocessorTest.java +++ b/jme3-core/src/test/java/com/jme3/shader/GLSLPreprocessorTest.java @@ -31,8 +31,8 @@ */ package com.jme3.shader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -43,7 +43,7 @@ import com.jme3.asset.AssetKey; import com.jme3.system.TestUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jme3tools.shader.Preprocessor; diff --git a/jme3-core/src/test/java/com/jme3/shader/UniformTest.java b/jme3-core/src/test/java/com/jme3/shader/UniformTest.java index 1c67633b4e..d6e88bb3a4 100644 --- a/jme3-core/src/test/java/com/jme3/shader/UniformTest.java +++ b/jme3-core/src/test/java/com/jme3/shader/UniformTest.java @@ -32,14 +32,14 @@ package com.jme3.shader; import com.jme3.math.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.Arrays; -import static org.junit.Assert.*; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; public class UniformTest { diff --git a/jme3-core/src/test/java/com/jme3/shadow/FilterPostProcessingTest.java b/jme3-core/src/test/java/com/jme3/shadow/FilterPostProcessingTest.java index 83ff564b0b..c747143bcd 100644 --- a/jme3-core/src/test/java/com/jme3/shadow/FilterPostProcessingTest.java +++ b/jme3-core/src/test/java/com/jme3/shadow/FilterPostProcessingTest.java @@ -10,8 +10,8 @@ import com.jme3.math.Vector3f; import com.jme3.post.Filter; import com.jme3.post.FilterPostProcessor; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code FilterPostProcessing} class. diff --git a/jme3-core/src/test/java/com/jme3/test/PreventCoreIssueRegressions.java b/jme3-core/src/test/java/com/jme3/test/PreventCoreIssueRegressions.java index d754c40ed3..c5af2b3038 100644 --- a/jme3-core/src/test/java/com/jme3/test/PreventCoreIssueRegressions.java +++ b/jme3-core/src/test/java/com/jme3/test/PreventCoreIssueRegressions.java @@ -50,12 +50,15 @@ import com.jme3.scene.Node; import com.jme3.system.JmeSystem; import com.jme3.system.NullRenderer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.lang.reflect.Field; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * The Test Suite to prevent regressions from previously fixed Core issues * @author Stephen Gold <sgold@sonic.net> @@ -86,21 +89,21 @@ public void simpleInitApp() { } app.getRenderManager().createPostView("null", new Camera(1, 1)); - Assert.assertTrue(app.getStateManager().attach(screenshotAppState)); + assertTrue(app.getStateManager().attach(screenshotAppState)); app.getStateManager().update(0f); // Causes SAS#initialize to be called // Confirm that the SceneProcessor is attached. List vps = app.getRenderManager().getPostViews(); - Assert.assertEquals(1, vps.size()); - Assert.assertEquals(1, vps.get(0).getProcessors().size()); - Assert.assertTrue(app.getInputManager().hasMapping("ScreenShot")); // Confirm that KEY_SYSRQ is mapped. - Assert.assertTrue(app.getStateManager().detach(screenshotAppState)); + assertEquals(1, vps.size()); + assertEquals(1, vps.get(0).getProcessors().size()); + assertTrue(app.getInputManager().hasMapping("ScreenShot")); // Confirm that KEY_SYSRQ is mapped. + assertTrue(app.getStateManager().detach(screenshotAppState)); app.getStateManager().update(0f); // Causes SAS#cleanup to be called // Check whether the SceneProcessor is still attached. - Assert.assertEquals(0, vps.get(0).getProcessors().size()); - Assert.assertFalse(app.getInputManager().hasMapping("ScreenShot")); // Confirm that KEY_SYSRQ is unmapped. + assertEquals(0, vps.get(0).getProcessors().size()); + assertFalse(app.getInputManager().hasMapping("ScreenShot")); // Confirm that KEY_SYSRQ is unmapped. } /** @@ -118,16 +121,16 @@ public void testIssue1138() { SkinningControl sControl = cgModel.getControl(SkinningControl.class); for (Joint joint : sControl.getArmature().getJointList()) { - Assert.assertTrue("Invalid translation for joint " + joint.getName(), - Vector3f.isValidVector(joint.getLocalTranslation())); + assertTrue(Vector3f.isValidVector(joint.getLocalTranslation()), + "Invalid translation for joint " + joint.getName()); } cgModel.updateLogicalState(1.0f); cgModel.updateGeometricState(); for (Joint joint : sControl.getArmature().getJointList()) { - Assert.assertTrue("Invalid translation for joint " + joint.getName(), - Vector3f.isValidVector(joint.getLocalTranslation())); + assertTrue(Vector3f.isValidVector(joint.getLocalTranslation()), + "Invalid translation for joint " + joint.getName()); } } } diff --git a/jme3-core/src/test/java/com/jme3/texture/TestIssue2250.java b/jme3-core/src/test/java/com/jme3/texture/TestIssue2250.java index 51d9e9e007..0ed611ba4f 100644 --- a/jme3-core/src/test/java/com/jme3/texture/TestIssue2250.java +++ b/jme3-core/src/test/java/com/jme3/texture/TestIssue2250.java @@ -35,7 +35,7 @@ import com.jme3.util.BufferUtils; import java.nio.ByteBuffer; import java.util.ArrayList; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Verify that setMultiSamples(1) can be applied to any Image. This was issue diff --git a/jme3-core/src/test/java/com/jme3/texture/TextureArrayTest.java b/jme3-core/src/test/java/com/jme3/texture/TextureArrayTest.java index bd861b9879..6d47239cfa 100644 --- a/jme3-core/src/test/java/com/jme3/texture/TextureArrayTest.java +++ b/jme3-core/src/test/java/com/jme3/texture/TextureArrayTest.java @@ -31,7 +31,7 @@ */ package com.jme3.texture; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; @@ -43,7 +43,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class TextureArrayTest { diff --git a/jme3-core/src/test/java/com/jme3/tools/LodGeneratorTest.java b/jme3-core/src/test/java/com/jme3/tools/LodGeneratorTest.java index cdf1e9fad5..3280d25da5 100644 --- a/jme3-core/src/test/java/com/jme3/tools/LodGeneratorTest.java +++ b/jme3-core/src/test/java/com/jme3/tools/LodGeneratorTest.java @@ -32,9 +32,9 @@ package com.jme3.tools; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.jme3.asset.AssetManager; import com.jme3.scene.Geometry; diff --git a/jme3-core/src/test/java/com/jme3/util/ListMapTest.java b/jme3-core/src/test/java/com/jme3/util/ListMapTest.java index 15430a8054..10deb87e77 100644 --- a/jme3-core/src/test/java/com/jme3/util/ListMapTest.java +++ b/jme3-core/src/test/java/com/jme3/util/ListMapTest.java @@ -32,7 +32,7 @@ package com.jme3.util; import java.util.Map.Entry; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Check if the {@link ListMap} class is working correctly. diff --git a/jme3-core/src/test/java/com/jme3/util/ListSortTest.java b/jme3-core/src/test/java/com/jme3/util/ListSortTest.java index 03483cc6f6..80d95825b5 100644 --- a/jme3-core/src/test/java/com/jme3/util/ListSortTest.java +++ b/jme3-core/src/test/java/com/jme3/util/ListSortTest.java @@ -37,10 +37,11 @@ import static org.hamcrest.CoreMatchers.everyItem; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Verifies order of entries sorted by {@link ListSort} and checks if all @@ -52,7 +53,7 @@ public class ListSortTest { private Integer[] arrayToSort; - @Before + @BeforeEach public void initTestArray() { arrayToSort = new Integer[]{36, 10, 16, 9, 14, 32, 35, 22, 1, 27, 18, 11, 30, 15, 2, 12, 32, 27, 11, 45, 7, 32, 36, 11, 39, 32, 45, 35, 40, 17, @@ -62,13 +63,13 @@ public void initTestArray() { @Test public void testBinarySortFirstRun() throws ReflectiveOperationException { - assertTrue("Array to sort must be smaller than merge-sort threshhold.", arrayToSort.length < 128); + assertTrue(arrayToSort.length < 128, "Array to sort must be smaller than merge-sort threshhold."); sortAndAssert(arrayToSort, false); } @Test public void testBinarySort() throws ReflectiveOperationException { - assertTrue("Array to sort must be smaller than merge-sort threshhold.", arrayToSort.length < 128); + assertTrue(arrayToSort.length < 128, "Array to sort must be smaller than merge-sort threshhold."); sortAndAssert(arrayToSort, true); } @@ -78,7 +79,7 @@ public void testMergeSortFirstRun() throws ReflectiveOperationException { System.arraycopy(arrayToSort, 0, bigArray, arrayToSort.length, arrayToSort.length); System.arraycopy(arrayToSort, 0, bigArray, arrayToSort.length * 2, arrayToSort.length); - assertTrue("Array to sort must be bigger than merge-sort threshhold.", bigArray.length > 128); + assertTrue(bigArray.length > 128, "Array to sort must be bigger than merge-sort threshhold."); sortAndAssert(bigArray, false); } @@ -88,7 +89,7 @@ public void testMergeSort() throws ReflectiveOperationException { System.arraycopy(arrayToSort, 0, bigArray, arrayToSort.length, arrayToSort.length); System.arraycopy(arrayToSort, 0, bigArray, arrayToSort.length * 2, arrayToSort.length); - assertTrue("Array to sort must be bigger than merge-sort threshhold.", bigArray.length > 128); + assertTrue(bigArray.length > 128, "Array to sort must be bigger than merge-sort threshhold."); sortAndAssert(bigArray, true); } diff --git a/jme3-core/src/test/java/com/jme3/util/StructTest.java b/jme3-core/src/test/java/com/jme3/util/StructTest.java index 6dace56b16..7f33494421 100644 --- a/jme3-core/src/test/java/com/jme3/util/StructTest.java +++ b/jme3-core/src/test/java/com/jme3/util/StructTest.java @@ -1,8 +1,8 @@ package com.jme3.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +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.nio.ByteBuffer; @@ -15,7 +15,7 @@ import com.jme3.util.struct.StructUtils; import com.jme3.util.struct.fields.*; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class StructTest { static class SubStruct implements Struct { @@ -119,7 +119,7 @@ public void testStd140PartialUpdate() { BufferRegion region = dirtyI.next(); if (region == null) break; - assertFalse("Update not expected", true); + assertFalse(true, "Update not expected"); nUpdated++; } bo.clearUpdateNeeded(); diff --git a/jme3-core/src/test/java/com/jme3/util/TempVarsTest.java b/jme3-core/src/test/java/com/jme3/util/TempVarsTest.java index c5138b5eaa..89daa71064 100644 --- a/jme3-core/src/test/java/com/jme3/util/TempVarsTest.java +++ b/jme3-core/src/test/java/com/jme3/util/TempVarsTest.java @@ -41,9 +41,10 @@ import static org.hamcrest.CoreMatchers.everyItem; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @@ -82,11 +83,11 @@ private void addAndAssertData(final TempVars tempVars) throws ReflectiveOperatio tempVars.spatialStack[0] = spatial0; tempVars.spatialStack[3] = spatial1; - assertArrayEquals("bihStack must contain two matching entries.", - new BIHNode.BIHStackData[]{bihStackData0, bihStackData1}, - tempVars.bihStack.toArray()); + assertArrayEquals(new BIHNode.BIHStackData[]{bihStackData0, bihStackData1}, + tempVars.bihStack.toArray(), + "bihStack must contain two matching entries."); - assertEquals("collisionResults must contain three entries.", 3, tempVars.collisionResults.size()); + assertEquals(3, tempVars.collisionResults.size(), "collisionResults must contain three entries."); assertThat("collisionResults must contain three matching entries.", tempVars.collisionResults, CoreMatchers.hasItems(collisionResult0, collisionResult1, collisionResult2)); @@ -94,7 +95,8 @@ private void addAndAssertData(final TempVars tempVars) throws ReflectiveOperatio final Spatial[] expectedSpatialStack = new Spatial[tempVars.spatialStack.length]; expectedSpatialStack[0] = spatial0; expectedSpatialStack[3] = spatial1; - assertArrayEquals("spatialStack must contain two matching entries.", expectedSpatialStack, tempVars.spatialStack); + assertArrayEquals(expectedSpatialStack, tempVars.spatialStack, + "spatialStack must contain two matching entries."); } @Test @@ -104,8 +106,9 @@ public void testRemovesValuesOnReleaseAndClose() throws ReflectiveOperationExcep addData(tempVars); tempVars.release(); - assertEquals("bihStack must be empty after releasing tempVars.", 0, tempVars.bihStack.size()); - assertEquals("collisionResults must be empty after releasing tempVars.", 0, tempVars.collisionResults.size()); + assertEquals(0, tempVars.bihStack.size(), "bihStack must be empty after releasing tempVars."); + assertEquals(0, tempVars.collisionResults.size(), + "collisionResults must be empty after releasing tempVars."); assertThat("All entries in spatialStack must be null after releasing tempVars.", Arrays.asList(tempVars.spatialStack), everyItem(nullValue(Spatial.class))); @@ -113,8 +116,10 @@ public void testRemovesValuesOnReleaseAndClose() throws ReflectiveOperationExcep { final TempVars tempVars = TempVars.get(); - assertEquals("bihStack must be empty after releasing and getting the same tempVars.", 0, tempVars.bihStack.size()); - assertEquals("collisionResults must be empty after releasing and getting the same tempVars.", 0, tempVars.collisionResults.size()); + assertEquals(0, tempVars.bihStack.size(), + "bihStack must be empty after releasing and getting the same tempVars."); + assertEquals(0, tempVars.collisionResults.size(), + "collisionResults must be empty after releasing and getting the same tempVars."); assertThat("All entries in spatialStack must be null after releasing and getting tempVars.", Arrays.asList(tempVars.spatialStack), everyItem(nullValue(Spatial.class))); @@ -126,8 +131,10 @@ public void testRemovesValuesOnReleaseAndClose() throws ReflectiveOperationExcep } try (final TempVars tempVars = TempVars.get()) { - assertEquals("bihStack must be empty after closing and getting the same tempVars.", 0, tempVars.bihStack.size()); - assertEquals("collisionResults must be empty after closing and getting the same tempVars.", 0, tempVars.collisionResults.size()); + assertEquals(0, tempVars.bihStack.size(), + "bihStack must be empty after closing and getting the same tempVars."); + assertEquals(0, tempVars.collisionResults.size(), + "collisionResults must be empty after closing and getting the same tempVars."); assertThat("All entries in spatialStack must be null after closing and getting tempVars.", Arrays.asList(tempVars.spatialStack), everyItem(nullValue(Spatial.class))); diff --git a/jme3-core/src/test/java/com/jme3/util/TestIssue1909.java b/jme3-core/src/test/java/com/jme3/util/TestIssue1909.java index 3cc91ef6f6..aed7efb7bf 100644 --- a/jme3-core/src/test/java/com/jme3/util/TestIssue1909.java +++ b/jme3-core/src/test/java/com/jme3/util/TestIssue1909.java @@ -36,8 +36,8 @@ import com.jme3.scene.VertexBuffer; import com.jme3.util.mikktspace.MikktspaceTangentGenerator; import java.nio.FloatBuffer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Verifies that tangents can be generated without an index buffer. This was @@ -92,6 +92,6 @@ public void testIssue1909() { MikktspaceTangentGenerator.generate(testGeometry); VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); - Assert.assertNotNull(tangents); + Assertions.assertNotNull(tangents); } } diff --git a/jme3-core/src/test/java/com/jme3/util/TestIssue1919.java b/jme3-core/src/test/java/com/jme3/util/TestIssue1919.java index 87283c1c9a..afe6f40b07 100644 --- a/jme3-core/src/test/java/com/jme3/util/TestIssue1919.java +++ b/jme3-core/src/test/java/com/jme3/util/TestIssue1919.java @@ -32,12 +32,15 @@ package com.jme3.util; import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; -import com.jme3.scene.VertexBuffer; -import com.jme3.util.mikktspace.MikktspaceTangentGenerator; -import java.nio.FloatBuffer; -import org.junit.Assert; -import org.junit.Test; +import com.jme3.scene.Mesh; +import com.jme3.scene.VertexBuffer; +import com.jme3.util.mikktspace.MikktspaceTangentGenerator; +import java.nio.FloatBuffer; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Verifies how MikktspaceTangentGenerator handles various mesh modes. This was @@ -54,10 +57,10 @@ public class TestIssue1919 { /** * Tests a Hybrid-mode mesh. */ - @Test(expected = UnsupportedOperationException.class) - public void testHybrid() { - Geometry testGeometry = createGeometry(Mesh.Mode.Hybrid); - MikktspaceTangentGenerator.generate(testGeometry); + @Test + public void testHybrid() { + assertThrows(UnsupportedOperationException.class, + () -> MikktspaceTangentGenerator.generate(createGeometry(Mesh.Mode.Hybrid))); } /** @@ -70,7 +73,7 @@ public void testLineLoop() { Mesh mesh = testGeometry.getMesh(); VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); - Assert.assertNull(tangents); /// skipped this mesh + assertNull(tangents); /// skipped this mesh } /** @@ -83,7 +86,7 @@ public void testLineStrip() { Mesh mesh = testGeometry.getMesh(); VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); - Assert.assertNull(tangents); /// skipped this mesh + assertNull(tangents); /// skipped this mesh } /** @@ -96,17 +99,17 @@ public void testLines() { Mesh mesh = testGeometry.getMesh(); VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); - Assert.assertNull(tangents); // skipped this mesh + assertNull(tangents); // skipped this mesh } /** * Tests a Patch-mode mesh. */ - @Test(expected = UnsupportedOperationException.class) - public void testPatch() { - Geometry testGeometry = createGeometry(Mesh.Mode.Patch); - MikktspaceTangentGenerator.generate(testGeometry); - } + @Test + public void testPatch() { + assertThrows(UnsupportedOperationException.class, + () -> MikktspaceTangentGenerator.generate(createGeometry(Mesh.Mode.Patch))); + } /** * Tests a Points-mode mesh. @@ -118,7 +121,7 @@ public void testPoints() { Mesh mesh = testGeometry.getMesh(); VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); - Assert.assertNull(tangents); // skipped this mesh + assertNull(tangents); // skipped this mesh } /** @@ -131,8 +134,8 @@ public void testTriangles() { Mesh mesh = testGeometry.getMesh(); VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); - Assert.assertNotNull(tangents); // generated tangents - } + assertNotNull(tangents); // generated tangents + } /** * Generates a geometry in the X-Z plane with the specified mesh mode. diff --git a/jme3-effects/src/test/java/com/jme3/post/filters/CartoonEdgeFilterTest.java b/jme3-effects/src/test/java/com/jme3/post/filters/CartoonEdgeFilterTest.java index 7c4972653c..79b19ec7b6 100644 --- a/jme3-effects/src/test/java/com/jme3/post/filters/CartoonEdgeFilterTest.java +++ b/jme3-effects/src/test/java/com/jme3/post/filters/CartoonEdgeFilterTest.java @@ -1,7 +1,7 @@ package com.jme3.post.filters; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; @@ -32,13 +32,13 @@ public void testSaveAndLoad() { CartoonEdgeFilter filter = BinaryExporter.saveAndLoad(assetManager, cartoon); - Assert.assertEquals(ColorRGBA.Red, filter.getEdgeColor()); - Assert.assertEquals(.5f, filter.getEdgeIntensity(), 0.0001); - Assert.assertEquals(1, filter.getEdgeWidth(), 0.0001); - Assert.assertEquals(2, filter.getNormalSensitivity(), 0.0001); - Assert.assertEquals(1, filter.getNormalThreshold(), 0.0001); - Assert.assertEquals(20, filter.getDepthSensitivity(), 0.0001); - Assert.assertEquals(2, filter.getDepthThreshold(), 0.0001); + Assertions.assertEquals(ColorRGBA.Red, filter.getEdgeColor()); + Assertions.assertEquals(.5f, filter.getEdgeIntensity(), 0.0001); + Assertions.assertEquals(1, filter.getEdgeWidth(), 0.0001); + Assertions.assertEquals(2, filter.getNormalSensitivity(), 0.0001); + Assertions.assertEquals(1, filter.getNormalThreshold(), 0.0001); + Assertions.assertEquals(20, filter.getDepthSensitivity(), 0.0001); + Assertions.assertEquals(2, filter.getDepthThreshold(), 0.0001); } } diff --git a/jme3-effects/src/test/java/com/jme3/post/filters/CrossHatchFilterTest.java b/jme3-effects/src/test/java/com/jme3/post/filters/CrossHatchFilterTest.java index 5b2006e55e..7fdc58e03a 100644 --- a/jme3-effects/src/test/java/com/jme3/post/filters/CrossHatchFilterTest.java +++ b/jme3-effects/src/test/java/com/jme3/post/filters/CrossHatchFilterTest.java @@ -35,8 +35,8 @@ import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; import com.jme3.math.ColorRGBA; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code CrossHatchFilter} class. @@ -71,20 +71,20 @@ public void testSaveAndLoad() { CrossHatchFilter copy = BinaryExporter.saveAndLoad(assetManager, filter); // Verify the parameter values of the copy: - Assert.assertEquals(0.7f, copy.getColorInfluenceLine(), 0f); - Assert.assertEquals(0.2f, copy.getColorInfluencePaper(), 0f); - Assert.assertEquals(0.95f, copy.getFillValue(), 0f); - Assert.assertEquals(ColorRGBA.Blue, copy.getLineColor()); - Assert.assertEquals(3f, copy.getLineDistance(), 0f); - Assert.assertEquals(0.9f, copy.getLineThickness(), 0f); - Assert.assertEquals(0.95f, copy.getLuminance1(), 0f); - Assert.assertEquals(0.75f, copy.getLuminance2(), 0f); - Assert.assertEquals(0.54f, copy.getLuminance3(), 0f); - Assert.assertEquals(0.32f, copy.getLuminance4(), 0f); - Assert.assertEquals(0.21f, copy.getLuminance5(), 0f); - Assert.assertEquals("CrossHatchFilter", copy.getName()); - Assert.assertEquals(ColorRGBA.Yellow, copy.getPaperColor()); - Assert.assertFalse(copy.isEnabled()); + Assertions.assertEquals(0.7f, copy.getColorInfluenceLine(), 0f); + Assertions.assertEquals(0.2f, copy.getColorInfluencePaper(), 0f); + Assertions.assertEquals(0.95f, copy.getFillValue(), 0f); + Assertions.assertEquals(ColorRGBA.Blue, copy.getLineColor()); + Assertions.assertEquals(3f, copy.getLineDistance(), 0f); + Assertions.assertEquals(0.9f, copy.getLineThickness(), 0f); + Assertions.assertEquals(0.95f, copy.getLuminance1(), 0f); + Assertions.assertEquals(0.75f, copy.getLuminance2(), 0f); + Assertions.assertEquals(0.54f, copy.getLuminance3(), 0f); + Assertions.assertEquals(0.32f, copy.getLuminance4(), 0f); + Assertions.assertEquals(0.21f, copy.getLuminance5(), 0f); + Assertions.assertEquals("CrossHatchFilter", copy.getName()); + Assertions.assertEquals(ColorRGBA.Yellow, copy.getPaperColor()); + Assertions.assertFalse(copy.isEnabled()); } /** @@ -94,19 +94,19 @@ public void testSaveAndLoad() { * @param filter (not null, unaffected) */ private void verifyDefaults(CrossHatchFilter filter) { - Assert.assertEquals(0.8f, filter.getColorInfluenceLine(), 0f); - Assert.assertEquals(0.1f, filter.getColorInfluencePaper(), 0f); - Assert.assertEquals(0.9f, filter.getFillValue(), 0f); - Assert.assertEquals(ColorRGBA.Black, filter.getLineColor()); - Assert.assertEquals(4f, filter.getLineDistance(), 0f); - Assert.assertEquals(1f, filter.getLineThickness(), 0f); - Assert.assertEquals(0.9f, filter.getLuminance1(), 0f); - Assert.assertEquals(0.7f, filter.getLuminance2(), 0f); - Assert.assertEquals(0.5f, filter.getLuminance3(), 0f); - Assert.assertEquals(0.3f, filter.getLuminance4(), 0f); - Assert.assertEquals(0f, filter.getLuminance5(), 0f); - Assert.assertEquals("CrossHatchFilter", filter.getName()); - Assert.assertEquals(ColorRGBA.White, filter.getPaperColor()); - Assert.assertTrue(filter.isEnabled()); + Assertions.assertEquals(0.8f, filter.getColorInfluenceLine(), 0f); + Assertions.assertEquals(0.1f, filter.getColorInfluencePaper(), 0f); + Assertions.assertEquals(0.9f, filter.getFillValue(), 0f); + Assertions.assertEquals(ColorRGBA.Black, filter.getLineColor()); + Assertions.assertEquals(4f, filter.getLineDistance(), 0f); + Assertions.assertEquals(1f, filter.getLineThickness(), 0f); + Assertions.assertEquals(0.9f, filter.getLuminance1(), 0f); + Assertions.assertEquals(0.7f, filter.getLuminance2(), 0f); + Assertions.assertEquals(0.5f, filter.getLuminance3(), 0f); + Assertions.assertEquals(0.3f, filter.getLuminance4(), 0f); + Assertions.assertEquals(0f, filter.getLuminance5(), 0f); + Assertions.assertEquals("CrossHatchFilter", filter.getName()); + Assertions.assertEquals(ColorRGBA.White, filter.getPaperColor()); + Assertions.assertTrue(filter.isEnabled()); } } diff --git a/jme3-effects/src/test/java/com/jme3/post/filters/DepthOfFieldFilterTest.java b/jme3-effects/src/test/java/com/jme3/post/filters/DepthOfFieldFilterTest.java index 700ba9ee77..64f23947ea 100644 --- a/jme3-effects/src/test/java/com/jme3/post/filters/DepthOfFieldFilterTest.java +++ b/jme3-effects/src/test/java/com/jme3/post/filters/DepthOfFieldFilterTest.java @@ -34,8 +34,8 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code DepthOfFieldFilter} class. @@ -67,13 +67,13 @@ public void testSaveAndLoad() { DepthOfFieldFilter copy = BinaryExporter.saveAndLoad(assetManager, filter); // Verify the parameter values of the copy: - Assert.assertEquals(10.5f, copy.getBlurScale(), 0f); - Assert.assertEquals(0.1f, copy.getBlurThreshold(), 0f); - Assert.assertTrue(copy.getDebugUnfocus()); - Assert.assertEquals(66f, copy.getFocusDistance(), 0f); - Assert.assertEquals(15f, copy.getFocusRange(), 0f); - Assert.assertEquals("Depth Of Field", copy.getName()); - Assert.assertFalse(copy.isEnabled()); + Assertions.assertEquals(10.5f, copy.getBlurScale(), 0f); + Assertions.assertEquals(0.1f, copy.getBlurThreshold(), 0f); + Assertions.assertTrue(copy.getDebugUnfocus()); + Assertions.assertEquals(66f, copy.getFocusDistance(), 0f); + Assertions.assertEquals(15f, copy.getFocusRange(), 0f); + Assertions.assertEquals("Depth Of Field", copy.getName()); + Assertions.assertFalse(copy.isEnabled()); } /** @@ -83,12 +83,12 @@ public void testSaveAndLoad() { * @param filter (not null, unaffected) */ private void verifyDefaults(DepthOfFieldFilter filter) { - Assert.assertEquals(1f, filter.getBlurScale(), 0f); - Assert.assertEquals(0.2f, filter.getBlurThreshold(), 0f); - Assert.assertFalse(filter.getDebugUnfocus()); - Assert.assertEquals(50f, filter.getFocusDistance(), 0f); - Assert.assertEquals(10f, filter.getFocusRange(), 0f); - Assert.assertEquals("Depth Of Field", filter.getName()); - Assert.assertTrue(filter.isEnabled()); + Assertions.assertEquals(1f, filter.getBlurScale(), 0f); + Assertions.assertEquals(0.2f, filter.getBlurThreshold(), 0f); + Assertions.assertFalse(filter.getDebugUnfocus()); + Assertions.assertEquals(50f, filter.getFocusDistance(), 0f); + Assertions.assertEquals(10f, filter.getFocusRange(), 0f); + Assertions.assertEquals("Depth Of Field", filter.getName()); + Assertions.assertTrue(filter.isEnabled()); } } diff --git a/jme3-effects/src/test/java/com/jme3/post/filters/FXAAFilterTest.java b/jme3-effects/src/test/java/com/jme3/post/filters/FXAAFilterTest.java index 698efd5749..9ae1545023 100644 --- a/jme3-effects/src/test/java/com/jme3/post/filters/FXAAFilterTest.java +++ b/jme3-effects/src/test/java/com/jme3/post/filters/FXAAFilterTest.java @@ -34,8 +34,8 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code FXAAFilter} class. @@ -66,12 +66,12 @@ public void testSaveAndLoad() { FXAAFilter copy = BinaryExporter.saveAndLoad(assetManager, filter); // Verify the parameter values of the copy: - Assert.assertEquals("FXAAFilter", copy.getName()); - Assert.assertEquals(0.22f, copy.getReduceMul(), 0f); - Assert.assertEquals(7f, copy.getSpanMax(), 0f); - Assert.assertEquals(0.33f, copy.getSubPixelShift(), 0f); - Assert.assertEquals(0.03f, copy.getVxOffset(), 0f); - Assert.assertFalse(copy.isEnabled()); + Assertions.assertEquals("FXAAFilter", copy.getName()); + Assertions.assertEquals(0.22f, copy.getReduceMul(), 0f); + Assertions.assertEquals(7f, copy.getSpanMax(), 0f); + Assertions.assertEquals(0.33f, copy.getSubPixelShift(), 0f); + Assertions.assertEquals(0.03f, copy.getVxOffset(), 0f); + Assertions.assertFalse(copy.isEnabled()); } /** @@ -80,11 +80,11 @@ public void testSaveAndLoad() { * @param filter (not null, unaffected) */ private void verifyDefaults(FXAAFilter filter) { - Assert.assertEquals("FXAAFilter", filter.getName()); - Assert.assertEquals(0.125f, filter.getReduceMul(), 0f); - Assert.assertEquals(8f, filter.getSpanMax(), 0f); - Assert.assertEquals(0.25f, filter.getSubPixelShift(), 0f); - Assert.assertEquals(0f, filter.getVxOffset(), 0f); - Assert.assertTrue(filter.isEnabled()); + Assertions.assertEquals("FXAAFilter", filter.getName()); + Assertions.assertEquals(0.125f, filter.getReduceMul(), 0f); + Assertions.assertEquals(8f, filter.getSpanMax(), 0f); + Assertions.assertEquals(0.25f, filter.getSubPixelShift(), 0f); + Assertions.assertEquals(0f, filter.getVxOffset(), 0f); + Assertions.assertTrue(filter.isEnabled()); } } diff --git a/jme3-effects/src/test/java/com/jme3/post/filters/PosterizationFilterTest.java b/jme3-effects/src/test/java/com/jme3/post/filters/PosterizationFilterTest.java index cef593526b..aab91421cc 100644 --- a/jme3-effects/src/test/java/com/jme3/post/filters/PosterizationFilterTest.java +++ b/jme3-effects/src/test/java/com/jme3/post/filters/PosterizationFilterTest.java @@ -34,8 +34,8 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code PosterizationFilter} class. @@ -67,10 +67,10 @@ public void testSaveAndLoad() { = BinaryExporter.saveAndLoad(assetManager, filter); // Verify the parameter values of the duplicate: - Assert.assertEquals(0.7f, copy.getGamma(), 0f); - Assert.assertEquals(4, copy.getNumColors(), 0f); - Assert.assertEquals(0.8f, copy.getStrength(), 0f); - Assert.assertFalse(copy.isEnabled()); + Assertions.assertEquals(0.7f, copy.getGamma(), 0f); + Assertions.assertEquals(4, copy.getNumColors(), 0f); + Assertions.assertEquals(0.8f, copy.getStrength(), 0f); + Assertions.assertFalse(copy.isEnabled()); } /** @@ -80,9 +80,9 @@ public void testSaveAndLoad() { * @param filter (not null, unaffected) */ private void verifyDefaults(PosterizationFilter filter) { - Assert.assertEquals(0.6f, filter.getGamma(), 0f); - Assert.assertEquals(8, filter.getNumColors(), 0f); - Assert.assertEquals(1f, filter.getStrength(), 0f); - Assert.assertTrue(filter.isEnabled()); + Assertions.assertEquals(0.6f, filter.getGamma(), 0f); + Assertions.assertEquals(8, filter.getNumColors(), 0f); + Assertions.assertEquals(1f, filter.getStrength(), 0f); + Assertions.assertTrue(filter.isEnabled()); } } diff --git a/jme3-effects/src/test/java/com/jme3/post/filters/SSAOFilterTest.java b/jme3-effects/src/test/java/com/jme3/post/filters/SSAOFilterTest.java index b002ac8236..3733f3ff48 100644 --- a/jme3-effects/src/test/java/com/jme3/post/filters/SSAOFilterTest.java +++ b/jme3-effects/src/test/java/com/jme3/post/filters/SSAOFilterTest.java @@ -4,8 +4,8 @@ import com.jme3.asset.DesktopAssetManager; import com.jme3.export.binary.BinaryExporter; import com.jme3.post.ssao.SSAOFilter; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Automated tests for the {@code SSAOFilter} class. @@ -37,13 +37,13 @@ public void testSaveAndLoad() { SSAOFilter copy = BinaryExporter.saveAndLoad(assetManager, filter); // Verify the parameter values of the copy: - Assert.assertEquals("SSAOFilter", copy.getName()); - Assert.assertEquals(4.5f, copy.getSampleRadius(), 0f); - Assert.assertEquals(1.8f, copy.getIntensity(), 0f); - Assert.assertEquals(0.4f, copy.getScale(), 0f); - Assert.assertEquals(0.5f, copy.getBias(), 0f); - Assert.assertTrue(copy.isApproximateNormals()); - Assert.assertFalse(copy.isEnabled()); + Assertions.assertEquals("SSAOFilter", copy.getName()); + Assertions.assertEquals(4.5f, copy.getSampleRadius(), 0f); + Assertions.assertEquals(1.8f, copy.getIntensity(), 0f); + Assertions.assertEquals(0.4f, copy.getScale(), 0f); + Assertions.assertEquals(0.5f, copy.getBias(), 0f); + Assertions.assertTrue(copy.isApproximateNormals()); + Assertions.assertFalse(copy.isEnabled()); } /** @@ -52,12 +52,12 @@ public void testSaveAndLoad() { * @param filter (not null, unaffected) */ private void verifyDefaults(SSAOFilter filter) { - Assert.assertEquals("SSAOFilter", filter.getName()); - Assert.assertEquals(5.1f, filter.getSampleRadius(), 0f); - Assert.assertEquals(1.5f, filter.getIntensity(), 0f); - Assert.assertEquals(0.2f, filter.getScale(), 0f); - Assert.assertEquals(0.1f, filter.getBias(), 0f); - Assert.assertFalse(filter.isApproximateNormals()); - Assert.assertTrue(filter.isEnabled()); + Assertions.assertEquals("SSAOFilter", filter.getName()); + Assertions.assertEquals(5.1f, filter.getSampleRadius(), 0f); + Assertions.assertEquals(1.5f, filter.getIntensity(), 0f); + Assertions.assertEquals(0.2f, filter.getScale(), 0f); + Assertions.assertEquals(0.1f, filter.getBias(), 0f); + Assertions.assertFalse(filter.isApproximateNormals()); + Assertions.assertTrue(filter.isEnabled()); } } diff --git a/jme3-jbullet/src/test/java/com/jme3/jbullet/test/PreventBulletIssueRegressions.java b/jme3-jbullet/src/test/java/com/jme3/jbullet/test/PreventBulletIssueRegressions.java index bb704578e9..f51dbf56b3 100644 --- a/jme3-jbullet/src/test/java/com/jme3/jbullet/test/PreventBulletIssueRegressions.java +++ b/jme3-jbullet/src/test/java/com/jme3/jbullet/test/PreventBulletIssueRegressions.java @@ -54,8 +54,8 @@ import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.VertexBuffer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -112,10 +112,10 @@ public void testIssue889() throws IllegalAccessException, NoSuchFieldException { gc.setPhysicsSpace(space); rootNode.addControl(gc); - Assert.assertFalse(space.getRigidBodyList().contains(rbc)); - Assert.assertFalse(tickListeners.contains(bcc)); - Assert.assertFalse(space.getRigidBodyList().contains(bcc_rb)); - Assert.assertFalse(space.getGhostObjectList().contains(gc)); + Assertions.assertFalse(space.getRigidBodyList().contains(rbc)); + Assertions.assertFalse(tickListeners.contains(bcc)); + Assertions.assertFalse(space.getRigidBodyList().contains(bcc_rb)); + Assertions.assertFalse(space.getGhostObjectList().contains(gc)); } /** @@ -149,8 +149,8 @@ public void testIssue970() throws IOException { rbc.setAngularVelocity(new Vector3f(0.04f, 0.05f, 0.06f)); rbc.setLinearVelocity(new Vector3f(0.26f, 0.27f, 0.28f)); - Assert.assertEquals(new Vector3f(0.04f, 0.05f, 0.06f), rbc.getAngularVelocity()); - Assert.assertEquals(new Vector3f(0.26f, 0.27f, 0.28f), rbc.getLinearVelocity()); + Assertions.assertEquals(new Vector3f(0.04f, 0.05f, 0.06f), rbc.getAngularVelocity()); + Assertions.assertEquals(new Vector3f(0.26f, 0.27f, 0.28f), rbc.getLinearVelocity()); // Write/Serialize the RBC ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -166,9 +166,9 @@ public InputStream openStream() { } }); - Assert.assertNotNull(rbcCopy); - Assert.assertEquals(new Vector3f(0.04f, 0.05f, 0.06f), rbcCopy.getAngularVelocity()); - Assert.assertEquals(new Vector3f(0.26f, 0.27f, 0.28f), rbcCopy.getLinearVelocity()); + Assertions.assertNotNull(rbcCopy); + Assertions.assertEquals(new Vector3f(0.04f, 0.05f, 0.06f), rbcCopy.getAngularVelocity()); + Assertions.assertEquals(new Vector3f(0.26f, 0.27f, 0.28f), rbcCopy.getLinearVelocity()); } /** diff --git a/jme3-plugins/src/test/java/com/jme3/export/InputOutputCapsuleTest.java b/jme3-plugins/src/test/java/com/jme3/export/InputOutputCapsuleTest.java index 74edd66d5a..b3b0f3194f 100644 --- a/jme3-plugins/src/test/java/com/jme3/export/InputOutputCapsuleTest.java +++ b/jme3-plugins/src/test/java/com/jme3/export/InputOutputCapsuleTest.java @@ -49,8 +49,7 @@ import java.nio.FloatBuffer; import java.util.Iterator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.jme3.asset.AssetInfo; import com.jme3.asset.DesktopAssetManager; @@ -68,6 +67,11 @@ import com.jme3.math.Transform; import com.jme3.math.Matrix4f; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Test suite for implementations of the JmeExporter and JmeImporter interfaces. * There are tests here for all write* and read* methods of the OutputCapsule and InputCapsule interfaces respectively. @@ -149,7 +153,7 @@ private static void saveAndLoad(Savable savable) { exporter.save(savable, outStream); exportedBytes = outStream.toByteArray(); } catch (IOException e) { - Assert.fail(exporter.getClass().getSimpleName() + ": " + e.toString()); + fail(exporter.getClass().getSimpleName() + ": " + e); } // write the xml into files for debugging. @@ -176,7 +180,7 @@ public InputStream openStream() { }; importer.load(info); // this is where assertions will fail if loaded data does not match saved data. } catch (IOException e) { - Assert.fail(exporter.getClass().getSimpleName() + ": " + e.toString()); + fail(exporter.getClass().getSimpleName() + ": " + e); } } } @@ -384,25 +388,25 @@ public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); for (int i = 0; i < testByteArray.length; i++) - Assert.assertEquals("readByte()", testByteArray[i], capsule.readByte("test_byte_" + i, (byte) 0)); + assertEquals(testByteArray[i], capsule.readByte("test_byte_" + i, (byte) 0), "readByte()"); for (int i = 0; i < testShortArray.length; i++) - Assert.assertEquals("readShort()", testShortArray[i], capsule.readShort("test_short_" + i, (short) 0)); + assertEquals(testShortArray[i], capsule.readShort("test_short_" + i, (short) 0), "readShort()"); for (int i = 0; i < testIntArray.length; i++) - Assert.assertEquals("readInt()", testIntArray[i], capsule.readInt("test_int_" + i, 0)); + assertEquals(testIntArray[i], capsule.readInt("test_int_" + i, 0), "readInt()"); for (int i = 0; i < testLongArray.length; i++) - Assert.assertEquals("readLong()", testLongArray[i], capsule.readLong("test_long_" + i, 0l)); + assertEquals(testLongArray[i], capsule.readLong("test_long_" + i, 0l), "readLong()"); for (int i = 0; i < testFloatArray.length; i++) - Assert.assertEquals("readFloat()", testFloatArray[i], capsule.readFloat("test_float_" + i, 0f), 0f); + assertEquals(testFloatArray[i], capsule.readFloat("test_float_" + i, 0f), 0f, "readFloat()"); for (int i = 0; i < testDoubleArray.length; i++) - Assert.assertEquals("readDouble()", testDoubleArray[i], capsule.readDouble("test_double_" + i, 0d), 0d); + assertEquals(testDoubleArray[i], capsule.readDouble("test_double_" + i, 0d), 0d, "readDouble()"); for (int i = 0; i < testBooleanArray.length; i++) - Assert.assertEquals("readBoolean()", testBooleanArray[i], capsule.readBoolean("test_boolean_" + i, false)); + assertEquals(testBooleanArray[i], capsule.readBoolean("test_boolean_" + i, false), "readBoolean()"); } } @@ -425,7 +429,7 @@ public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); for (int i = 0; i < testStringArray.length; i++) { - Assert.assertEquals("readString()", testStringArray[i], capsule.readString("test_string_" + i, null)); + assertEquals(testStringArray[i], capsule.readString("test_string_" + i, null), "readString()"); } } } @@ -449,7 +453,7 @@ public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); for (int i = 0; i < testEnumArray.length; i++) { - Assert.assertEquals("readEnum()", testEnumArray[i], capsule.readEnum("test_enum_" + i, CullHint.class, null)); + assertEquals(testEnumArray[i], capsule.readEnum("test_enum_" + i, CullHint.class, null), "readEnum()"); } } } @@ -473,7 +477,7 @@ public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); for (int i = 0; i < testBitSetArray.length; i++) { - Assert.assertEquals("readBitSet()", testBitSetArray[i], capsule.readBitSet("test_bit_set_" + i, null)); + assertEquals(testBitSetArray[i], capsule.readBitSet("test_bit_set_" + i, null), "readBitSet()"); } } } @@ -496,7 +500,7 @@ public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); for(int i = 0; i < testSavableArray.length; i++) - Assert.assertEquals("readSavable()", testSavableArray[i], capsule.readSavable("test_savable_" + i, null)); + assertEquals(testSavableArray[i], capsule.readSavable("test_savable_" + i, null), "readSavable()"); } } @@ -535,13 +539,14 @@ public void read(JmeImporter ji) throws IOException { Vector3f alsoV1 = (Vector3f) capsule.readSavable("also_v1", null); Vector3f notV1 = (Vector3f) capsule.readSavable("not_v1", null); - Assert.assertTrue("readSavable() savable duplicated, references not preserved.", v1 == alsoV1); - Assert.assertTrue("readSavable() unique savables merged, unexpected shared references.", v1 != notV1); + assertTrue(v1 == alsoV1, "readSavable() savable duplicated, references not preserved."); + assertTrue(v1 != notV1, "readSavable() unique savables merged, unexpected shared references."); Node n1 = (Node) capsule.readSavable("node_1", null); Node n2 = (Node) capsule.readSavable("node_2", null); - Assert.assertTrue("readSavable() reference loop not preserved.", n1.getUserData("node_2") == n2 && n2.getUserData("node_1") == n1); + assertTrue(n1.getUserData("node_2") == n2 && n2.getUserData("node_1") == n1, + "readSavable() reference loop not preserved."); } } @@ -589,35 +594,35 @@ public void write(JmeExporter je) throws IOException { public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); - Assert.assertArrayEquals("readByteArray()", testByteArray, capsule.readByteArray("testByteArray", null)); - Assert.assertArrayEquals("readShortArray()", testShortArray, capsule.readShortArray("testShortArray", null)); - Assert.assertArrayEquals("readIntArray()", testIntArray, capsule.readIntArray("testIntArray", null)); - Assert.assertArrayEquals("readLongArray()", testLongArray, capsule.readLongArray("testLongArray", null)); - Assert.assertArrayEquals("readFloatArray()", testFloatArray, capsule.readFloatArray("testFloatArray", null), 0f); - Assert.assertArrayEquals("readDoubleArray()", testDoubleArray, capsule.readDoubleArray("testDoubleArray", null), 0d); - Assert.assertArrayEquals("readBooleanArray()", testBooleanArray, capsule.readBooleanArray("testBooleanArray", null)); - Assert.assertArrayEquals("readStringArray()", testStringArray, capsule.readStringArray("testStringArray", null)); - Assert.assertArrayEquals("readSavableArray()", testSavableArray, capsule.readSavableArray("testSavableArray", null)); - - Assert.assertArrayEquals("readByteArray()", new byte[0], capsule.readByteArray("emptyByteArray", null)); - Assert.assertArrayEquals("readShortArray()", new short[0], capsule.readShortArray("emptyShortArray", null)); - Assert.assertArrayEquals("readIntArray()", new int[0], capsule.readIntArray("emptyIntArray", null)); - Assert.assertArrayEquals("readLongArray()", new long[0], capsule.readLongArray("emptyLongArray", null)); - Assert.assertArrayEquals("readFloatArray()", new float[0], capsule.readFloatArray("emptyFloatArray", null), 0f); - Assert.assertArrayEquals("readDoubleArray()", new double[0], capsule.readDoubleArray("emptyDoubleArray", null), 0d); - Assert.assertArrayEquals("readBooleanArray()", new boolean[0], capsule.readBooleanArray("emptyBooleanArray", null)); - Assert.assertArrayEquals("readStringArray()", new String[0], capsule.readStringArray("emptyStringArray", null)); - Assert.assertArrayEquals("readSavableArray()", new Savable[0], capsule.readSavableArray("emptySavableArray", null)); - - Assert.assertArrayEquals("readByteArray2D()", testByteArray2D, capsule.readByteArray2D("testByteArray2D", null)); - Assert.assertArrayEquals("readShortArray2D()", testShortArray2D, capsule.readShortArray2D("testShortArray2D", null)); - Assert.assertArrayEquals("readIntArray2D()", testIntArray2D, capsule.readIntArray2D("testIntArray2D", null)); - Assert.assertArrayEquals("readLongArray2D()", testLongArray2D, capsule.readLongArray2D("testLongArray2D", null)); - Assert.assertArrayEquals("readFloatArray2D()", testFloatArray2D, capsule.readFloatArray2D("testFloatArray2D", null)); - Assert.assertArrayEquals("readDoubleArray2D()", testDoubleArray2D, capsule.readDoubleArray2D("testDoubleArray2D", null)); - Assert.assertArrayEquals("readBooleanArray2D()", testBooleanArray2D, capsule.readBooleanArray2D("testBooleanArray2D", null)); - Assert.assertArrayEquals("readStringArray2D()", testStringArray2D, capsule.readStringArray2D("testStringArray2D", null)); - Assert.assertArrayEquals("readSavableArray2D()", testSavableArray2D, capsule.readSavableArray2D("testSavableArray2D", null)); + assertArrayEquals(testByteArray, capsule.readByteArray("testByteArray", null), "readByteArray()"); + assertArrayEquals(testShortArray, capsule.readShortArray("testShortArray", null), "readShortArray()"); + assertArrayEquals(testIntArray, capsule.readIntArray("testIntArray", null), "readIntArray()"); + assertArrayEquals(testLongArray, capsule.readLongArray("testLongArray", null), "readLongArray()"); + assertArrayEquals(testFloatArray, capsule.readFloatArray("testFloatArray", null), 0f, "readFloatArray()"); + assertArrayEquals(testDoubleArray, capsule.readDoubleArray("testDoubleArray", null), 0d, "readDoubleArray()"); + assertArrayEquals(testBooleanArray, capsule.readBooleanArray("testBooleanArray", null), "readBooleanArray()"); + assertArrayEquals(testStringArray, capsule.readStringArray("testStringArray", null), "readStringArray()"); + assertArrayEquals(testSavableArray, capsule.readSavableArray("testSavableArray", null), "readSavableArray()"); + + assertArrayEquals(new byte[0], capsule.readByteArray("emptyByteArray", null), "readByteArray()"); + assertArrayEquals(new short[0], capsule.readShortArray("emptyShortArray", null), "readShortArray()"); + assertArrayEquals(new int[0], capsule.readIntArray("emptyIntArray", null), "readIntArray()"); + assertArrayEquals(new long[0], capsule.readLongArray("emptyLongArray", null), "readLongArray()"); + assertArrayEquals(new float[0], capsule.readFloatArray("emptyFloatArray", null), 0f, "readFloatArray()"); + assertArrayEquals(new double[0], capsule.readDoubleArray("emptyDoubleArray", null), 0d, "readDoubleArray()"); + assertArrayEquals(new boolean[0], capsule.readBooleanArray("emptyBooleanArray", null), "readBooleanArray()"); + assertArrayEquals(new String[0], capsule.readStringArray("emptyStringArray", null), "readStringArray()"); + assertArrayEquals(new Savable[0], capsule.readSavableArray("emptySavableArray", null), "readSavableArray()"); + + assertArrayEquals(testByteArray2D, capsule.readByteArray2D("testByteArray2D", null), "readByteArray2D()"); + assertArrayEquals(testShortArray2D, capsule.readShortArray2D("testShortArray2D", null), "readShortArray2D()"); + assertArrayEquals(testIntArray2D, capsule.readIntArray2D("testIntArray2D", null), "readIntArray2D()"); + assertArrayEquals(testLongArray2D, capsule.readLongArray2D("testLongArray2D", null), "readLongArray2D()"); + assertArrayEquals(testFloatArray2D, capsule.readFloatArray2D("testFloatArray2D", null), "readFloatArray2D()"); + assertArrayEquals(testDoubleArray2D, capsule.readDoubleArray2D("testDoubleArray2D", null), "readDoubleArray2D()"); + assertArrayEquals(testBooleanArray2D, capsule.readBooleanArray2D("testBooleanArray2D", null), "readBooleanArray2D()"); + assertArrayEquals(testStringArray2D, capsule.readStringArray2D("testStringArray2D", null), "readStringArray2D()"); + assertArrayEquals(testSavableArray2D, capsule.readSavableArray2D("testSavableArray2D", null), "readSavableArray2D()"); } } @@ -644,15 +649,15 @@ public void write(JmeExporter je) throws IOException { public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); - Assert.assertEquals("readByteBuffer()", testByteBuffer, capsule.readByteBuffer("testByteBuffer", null)); - Assert.assertEquals("readShortBuffer()", testShortBuffer, capsule.readShortBuffer("testShortBuffer", null)); - Assert.assertEquals("readIntBuffer()", testIntBuffer, capsule.readIntBuffer("testIntBuffer", null)); - Assert.assertEquals("readFloatBuffer()", testFloatBuffer, capsule.readFloatBuffer("testFloatBuffer", null)); + assertEquals(testByteBuffer, capsule.readByteBuffer("testByteBuffer", null), "readByteBuffer()"); + assertEquals(testShortBuffer, capsule.readShortBuffer("testShortBuffer", null), "readShortBuffer()"); + assertEquals(testIntBuffer, capsule.readIntBuffer("testIntBuffer", null), "readIntBuffer()"); + assertEquals(testFloatBuffer, capsule.readFloatBuffer("testFloatBuffer", null), "readFloatBuffer()"); - Assert.assertEquals("readByteBuffer()", BufferUtils.createByteBuffer(0), capsule.readByteBuffer("emptyByteBuffer", null)); - Assert.assertEquals("readShortBuffer()", BufferUtils.createShortBuffer(0), capsule.readShortBuffer("emptyShortBuffer", null)); - Assert.assertEquals("readIntBuffer()", BufferUtils.createIntBuffer(0), capsule.readIntBuffer("emptyIntBuffer", null)); - Assert.assertEquals("readFloatBuffer()", BufferUtils.createFloatBuffer(0), capsule.readFloatBuffer("emptyFloatBuffer", null)); + assertEquals(BufferUtils.createByteBuffer(0), capsule.readByteBuffer("emptyByteBuffer", null), "readByteBuffer()"); + assertEquals(BufferUtils.createShortBuffer(0), capsule.readShortBuffer("emptyShortBuffer", null), "readShortBuffer()"); + assertEquals(BufferUtils.createIntBuffer(0), capsule.readIntBuffer("emptyIntBuffer", null), "readIntBuffer()"); + assertEquals(BufferUtils.createFloatBuffer(0), capsule.readFloatBuffer("emptyFloatBuffer", null), "readFloatBuffer()"); } } @@ -676,11 +681,15 @@ public void write(JmeExporter je) throws IOException { public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); - Assert.assertEquals("readByteBufferArrayList()", testByteBufferArrayList, capsule.readByteBufferArrayList("testByteBufferArrayList", null)); - Assert.assertEquals("readFloatBufferArrayList()", testFloatBufferArrayList, capsule.readFloatBufferArrayList("testFloatBufferArrayList", null)); - Assert.assertEquals("readSavableArrayList()", testSavableArrayList, capsule.readSavableArrayList("testSavableArrayList", null)); - Assert.assertEquals("readSavableArrayListArray()", testSavableArrayListArray, capsule.readSavableArrayListArray("testSavableArrayListArray", null)); - Assert.assertEquals("readSavableArrayListArray2D()", testSavableArrayListArray2D, capsule.readSavableArrayListArray2D("testSavableArrayListArray2D", null)); + assertEquals(testByteBufferArrayList, capsule.readByteBufferArrayList("testByteBufferArrayList", null), "readByteBufferArrayList()"); + assertEquals(testFloatBufferArrayList, capsule.readFloatBufferArrayList("testFloatBufferArrayList", null), "readFloatBufferArrayList()"); + assertEquals(testSavableArrayList, capsule.readSavableArrayList("testSavableArrayList", null), "readSavableArrayList()"); + assertArrayEquals(testSavableArrayListArray, + capsule.readSavableArrayListArray("testSavableArrayListArray", null), + "readSavableArrayListArray()"); + assertArrayEquals(testSavableArrayListArray2D, + capsule.readSavableArrayListArray2D("testSavableArrayListArray2D", null), + "readSavableArrayListArray2D()"); } } @@ -702,15 +711,15 @@ public void write(JmeExporter je) throws IOException { public void read(JmeImporter ji) throws IOException { InputCapsule capsule = ji.getCapsule(this); - Assert.assertEquals("readSavableMap()", testSavableMap, capsule.readSavableMap("testSavableMap", null)); - Assert.assertEquals("readStringSavableMap()", testStringSavableMap, capsule.readStringSavableMap("testStringSavableMap", null)); + assertEquals(testSavableMap, capsule.readSavableMap("testSavableMap", null), "readSavableMap()"); + assertEquals(testStringSavableMap, capsule.readStringSavableMap("testStringSavableMap", null), "readStringSavableMap()"); // IntMap does not implement equals() so we have to do it manually IntMap loadedIntMap = capsule.readIntSavableMap("testIntSavableMap", null); Iterator iterator = testIntSavableMap.iterator(); while(iterator.hasNext()) { IntMap.Entry entry = (IntMap.Entry) iterator.next(); - Assert.assertEquals("readIntSavableMap()", entry.getValue(), loadedIntMap.get(entry.getKey())); + assertEquals(entry.getValue(), loadedIntMap.get(entry.getKey()), "readIntSavableMap()"); } } } diff --git a/jme3-plugins/src/test/java/com/jme3/export/JmeExporterTest.java b/jme3-plugins/src/test/java/com/jme3/export/JmeExporterTest.java index d11df242cc..9b86ca2902 100644 --- a/jme3-plugins/src/test/java/com/jme3/export/JmeExporterTest.java +++ b/jme3-plugins/src/test/java/com/jme3/export/JmeExporterTest.java @@ -37,19 +37,13 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.Map; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import java.util.stream.Stream; import com.jme3.asset.AssetInfo; import com.jme3.asset.AssetManager; @@ -62,81 +56,87 @@ import com.jme3.material.Material; import com.jme3.material.plugin.export.material.J3MExporter; import com.jme3.scene.Node; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests the methods on classes that implements the JmeExporter interface. */ -@RunWith(Parameterized.class) public class JmeExporterTest { // test saving with a material since the J3MExporter expects one private static Material material; - private final JmeExporter exporter; - - @Rule - public TemporaryFolder folder = new TemporaryFolder(); + @TempDir + Path tempDir; - @BeforeClass + @BeforeAll public static void beforeClass() { AssetManager assetManager = new DesktopAssetManager(true); material = new Material(assetManager, "Common/MatDefs/Gui/Gui.j3md"); } - public JmeExporterTest(JmeExporter exporter) { - this.exporter = exporter; - } - - @Parameterized.Parameters - public static Collection defineExporters() { - return Arrays.asList(new BinaryExporter(), new XMLExporter(), new J3MExporter()); + static Stream defineExporters() { + return Stream.of(new BinaryExporter(), new XMLExporter(), new J3MExporter()); } private File fileWithMissingParent() { - File dir = new File(folder.getRoot(), "missingDir"); + File dir = tempDir.resolve("missingDir").toFile(); return new File(dir, "afile.txt"); } private File fileWithExistingParent() throws IOException { - File dir = folder.newFolder(); + File dir = Files.createTempDirectory(tempDir, "exporter-test").toFile(); return new File(dir, "afile.txt"); } - @Test - public void testSaveWhenPathDoesntExist() throws IOException { + @ParameterizedTest + @MethodSource("defineExporters") + public void testSaveWhenPathDoesntExist(JmeExporter exporter) throws IOException { File file = fileWithMissingParent(); - Assert.assertFalse(file.exists()); + assertFalse(file.exists()); exporter.save(material, file); - Assert.assertTrue(file.exists()); + assertTrue(file.exists()); } - @Test - public void testSaveWhenPathDoesExist() throws IOException { + @ParameterizedTest + @MethodSource("defineExporters") + public void testSaveWhenPathDoesExist(JmeExporter exporter) throws IOException { File file = fileWithExistingParent(); exporter.save(material, file); - Assert.assertTrue(file.exists()); + assertTrue(file.exists()); } - @Test(expected = FileNotFoundException.class) - public void testSaveWhenPathDoesntExistWithoutCreateDirs() throws IOException { + @ParameterizedTest + @MethodSource("defineExporters") + public void testSaveWhenPathDoesntExistWithoutCreateDirs(JmeExporter exporter) throws IOException { File file = fileWithMissingParent(); - exporter.save(material, file, false); - Assert.assertTrue(file.exists()); + assertThrows(FileNotFoundException.class, () -> exporter.save(material, file, false)); } - @Test - public void testSaveWithNullParent() throws IOException { + @ParameterizedTest + @MethodSource("defineExporters") + public void testSaveWithNullParent(JmeExporter exporter) throws IOException { File file = new File("someFile.txt"); try { exporter.save(material, file); - Assert.assertTrue(file.exists()); + assertTrue(file.exists()); } finally { file.delete(); } } - @Test - public void testExporterConsistency() { + @ParameterizedTest + @MethodSource("defineExporters") + public void testExporterConsistency(JmeExporter currentExporter) { // final boolean testXML = true; final boolean testLists = false; @@ -189,7 +189,7 @@ public void testExporterConsistency() { try { exporter.save(origin, outs[i]); } catch (IOException ex) { - Assert.fail(ex.getMessage()); + fail(ex.getMessage()); } } @@ -222,7 +222,7 @@ public InputStream openStream() { }; nodes[i + 1] = (Node) importer.load(info); } catch (IOException ex) { - Assert.fail(ex.getMessage()); + fail(ex.getMessage()); } } @@ -243,22 +243,22 @@ private static final void compareMaps(Map[] maps) { // check if all maps have the same keys and values for those keys for (int i = 1; i < maps.length; i++) { Map map = maps[i]; - Assert.assertEquals("Map " + i + " keys do not match", keys.length, map.size()); + assertEquals(keys.length, map.size(), "Map " + i + " keys do not match"); for (String key : keys) { - Assert.assertTrue("Missing key " + key + " in map " + i, map.containsKey(key)); + assertTrue(map.containsKey(key), "Missing key " + key + " in map " + i); Object v1 = maps[0].get(key); Object v2 = map.get(key); if (v1.getClass().isArray()) { boolean c = Arrays.equals((Object[]) v1, (Object[]) v2); if (c) System.out.println(key + " match"); - Assert.assertTrue("Value does not match in map " + i + " for key " + key + " expected " + assertTrue(c, "Value does not match in map " + i + " for key " + key + " expected " + Arrays.deepToString((Object[]) v1) + " but got " - + Arrays.deepToString((Object[]) v2), c); + + Arrays.deepToString((Object[]) v2)); } else { boolean c = v1.equals(v2); if (c) System.out.println(key + " match"); - Assert.assertTrue("Value does not match in map " + i + " for key " + key + " expected " - + v1 + " but got " + v2, c); + assertTrue(c, "Value does not match in map " + i + " for key " + key + " expected " + + v1 + " but got " + v2); } } } diff --git a/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialDefWrite.java b/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialDefWrite.java index 32b23f8d40..c5522c2cb8 100644 --- a/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialDefWrite.java +++ b/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialDefWrite.java @@ -37,20 +37,21 @@ import com.jme3.material.plugins.J3MLoader; import com.jme3.shader.*; import com.jme3.system.JmeSystem; -import org.junit.*; import java.io.*; import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestMaterialDefWrite { private AssetManager assetManager; - @Before + @BeforeEach public void init() { assetManager = JmeSystem.newAssetManager( TestMaterialDefWrite.class.getResource("/com/jme3/asset/Desktop.cfg")); @@ -87,7 +88,7 @@ public InputStream openStream() { for (MatParam refParam : ref.getMaterialParams()) { MatParam matParam = matDef.getMaterialParam(refParam.getName()); - assertTrue(refParam != null); + assertNotNull(refParam); assertEquals(refParam,matParam); } diff --git a/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialWrite.java b/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialWrite.java index 1007a2f764..298fb85f6c 100644 --- a/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialWrite.java +++ b/jme3-plugins/src/test/java/com/jme3/material/plugin/TestMaterialWrite.java @@ -42,8 +42,8 @@ import com.jme3.math.ColorRGBA; import com.jme3.system.JmeSystem; import com.jme3.texture.Texture; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -51,13 +51,13 @@ import java.io.InputStream; import java.net.URL; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestMaterialWrite { private AssetManager assetManager; - @Before + @BeforeEach public void init() { URL configFile = TestMaterialWrite.class.getResource("/com/jme3/asset/Desktop.cfg"); assetManager = JmeSystem.newAssetManager(configFile); diff --git a/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java b/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java index ebec4b4300..d2662b9ec0 100644 --- a/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java +++ b/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java @@ -46,9 +46,9 @@ import com.jme3.scene.VertexBuffer; import com.jme3.system.JmeSystem; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** @@ -60,7 +60,7 @@ public class GltfLoaderTest { private AssetManager assetManager; - @Before + @BeforeEach public void init() { assetManager = JmeSystem.newAssetManager( TestMaterialWrite.class.getResource("/com/jme3/asset/Desktop.cfg")); @@ -82,7 +82,7 @@ public void testLoadEmptyScene() { dumpScene(scene, 0); } catch (AssetLoadException ex) { ex.printStackTrace(); - Assert.fail("Failed to import gltf model with empty scene"); + Assertions.fail("Failed to import gltf model with empty scene"); } } @@ -93,7 +93,7 @@ public void testLightsPunctualExtension() { dumpScene(scene, 0); } catch (AssetLoadException ex) { ex.printStackTrace(); - Assert.fail("Failed to import gltf model with lights punctual extension"); + Assertions.fail("Failed to import gltf model with lights punctual extension"); } } @@ -103,7 +103,7 @@ public void testRequiredExtensionHandling() { // By default, the unsupported extension that is listed in // the 'extensionsRequired' will cause an AssetLoadException - Assert.assertThrows(AssetLoadException.class, () -> { + Assertions.assertThrows(AssetLoadException.class, () -> { GltfModelKey gltfModelKey = new GltfModelKey("gltf/TriangleUnsupportedExtensionRequired.gltf"); Spatial scene = assetManager.loadModel(gltfModelKey); dumpScene(scene, 0); @@ -118,7 +118,7 @@ public void testRequiredExtensionHandling() { dumpScene(scene, 0); } catch (AssetLoadException ex) { ex.printStackTrace(); - Assert.fail("Failed to load TriangleUnsupportedExtensionRequired"); + Assertions.fail("Failed to load TriangleUnsupportedExtensionRequired"); } } @@ -137,29 +137,29 @@ public void testDracoExtension() { // The geometry has 11x11 vertices arranged in a square, // so there are 10 x 10 * 2 triangles VertexBuffer indices = mesh.getBuffer(VertexBuffer.Type.Index); - Assert.assertEquals(10 * 10 * 2, indices.getNumElements()); - Assert.assertEquals(VertexBuffer.Format.UnsignedShort, indices.getFormat()); + Assertions.assertEquals(10 * 10 * 2, indices.getNumElements()); + Assertions.assertEquals(VertexBuffer.Format.UnsignedShort, indices.getFormat()); // All attributes of the 11 x 11 vertices are stored as Float // attributes (even the texture coordinates, which originally // had been normalized(!) unsigned shorts!) VertexBuffer positions = mesh.getBuffer(VertexBuffer.Type.Position); - Assert.assertEquals(11 * 11, positions.getNumElements()); - Assert.assertEquals(VertexBuffer.Format.Float, positions.getFormat()); + Assertions.assertEquals(11 * 11, positions.getNumElements()); + Assertions.assertEquals(VertexBuffer.Format.Float, positions.getFormat()); VertexBuffer normal = mesh.getBuffer(VertexBuffer.Type.Normal); - Assert.assertEquals(11 * 11, normal.getNumElements()); - Assert.assertEquals(VertexBuffer.Format.Float, normal.getFormat()); + Assertions.assertEquals(11 * 11, normal.getNumElements()); + Assertions.assertEquals(VertexBuffer.Format.Float, normal.getFormat()); VertexBuffer texCoord = mesh.getBuffer(VertexBuffer.Type.TexCoord); - Assert.assertEquals(11 * 11, texCoord.getNumElements()); - Assert.assertEquals(VertexBuffer.Format.Float, texCoord.getFormat()); + Assertions.assertEquals(11 * 11, texCoord.getNumElements()); + Assertions.assertEquals(VertexBuffer.Format.Float, texCoord.getFormat()); dumpScene(scene, 0); } catch (AssetLoadException ex) { ex.printStackTrace(); - Assert.fail("Failed to import unitSquare11x11_unsignedShortTexCoords"); + Assertions.fail("Failed to import unitSquare11x11_unsignedShortTexCoords"); } } diff --git a/jme3-saferallocator/src/test/java/com/jme3/util/SaferAllocMemoryGuardTest.java b/jme3-saferallocator/src/test/java/com/jme3/util/SaferAllocMemoryGuardTest.java index 102e8ea362..b9448174e7 100644 --- a/jme3-saferallocator/src/test/java/com/jme3/util/SaferAllocMemoryGuardTest.java +++ b/jme3-saferallocator/src/test/java/com/jme3/util/SaferAllocMemoryGuardTest.java @@ -3,22 +3,24 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SaferAllocMemoryGuardTest { private static final long MIB = 1024L * 1024L; - @Before + @BeforeEach public void setUp() { SaferAllocMemoryGuard.resetStateForTests(); SaferAllocMemoryGuard.setTestHooks(null, null, null); } - @After + @AfterEach public void tearDown() { SaferAllocMemoryGuard.resetStateForTests(); SaferAllocMemoryGuard.setTestHooks(null, null, null); @@ -42,8 +44,8 @@ public void shouldAdaptBudgetUpThenDown() { SaferAllocMemoryGuard.beforeAlloc(0L); long grownBudget = SaferAllocMemoryGuard.getSoftBudgetForTests(); - Assert.assertTrue("Expected budget to grow under sustained high pressure", grownBudget > initialBudget); - Assert.assertEquals("Should not request GC while still below budget", 0, gcCalls.get()); + assertTrue(grownBudget > initialBudget, "Expected budget to grow under sustained high pressure"); + assertEquals(0, gcCalls.get(), "Should not request GC while still below budget"); currentBytes.set(0L); for (int i = 0; i < 8; i++) { @@ -52,7 +54,7 @@ public void shouldAdaptBudgetUpThenDown() { } long shrunkBudget = SaferAllocMemoryGuard.getSoftBudgetForTests(); - Assert.assertTrue("Expected budget to shrink under sustained low pressure", shrunkBudget < grownBudget); + assertTrue(shrunkBudget < grownBudget, "Expected budget to shrink under sustained low pressure"); } @Test @@ -73,13 +75,13 @@ public void shouldRequestGcOnBurstEvenWithAdaptiveBudget() { SaferAllocMemoryGuard.beforeAlloc(0L); long grownBudget = SaferAllocMemoryGuard.getSoftBudgetForTests(); - Assert.assertTrue(grownBudget > initialBudget); + assertTrue(grownBudget > initialBudget); currentBytes.set(grownBudget + 64L * MIB); now.addAndGet(3_000L); SaferAllocMemoryGuard.beforeAlloc(0L); - Assert.assertTrue("Expected explicit GC request on over-budget burst", gcCalls.get() >= 2); + assertTrue(gcCalls.get() >= 2, "Expected explicit GC request on over-budget burst"); } @Test @@ -94,11 +96,11 @@ public void shouldRequestMaintenanceGcAfterSilence() { currentBytes.set((long) (budget * 0.50f)); SaferAllocMemoryGuard.beforeAlloc(0L); - Assert.assertEquals(0, gcCalls.get()); + assertEquals(0, gcCalls.get()); now.set(61_000L); SaferAllocMemoryGuard.beforeAlloc(0L); - Assert.assertTrue("Expected maintenance GC after long silence under non-trivial usage", gcCalls.get() >= 2); + assertTrue(gcCalls.get() >= 2, "Expected maintenance GC after long silence under non-trivial usage"); } } diff --git a/jme3-terrain/src/test/java/com/jme3/terrain/TestTerrainExporting.java b/jme3-terrain/src/test/java/com/jme3/terrain/TestTerrainExporting.java index 7dceb63b0e..220c92047a 100644 --- a/jme3-terrain/src/test/java/com/jme3/terrain/TestTerrainExporting.java +++ b/jme3-terrain/src/test/java/com/jme3/terrain/TestTerrainExporting.java @@ -39,8 +39,8 @@ import com.jme3.terrain.heightmap.AbstractHeightMap; import com.jme3.terrain.heightmap.ImageBasedHeightMap; import com.jme3.texture.Texture; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test saving/loading terrain. @@ -63,9 +63,9 @@ public void testTerrainExporting() { TerrainQuad saveAndLoad = BinaryExporter.saveAndLoad(getAssetManager(), terrain); - Assert.assertEquals(513, saveAndLoad.getTotalSize()); - Assert.assertEquals(65, saveAndLoad.getPatchSize()); - Assert.assertArrayEquals(terrain.getHeightMap(), saveAndLoad.getHeightMap(), FastMath.ZERO_TOLERANCE); + Assertions.assertEquals(513, saveAndLoad.getTotalSize()); + Assertions.assertEquals(65, saveAndLoad.getPatchSize()); + Assertions.assertArrayEquals(terrain.getHeightMap(), saveAndLoad.getHeightMap(), FastMath.ZERO_TOLERANCE); } } diff --git a/jme3-terrain/src/test/java/com/jme3/terrain/collision/TerrainCollisionTest.java b/jme3-terrain/src/test/java/com/jme3/terrain/collision/TerrainCollisionTest.java index 32768f4060..9a3d58fa9d 100644 --- a/jme3-terrain/src/test/java/com/jme3/terrain/collision/TerrainCollisionTest.java +++ b/jme3-terrain/src/test/java/com/jme3/terrain/collision/TerrainCollisionTest.java @@ -7,14 +7,14 @@ import com.jme3.terrain.heightmap.AbstractHeightMap; import com.jme3.terrain.heightmap.ImageBasedHeightMap; import com.jme3.texture.Texture; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class TerrainCollisionTest extends BaseAWTTest { TerrainQuad quad; - @Before + @BeforeEach public void initQuad() { Texture heightMapImage = getAssetManager().loadTexture("Textures/Terrain/splat/mountains512.png"); AbstractHeightMap map = new ImageBasedHeightMap(heightMapImage.getImage(), 0.25f); @@ -35,10 +35,10 @@ public void testNoCollision() { int cw = quad.collideWith(r, cr); System.out.println((System.nanoTime() - l) + " ns"); - Assert.assertEquals(0, cw); - Assert.assertEquals(0, cr.size()); - Assert.assertEquals(null, cr.getClosestCollision()); - Assert.assertEquals(null, cr.getFarthestCollision()); + Assertions.assertEquals(0, cw); + Assertions.assertEquals(0, cr.size()); + Assertions.assertEquals(null, cr.getClosestCollision()); + Assertions.assertEquals(null, cr.getFarthestCollision()); } @Test @@ -47,12 +47,12 @@ public void testPerpendicularCollision() { CollisionResults cr = new CollisionResults(); int cw = quad.collideWith(r, cr); - Assert.assertEquals(1, cw); - Assert.assertEquals(1, cr.size()); - Assert.assertEquals(new Vector3f(0f, 28f, 0f), cr.getClosestCollision().getContactPoint()); - Assert.assertEquals(new Vector3f(-0.5144958f, 0.6859944f, 0.5144958f), cr.getClosestCollision().getContactNormal()); - Assert.assertEquals(12, cr.getClosestCollision().getDistance(), 0.01d); - Assert.assertEquals(0, cr.getClosestCollision().getTriangleIndex()); + Assertions.assertEquals(1, cw); + Assertions.assertEquals(1, cr.size()); + Assertions.assertEquals(new Vector3f(0f, 28f, 0f), cr.getClosestCollision().getContactPoint()); + Assertions.assertEquals(new Vector3f(-0.5144958f, 0.6859944f, 0.5144958f), cr.getClosestCollision().getContactNormal()); + Assertions.assertEquals(12, cr.getClosestCollision().getDistance(), 0.01d); + Assertions.assertEquals(0, cr.getClosestCollision().getTriangleIndex()); } @Test @@ -64,8 +64,8 @@ public void testMultiCollision() { long l = System.nanoTime(); int cw = quad.collideWith(r, cr); System.out.println((System.nanoTime() - l) + " ns"); - Assert.assertEquals(6, cw); - Assert.assertEquals(6, cr.size()); + Assertions.assertEquals(6, cw); + Assertions.assertEquals(6, cr.size()); } @@ -78,10 +78,10 @@ public void testPreventRegression() { CollisionResults cr = new CollisionResults(); quad.collideWith(r, cr); - Assert.assertEquals(3, cr.size()); - Assert.assertEquals(68.1499f, cr.getClosestCollision().getDistance(), 0.01f); - Assert.assertEquals(new Vector3f(73.07381f, 39.88039f, 66.11114f), cr.getClosestCollision().getContactPoint()); - Assert.assertEquals(new Vector3f(0.9103665f, 0.33104235f, -0.24828176f), cr.getClosestCollision().getContactNormal()); + Assertions.assertEquals(3, cr.size()); + Assertions.assertEquals(68.1499f, cr.getClosestCollision().getDistance(), 0.01f); + Assertions.assertEquals(new Vector3f(73.07381f, 39.88039f, 66.11114f), cr.getClosestCollision().getContactPoint()); + Assertions.assertEquals(new Vector3f(0.9103665f, 0.33104235f, -0.24828176f), cr.getClosestCollision().getContactNormal()); } }