Search in sources :

Example 1 with RolloverCondition

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()));
}
Also used : RolloverCondition(org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition) File(java.io.File) Test(org.junit.Test)

Example 2 with RolloverCondition

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);
}
Also used : RolloverCondition(org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition) Test(org.junit.Test)

Example 3 with 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 }));
}
Also used : RolloverCondition(org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition) File(java.io.File) Test(org.junit.Test)

Example 4 with RolloverCondition

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();
}
Also used : TempFileGenerator(org.codice.alliance.video.stream.mpegts.filename.TempFileGenerator) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RolloverCondition(org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition) File(java.io.File) Before(org.junit.Before)

Example 5 with RolloverCondition

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));
}
Also used : RolloverCondition(org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition) File(java.io.File) Test(org.junit.Test)

Aggregations

RolloverCondition (org.codice.alliance.video.stream.mpegts.rollover.RolloverCondition)7 Test (org.junit.Test)6 File (java.io.File)4 StreamMonitor (org.codice.alliance.video.stream.mpegts.StreamMonitor)2 CatalogFramework (ddf.catalog.CatalogFramework)1 MetacardType (ddf.catalog.data.MetacardType)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 SimpleSubject (org.codice.alliance.video.stream.mpegts.SimpleSubject)1 FilenameGenerator (org.codice.alliance.video.stream.mpegts.filename.FilenameGenerator)1 TempFileGenerator (org.codice.alliance.video.stream.mpegts.filename.TempFileGenerator)1 MetacardUpdater (org.codice.alliance.video.stream.mpegts.metacard.MetacardUpdater)1 StreamEndPlugin (org.codice.alliance.video.stream.mpegts.plugins.StreamEndPlugin)1 StreamShutdownPlugin (org.codice.alliance.video.stream.mpegts.plugins.StreamShutdownPlugin)1 RolloverAction (org.codice.alliance.video.stream.mpegts.rollover.RolloverAction)1 Before (org.junit.Before)1