diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index b5728cdb..951073e8 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -104,6 +104,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.java.JavaPluginLoader; import org.mcstats.Metrics; import java.io.*; @@ -137,16 +138,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { /** * This is for unit testing. - * @deprecated - * @param loader deprecated - * @param server deprecated - * @param description deprecated - * @param dataFolder deprecated - * @param file deprecated + * @param loader The PluginLoader to use. + * @param description The Description file to use. + * @param dataFolder The folder that other datafiles can be found in. + * @param file The location of the plugin. */ - @Deprecated - public MultiverseCore(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file) { - super(loader, server, description, dataFolder, file); + public MultiverseCore(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) { + super(loader, description, dataFolder, file); } /** diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestDebugMode.java b/src/test/java/com/onarandombox/MultiverseCore/TestDebugMode.java index 3e446dc6..f7924447 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestDebugMode.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestDebugMode.java @@ -15,6 +15,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPluginLoader; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -30,7 +31,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) -@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class }) +@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class}) public class TestDebugMode { TestInstanceCreator creator; Server mockServer; diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java b/src/test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java index 001b10a8..e6b985a1 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestEntitySpawnRules.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPluginLoader; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -29,7 +30,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.*; @RunWith(PowerMockRunner.class) -@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class }) +@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class}) public class TestEntitySpawnRules { TestInstanceCreator creator; MultiverseCore core; diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java b/src/test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java index aaa869b7..7d64081c 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestModifyCommand.java @@ -7,6 +7,7 @@ import org.bukkit.World.Environment; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPluginLoader; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -20,7 +21,7 @@ import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) -@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class }) +@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class }) public class TestModifyCommand { TestInstanceCreator creator; Server mockServer; diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java b/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java index b74957c1..751ad97c 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestWorldProperties.java @@ -37,6 +37,7 @@ import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.permissions.Permission; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPluginLoader; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -57,7 +58,7 @@ import static org.mockito.Mockito.*; @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 }) + FoodLevelChangeEvent.class, WorldManager.class, PluginDescriptionFile.class, JavaPluginLoader.class }) public class TestWorldProperties { private TestInstanceCreator creator; private MultiverseCore core; diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java b/src/test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java index cd01d700..838bb057 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestWorldPurger.java @@ -9,6 +9,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Sheep; import org.bukkit.entity.Zombie; import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.java.JavaPluginLoader; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -22,7 +23,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.*; @RunWith(PowerMockRunner.class) -@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class }) +@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class }) public class TestWorldPurger { TestInstanceCreator creator; MultiverseCore core; diff --git a/src/test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java b/src/test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java index d93f4782..b98725d1 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java +++ b/src/test/java/com/onarandombox/MultiverseCore/TestWorldStuff.java @@ -23,6 +23,7 @@ import org.bukkit.permissions.Permission; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPluginLoader; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -38,7 +39,8 @@ 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 }) +@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class, WorldManager.class, + PluginDescriptionFile.class, JavaPluginLoader.class }) public class TestWorldStuff { private TestInstanceCreator creator; diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java b/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java index e363cf97..b836fb8a 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java +++ b/src/test/java/com/onarandombox/MultiverseCore/utils/TestInstanceCreator.java @@ -25,12 +25,15 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.plugin.java.JavaPluginLoader; import org.bukkit.scheduler.BukkitScheduler; import org.mockito.Matchers; 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; @@ -62,10 +65,10 @@ public class TestInstanceCreator { MockGateway.MOCK_STANDARD_METHODS = false; - TestPluginLoader pluginLoader = new TestPluginLoader(); - // Initialize the Mock server. mockServer = mock(Server.class); + JavaPluginLoader mockPluginLoader = PowerMock.createMock(JavaPluginLoader.class); + Whitebox.setInternalState(mockPluginLoader, "server", mockServer); when(mockServer.getName()).thenReturn("TestBukkit"); Logger.getLogger("Minecraft").setParent(Util.logger); when(mockServer.getLogger()).thenReturn(Util.logger); @@ -75,8 +78,7 @@ public class TestInstanceCreator { PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Multiverse-Core", "2.2-Test", "com.onarandombox.MultiverseCore.MultiverseCore")); when(pdf.getAuthors()).thenReturn(new ArrayList()); - - core = PowerMockito.spy(new MultiverseCore(pluginLoader, mockServer, pdf, pluginDirectory, new File(pluginDirectory, "testPluginFile"))); + core = PowerMockito.spy(new MultiverseCore(mockPluginLoader, pdf, pluginDirectory, new File(pluginDirectory, "testPluginFile"))); PowerMockito.doAnswer(new Answer() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { diff --git a/src/test/java/com/onarandombox/MultiverseCore/utils/TestPluginLoader.java b/src/test/java/com/onarandombox/MultiverseCore/utils/TestPluginLoader.java deleted file mode 100644 index 7c96a456..00000000 --- a/src/test/java/com/onarandombox/MultiverseCore/utils/TestPluginLoader.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.onarandombox.MultiverseCore.utils; - -import org.bukkit.event.Event; -import org.bukkit.event.Listener; -import org.bukkit.plugin.InvalidDescriptionException; -import org.bukkit.plugin.InvalidPluginException; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.plugin.PluginLoader; -import org.bukkit.plugin.RegisteredListener; -import org.bukkit.plugin.UnknownDependencyException; - -import java.io.File; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; - -public class TestPluginLoader implements PluginLoader { - - @Override - public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException { - return null; - } - - @Override - public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException { - return null; - } - - @Override - public Pattern[] getPluginFileFilters() { - return new Pattern[0]; - } - - @Override - public Map, Set> createRegisteredListeners(Listener listener, Plugin plugin) { - return null; - } - - @Override - public void enablePlugin(Plugin plugin) { - - } - - @Override - public void disablePlugin(Plugin plugin) { - - } -}