View Javadoc

1   /***
2    * Jetrix TetriNET Server
3    * Copyright (C) 2005  Emmanuel Bourg
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18   */
19  
20  package net.jetrix.agent;
21  
22  import java.util.List;
23  
24  import junit.framework.TestCase;
25  
26  /***
27   * @author Emmanuel Bourg
28   * @version $Revision: 837 $, $Date: 2010-04-12 00:42:20 +0200 (lun., 12 avr. 2010) $
29   */
30  public class QueryAgentTest extends TestCase
31  {
32      private String hostname = "tetrinet.fr";
33  
34      public void testGetVersion() throws Exception
35      {
36          QueryAgent agent = new QueryAgent();
37          agent.connect(hostname);
38          String version = agent.getVersion();
39          agent.disconnect();
40  
41          assertEquals("version", "1.13.2ice Dual server", version);
42      }
43  
44      public void testGetPlayerNumber() throws Exception
45      {
46          QueryAgent agent = new QueryAgent();
47          agent.connect(hostname);
48          int count = agent.getPlayerNumber();
49          agent.disconnect();
50  
51          assertTrue("player number", count >= 0) ;
52      }
53  
54      public void testGetChannels() throws Exception
55      {
56          QueryAgent agent = new QueryAgent();
57          agent.connect(hostname);
58          List<ChannelInfo> channels = agent.getChannels();
59          agent.disconnect();
60  
61          assertNotNull("null list", channels);
62          assertFalse("list is empty", channels.isEmpty());
63      }
64  
65      public void testGetPlayers() throws Exception
66      {
67          QueryAgent agent = new QueryAgent();
68          agent.connect("tetridome.com");
69          List<PlayerInfo> players = agent.getPlayers();
70          agent.disconnect();
71  
72          assertNotNull("null list", players);
73          assertFalse("list is empty", players.isEmpty());
74      }
75  
76      public void testGetPing() throws Exception
77      {
78          QueryAgent agent = new QueryAgent();
79          agent.connect(hostname);
80          long ping = agent.getPing();
81          agent.disconnect();
82  
83          assertTrue("ping", ping > 0);
84      }
85  }