Search in sources :

Example 1 with QueryHandler

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);
}
Also used : QueryHandler(net.glowstone.net.query.QueryHandler) World(org.bukkit.World) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with QueryHandler

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);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) QueryHandler(net.glowstone.net.query.QueryHandler) GlowPlayer(net.glowstone.entity.GlowPlayer) World(org.bukkit.World) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with QueryHandler

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);
}
Also used : QueryHandler(net.glowstone.net.query.QueryHandler) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

QueryHandler (net.glowstone.net.query.QueryHandler)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 World (org.bukkit.World)2 GlowPlayer (net.glowstone.entity.GlowPlayer)1 PluginManager (org.bukkit.plugin.PluginManager)1