From 821051a3bc384918dc277a9e3b9d9577f72b3ba6 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Fri, 25 Apr 2014 17:56:52 -0500 Subject: [PATCH] Fix the tests failing, happy day! --- .../jail/util/TestInstanceCreator.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java b/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java index 44f20ee..4f82500 100644 --- a/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java +++ b/src/test/java/test/java/com/graywolf336/jail/util/TestInstanceCreator.java @@ -34,6 +34,8 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.*; +import static org.powermock.api.support.membermodification.MemberMatcher.constructor; +import static org.powermock.api.support.membermodification.MemberModifier.suppress; import com.graywolf336.jail.JailMain; @@ -66,6 +68,7 @@ public class TestInstanceCreator { when(mockServer.getWorldContainer()).thenReturn(worldsDirectory); when(mockServer.getItemFactory()).thenReturn(CraftItemFactory.instance()); + suppress(constructor(JailMain.class)); main = PowerMockito.spy(new JailMain()); PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Jail", "3.0.0-Test", "com.graywolf336.jail.JailMain")); @@ -74,12 +77,13 @@ public class TestInstanceCreator { authors.add("matejdro"); authors.add("multidude"); authors.add("graywolf336"); - doReturn(authors).when(pdf).getAuthors(); - doReturn(pdf).when(main).getDescription(); - doReturn(true).when(main).isEnabled(); - doReturn(Util.logger).when(main).getLogger(); - doReturn(mockServer).when(main).getServer(); - doReturn(pluginDirectory).when(main).getDataFolder(); + when(pdf.getAuthors()).thenReturn(authors); + + when(main.getDescription()).thenReturn(pdf); + when(main.getDataFolder()).thenReturn(pluginDirectory); + when(main.isEnabled()).thenReturn(true); + when(main.getLogger()).thenReturn(Util.logger); + when(main.getServer()).thenReturn(mockServer); Field configFile = JavaPlugin.class.getDeclaredField("configFile"); configFile.setAccessible(true); @@ -278,9 +282,9 @@ public class TestInstanceCreator { main.onDisable(); - + deleteFolder(pluginDirectory); + deleteFolder(worldsDirectory); deleteFolder(serverDirectory); - return true; }