diff --git a/.gitignore b/.gitignore
index 5eb4c929aef..a5f07bfdc1c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,7 +50,7 @@ Mage.Updater/target
mage.updater.client/target
releases
-Utils/author.txt
+Utils/author.txt
.DS_Store
.metadata
.project
@@ -89,4 +89,7 @@ Mage.Server.Plugins/Mage.Draft.8PlayerBooster/target
*.netbeans_automatic_build
*.txt
Mage.Client/serverlist.txt
-/Mage.Network/target/
+/Mage.Network/target/
+/Mage.Server.Tests/target/
+/Mage.Server.Tests/db
+/Mage.Server.Tests/*.log
\ No newline at end of file
diff --git a/Mage.Server.Tests/config/config.xml b/Mage.Server.Tests/config/config.xml
new file mode 100644
index 00000000000..62049a2fc80
--- /dev/null
+++ b/Mage.Server.Tests/config/config.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Mage.Server.Tests/pom.xml b/Mage.Server.Tests/pom.xml
new file mode 100644
index 00000000000..b64139fe199
--- /dev/null
+++ b/Mage.Server.Tests/pom.xml
@@ -0,0 +1,41 @@
+
+
+ 4.0.0
+
+
+ org.mage
+ mage-root
+ 1.4.0
+
+
+ mage-server-tests
+ jar
+ Mage Server Tests
+
+
+
+ junit
+ junit
+ test
+
+
+ ${project.groupId}
+ mage-server
+ ${project.version}
+
+
+ org.jboss
+ jboss-common-core
+
+
+ org.jboss.remoting
+ jboss-remoting
+
+
+ jboss
+ jboss-serialization
+
+
+
+
+
\ No newline at end of file
diff --git a/Mage.Server.Tests/src/test/java/org/mage/server/test/ServerTest.java b/Mage.Server.Tests/src/test/java/org/mage/server/test/ServerTest.java
new file mode 100644
index 00000000000..86660ecb618
--- /dev/null
+++ b/Mage.Server.Tests/src/test/java/org/mage/server/test/ServerTest.java
@@ -0,0 +1,78 @@
+package org.mage.server.test;
+
+import java.util.List;
+import mage.server.ServerMain;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author BetaSteward
+ */
+public class ServerTest {
+
+ private static TestClient client;
+
+ public ServerTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ ServerMain.main(new String[] {"-fastDbMode=true"});
+ }
+ }).start();
+ client = new TestClient();
+ try {
+ Thread.sleep(10000); //wait for server to startup
+ } catch (InterruptedException ex) {
+ }
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void connectTest() {
+ if (!client.isConnected()) {
+ Assert.assertTrue("Connect failed", client.connect());
+ }
+ }
+
+ @Test
+ public void serverMessagesTest() {
+ if (!client.isConnected()) {
+ connectTest();
+ }
+ List serverMessages = client.getServerMessages();
+ Assert.assertEquals("Message count did not match", 3, serverMessages.size());
+ Assert.assertEquals("Message 1 did not match", "This is message #1", serverMessages.get(0));
+ Assert.assertEquals("Message 2 did not match", "And this is message #2", serverMessages.get(1));
+ }
+
+ @Test
+ public void serverStateTest() {
+ if (!client.isConnected()) {
+ connectTest();
+ }
+ Assert.assertNotNull("ServerState was null", client.getServerState());
+ Assert.assertNotNull("MainRoomId was null", client.getMainRoomId());
+ }
+
+
+}
diff --git a/Mage.Server.Tests/src/test/java/org/mage/server/test/TestClient.java b/Mage.Server.Tests/src/test/java/org/mage/server/test/TestClient.java
new file mode 100644
index 00000000000..a7271ad262e
--- /dev/null
+++ b/Mage.Server.Tests/src/test/java/org/mage/server/test/TestClient.java
@@ -0,0 +1,162 @@
+package org.mage.server.test;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import mage.choices.Choice;
+import mage.interfaces.ServerState;
+import mage.remote.Connection;
+import mage.utils.MageVersion;
+import mage.view.AbilityPickerView;
+import mage.view.CardsView;
+import mage.view.ChatMessage;
+import mage.view.GameEndView;
+import mage.view.GameView;
+import mage.view.UserRequestMessage;
+import org.mage.network.Client;
+
+import org.mage.network.interfaces.MageClient;
+import org.mage.network.model.MessageType;
+
+/**
+ *
+ * @author BetaSteward
+ */
+public class TestClient implements MageClient {
+
+ private Client client;
+ private ServerState serverState;
+
+ public TestClient() {
+ client = new Client(this);
+ }
+
+ public boolean connect() {
+ Connection connection = new Connection();
+ connection.setHost("localhost");
+ connection.setPort(17171);
+ connection.setSSL(true);
+ connection.setUsername("test_user");
+ connection.setForceDBComparison(false);
+ return client.connect(connection, MageVersion.getCurrent());
+ }
+
+ public boolean isConnected() {
+ return client.isConnected();
+ }
+
+ @Override
+ public void connected(String message) {
+ }
+
+ @Override
+ public void disconnected(boolean error) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void inform(String title, String message, MessageType type) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void receiveChatMessage(UUID chatId, ChatMessage message) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void receiveBroadcastMessage(String message) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void clientRegistered(ServerState state) {
+ this.serverState = state;
+ }
+
+ @Override
+ public ServerState getServerState() {
+ return serverState;
+ }
+
+ @Override
+ public void joinedTable(UUID roomId, UUID tableId, UUID chatId, boolean owner, boolean tournament) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameStarted(UUID gameId, UUID playerId) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void initGame(UUID gameId, GameView gameView) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameAsk(UUID gameId, GameView gameView, String question) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameTarget(UUID gameId, GameView gameView, String question, CardsView cardView, Set targets, boolean required, Map options) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameChooseAbility(UUID gameId, AbilityPickerView abilities) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameChoosePile(UUID gameId, String message, CardsView pile1, CardsView pile2) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameChooseChoice(UUID gameId, Choice choice) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gamePlayMana(UUID gameId, GameView gameView, String message) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gamePlayXMana(UUID gameId, GameView gameView, String message) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameSelectAmount(UUID gameId, String message, int min, int max) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameSelect(UUID gameId, GameView gameView, String message, Map options) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void gameEndInfo(UUID gameId, GameEndView view) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void userRequestDialog(UUID gameId, UserRequestMessage userRequestMessage) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ public List getServerMessages() {
+ return client.getServerMessages();
+ }
+
+ public UUID getMainRoomId() {
+ return serverState.getMainRoomId();
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 41b2da52c39..d3d6cbda2ae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,7 @@
Mage.Updater
Mage.Stats
Mage.Network
+ Mage.Server.Tests