Search in sources :

Example 1 with UdpStreamProcessor

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

the class FindChildrenStreamEndPluginTest method setup.

@Before
public void setup() throws UnsupportedQueryException, SourceUnavailableException, FederationException {
    catalogFramework = mock(CatalogFramework.class);
    parentMetacard = mock(Metacard.class);
    metacard1 = mock(Metacard.class);
    metacard2 = mock(Metacard.class);
    Result result1 = mock(Result.class);
    when(result1.getMetacard()).thenReturn(metacard1);
    Result result2 = mock(Result.class);
    when(result2.getMetacard()).thenReturn(metacard2);
    queryResponse1 = mock(QueryResponse.class);
    when(queryResponse1.getHits()).thenReturn(2L);
    when(queryResponse1.getResults()).thenReturn(Collections.singletonList(result1));
    queryResponse2 = mock(QueryResponse.class);
    when(queryResponse2.getHits()).thenReturn(2L);
    when(queryResponse2.getResults()).thenReturn(Collections.singletonList(result2));
    when(catalogFramework.query(any())).thenReturn(queryResponse1, queryResponse2);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    when(udpStreamProcessor.getCatalogFramework()).thenReturn(catalogFramework);
    context = new Context(udpStreamProcessor);
    context.setParentMetacard(parentMetacard);
    handler = mock(FindChildrenStreamEndPlugin.Handler.class);
    FindChildrenStreamEndPlugin.Factory factory = mock(FindChildrenStreamEndPlugin.Factory.class);
    when(factory.build()).thenReturn(handler);
    findChildrenStreamEndPlugin = new FindChildrenStreamEndPlugin(new GeotoolsFilterBuilder(), factory);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) QueryResponse(ddf.catalog.operation.QueryResponse) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) CatalogFramework(ddf.catalog.CatalogFramework) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Result(ddf.catalog.data.Result) Before(org.junit.Before)

Example 2 with UdpStreamProcessor

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

the class FlushPacketBufferStreamShutdownPluginTest method testOnShutdown.

@Test
public void testOnShutdown() throws StreamShutdownException, IOException {
    Context context = mock(Context.class);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    PacketBuffer packetBuffer = mock(PacketBuffer.class);
    File file = mock(File.class);
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    when(udpStreamProcessor.getPacketBuffer()).thenReturn(packetBuffer);
    when(packetBuffer.flushAndRotate()).thenReturn(new RotateResult(file, false));
    FlushPacketBufferStreamShutdownPlugin flushPacketBufferStreamShutdownPlugin = new FlushPacketBufferStreamShutdownPlugin();
    flushPacketBufferStreamShutdownPlugin.onShutdown(context);
    verify(udpStreamProcessor).doRollover(file);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) File(java.io.File) PacketBuffer(org.codice.alliance.video.stream.mpegts.netty.PacketBuffer) RotateResult(org.codice.alliance.video.stream.mpegts.netty.RotateResult) Test(org.junit.Test)

Example 3 with UdpStreamProcessor

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

the class RolloverStreamCreationPluginTest method testOnCreate.

@Test
public void testOnCreate() throws StreamCreationException {
    Context context = mock(Context.class);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    when(udpStreamProcessor.getFilenameGenerator()).thenReturn(mock(FilenameGenerator.class));
    when(udpStreamProcessor.getFilenameTemplate()).thenReturn("template");
    when(udpStreamProcessor.getCatalogFramework()).thenReturn(mock(CatalogFramework.class));
    when(udpStreamProcessor.getParentMetacardUpdater()).thenReturn(mock(MetacardUpdater.class));
    UuidGenerator uuidGenerator = mock(UuidGenerator.class);
    when(uuidGenerator.generateUuid()).thenReturn("anId");
    when(udpStreamProcessor.getUuidGenerator()).thenReturn(uuidGenerator);
    RolloverStreamCreationPlugin rolloverStreamCreationPlugin = new RolloverStreamCreationPlugin();
    rolloverStreamCreationPlugin.onCreate(context);
    verify(udpStreamProcessor).setRolloverAction(any());
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) MetacardUpdater(org.codice.alliance.video.stream.mpegts.metacard.MetacardUpdater) FilenameGenerator(org.codice.alliance.video.stream.mpegts.filename.FilenameGenerator) CatalogFramework(ddf.catalog.CatalogFramework) UdpStreamProcessor(org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor) Test(org.junit.Test)

Example 4 with UdpStreamProcessor

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

the class TimerStreamCreationPluginTest method testOnCreate.

@Test
public void testOnCreate() throws StreamCreationException {
    Context context = mock(Context.class);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    Supplier<Timer> timerSupplier = mock(Supplier.class);
    Timer timer = mock(Timer.class);
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    when(timerSupplier.get()).thenReturn(timer);
    TimerStreamCreationPlugin timerStreamCreationPlugin = new TimerStreamCreationPlugin(timerSupplier);
    timerStreamCreationPlugin.onCreate(context);
    verify(udpStreamProcessor).setTimer(timer);
}
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 5 with UdpStreamProcessor

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

the class TimerStreamShutdownPluginTest method testOnShutdown.

@Test
public void testOnShutdown() throws StreamShutdownException {
    Context context = mock(Context.class);
    UdpStreamProcessor udpStreamProcessor = mock(UdpStreamProcessor.class);
    Timer timer = mock(Timer.class);
    when(context.getUdpStreamProcessor()).thenReturn(udpStreamProcessor);
    when(udpStreamProcessor.getTimer()).thenReturn(timer);
    TimerStreamShutdownPlugin timerStreamShutdownPlugin = new TimerStreamShutdownPlugin();
    timerStreamShutdownPlugin.onShutdown(context);
    verify(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)

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