use of net.glowstone.net.query.QueryHandler in project Glowstone by GlowstoneMC.
the class QueryTest method testBasicStats.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testBasicStats() throws Exception {
World world = mock(World.class);
when(world.getName()).thenReturn("world");
when(glowServer.getMotd()).thenReturn("A Minecraft Server");
when(glowServer.getOnlinePlayers()).thenReturn((List) Arrays.asList(new Object(), new Object()));
when(glowServer.getMaxPlayers()).thenReturn(20);
when(glowServer.getPort()).thenReturn(25565);
when(glowServer.getWorlds()).thenReturn(Arrays.asList(world));
when(glowServer.getIp()).thenReturn("");
QueryHandler handler = new QueryHandler(server, queryPlugins);
when(random.nextInt()).thenReturn(9513307);
server.generateChallengeToken(address);
testChannelRead(handler, BASIC_STATS_RECV, BASIC_STATS_SEND);
}
use of net.glowstone.net.query.QueryHandler in project Glowstone by GlowstoneMC.
the class QueryTest method testFullStats.
@Test
public void testFullStats() throws Exception {
World world = mock(World.class);
when(world.getName()).thenReturn("world");
GlowPlayer p1 = mock(GlowPlayer.class);
GlowPlayer p2 = mock(GlowPlayer.class);
when(p1.getName()).thenReturn("barneygale");
when(p2.getName()).thenReturn("Vivalahelvig");
PluginManager pluginManager = mock(PluginManager.class);
when(glowServer.getMotd()).thenReturn("A Minecraft Server");
Mockito.doReturn(Arrays.asList(p1, p2)).when(glowServer).getOnlinePlayers();
when(glowServer.getMaxPlayers()).thenReturn(20);
when(glowServer.getPort()).thenReturn(25565);
when(glowServer.getWorlds()).thenReturn(Arrays.asList(world));
when(glowServer.getIp()).thenReturn("");
when(glowServer.getVersion()).thenReturn("123");
when(glowServer.getBukkitVersion()).thenReturn("xyz");
when(glowServer.getPluginManager()).thenReturn(pluginManager);
when(pluginManager.getPlugins()).thenReturn(new Plugin[0]);
QueryHandler handler = new QueryHandler(server, queryPlugins);
when(random.nextInt()).thenReturn(9513307);
server.generateChallengeToken(address);
testChannelRead(handler, FULL_STATS_RECV, FULL_STATS_SEND);
}
use of net.glowstone.net.query.QueryHandler in project Glowstone by GlowstoneMC.
the class QueryTest method testHandshake.
@Test
public void testHandshake() throws Exception {
QueryHandler handler = new QueryHandler(server, queryPlugins);
when(random.nextInt()).thenReturn(9513307);
testChannelRead(handler, HANDSHAKE_RECV, HANDSHAKE_SEND);
}
Aggregations