2011-10-12 23:39:52 +00:00
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
import junit.framework.TestCase;
|
2011-11-23 01:43:38 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.World.Environment;
|
|
|
|
import org.bukkit.plugin.InvalidDescriptionException;
|
2011-10-12 23:39:52 +00:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2011-10-12 23:39:52 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
public class StorageTest extends TestCase {
|
|
|
|
Essentials ess;
|
|
|
|
FakeServer server;
|
|
|
|
World world;
|
2011-11-23 01:43:38 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
public StorageTest() {
|
|
|
|
server = new FakeServer();
|
|
|
|
world = server.createWorld("testWorld", Environment.NORMAL);
|
|
|
|
ess = new Essentials(server);
|
|
|
|
try {
|
|
|
|
ess.setupForTesting(server);
|
|
|
|
} catch (InvalidDescriptionException ex) {
|
|
|
|
fail("InvalidDescriptionException");
|
|
|
|
} catch (IOException ex) {
|
|
|
|
fail("IOException");
|
|
|
|
}
|
|
|
|
}
|
2011-11-23 01:43:38 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Test
|
|
|
|
public void testOldUserdata() {
|
|
|
|
ExecuteTimer ext = new ExecuteTimer();
|
|
|
|
ext.start();
|
|
|
|
OfflinePlayer base1 = server.createPlayer("testPlayer1");
|
|
|
|
server.addPlayer(base1);
|
|
|
|
ext.mark("fake user created");
|
2015-06-03 20:11:56 +00:00
|
|
|
UserData user = ess.getUser(base1);
|
2015-04-15 04:06:16 +00:00
|
|
|
ext.mark("load empty user");
|
|
|
|
for (int j = 0; j < 1; j++) {
|
|
|
|
user.setHome("home", new Location(world, j, j, j));
|
|
|
|
}
|
|
|
|
ext.mark("change home 1 times");
|
|
|
|
user.save();
|
|
|
|
ext.mark("write user");
|
|
|
|
user.save();
|
|
|
|
ext.mark("write user (cached)");
|
|
|
|
user.reloadConfig();
|
|
|
|
ext.mark("reloaded file");
|
|
|
|
user.reloadConfig();
|
|
|
|
ext.mark("reloaded file (cached)");
|
|
|
|
System.out.println(ext.end());
|
|
|
|
}
|
2011-10-12 23:39:52 +00:00
|
|
|
}
|