mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 02:25:41 +01:00
remove PowerMockito
This commit is contained in:
parent
28585dd6f9
commit
b9b1fa6164
21
pom.xml
21
pom.xml
@ -348,24 +348,9 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-easymock</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<type>jar</type>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.11.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -20,9 +20,6 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -31,9 +28,6 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
|
||||
@PowerMockIgnore("javax.script.*")
|
||||
public class TestDebugMode {
|
||||
TestInstanceCreator creator;
|
||||
Server mockServer;
|
||||
|
@ -20,9 +20,6 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
@ -33,9 +30,6 @@ import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
|
||||
@PowerMockIgnore("javax.script.*")
|
||||
public class TestEntitySpawnRules {
|
||||
TestInstanceCreator creator;
|
||||
MultiverseCore core;
|
||||
|
@ -8,18 +8,12 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
|
||||
@PowerMockIgnore("javax.script.*")
|
||||
public class TestEntryFeeConversion {
|
||||
|
||||
private TestInstanceCreator creator;
|
||||
|
@ -12,18 +12,11 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class })
|
||||
@PowerMockIgnore("javax.script.*")
|
||||
public class TestModifyCommand {
|
||||
TestInstanceCreator creator;
|
||||
Server mockServer;
|
||||
|
@ -45,10 +45,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.internal.verification.VerificationModeFactory;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -57,12 +53,6 @@ import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class,
|
||||
WeatherChangeEvent.class, ThunderChangeEvent.class, AsyncPlayerChatEvent.class,
|
||||
PlayerJoinEvent.class, PlayerRespawnEvent.class, EntityRegainHealthEvent.class,
|
||||
FoodLevelChangeEvent.class, WorldManager.class, PluginDescriptionFile.class, JavaPluginLoader.class })
|
||||
@PowerMockIgnore("javax.script.*")
|
||||
public class TestWorldProperties {
|
||||
private TestInstanceCreator creator;
|
||||
private MultiverseCore core;
|
||||
@ -366,36 +356,36 @@ public class TestWorldProperties {
|
||||
when(mockPlayer.hasPlayedBefore()).thenReturn(true);
|
||||
when(mockPlayer.hasPermission("multiverse.access.world")).thenReturn(true);
|
||||
when(mockPlayer.getName()).thenReturn("MultiverseMan");
|
||||
playerChatEvent = PowerMockito.mock(AsyncPlayerChatEvent.class);
|
||||
playerChatEvent = mock(AsyncPlayerChatEvent.class);
|
||||
when(playerChatEvent.getPlayer()).thenReturn(mockPlayer);
|
||||
when(playerChatEvent.getFormat()).thenReturn("format");
|
||||
// player join
|
||||
mockNewPlayer = mock(Player.class);
|
||||
when(mockNewPlayer.hasPlayedBefore()).thenReturn(false);
|
||||
playerJoinEvent = PowerMockito.mock(PlayerJoinEvent.class);
|
||||
playerJoinEvent = mock(PlayerJoinEvent.class);
|
||||
when(playerJoinEvent.getPlayer()).thenReturn(mockPlayer);
|
||||
playerNewJoinEvent = PowerMockito.mock(PlayerJoinEvent.class);
|
||||
playerNewJoinEvent = mock(PlayerJoinEvent.class);
|
||||
when(playerNewJoinEvent.getPlayer()).thenReturn(mockNewPlayer);
|
||||
// player respawn
|
||||
playerRespawnBed = PowerMockito.mock(PlayerRespawnEvent.class);
|
||||
playerRespawnBed = mock(PlayerRespawnEvent.class);
|
||||
when(playerRespawnBed.getPlayer()).thenReturn(mockPlayer);
|
||||
when(playerRespawnBed.isBedSpawn()).thenReturn(true);
|
||||
playerRespawnNormal = PowerMockito.mock(PlayerRespawnEvent.class);
|
||||
playerRespawnNormal = mock(PlayerRespawnEvent.class);
|
||||
when(playerRespawnNormal.getPlayer()).thenReturn(mockPlayer);
|
||||
when(playerRespawnNormal.isBedSpawn()).thenReturn(false);
|
||||
//// Entity events
|
||||
mockHumanEntity = mock(HumanEntity.class);
|
||||
// entity regain health
|
||||
entityRegainHealthEvent = PowerMockito.mock(EntityRegainHealthEvent.class);
|
||||
entityRegainHealthEvent = mock(EntityRegainHealthEvent.class);
|
||||
when(entityRegainHealthEvent.getRegainReason()).thenReturn(RegainReason.REGEN);
|
||||
when(mockHumanEntity.getLocation()).thenReturn(new Location(world, 0, 0, 0));
|
||||
when(entityRegainHealthEvent.getEntity()).thenReturn(mockHumanEntity);
|
||||
// entity food level change event
|
||||
entityFoodLevelChangeEvent = PowerMockito.mock(FoodLevelChangeEvent.class);
|
||||
entityFoodLevelChangeEvent = mock(FoodLevelChangeEvent.class);
|
||||
// this won't do anything since we're not mocking a player,
|
||||
// but the plugin should be able to handle this!
|
||||
when(entityFoodLevelChangeEvent.getEntity()).thenReturn(mockHumanEntity);
|
||||
entityFoodLevelRiseEvent = PowerMockito.mock(FoodLevelChangeEvent.class);
|
||||
entityFoodLevelRiseEvent = mock(FoodLevelChangeEvent.class);
|
||||
when(mockPlayer.getFoodLevel()).thenReturn(2);
|
||||
when(entityFoodLevelRiseEvent.getEntity()).thenReturn(mockPlayer);
|
||||
when(entityFoodLevelRiseEvent.getFoodLevel()).thenReturn(3);
|
||||
|
@ -14,18 +14,12 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class })
|
||||
@PowerMockIgnore("javax.script.*")
|
||||
public class TestWorldPurger {
|
||||
TestInstanceCreator creator;
|
||||
MultiverseCore core;
|
||||
|
@ -32,19 +32,12 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.internal.verification.VerificationModeFactory;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static junit.framework.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class, WorldManager.class,
|
||||
PluginDescriptionFile.class, JavaPluginLoader.class })
|
||||
@PowerMockIgnore("javax.script.*")
|
||||
public class TestWorldStuff {
|
||||
|
||||
private TestInstanceCreator creator;
|
||||
|
@ -28,12 +28,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.internal.util.reflection.ReflectionMemberAccessor;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.easymock.PowerMock;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.MockGateway;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
@ -52,6 +49,7 @@ import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
|
||||
public class TestInstanceCreator {
|
||||
@ -69,22 +67,20 @@ public class TestInstanceCreator {
|
||||
pluginDirectory.mkdirs();
|
||||
assertTrue(pluginDirectory.exists());
|
||||
|
||||
MockGateway.MOCK_STANDARD_METHODS = false;
|
||||
|
||||
// Initialize the Mock server.
|
||||
mockServer = mock(Server.class);
|
||||
JavaPluginLoader mockPluginLoader = PowerMock.createMock(JavaPluginLoader.class);
|
||||
Whitebox.setInternalState(mockPluginLoader, "server", mockServer);
|
||||
JavaPluginLoader mockPluginLoader = mock(JavaPluginLoader.class);
|
||||
new ReflectionMemberAccessor().set(JavaPluginLoader.class.getDeclaredField("server"), mockPluginLoader, mockServer);
|
||||
when(mockServer.getName()).thenReturn("TestBukkit");
|
||||
Logger.getLogger("Minecraft").setParent(Util.logger);
|
||||
when(mockServer.getLogger()).thenReturn(Util.logger);
|
||||
when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
|
||||
|
||||
// Return a fake PDF file.
|
||||
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Multiverse-Core", "2.2-Test",
|
||||
PluginDescriptionFile pdf = spy(new PluginDescriptionFile("Multiverse-Core", "2.2-Test",
|
||||
"com.onarandombox.MultiverseCore.MultiverseCore"));
|
||||
when(pdf.getAuthors()).thenReturn(new ArrayList<String>());
|
||||
core = PowerMockito.spy(new MultiverseCore(mockPluginLoader, pdf, pluginDirectory, new File(pluginDirectory, "testPluginFile")));
|
||||
core = spy(new MultiverseCore(mockPluginLoader, pdf, pluginDirectory, new File(pluginDirectory, "testPluginFile")));
|
||||
|
||||
// Let's let all MV files go to bin/test
|
||||
doReturn(pluginDirectory).when(core).getDataFolder();
|
||||
@ -97,7 +93,7 @@ public class TestInstanceCreator {
|
||||
JavaPlugin[] plugins = new JavaPlugin[] { core };
|
||||
|
||||
// Mock the Plugin Manager
|
||||
PluginManager mockPluginManager = PowerMockito.mock(PluginManager.class);
|
||||
PluginManager mockPluginManager = mock(PluginManager.class);
|
||||
when(mockPluginManager.getPlugins()).thenReturn(plugins);
|
||||
when(mockPluginManager.getPlugin("Multiverse-Core")).thenReturn(core);
|
||||
when(mockPluginManager.getPermission(anyString())).thenReturn(null);
|
||||
@ -213,7 +209,7 @@ public class TestInstanceCreator {
|
||||
buscriptfield.setAccessible(true);
|
||||
|
||||
try {
|
||||
buscript = PowerMockito.spy(new Buscript(core));
|
||||
buscript = spy(new Buscript(core));
|
||||
when(buscript.getPlugin()).thenReturn(core);
|
||||
} catch (NullPointerException e) {
|
||||
buscript = null;
|
||||
@ -222,25 +218,25 @@ public class TestInstanceCreator {
|
||||
buscriptfield.set(core, buscript);
|
||||
|
||||
// Set worldManager
|
||||
WorldManager wm = PowerMockito.spy(new WorldManager(core));
|
||||
WorldManager wm = spy(new WorldManager(core));
|
||||
Field worldmanagerfield = MultiverseCore.class.getDeclaredField("worldManager");
|
||||
worldmanagerfield.setAccessible(true);
|
||||
worldmanagerfield.set(core, wm);
|
||||
|
||||
// Set playerListener
|
||||
MVPlayerListener pl = PowerMockito.spy(new MVPlayerListener(core));
|
||||
MVPlayerListener pl = spy(new MVPlayerListener(core));
|
||||
Field playerlistenerfield = MultiverseCore.class.getDeclaredField("playerListener");
|
||||
playerlistenerfield.setAccessible(true);
|
||||
playerlistenerfield.set(core, pl);
|
||||
|
||||
// Set entityListener
|
||||
MVEntityListener el = PowerMockito.spy(new MVEntityListener(core));
|
||||
MVEntityListener el = spy(new MVEntityListener(core));
|
||||
Field entitylistenerfield = MultiverseCore.class.getDeclaredField("entityListener");
|
||||
entitylistenerfield.setAccessible(true);
|
||||
entitylistenerfield.set(core, el);
|
||||
|
||||
// Set weatherListener
|
||||
MVWeatherListener wl = PowerMockito.spy(new MVWeatherListener(core));
|
||||
MVWeatherListener wl = spy(new MVWeatherListener(core));
|
||||
Field weatherlistenerfield = MultiverseCore.class.getDeclaredField("weatherListener");
|
||||
weatherlistenerfield.setAccessible(true);
|
||||
weatherlistenerfield.set(core, wl);
|
||||
|
@ -0,0 +1 @@
|
||||
mock-maker-inline
|
Loading…
Reference in New Issue
Block a user