Merge branch 'Network_Upgrade' of https://github.com/magefree/mage into Network_Upgrade

This commit is contained in:
betasteward 2015-08-21 10:41:31 -04:00
commit b3d739e2c0
5 changed files with 40 additions and 9 deletions

View file

@ -765,6 +765,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public boolean connect(Connection connection) {
client = new Client(instance);
boolean result = client.connect(connection, version);
setWindowTitle();
if (result) {
updateDatabase(connection.isForceDBComparison(), serverState);
}

View file

@ -191,7 +191,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
//this.cardTableSelector.loadCards(this.bigCard);
this.btnExit.setVisible(true);
this.btnImport.setVisible(true);
if (!MageFrame.getClient().getServerState().isTestMode()) {
if (MageFrame.getClient().getServerState() != null && !MageFrame.getClient().getServerState().isTestMode()) {
this.btnLoad.setVisible(true);
}
this.deckArea.showSideboard(true);

View file

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

View file

@ -1,5 +1,9 @@
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 mage.cards.decks.importer.DeckImporterUtil;
import mage.constants.MatchTimeLimit;
@ -35,14 +39,15 @@ public class ServerTest {
new Thread(new Runnable() {
@Override
public void run() {
ServerMain.main(new String[] {"-fastDbMode=true"});
// ServerMain.main(new String[] {"-fastDbMode=true"});
ServerMain.main(new String[] {""});
}
}).start();
client = new TestClient();
try {
Thread.sleep(10000); //wait for server to startup
} catch (InterruptedException ex) {
waitForServer("ACTIVE"); //wait for server to startup
} catch (InterruptedException | IOException ex) {
}
client = new TestClient();
client.connect(USERNAME);
try {
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
public static void tearDownClass() {
}

View file

@ -9,6 +9,7 @@ import mage.cards.decks.DeckCardLists;
import mage.choices.Choice;
import mage.game.match.MatchOptions;
import mage.interfaces.ServerState;
import mage.players.net.UserGroup;
import mage.players.net.UserSkipPrioritySteps;
import mage.remote.Connection;
import mage.utils.MageVersion;
@ -50,7 +51,7 @@ public class TestClient implements MageClient {
connection.setSSL(true);
connection.setUsername(userName);
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());
}
@ -112,7 +113,7 @@ public class TestClient implements MageClient {
}
@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.
}
@ -137,7 +138,7 @@ public class TestClient implements MageClient {
}
@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.
}
@ -260,4 +261,5 @@ public class TestClient implements MageClient {
public void watchGame(UUID gameId, UUID chatId, GameView game) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}