use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.
the class TraceDataReaderImplTest method readTraceDir_checkExternalVideoAndTime.
@Test
public void readTraceDir_checkExternalVideoAndTime() throws IOException {
String[] time = { "1410212153.578 1410213352.550", "272927100", "1410213352.550" };
String[] appId = {};
traceDataReaderImpl.setFileReader(filereader);
when(filereader.directoryExist(any(String.class))).thenReturn(true);
when(filereader.readAllLine(any(String.class))).thenReturn(time);
when(filereader.readAllLine(any(String.class))).thenReturn(appId);
when(filereader.readAllLine(Util.getCurrentRunningDir() + Util.FILE_SEPARATOR + "exVideo_time")).thenReturn(time);
when(filereader.fileExist(any(String.class))).thenReturn(true);
when(filereader.fileExist(Util.getCurrentRunningDir() + Util.FILE_SEPARATOR + "traffic1.cap")).thenReturn(false);
when(filereader.fileExist(Util.getCurrentRunningDir() + Util.FILE_SEPARATOR + "time")).thenReturn(false);
Map<String, List<ScheduledAlarmInfo>> scheduledAlarms = new HashMap<String, List<ScheduledAlarmInfo>>();
List<AlarmAnalysisInfo> statistics = new ArrayList<AlarmAnalysisInfo>();
AlarmAnalysisResult alarmResult = mock(AlarmAnalysisResult.class);
when(alarmResult.getScheduledAlarms()).thenReturn(scheduledAlarms);
when(alarmResult.getStatistics()).thenReturn(statistics);
when(alarmanalysisinfoparser.parse(any(String.class), any(String.class), any(String.class), any(double.class), any(double.class), any(Date.class))).thenReturn(alarmResult);
Mockito.doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
byte b = 3;
short s = 1;
InetAddress address1 = null;
InetAddress address2 = null;
try {
address2 = InetAddress.getByName("78.46.84.177");
address1 = InetAddress.getByName("78.46.84.171");
} catch (UnknownHostException e) {
e.printStackTrace();
}
Date date1 = new Date();
IPPacket ippack01 = mock(IPPacket.class);
when(ippack01.getIPVersion()).thenReturn(b);
when(ippack01.getFragmentOffset()).thenReturn(s);
when(ippack01.getSourceIPAddress()).thenReturn(address1);
when(ippack01.getDestinationIPAddress()).thenReturn(address2);
when(ippack01.getTimeStamp()).thenReturn((double) date1.getTime());
// pretend jpcap lib
traceDataReaderImpl.packetArrived("com.google.android.youtube", ippack01);
return null;
}
}).when(packetreader).readPacket(any(String.class), any(IPacketListener.class));
AppInfo app = new AppInfo();
Map<String, String> appMap = new HashMap<String, String>();
appMap.put("flipboard.app", "2.3.8");
appMap.put("com.att.android.arodatacollector", "3.1.1.6");
appMap.put("com.google.android.youtube", "4.0.23");
app.setAppVersionMap(appMap);
List<String> appInfos = new ArrayList<String>();
appInfos.add("flipboard.app");
appInfos.add("com.att.android.arodatacollector");
appInfos.add("com.google.android.youtube");
app.setAppInfos(appInfos);
when(appinforeader.readData(any(String.class))).thenReturn(app);
DeviceDetail device = new DeviceDetail();
when(devicedetailreader.readData(any(String.class))).thenReturn(device);
NetworkTypeObject obj = new NetworkTypeObject();
when(networktypereader.readData(any(String.class), any(double.class), any(double.class))).thenReturn(obj);
TraceDirectoryResult result = traceDataReaderImpl.readTraceDirectory(Util.getCurrentRunningDir());
assertSame(0, result.getAppIds().size());
}
Aggregations