use of org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition in project alliance by codice.
the class PacketBufferTest method testRotate1.
/**
* Test that the packet buffer does not rotate when the rollover condition is false.
*/
@Test
public void testRotate1() {
completeVideoSequence(new byte[] { 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03 });
RolloverCondition rc = mock(RolloverCondition.class);
when(rc.isRolloverReady(any())).thenReturn(false);
Optional<File> file = packetBuffer.rotate(rc).getFile();
assertThat(file, is(Optional.empty()));
}
use of org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition in project alliance by codice.
the class UdpStreamMonitorTest method testSetRolloverCondition.
@Test
public void testSetRolloverCondition() {
RolloverCondition rolloverCondition = mock(RolloverCondition.class);
udpStreamMonitor.setRolloverCondition(rolloverCondition);
verify(udpStreamProcessor).setRolloverCondition(rolloverCondition);
}
use of org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition in project alliance by codice.
the class PacketBufferTest method testActivityTimeout.
/**
* With the sleep, the last three packets gets flushed.
*
* @throws InterruptedException
*/
@Test
public void testActivityTimeout() throws InterruptedException {
packetBuffer.setOutputStreamFactory((file, append) -> os);
completeVideoSequence(new byte[] { 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03 });
RolloverCondition rc = mock(RolloverCondition.class);
when(rc.isRolloverReady(any())).thenReturn(true);
Thread.sleep(PacketBuffer.ACTIVITY_TIMEOUT);
Optional<File> file = packetBuffer.rotate(rc).getFile();
assertThat(file.isPresent(), is(true));
assertThat(os.toByteArray(), is(new byte[] { 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03 }));
}
use of org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition in project alliance by codice.
the class PacketBufferTest method setup.
@Before
public void setup() throws IOException {
TempFileGenerator tempFileGenerator = mock(TempFileGenerator.class);
when(tempFileGenerator.generate()).thenReturn(new File("x"));
packetBuffer = new PacketBuffer();
outputStream = mock(OutputStream.class);
packetBuffer.setOutputStreamFactory((file, append) -> outputStream);
packetBuffer.setTempFileGenerator(tempFileGenerator);
rolloverCondition = mock(RolloverCondition.class);
when(rolloverCondition.isRolloverReady(any())).thenReturn(true);
tempFile = null;
os = new ByteArrayOutputStream();
}
use of org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition in project alliance by codice.
the class PacketBufferTest method testRotate2.
/**
* Test that the packet buffer does rotate when the condition is true.
*/
@Test
public void testRotate2() {
completeVideoSequence(new byte[] { 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03 });
RolloverCondition rc = mock(RolloverCondition.class);
when(rc.isRolloverReady(any())).thenReturn(true);
Optional<File> file = packetBuffer.rotate(rc).getFile();
assertThat(file.isPresent(), is(true));
}
Aggregations