// Path: Source/test/jReto/util/TestData.java
// public class TestData {
// 	public static ByteBuffer generate(int length) {
// 		ByteBuffer buffer = ByteBuffer.allocate(length);
// 		for (int i=0; i<length; i++) {
// 			buffer.put((byte)(i%127));
// 		}
// 		buffer.rewind();
// 		return buffer;
// 	}
// 	
// 	public static void verify(ByteBuffer buffer, int length) {
// 		int count = buffer.remaining();
// 		if (count != length) throw new IllegalArgumentException("Test data needs to have the correct length");
// 		
// 		for (int i=0; i<count; i++) {
// 			byte value = buffer.get();
// 			
// 			if (value != i%127) throw new IllegalArgumentException("Buffer has incorrect value: "+value+", should be: "+i%127);
// 		}
// 	}
// }
// 
// Path: Source/src/de/tum/in/www1/jReto/connectivity/packet/DataPacket.java
// public class DataPacket implements Packet {
// 	public final static PacketType TYPE = PacketType.DATA_PACKET;
// 	public final static int MINIMUM_LENGTH = Constants.PACKET_TYPE_SIZE;
// 	
// 	public final ByteBuffer data;
// 
// 	public DataPacket(ByteBuffer data) {
// 		this.data = data;
// 	}
// 	
// 	public static DataPacket deserialize(ByteBuffer data) {
// 		DataReader reader = new DataReader(data);
// 		if (!DataChecker.check(reader, TYPE, MINIMUM_LENGTH)) return null;
// 		
// 		return new DataPacket(reader.getRemainingData());
// 	}
// 	public ByteBuffer serialize() {
// 		DataWriter data = new DataWriter(MINIMUM_LENGTH + this.data.remaining());
// 		data.add(TYPE);
// 		data.add(this.data);
// 		return data.getData();
// 	}
// }
// 
// Path: Source/src/de/tum/in/www1/jReto/routing/packets/FloodingPacket.java
// public class FloodingPacket implements Packet {
// 	public final static PacketType TYPE = PacketType.FLOODED_PACKET;
// 	public final static int MINIMUM_LENGTH = Constants.PACKET_TYPE_SIZE + Constants.INT_SIZE + Constants.UUID_SIZE;
// 	
// 	public final UUID originIdentifier;
// 	public final int sequenceNumber;
// 	public final ByteBuffer payload;
// 	
// 	public FloodingPacket(UUID originIdentifier, int sequenceNumber, ByteBuffer payload) {
// 		if (payload.remaining() == 0) {
// 			System.err.println("Warning: Created FloodingPacket with 0 length payload.");
// 		}
// 		
// 		this.originIdentifier = originIdentifier;
// 		this.sequenceNumber = sequenceNumber;
// 		this.payload = payload;
// 	}
// 	
// 	public static FloodingPacket deserialize(ByteBuffer data) {
// 		DataReader reader = new DataReader(data);
// 		if (!DataChecker.check(reader, TYPE, MINIMUM_LENGTH)) return null;
// 		
// 		return new FloodingPacket(reader.getUUID(), reader.getInt(),  reader.getRemainingData());
// 	}
// 	public ByteBuffer serialize() {
// 		this.payload.rewind(); // Maybe someone from outside accessed the buffer and didn't rewind it
// 		DataWriter data = new DataWriter(MINIMUM_LENGTH + this.payload.remaining());
// 		data.add(TYPE);
// 		data.add(this.originIdentifier);
// 		data.add(this.sequenceNumber);
// 		data.add(this.payload);
// 		this.payload.rewind(); // Make sure someone from outside can use the buffer without rewinding first
// 		return data.getData();
// 	}
// }


import static org.junit.Assert.*;
import java.util.UUID;
import jReto.util.TestData;
import org.junit.Test;
import de.tum.in.www1.jReto.connectivity.packet.DataPacket;
import de.tum.in.www1.jReto.routing.packets.FloodingPacket;
package jReto.unit;






public class FloodingPacketTest {

