use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class HttpRequestResponseHelperImplTest method getContent.
@Test
public void getContent() {
Session session = null;
session = mock(Session.class);
HttpRequestResponseInfo req = null;
req = mock(HttpRequestResponseInfo.class);
String stringData = "this was compressed";
byte[] data = stringData.getBytes();
byte[] gzipped_data = null;
try {
ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(data.length / 2);
GZIPOutputStream gzipOutput = new GZIPOutputStream(byteOutput);
gzipOutput.write(data);
gzipOutput.close();
gzipped_data = byteOutput.toByteArray();
} catch (IOException e1) {
e1.printStackTrace();
}
SortedMap<Integer, Integer> contentOffsetTreeMap = new TreeMap<Integer, Integer>();
contentOffsetTreeMap.put(0, gzipped_data == null ? 0 : gzipped_data.length);
Mockito.when(req.getContentEncoding()).thenReturn("gzip");
Mockito.when(req.getContentOffsetLength()).thenReturn(contentOffsetTreeMap);
Mockito.when(req.getPacketDirection()).thenReturn(PacketDirection.DOWNLINK);
Mockito.when(session.getStorageDl()).thenReturn(gzipped_data);
Mockito.when(session.getStorageUl()).thenReturn(gzipped_data);
try {
assertEquals(stringData, httpRequestResponseHelper.getContentString(req, session));
Mockito.when(session.getStorageDl()).thenReturn(data);
} catch (Exception e) {
assertEquals(null, e.getMessage());
}
// bad gzip data
assertNotNull(gzipped_data);
gzipped_data[20] = 42;
Mockito.when(session.getStorageDl()).thenReturn(gzipped_data);
Mockito.when(session.getStorageUl()).thenReturn(gzipped_data);
try {
String thisWasFromCorruptedZip = httpRequestResponseHelper.getContentString(req, session);
assertEquals("this was bwmpressed", thisWasFromCorruptedZip);
} catch (Exception e) {
}
}
use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class ParseHeaderLineTest method setUp.
@Before
public void setUp() {
parser = (ParseHeaderLineImpl) context.getBean(IParseHeaderLine.class);
MockitoAnnotations.initMocks(this);
rrInfo = new HttpRequestResponseInfo();
}
use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class SpriteImageImplTest method runTest_resIsPass.
@Test
public void runTest_resIsPass() {
Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo01.getContentType()).thenReturn("abc");
Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(6145);
Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
value.add(httpRequestInfo01);
value.add(httpRequestInfo02);
value.add(httpRequestInfo03);
value.add(httpRequestInfo04);
Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
List<Session> sessionList = new ArrayList<Session>();
Mockito.when(session01.getDomainName()).thenReturn("www.google.com");
sessionList.add(session01);
Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
AbstractBestPracticeResult testResult = spriteImageImpl.runTest(tracedata);
assertEquals(BPResultType.PASS, testResult.getResultType());
}
use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class SpriteImageImplTest method runTest_resIsFail.
@Test
public void runTest_resIsFail() {
Date date = new Date();
Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo01.getFirstDataPacket()).thenReturn(pktInfo01);
Mockito.when(httpRequestInfo01.getContentType()).thenReturn("image/");
Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(1);
Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
Mockito.when(httpRequestInfo02.getContentType()).thenReturn(null);
Mockito.when(httpRequestInfo02.getContentLength()).thenReturn(0);
Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo03.getFirstDataPacket()).thenReturn(pktInfo02);
Mockito.when(httpRequestInfo03.getContentType()).thenReturn("image/");
Mockito.when(httpRequestInfo03.getContentLength()).thenReturn(2);
Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo04.getFirstDataPacket()).thenReturn(pktInfo01);
Mockito.when(httpRequestInfo04.getContentType()).thenReturn("image/");
Mockito.when(httpRequestInfo04.getContentLength()).thenReturn(3);
Mockito.when(pktInfo01.getTimeStamp()).thenReturn((date.getTime()) / 1000 + 0.0);
Mockito.when(pktInfo02.getTimeStamp()).thenReturn((date.getTime() / 1000) + 1.0);
List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
value.add(httpRequestInfo01);
value.add(httpRequestInfo02);
value.add(httpRequestInfo03);
value.add(httpRequestInfo04);
Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
List<Session> sessionList = new ArrayList<Session>();
Mockito.when(session01.getDomainName()).thenReturn("www.google.com");
sessionList.add(session01);
Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
AbstractBestPracticeResult testResult = spriteImageImpl.runTest(tracedata);
assertEquals(BPResultType.FAIL, testResult.getResultType());
}
use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class DiagnosticsTab method buildHttpRequestResponseWithSession.
/**
* TODO: This belongs in core! As a matter of fact, it's mostly copied and
* pasted from internal code in CacheAnalysisImpl
*
* @param sessions
* @return
*/
private List<HttpRequestResponseInfoWithSession> buildHttpRequestResponseWithSession(List<Session> sessions) {
List<HttpRequestResponseInfoWithSession> returnList = new ArrayList<HttpRequestResponseInfoWithSession>();
for (Session session : sessions) {
if (!session.isUdpOnly()) {
for (HttpRequestResponseInfo item : session.getRequestResponseInfo()) {
HttpRequestResponseInfoWithSession itemsession = new HttpRequestResponseInfoWithSession();
itemsession.setInfo(item);
itemsession.setSession(session);
returnList.add(itemsession);
}
}
}
Collections.sort(returnList);
return Collections.unmodifiableList(returnList);
}
Aggregations