Search in sources :

Example 71 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class ImageCompressionImpl method getEntryList.

private List<ImageCompressionEntry> getEntryList() {
    String originalImage = "";
    String midCompressedImagePath = "";
    String logCompressedImagepath = "";
    long lowQualityImgSize = 0L;
    long midQualityImgSize = 0L;
    long orgImageSize = 0L;
    String imgExtn = "";
    List<ImageCompressionEntry> entryList = new ArrayList<ImageCompressionEntry>();
    for (Session session : packetResult.getSessionlist()) {
        for (HttpRequestResponseInfo reqResp : session.getRequestResponseInfo()) {
            if (reqResp.getDirection() == HttpDirection.RESPONSE && reqResp.getContentType() != null && reqResp.getContentType().contains("image/")) {
                originalImage = ImageHelper.extractFullNameFromRRInfo(reqResp);
                if ((!originalImage.isEmpty() && !(originalImage.contains(".jpeg") || originalImage.contains(".jpg"))) && reqResp.getContentType().contains("jpeg")) {
                    originalImage = Util.parseImageName(originalImage, reqResp);
                }
                int pos = originalImage.lastIndexOf(".");
                if (pos != -1) {
                    imgExtn = originalImage.substring(pos + 1, originalImage.length());
                    if (Util.isJPG(new File(imageFolderPath + originalImage), imgExtn)) {
                        midCompressedImagePath = imageCompressionFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".")) + Quality.MID.getFileDesc() + originalImage.substring(originalImage.lastIndexOf("."), originalImage.length());
                        logCompressedImagepath = imageCompressionFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".")) + Quality.LOW.getFileDesc() + originalImage.substring(originalImage.lastIndexOf("."), originalImage.length());
                        orgImageSize = new File(imageFolderPath + originalImage).length();
                        midQualityImgSize = new File(midCompressedImagePath).length();
                        lowQualityImgSize = new File(logCompressedImagepath).length();
                        if (midQualityImgSize > 0 && ((orgImageSize - midQualityImgSize) * 100 / orgImageSize >= 15) && lowQualityImgSize < orgImageSize) {
                            orginalImagesSize = orginalImagesSize + orgImageSize;
                            midQualImgsSize = midQualImgsSize + midQualityImgSize;
                            entryList.add(new ImageCompressionEntry(reqResp, session.getDomainName(), imageFolderPath + originalImage, Util.doubleFileSize(orgImageSize), Util.doubleFileSize(midQualityImgSize), Util.doubleFileSize(lowQualityImgSize)));
                        }
                    }
                }
            }
        }
    }
    return entryList;
}
Also used : ImageCompressionEntry(com.att.aro.core.bestpractice.pojo.ImageCompressionEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 72 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class SimultnsUtil method getTimeMap.

public MultipleConnectionsEntry getTimeMap(List<SessionValues> tMap, int maxCount, boolean isManyServer) {
    String ipInside = "";
    String domainVal = "";
    TreeMap<Double, Double> timeMap = new TreeMap<Double, Double>();
    TreeMap<Double, HttpRequestResponseInfo> reqRespTimeMap = new TreeMap<Double, HttpRequestResponseInfo>();
    int iterator = 0;
    double sessionStartTime = 0.0;
    double sessionEndTime = 0.0;
    double[] start = new double[tMap.size()];
    double[] end = new double[tMap.size()];
    for (SessionValues indSessionVal : tMap) {
        sessionStartTime = indSessionVal.getStartTime();
        sessionEndTime = indSessionVal.getEndTime();
        timeMap.put(sessionStartTime, sessionEndTime);
        start[iterator] = sessionStartTime;
        end[iterator] = sessionEndTime;
        ipInside = indSessionVal.getIp().substring(indSessionVal.getIp().lastIndexOf('/') + 1, indSessionVal.getIp().length());
        ipMap.put(sessionStartTime, ipInside);
        if (indSessionVal.getReqRespInfo() != null) {
            HttpRequestResponseInfo reqResponseSessionData = indSessionVal.getReqRespInfo();
            if (reqResponseSessionData.getHostName() != null) {
                domainVal = reqResponseSessionData.getHostName();
            } else {
                domainVal = ipInside;
            }
            reqRespTimeMap.put(sessionStartTime, reqResponseSessionData);
        } else {
            reqRespTimeMap.put(sessionStartTime, new HttpRequestResponseInfo());
        }
        iterator++;
    }
    return maxOverlapIntervalCount(domainVal, start, end, maxCount, timeMap, isManyServer, reqRespTimeMap, ipInside);
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) TreeMap(java.util.TreeMap) SessionValues(com.att.aro.core.packetanalysis.pojo.SessionValues)

Example 73 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class EmptyUrlImplTest 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(1);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(reqhelper.isHtml(any(String.class))).thenReturn(true);
    try {
        Mockito.when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenReturn(htmlString);
    } catch (Exception e) {
        e.printStackTrace();
    }
    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);
    emptyUrlImpl.setHttpReqResHelper(reqhelper);
    AbstractBestPracticeResult testResult = emptyUrlImpl.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 74 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class Http10UsageImplTest method runTest_resTypeIsFail.

@Test
public void runTest_resTypeIsFail() {
    Mockito.when(httpRequestInfo01.getVersion()).thenReturn(HttpRequestResponseInfo.HTTP10);
    Mockito.when(httpRequestInfo02.getVersion()).thenReturn(HttpRequestResponseInfo.HTTP10);
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
    List<Session> sessionList = new ArrayList<Session>();
    sessionList.add(session01);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
    httpUsageImpl = (Http10UsageImpl) context.getBean("http10Usage");
    AbstractBestPracticeResult result = httpUsageImpl.runTest(tracedata);
    assertEquals(BPResultType.WARNING, result.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 75 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.

the class Http4xx5xxImplTest method runTest_resTypeIsFail.

@Test
public void runTest_resTypeIsFail() {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getScheme()).thenReturn(HttpRequestResponseInfo.HTTP_SCHEME);
    Mockito.when(httpRequestInfo01.getStatusCode()).thenReturn(404);
    Mockito.when(httpRequestInfo01.getObjName()).thenReturn("");
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo02.getObjName()).thenReturn("");
    Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo03.getScheme()).thenReturn(HttpRequestResponseInfo.HTTP_SCHEME);
    Mockito.when(httpRequestInfo03.getStatusCode()).thenReturn(505);
    Mockito.when(httpRequestInfo03.getObjName()).thenReturn("");
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo04.getObjName()).thenReturn("");
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    value.add(httpRequestInfo03);
    value.add(httpRequestInfo04);
    value.add(httpRequestInfo03);
    Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
    Mockito.when(session01.getDomainName()).thenReturn("www.google.com");
    List<Session> sessionList = new ArrayList<Session>();
    sessionList.add(session01);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
    http4xx5xxImpl = (Http4xx5xxImpl) context.getBean("http4xx5xx");
    AbstractBestPracticeResult result = http4xx5xxImpl.runTest(tracedata);
    assertEquals(BPResultType.FAIL, result.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)

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