mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Tests: improved performance in game tests;
This commit is contained in:
parent
2fa76fc7be
commit
2cf005f971
6 changed files with 123 additions and 34 deletions
|
|
@ -102,21 +102,25 @@ public abstract class MageTestBase {
|
|||
@BeforeClass
|
||||
public static void init() {
|
||||
Logger.getRootLogger().setLevel(Level.DEBUG);
|
||||
deleteSavedGames();
|
||||
ConfigSettings config = new ConfigWrapper(ConfigFactory.loadFromFile("config/config.xml"));
|
||||
config.getGameTypes().forEach((gameType) -> {
|
||||
GameFactory.instance.addGameType(gameType.getName(), loadGameType(gameType), loadPlugin(gameType));
|
||||
});
|
||||
config.getTournamentTypes().forEach((tournamentType) -> {
|
||||
TournamentFactory.instance.addTournamentType(tournamentType.getName(), loadTournamentType(tournamentType), loadPlugin(tournamentType));
|
||||
});
|
||||
config.getPlayerTypes().forEach((playerType) -> {
|
||||
PlayerFactory.instance.addPlayerType(playerType.getName(), loadPlugin(playerType));
|
||||
});
|
||||
|
||||
// one time init for all tests
|
||||
if (GameFactory.instance.getGameTypes().isEmpty()) {
|
||||
deleteSavedGames();
|
||||
ConfigSettings config = new ConfigWrapper(ConfigFactory.loadFromFile("config/config.xml"));
|
||||
config.getGameTypes().forEach((gameType) -> {
|
||||
GameFactory.instance.addGameType(gameType.getName(), loadGameType(gameType), loadPlugin(gameType));
|
||||
});
|
||||
config.getTournamentTypes().forEach((tournamentType) -> {
|
||||
TournamentFactory.instance.addTournamentType(tournamentType.getName(), loadTournamentType(tournamentType), loadPlugin(tournamentType));
|
||||
});
|
||||
config.getPlayerTypes().forEach((playerType) -> {
|
||||
PlayerFactory.instance.addPlayerType(playerType.getName(), loadPlugin(playerType));
|
||||
});
|
||||
// for (Plugin plugin : config.getDeckTypes()) {
|
||||
// DeckValidatorFactory.getInstance().addDeckType(plugin.getName(), loadPlugin(plugin));
|
||||
// }
|
||||
Copier.setLoader(classLoader);
|
||||
Copier.setLoader(classLoader);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("UseSpecificCatch")
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ public abstract class MageTestPlayerBase {
|
|||
|
||||
protected Map<TestPlayer, Map<Zone, String>> commands = new HashMap<>();
|
||||
|
||||
protected static Map<String, DeckCardLists> loadedDeckCardLists = new HashMap<>(); // test decks buffer
|
||||
protected static Map<String, DeckCardLists> loadedDecks = new HashMap<>(); // deck's cache
|
||||
protected static Map<String, CardInfo> loadedCardInfo = new HashMap<>(); // db card's cache
|
||||
|
||||
protected TestPlayer playerA;
|
||||
protected TestPlayer playerB;
|
||||
|
|
@ -131,12 +132,15 @@ public abstract class MageTestPlayerBase {
|
|||
logger.debug("Logging level: " + logger.getLevel());
|
||||
logger.debug("Default charset: " + Charset.defaultCharset());
|
||||
|
||||
deleteSavedGames();
|
||||
ConfigSettings config = new ConfigWrapper(ConfigFactory.loadFromFile("config/config.xml"));
|
||||
for (GamePlugin plugin : config.getGameTypes()) {
|
||||
GameFactory.instance.addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
||||
// one time init for all tests
|
||||
if (GameFactory.instance.getGameTypes().isEmpty()) {
|
||||
deleteSavedGames();
|
||||
ConfigSettings config = new ConfigWrapper(ConfigFactory.loadFromFile("config/config.xml"));
|
||||
for (GamePlugin plugin : config.getGameTypes()) {
|
||||
GameFactory.instance.addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
Copier.setLoader(classLoader);
|
||||
}
|
||||
Copier.setLoader(classLoader);
|
||||
}
|
||||
|
||||
private static Class<?> loadPlugin(Plugin plugin) {
|
||||
|
|
|
|||
|
|
@ -259,13 +259,13 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
|
||||
logger.debug("Loading deck...");
|
||||
DeckCardLists list;
|
||||
if (loadedDeckCardLists.containsKey(deckName)) {
|
||||
list = loadedDeckCardLists.get(deckName);
|
||||
if (loadedDecks.containsKey(deckName)) {
|
||||
list = loadedDecks.get(deckName);
|
||||
} else {
|
||||
list = DeckImporter.importDeckFromFile(deckName, true);
|
||||
loadedDeckCardLists.put(deckName, list);
|
||||
loadedDecks.put(deckName, list);
|
||||
}
|
||||
Deck deck = Deck.load(list, false, false);
|
||||
Deck deck = Deck.load(list, false, false, loadedCardInfo);
|
||||
logger.debug("Done!");
|
||||
if (deck.getCards().size() < 40) {
|
||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue