Add some tests to test the default config values.

This commit is contained in:
graywolf336 2013-12-05 19:22:16 -06:00
parent d66b9d3447
commit ed36605506

View File

@ -1,43 +1,56 @@
package test.java.com.graywolf336.jail; package test.java.com.graywolf336.jail;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.com.graywolf336.jail.util.TestInstanceCreator; import test.java.com.graywolf336.jail.util.TestInstanceCreator;
import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailMain;
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({ JailMain.class, PluginDescriptionFile.class }) @PrepareForTest({ JailMain.class, PluginDescriptionFile.class })
public class TestJailStuff { public class TestJailStuff {
private TestInstanceCreator creator; private TestInstanceCreator creator;
private JailMain main; private JailMain main;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
creator = new TestInstanceCreator(); creator = new TestInstanceCreator();
creator.setup(); creator.setup();
main = creator.getMain(); main = creator.getMain();
} }
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
creator.tearDown(); creator.tearDown();
} }
@Test @Test
public void testForJails() { public void testForJails() {
assertNotNull("The JailIO is null.", main.getJailIO()); assertNotNull("The JailIO is null.", main.getJailIO());
assertNotNull("The JailManager is null.", main.getJailManager()); assertNotNull("The JailManager is null.", main.getJailManager());
assertNotNull("The HashSet for jails return is null.", main.getJailManager().getJails()); assertNotNull("The HashSet for jails return is null.", main.getJailManager().getJails());
assertThat(main, is(main.getJailManager().getPlugin())); assertThat(main, is(main.getJailManager().getPlugin()));
} }
}
@Test
public void testDefaultConfig() {
assertEquals("The config version is not 3.", main.getConfig().getInt("system.configVersion"), 3);
assertFalse("Default debugging is on.", main.getConfig().getBoolean("system.debug"));
assertTrue("Default updating notifications is false.", main.getConfig().getBoolean("system.updateNotifications"));
assertEquals("The default storage system is not flatfile.", main.getConfig().getString("storage.type"), "flatfile");
assertEquals("The default mysql host is not localhost.", main.getConfig().getString("storage.mysql.host"), "localhost");
assertEquals("The default mysql port is not 3306.", main.getConfig().getInt("storage.mysql.port"), 3306);
assertEquals("The default mysql username is not root.", main.getConfig().getString("storage.mysql.username"), "root");
assertEquals("The default mysql password is not password.", main.getConfig().getString("storage.mysql.password"), "password");
}
}