Search in sources :

Example 11 with HttpRequestResponseInfo

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) {
    }
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) TreeMap(java.util.TreeMap) IOException(java.io.IOException) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 12 with HttpRequestResponseInfo

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();
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Before(org.junit.Before)

Example 13 with 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());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 14 with HttpRequestResponseInfo

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());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Date(java.util.Date) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 15 with HttpRequestResponseInfo

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);
}
Also used : HttpRequestResponseInfoWithSession(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) HttpRequestResponseInfoWithSession(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)108 Session (com.att.aro.core.packetanalysis.pojo.Session)74 ArrayList (java.util.ArrayList)62 BaseTest (com.att.aro.core.BaseTest)40 Test (org.junit.Test)40 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)29 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)14 IOException (java.io.IOException)10 HashMap (java.util.HashMap)10 TreeMap (java.util.TreeMap)10 File (java.io.File)9 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)5 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)5 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)5 URISyntaxException (java.net.URISyntaxException)5 List (java.util.List)5 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InetAddress (java.net.InetAddress)4