fixed old version + improved wait for server method

This commit is contained in:
betasteward 2015-08-20 15:31:17 -04:00
parent 129b6d1e82
commit 3a96ff7933
3 changed files with 38 additions and 8 deletions

View file

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>1.4.1</version> <version>1.4.3</version>
</parent> </parent>
<artifactId>mage-server-tests</artifactId> <artifactId>mage-server-tests</artifactId>

View file

@ -1,5 +1,9 @@
package org.mage.server.test; package org.mage.server.test;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.List; import java.util.List;
import mage.cards.decks.importer.DeckImporterUtil; import mage.cards.decks.importer.DeckImporterUtil;
import mage.constants.MatchTimeLimit; import mage.constants.MatchTimeLimit;
@ -35,14 +39,15 @@ public class ServerTest {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
ServerMain.main(new String[] {"-fastDbMode=true"}); // ServerMain.main(new String[] {"-fastDbMode=true"});
ServerMain.main(new String[] {""});
} }
}).start(); }).start();
client = new TestClient();
try { try {
Thread.sleep(10000); //wait for server to startup waitForServer("ACTIVE"); //wait for server to startup
} catch (InterruptedException ex) { } catch (InterruptedException | IOException ex) {
} }
client = new TestClient();
client.connect(USERNAME); client.connect(USERNAME);
try { try {
Thread.sleep(10000); //wait for user to join main room Thread.sleep(10000); //wait for user to join main room
@ -50,6 +55,29 @@ public class ServerTest {
} }
} }
public static void waitForServer(String message) throws FileNotFoundException, IOException, InterruptedException {
FileReader fr = new FileReader("mageserver.log");
BufferedReader br = new BufferedReader(fr);
do { //read until end-of-file
String line = br.readLine();
if (line == null) {
break;
}
} while (true);
do { //read only new lines
String line = br.readLine();
if (line == null) {
Thread.sleep(1000);
}
else {
if (line.contains(message))
break;
}
} while (true);
}
@AfterClass @AfterClass
public static void tearDownClass() { public static void tearDownClass() {
} }

View file

@ -9,6 +9,7 @@ import mage.cards.decks.DeckCardLists;
import mage.choices.Choice; import mage.choices.Choice;
import mage.game.match.MatchOptions; import mage.game.match.MatchOptions;
import mage.interfaces.ServerState; import mage.interfaces.ServerState;
import mage.players.net.UserGroup;
import mage.players.net.UserSkipPrioritySteps; import mage.players.net.UserSkipPrioritySteps;
import mage.remote.Connection; import mage.remote.Connection;
import mage.utils.MageVersion; import mage.utils.MageVersion;
@ -50,7 +51,7 @@ public class TestClient implements MageClient {
connection.setSSL(true); connection.setSSL(true);
connection.setUsername(userName); connection.setUsername(userName);
connection.setForceDBComparison(false); connection.setForceDBComparison(false);
connection.setUserData(new UserDataView(51, false, false, false, new UserSkipPrioritySteps(), "world", false)); connection.setUserData(new UserDataView(UserGroup.PLAYER, 51, false, false, false, new UserSkipPrioritySteps(), "world", false, false, false));
return client.connect(connection, MageVersion.getCurrent()); return client.connect(connection, MageVersion.getCurrent());
} }
@ -112,7 +113,7 @@ public class TestClient implements MageClient {
} }
@Override @Override
public void gameAsk(UUID gameId, GameView gameView, String question) { public void gameAsk(UUID gameId, GameView gameView, String question, Map<String, Serializable> options) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }
@ -137,7 +138,7 @@ public class TestClient implements MageClient {
} }
@Override @Override
public void gamePlayMana(UUID gameId, GameView gameView, String message) { public void gamePlayMana(UUID gameId, GameView gameView, String message, Map<String, Serializable> options) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }
@ -260,4 +261,5 @@ public class TestClient implements MageClient {
public void watchGame(UUID gameId, UUID chatId, GameView game) { public void watchGame(UUID gameId, UUID chatId, GameView game) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} }
} }