Search in sources :

Example 6 with UdpStreamProcessor

use of org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor in project alliance by codice.

the class TimerTaskStreamCreationPluginTest method testOnCreate.

/**
 * Use a real Timer instead of a mock timer to make sure the timer task is scheduled correctly and
 * calls the checkRollover method.
 *
 * @throws StreamCreationException
 * @throws InterruptedException
 */
@Test
public void testOnCreate() throws StreamCreationException, InterruptedException {
    long period = 100;
    Timer timer = new Timer();
    try {
        Context context = mock(Context.class);
        UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
        when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
        when(udpStreamProcessor.getTimer()).thenReturn(timer);
        TimerTaskStreamCreationPlugin timerTaskStreamCreationPlugin = new TimerTaskStreamCreationPlugin(period);
        timerTaskStreamCreationPlugin.onCreate(context);
        verify(udpStreamProcessor, after((int) period * 2).atLeastOnce()).checkForRollover();
    } finally {
        timer.cancel();
    }
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Timer(java.util.Timer) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Test(org.junit.Test)

Example 7 with UdpStreamProcessor

use of org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor in project alliance by codice.

the class UpdateParentTest method testEnd.

/**
 * Test that #end calls the catalog framework
 */
@Test
public void testEnd() throws SourceUnavailableException, IngestException {
    UpdateParent.UpdateField updateField = mock(UpdateParent.UpdateField.class);
    UpdateParent updateParent = new UpdateParent(updateField);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    CatalogFramework catalogFramework = mock(CatalogFramework.class);
    when(udpStreamProcessor.getCatalogFramework()).thenReturn(catalogFramework);
    when(udpStreamProcessor.getMetacardUpdateInitialDelay()).thenReturn(1L);
    Context context = mock(Context.class);
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    Metacard parent = mock(Metacard.class);
    UpdateResponse updateResponse = mock(UpdateResponse.class);
    Update update = mock(Update.class);
    when(update.getNewMetacard()).thenReturn(parent);
    when(updateResponse.getUpdatedMetacards()).thenReturn(Collections.singletonList(update));
    when(catalogFramework.update(any(UpdateRequest.class))).thenReturn(updateResponse);
    updateParent.end(context, parent);
    verify(updateField).end(parent, context);
    ArgumentCaptor<UpdateRequest> captor = ArgumentCaptor.forClass(UpdateRequest.class);
    verify(catalogFramework).update(captor.capture());
    assertThat(captor.getValue().getUpdates().get(0).getValue(), is(parent));
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) UpdateResponse(ddf.catalog.operation.UpdateResponse) Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) CatalogFramework(ddf.catalog.CatalogFramework) Update(ddf.catalog.operation.Update) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Test(org.junit.Test)

Example 8 with UdpStreamProcessor

use of org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor in project alliance by codice.

the class RolloverStreamCreationPlugin method doOnCreate.

@Override
protected void doOnCreate(Context context) throws StreamCreationException {
    UdpStreamProcessor udpStreamProcessor = context.getUdpStreamProcessor();
    udpStreamProcessor.setRolloverAction(new ListRolloverAction(Arrays.asList(new CreateMetacardRolloverAction(udpStreamProcessor.getMetacardTypeList()), new CatalogRolloverAction(udpStreamProcessor.getFilenameGenerator(), udpStreamProcessor.getFilenameTemplate(), udpStreamProcessor.getCatalogFramework(), context, udpStreamProcessor.getParentMetacardUpdater(), udpStreamProcessor.getUuidGenerator()))));
}
Also used : CatalogRolloverAction(org.codice.alliance.video.stream.mpegts.rollover.CatalogRolloverAction) CreateMetacardRolloverAction(org.codice.alliance.video.stream.mpegts.rollover.CreateMetacardRolloverAction) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) ListRolloverAction(org.codice.alliance.video.stream.mpegts.rollover.ListRolloverAction)

Example 9 with UdpStreamProcessor

use of org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor in project alliance by codice.

the class ParentMetacardStreamCreationPluginTest method setup.

@Before
public void setup() throws SourceUnavailableException, IngestException {
    context = mock(Context.class);
    uri = URI.create("udp://127.0.0.1:10000");
    title = "theTitleString";
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    when(udpStreamProcessor.getStreamUri()).thenReturn(Optional.of(uri));
    when(udpStreamProcessor.getTitle()).thenReturn(Optional.of(title));
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    Security security = mock(Security.class);
    Subject subject = mock(Subject.class);
    when(security.getSystemSubject()).thenReturn(subject);
    catalogFramework = mock(CatalogFramework.class);
    parentMetacardStreamCreationPlugin = new ParentMetacardStreamCreationPlugin(catalogFramework, Collections.singletonList(mock(MetacardType.class)));
    CreateResponse createResponse = mock(CreateResponse.class);
    Metacard createdParentMetacard = mock(Metacard.class);
    context.setParentMetacard(createdParentMetacard);
    when(createResponse.getCreatedMetacards()).thenReturn(Collections.singletonList(createdParentMetacard));
    when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequest(ddf.catalog.operation.CreateRequest) CatalogFramework(ddf.catalog.CatalogFramework) Security(org.codice.ddf.security.common.Security) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Subject(ddf.security.Subject) MetacardType(ddf.catalog.data.MetacardType) Before(org.junit.Before)

Example 10 with UdpStreamProcessor

use of org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor in project alliance by codice.

the class ResetPacketBufferStreamShutdownPluginTest method testOnShutdown.

@Test
public void testOnShutdown() throws StreamShutdownException {
    PacketBuffer packetBuffer = mock(PacketBuffer.class);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    Context context = mock(Context.class);
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    when(udpStreamProcessor.getPacketBuffer()).thenReturn(packetBuffer);
    ResetPacketBufferStreamShutdownPlugin resetPacketBufferStreamShutdownPlugin = new ResetPacketBufferStreamShutdownPlugin();
    resetPacketBufferStreamShutdownPlugin.onShutdown(context);
    verify(packetBuffer).reset();
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) PacketBuffer(org.codice.alliance.video.stream.mpegts.netty.PacketBuffer) Test(org.junit.Test)

Aggregations

UdpStreamProcessor (org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor)11 Context (org.codice.alliance.video.stream.mpegts.Context)10 Test (org.junit.Test)7 CatalogFramework (ddf.catalog.CatalogFramework)5 Metacard (ddf.catalog.data.Metacard)4 Timer (java.util.Timer)3 Before (org.junit.Before)3 MetacardType (ddf.catalog.data.MetacardType)2 CreateRequest (ddf.catalog.operation.CreateRequest)2 CreateResponse (ddf.catalog.operation.CreateResponse)2 Update (ddf.catalog.operation.Update)2 UpdateResponse (ddf.catalog.operation.UpdateResponse)2 Subject (ddf.security.Subject)2 File (java.io.File)2 FilenameGenerator (org.codice.alliance.video.stream.mpegts.filename.FilenameGenerator)2 PacketBuffer (org.codice.alliance.video.stream.mpegts.netty.PacketBuffer)2 UuidGenerator (org.codice.ddf.platform.util.uuidgenerator.UuidGenerator)2 Security (org.codice.ddf.security.common.Security)2 CreateStorageRequest (ddf.catalog.content.operation.CreateStorageRequest)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1