mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Move Core to JUnit 5
This commit is contained in:
parent
e98b99edcd
commit
429d022752
@ -6,6 +6,7 @@ import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.plugins.quality.CheckstyleExtension
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.external.javadoc.CoreJavadocOptions
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
@ -39,8 +40,13 @@ fun Project.applyPlatformAndCoreConfiguration() {
|
||||
toolVersion = "7.6.1"
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"testImplementation"("junit:junit:4.12")
|
||||
"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
|
||||
"testRuntime"("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}")
|
||||
}
|
||||
|
||||
// Java 8 turns on doclint which we fail
|
||||
|
@ -3,4 +3,5 @@ object Versions {
|
||||
const val TEXT_EXTRAS = "3.0.2"
|
||||
const val PISTON = "0.4.2"
|
||||
const val AUTO_VALUE = "1.6.5"
|
||||
const val JUNIT = "5.5.0"
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ configurations.all {
|
||||
dependencies {
|
||||
"api"(project(":worldedit-core"))
|
||||
"api"(project(":worldedit-libs:bukkit"))
|
||||
"api"("org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT")
|
||||
"api"("org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT") {
|
||||
exclude("junit", "junit")
|
||||
}
|
||||
"compileOnly"("com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT")
|
||||
"implementation"("io.papermc:paperlib:1.0.2")
|
||||
"compileOnly"("com.sk89q:dummypermscompat:1.10")
|
||||
|
@ -19,19 +19,20 @@
|
||||
|
||||
package com.sk89q.minecraft.util.commands;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
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;
|
||||
|
||||
public class CommandContextTest {
|
||||
|
||||
@ -39,7 +40,7 @@ public class CommandContextTest {
|
||||
private static final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something";
|
||||
CommandContext firstCommand;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUpTest() {
|
||||
try {
|
||||
firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w')));
|
||||
@ -49,10 +50,12 @@ public class CommandContextTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = CommandException.class)
|
||||
public void testInvalidFlags() throws CommandException {
|
||||
@Test
|
||||
public void testInvalidFlags() {
|
||||
final String failingCommand = "herpderp -opw testers";
|
||||
new CommandContext(failingCommand, new HashSet<>(Arrays.asList('o', 'w')));
|
||||
assertThrows(CommandException.class, () -> {
|
||||
new CommandContext(failingCommand, new HashSet<>(Arrays.asList('o', 'w')));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -19,33 +19,33 @@
|
||||
|
||||
package com.sk89q.worldedit.extent.transform;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Ignore("A platform is currently required to get properties, preventing this test.")
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@Disabled("A platform is currently required to get properties, preventing this test.")
|
||||
public class BlockTransformExtentTest {
|
||||
|
||||
private static final Transform ROTATE_90 = new AffineTransform().rotateY(-90);
|
||||
private static final Transform ROTATE_NEG_90 = new AffineTransform().rotateY(90);
|
||||
private final Set<BlockType> ignored = new HashSet<>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
BlockType.REGISTRY.register("worldedit:test", new BlockType("worldedit:test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransform() throws Exception {
|
||||
public void testTransform() {
|
||||
for (BlockType type : BlockType.REGISTRY.values()) {
|
||||
if (ignored.contains(type)) {
|
||||
continue;
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.internal.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.internal.util.Substring;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static com.sk89q.worldedit.internal.command.CommandArgParser.spaceSplit;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class CommandArgParserTest {
|
||||
@Test
|
||||
|
@ -19,16 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.expression;
|
||||
|
||||
import static java.lang.Math.atan2;
|
||||
import static java.lang.Math.sin;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
@ -36,9 +26,18 @@ import com.sk89q.worldedit.internal.expression.lexer.LexerException;
|
||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static java.lang.Math.atan2;
|
||||
import static java.lang.Math.sin;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class ExpressionTest {
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
Platform mockPlat = Mockito.mock(Platform.class);
|
||||
Mockito.when(mockPlat.getConfiguration()).thenReturn(new LocalConfiguration() {
|
||||
@ -51,7 +50,7 @@ public class ExpressionTest {
|
||||
|
||||
@Test
|
||||
public void testEvaluate() throws ExpressionException {
|
||||
// check
|
||||
// check
|
||||
assertEquals(1 - 2 + 3, simpleEval("1 - 2 + 3"), 0);
|
||||
|
||||
// check unary ops
|
||||
@ -74,7 +73,7 @@ public class ExpressionTest {
|
||||
compile("#");
|
||||
fail("Error expected");
|
||||
} catch (LexerException e) {
|
||||
assertEquals("Error position", 0, e.getPosition());
|
||||
assertEquals(0, e.getPosition(), "Error position");
|
||||
}
|
||||
|
||||
// test parser errors
|
||||
@ -82,13 +81,13 @@ public class ExpressionTest {
|
||||
compile("x");
|
||||
fail("Error expected");
|
||||
} catch (ParserException e) {
|
||||
assertEquals("Error position", 0, e.getPosition());
|
||||
assertEquals(0, e.getPosition(), "Error position");
|
||||
}
|
||||
try {
|
||||
compile("x()");
|
||||
fail("Error expected");
|
||||
} catch (ParserException e) {
|
||||
assertEquals("Error position", 0, e.getPosition());
|
||||
assertEquals(0, e.getPosition(), "Error position");
|
||||
}
|
||||
try {
|
||||
compile("(");
|
||||
@ -104,19 +103,19 @@ public class ExpressionTest {
|
||||
compile("atan2(1)");
|
||||
fail("Error expected");
|
||||
} catch (ParserException e) {
|
||||
assertEquals("Error position", 0, e.getPosition());
|
||||
assertEquals(0, e.getPosition(), "Error position");
|
||||
}
|
||||
try {
|
||||
compile("atan2(1, 2, 3)");
|
||||
fail("Error expected");
|
||||
} catch (ParserException e) {
|
||||
assertEquals("Error position", 0, e.getPosition());
|
||||
assertEquals(0, e.getPosition(), "Error position");
|
||||
}
|
||||
try {
|
||||
compile("rotate(1, 2, 3)");
|
||||
fail("Error expected");
|
||||
} catch (ParserException e) {
|
||||
assertEquals("Error position", 0, e.getPosition());
|
||||
assertEquals(0, e.getPosition(), "Error position");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests {@link Location}.
|
||||
|
@ -19,14 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.util.eventbus;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class EventBusTest {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user