	@Test
	public void test() {
		UUID identifier = UUID.randomUUID();
// Path: Source/test/jReto/util/TestData.java
// public class TestData {
// 	public static ByteBuffer generate(int length) {
// 		ByteBuffer buffer = ByteBuffer.allocate(length);
// 		for (int i=0; i<length; i++) {
// 			buffer.put((byte)(i%127));
// 		}
// 		buffer.rewind();
// 		return buffer;
// 	}
// 	
// 	public static void verify(ByteBuffer buffer, int length) {
// 		int count = buffer.remaining();
// 		if (count != length) throw new IllegalArgumentException("Test data needs to have the correct length");
// 		
// 		for (int i=0; i<count; i++) {
// 			byte value = buffer.get();
// 			
// 			if (value != i%127) throw new IllegalArgumentException("Buffer has incorrect value: "+value+", should be: "+i%127);
// 		}
// 	}
// }
// 
// Path: Source/src/de/tum/in/www1/jReto/connectivity/packet/DataPacket.java
// public class DataPacket implements Packet {
// 	public final static PacketType TYPE = PacketType.DATA_PACKET;
// 	public final static int MINIMUM_LENGTH = Constants.PACKET_TYPE_SIZE;
// 	
// 	public final ByteBuffer data;
// 
// 	public DataPacket(ByteBuffer data) {
// 		this.data = data;
// 	}
// 	
// 	public static DataPacket deserialize(ByteBuffer data) {
// 		DataReader reader = new DataReader(data);
// 		if (!DataChecker.check(reader, TYPE, MINIMUM_LENGTH)) return null;
// 		
// 		return new DataPacket(reader.getRemainingData());
// 	}
// 	public ByteBuffer serialize() {
// 		DataWriter data = new DataWriter(MINIMUM_LENGTH + this.data.remaining());
// 		data.add(TYPE);
// 		data.add(this.data);
// 		return data.getData();
// 	}
// }
// 
// Path: Source/src/de/tum/in/www1/jReto/routing/packets/FloodingPacket.java
// public class FloodingPacket implements Packet {
// 	public final static PacketType TYPE = PacketType.FLOODED_PACKET;
// 	public final static int MINIMUM_LENGTH = Constants.PACKET_TYPE_SIZE + Constants.INT_SIZE + Constants.UUID_SIZE;
// 	
// 	public final UUID originIdentifier;
// 	public final int sequenceNumber;
// 	public final ByteBuffer payload;
// 	
// 	public FloodingPacket(UUID originIdentifier, int sequenceNumber, ByteBuffer payload) {
// 		if (payload.remaining() == 0) {
// 			System.err.println("Warning: Created FloodingPacket with 0 length payload.");
// 		}
// 		
// 		this.originIdentifier = originIdentifier;
// 		this.sequenceNumber = sequenceNumber;
// 		this.payload = payload;
// 	}
// 	
// 	public static FloodingPacket deserialize(ByteBuffer data) {
// 		DataReader reader = new DataReader(data);
// 		if (!DataChecker.check(reader, TYPE, MINIMUM_LENGTH)) return null;
// 		
// 		return new FloodingPacket(reader.getUUID(), reader.getInt(),  reader.getRemainingData());
// 	}
// 	public ByteBuffer serialize() {
// 		this.payload.rewind(); // Maybe someone from outside accessed the buffer and didn't rewind it
// 		DataWriter data = new DataWriter(MINIMUM_LENGTH + this.payload.remaining());
// 		data.add(TYPE);
// 		data.add(this.originIdentifier);
// 		data.add(this.sequenceNumber);
// 		data.add(this.payload);
// 		this.payload.rewind(); // Make sure someone from outside can use the buffer without rewinding first
// 		return data.getData();
// 	}
// }


// Path: Source/test/jReto/unit/FloodingPacketTest.java
import static org.junit.Assert.*;
import java.util.UUID;
import jReto.util.TestData;
import org.junit.Test;
import de.tum.in.www1.jReto.connectivity.packet.DataPacket;
import de.tum.in.www1.jReto.routing.packets.FloodingPacket;

package jReto.unit;






public class FloodingPacketTest {

	@Test
	public void test() {
		UUID identifier = UUID.randomUUID();
		DataPacket packet = new DataPacket(TestData.generate(16));