Add missing files
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
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.Packet6Disconnect;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class Packet6DisconnectTest extends PacketTestBase {
|
||||
|
||||
@Mock
|
||||
NetworkHandler handler;
|
||||
|
||||
private static final byte PACKET_ID = 6;
|
||||
private static final String REASON = "reason";
|
||||
private static final int CODE = 1337;
|
||||
|
||||
@Test
|
||||
public void testWrite() throws IOException
|
||||
{
|
||||
Packet6Disconnect packet = new Packet6Disconnect(CODE, REASON);
|
||||
assertEquals(packet.getCode(), CODE);
|
||||
assertEquals(REASON, packet.getReason());
|
||||
packet.sendPacket(output());
|
||||
|
||||
assertEquals(PACKET_ID, input().readByte());
|
||||
assertEquals(CODE, input().readInt());
|
||||
assertEquals(REASON, input().readUTF());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() throws IOException
|
||||
{
|
||||
Packet6Disconnect packet = new Packet6Disconnect();
|
||||
|
||||
output().writeInt(CODE);
|
||||
output().writeUTF(REASON);
|
||||
|
||||
packet.recievePacket(input());
|
||||
|
||||
assertEquals(CODE, packet.getCode());
|
||||
assertEquals(REASON, packet.getReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcess() throws IOException
|
||||
{
|
||||
Packet6Disconnect packet = new Packet6Disconnect(CODE, REASON);
|
||||
packet.processPacket(handler);
|
||||
Mockito.verify(handler, Mockito.times(1)).handlePacket(packet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeCopy()
|
||||
{
|
||||
Packet6Disconnect packet = new Packet6Disconnect();
|
||||
Packet clonedPacket = packet.cloneTypeOnly();
|
||||
assertEquals(packet.getClass(), clonedPacket.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
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.Packet7LogEntry;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class Packet7LogEntryTest extends PacketTestBase {
|
||||
|
||||
@Mock
|
||||
NetworkHandler handler;
|
||||
|
||||
private static final byte PACKET_ID = 7;
|
||||
private static final String LOG_ENTRY = "reason";
|
||||
private static final byte STD_OUTPUT = Packet7LogEntry.STD_ERR;
|
||||
|
||||
@Test
|
||||
public void testWrite() throws IOException
|
||||
{
|
||||
Packet7LogEntry packet = new Packet7LogEntry(STD_OUTPUT, LOG_ENTRY);
|
||||
assertEquals(packet.getStdOutput(), STD_OUTPUT);
|
||||
assertEquals(LOG_ENTRY, packet.getLogEntry());
|
||||
packet.sendPacket(output());
|
||||
|
||||
assertEquals(PACKET_ID, input().readByte());
|
||||
assertEquals(STD_OUTPUT, input().readByte());
|
||||
assertEquals(LOG_ENTRY, input().readUTF());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRead() throws IOException
|
||||
{
|
||||
Packet7LogEntry packet = new Packet7LogEntry();
|
||||
|
||||
output().writeByte(STD_OUTPUT);
|
||||
output().writeUTF(LOG_ENTRY);
|
||||
|
||||
packet.recievePacket(input());
|
||||
|
||||
assertEquals(STD_OUTPUT, packet.getStdOutput());
|
||||
assertEquals(LOG_ENTRY, packet.getLogEntry());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcess() throws IOException
|
||||
{
|
||||
Packet7LogEntry packet = new Packet7LogEntry(STD_OUTPUT, LOG_ENTRY);
|
||||
packet.processPacket(handler);
|
||||
Mockito.verify(handler, Mockito.times(1)).handlePacket(packet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeCopy()
|
||||
{
|
||||
Packet7LogEntry packet = new Packet7LogEntry();
|
||||
Packet clonedPacket = packet.cloneTypeOnly();
|
||||
assertEquals(packet.getClass(), clonedPacket.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user