Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,6 +79,7 @@ javadoc {
}

test {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
Expand Down Expand Up @@ -227,4 +231,4 @@ tasks.withType(Checkstyle) {
html.required.set(true)
}
include("**/com/jme3/renderer/**/*.java")
}
}
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
10 changes: 7 additions & 3 deletions jme3-core/src/test/java/com/jme3/SetupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@
*/
package com.jme3;

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

import static org.junit.jupiter.api.Assertions.assertThrows;

/**
*
* @author davidB
*/
public class SetupTest {

@Test(expected=AssertionError.class)
@Test
public void testAssertionEnabled() {
assert false;
assertThrows(AssertionError.class, () -> {
assert false;
});
}
}
35 changes: 20 additions & 15 deletions jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -86,29 +89,31 @@ 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
public void testHasDefaultLayer() {
AnimComposer composer = new AnimComposer();

AnimLayer defaultLayer = composer.getLayer("Default");
Assert.assertNotNull(defaultLayer);
assertNotNull(defaultLayer);
}

@Test
Expand All @@ -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));
}

}
12 changes: 6 additions & 6 deletions jme3-core/src/test/java/com/jme3/anim/ArmatureMaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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));
}
}
}
Expand All @@ -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));
}
}
}
Expand Down Expand Up @@ -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));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions jme3-core/src/test/java/com/jme3/anim/JointCloneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
28 changes: 15 additions & 13 deletions jme3-core/src/test/java/com/jme3/asset/TestLocators.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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"));
}

/**
Expand All @@ -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"));
}

Expand All @@ -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");
}
}
18 changes: 9 additions & 9 deletions jme3-core/src/test/java/com/jme3/audio/AudioFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

}
Loading
Loading