Search in sources :

Example 11 with Context

use of org.codice.alliance.video.stream.mpegts.Context 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)

Example 12 with Context

use of org.codice.alliance.video.stream.mpegts.Context 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 13 with Context

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

the class UpdateFieldListTest method testEnd.

@Test
public void testEnd() {
    UpdateParent.UpdateField updateField = mock(UpdateParent.UpdateField.class);
    UpdateFieldList updateFieldList = new UpdateFieldList(Collections.singletonList(updateField));
    Metacard parent = mock(Metacard.class);
    Context context = mock(Context.class);
    updateFieldList.end(parent, context);
    verify(updateField).end(parent, context);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) Test(org.junit.Test)

Example 14 with Context

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

the class UpdateFieldListTest method testUpdateField.

@Test
public void testUpdateField() {
    UpdateParent.UpdateField updateField = mock(UpdateParent.UpdateField.class);
    UpdateFieldList updateFieldList = new UpdateFieldList(Collections.singletonList(updateField));
    Metacard parent = mock(Metacard.class);
    List<Metacard> children = mock(List.class);
    Context context = mock(Context.class);
    updateFieldList.updateField(parent, children, context);
    verify(updateField).updateField(parent, children, context);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) Test(org.junit.Test)

Example 15 with Context

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

the class UpdateParentTest method testHandle.

/**
 * Test that #handle calls the UpdateField object
 */
@Test
public void testHandle() {
    UpdateParent.UpdateField updateField = mock(UpdateParent.UpdateField.class);
    UpdateParent updateParent = new UpdateParent(updateField);
    Context context = mock(Context.class);
    Metacard parent = mock(Metacard.class);
    List<Metacard> children = mock(List.class);
    updateParent.handle(context, parent, children);
    verify(updateField).updateField(parent, children, context);
}
Also used : Context(org.codice.alliance.video.stream.mpegts.Context) Metacard(ddf.catalog.data.Metacard) Test(org.junit.Test)

Aggregations

Context (org.codice.alliance.video.stream.mpegts.Context)29 Test (org.junit.Test)24 Metacard (ddf.catalog.data.Metacard)19 UdpStreamProcessor (org.codice.alliance.video.stream.mpegts.netty.UdpStreamProcessor)10 GeometryOperator (org.codice.alliance.libs.klv.GeometryOperator)8 Attribute (ddf.catalog.data.Attribute)7 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)7 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)6 CatalogFramework (ddf.catalog.CatalogFramework)5 Geometry (com.vividsolutions.jts.geom.Geometry)4 WKTReader (com.vividsolutions.jts.io.WKTReader)4 List (java.util.List)3 Timer (java.util.Timer)3 Before (org.junit.Before)3 WKTWriter (com.vividsolutions.jts.io.WKTWriter)2 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