57 lines
1.3 KiB
Java
57 lines
1.3 KiB
Java
package com.flaremicro.crossjeeves.net.packet.test;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import java.io.IOException;
|
|
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.mockito.Mock;
|
|
import org.mockito.Mockito;
|
|
import org.mockito.junit.MockitoJUnitRunner;
|
|
|
|
import com.flaremicro.crossjeeves.net.NetworkHandler;
|
|
import com.flaremicro.crossjeeves.net.packet.Packet;
|
|
import com.flaremicro.crossjeeves.net.packet.Packet127KeepAlive;
|
|
|
|
@RunWith(MockitoJUnitRunner.class)
|
|
public class Packet127KeepAliveTest extends PacketTestBase {
|
|
|
|
@Mock
|
|
NetworkHandler handler;
|
|
|
|
@Test
|
|
public void testWrite() throws IOException
|
|
{
|
|
Packet127KeepAlive packet = new Packet127KeepAlive();
|
|
|
|
packet.sendPacket(output());
|
|
|
|
assertEquals(127, input().readByte());
|
|
}
|
|
|
|
@Test
|
|
public void testRead() throws IOException
|
|
{
|
|
Packet127KeepAlive packet = new Packet127KeepAlive();
|
|
packet.recievePacket(input());
|
|
}
|
|
|
|
@Test
|
|
public void testProcess() throws IOException
|
|
{
|
|
Packet127KeepAlive packet = new Packet127KeepAlive();
|
|
packet.processPacket(handler);
|
|
Mockito.verify(handler, Mockito.times(1)).handlePacket(packet);
|
|
}
|
|
|
|
@Test
|
|
public void testTypeCopy()
|
|
{
|
|
Packet127KeepAlive packet = new Packet127KeepAlive();
|
|
Packet clonedPacket = packet.cloneTypeOnly();
|
|
assertEquals(packet.getClass(), clonedPacket.getClass());
|
|
}
|
|
|
|
}
|