package be.Balor.JUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.io.File;
import java.io.IOException;
import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.inventory.ItemStack;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import be.Balor.Player.BannedPlayer;
import be.Balor.Tools.Configuration.File.ExtendedConfiguration;
private File file;
@Before
public void setUp()
throws Exception {
ExtendedConfiguration.setClassLoader(this.getClass().getClassLoader());
file = new File("test.yml");
final ExtendedConfiguration conf = ExtendedConfiguration
.loadConfiguration(file);
conf.add("test", "blah");
conf.createSection("yatta").set("test", "blah");
conf.save();
}
@Test
final ExtendedConfiguration conf = ExtendedConfiguration
.loadConfiguration(file);
assertEquals("blah", conf.get("test"));
assertFalse(conf.add("test", "test"));
assertEquals("blah", conf.get("test"));
}
@Test
InvalidConfigurationException {
final ExtendedConfiguration conf = ExtendedConfiguration
.loadConfiguration(file);
final ItemStack test = new ItemStack(Material.WATER, 10);
conf.set("serial.item", test);
conf.save();
conf.reload();
assertEquals(new ItemStack(Material.WATER, 10), conf.get("serial.item"));
}
@Test
InvalidConfigurationException {
final ExtendedConfiguration conf = ExtendedConfiguration
.loadConfiguration(file);
conf.set("serial.banPlayer", new BannedPlayer("Test", "testing"));
conf.save();
conf.reload();
assertEquals("Test",
((BannedPlayer) conf.get("serial.banPlayer")).getPlayer());
}
@After
public void tearDown()
throws Exception {
file.deleteOnExit();
}
}