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();
}
}
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));
}
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()))));
}
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);
}
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();
}
Aggregations