Search in sources :

Example 61 with HttpRequestResponseInfo

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

the class CombineCsJssImplTest method runTest_resIsNoErrResultTypeIsPass.

@Test
public void runTest_resIsNoErrResultTypeIsPass() {
    Mockito.when(pktInfo01.getTimeStamp()).thenReturn(1.0);
    Mockito.when(pktInfo02.getTimeStamp()).thenReturn(2.0);
    httpRequestInfo01 = Mockito.mock(HttpRequestResponseInfo.class);
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo01.getFirstDataPacket()).thenReturn(pktInfo01);
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
    Mockito.when(session02.getRequestResponseInfo()).thenReturn(value);
    List<Session> sessionList = new ArrayList<Session>();
    sessionList.add(session01);
    sessionList.add(session02);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
    csjsImpl = (CombineCsJssImpl) context.getBean("combineCsJss");
    AbstractBestPracticeResult result = csjsImpl.runTest(tracedata);
    assertEquals(BPResultType.PASS, 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 62 with HttpRequestResponseInfo

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

the class DisplayNoneInCSSImplTest method runTest_ResultIsFail.

@Test
public void runTest_ResultIsFail() {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo01.getAssocReqResp()).thenReturn(httpRequestInfo01);
    Mockito.when(httpRequestInfo01.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo02.getContentType()).thenReturn("");
    Mockito.when(httpRequestInfo02.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo02.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo02.getAssocReqResp()).thenReturn(httpRequestInfo02);
    Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo03.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo03.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo03.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo03.getAssocReqResp()).thenReturn(httpRequestInfo03);
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo04.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo04.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo04.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo04.getAssocReqResp()).thenReturn(httpRequestInfo04);
    Mockito.when(httpRequestInfo05.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo05.getContentType()).thenReturn("text/css");
    Mockito.when(httpRequestInfo05.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo05.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo05.getAssocReqResp()).thenReturn(httpRequestInfo04);
    displayNoneInCSSImpl.setHttpRequestResponseHelper(reqhelper);
    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);
    value.add(httpRequestInfo05);
    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 = displayNoneInCSSImpl.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) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 63 with HttpRequestResponseInfo

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

the class DisplayNoneInCSSImplTest method runTest_ResultIsPass.

@Test
public void runTest_ResultIsPass() {
    Mockito.when(httpRequestInfo06.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo06.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo06.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo06.getAssocReqResp()).thenReturn(httpRequestInfo01);
    Mockito.when(httpRequestInfo06.getObjName()).thenReturn(htmlString);
    displayNoneInCSSImpl.setHttpRequestResponseHelper(reqhelper);
    try {
        Mockito.when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenReturn(htmlString2);
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo06);
    Mockito.when(session03.getRequestResponseInfo()).thenReturn(value);
    List<Session> sessionList = new ArrayList<Session>();
    Mockito.when(session03.getDomainName()).thenReturn("www.google.com");
    sessionList.add(session03);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
    AbstractBestPracticeResult testResult = displayNoneInCSSImpl.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 64 with HttpRequestResponseInfo

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

the class FileTypesChartPanel method generateDataForChart.

/**
 * Creates the FilTypes list to be plotted on the chart.
 * @return
 */
private void generateDataForChart() {
    Map<String, FileTypeSummary> content = new HashMap<String, FileTypeSummary>();
    int totalContentLength = 0;
    if (traceDataModel != null && traceDataModel.getAnalyzerResult() != null) {
        for (Session tcp : traceDataModel.getAnalyzerResult().getSessionlist()) {
            if (!tcp.isUdpOnly()) {
                for (HttpRequestResponseInfo info : tcp.getRequestResponseInfo()) {
                    if (HttpDirection.RESPONSE.equals(info.getDirection())) {
                        long contentLength = info.getContentLength();
                        if (contentLength > 0) {
                            String contentType = info.getContentType();
                            if (contentType == null || contentType.isEmpty()) {
                                contentType = ResourceBundleHelper.getMessageString("chart.filetype.unknown");
                            }
                            FileTypeSummary summary = content.get(contentType);
                            if (summary == null) {
                                summary = new FileTypeSummary(contentType);
                                content.put(contentType, summary);
                            }
                            // summary.bytes += contentLength;
                            summary.setBytes(summary.getBytes() + contentLength);
                            totalContentLength += contentLength;
                        }
                    }
                }
            }
        }
    }
    List<FileTypeSummary> result = new ArrayList<FileTypeSummary>(content.values());
    Collections.sort(result);
    if (result.size() > MAX_LIMIT_FILETYPES) {
        long otherValuesTotal = 0;
        Iterator<FileTypeSummary> iterator = result.iterator();
        for (int index = 0; index < (MAX_LIMIT_FILETYPES - 1); index++) {
            iterator.next();
        }
        while (iterator.hasNext()) {
            otherValuesTotal += iterator.next().getBytes();
            iterator.remove();
        }
        FileTypeSummary other = new FileTypeSummary(ResourceBundleHelper.getMessageString("chart.filetype.others"));
        other.setBytes(otherValuesTotal);
        result.add(other);
        // Sort again
        Collections.sort(result);
    }
    for (FileTypeSummary summary : result) {
        summary.setPct((double) summary.getBytes() / totalContentLength * 100.0);
    }
    this.setFileTypeContent(result);
}
Also used : HashMap(java.util.HashMap) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) FileTypeSummary(com.att.aro.ui.model.overview.FileTypeSummary) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 65 with HttpRequestResponseInfo

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

the class WaterfallPanel method refresh.

/**
 * Refreshes the waterfall display with the specified analysis data
 * @param Analyzed data from aro core.
 */
public void refresh(AROTraceData aModel) {
    this.data = aModel;
    this.popup.refresh(null, 0);
    this.popup.setVisible(false);
    // Create sorted list of request/response pairs
    categoryList = new ArrayList<WaterfallCategory>();
    if (aModel != null && aModel.getAnalyzerResult() != null) {
        this.traceDuration = aModel.getAnalyzerResult().getTraceresult().getTraceDuration();
        // add 20% to make sure labels close to the right edge of the screen are visible
        this.traceDuration *= 1.2;
        for (Session tcpSession : aModel.getAnalyzerResult().getSessionlist()) {
            Session thisSession = tcpSession;
            if (!tcpSession.isUdpOnly()) {
                for (HttpRequestResponseInfo reqResInfo : tcpSession.getRequestResponseInfo()) {
                    if (reqResInfo.getDirection() == HttpDirection.REQUEST && reqResInfo.getWaterfallInfos() != null) {
                        categoryList.add(new WaterfallCategory(reqResInfo, thisSession));
                    }
                }
            }
        }
        // Sort and set index
        Collections.sort(categoryList);
        int index = 0;
        for (WaterfallCategory wCategory : categoryList) {
            wCategory.setIndex(++index);
        }
    }
    // Horizontal scroll bar used to scroll through trace duration
    JScrollBar hScrollBar = getHorizontalScroll();
    hScrollBar.setMaximum((int) Math.ceil(this.traceDuration));
    CategoryAxis cAxis = getCategoryAxis();
    cAxis.clearCategoryLabelToolTips();
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    for (WaterfallCategory wfc : categoryList) {
        RequestResponseTimeline rrTimeLine = wfc.getReqResp().getWaterfallInfos();
        underlying.addValue(rrTimeLine.getStartTime(), Waterfall.BEFORE, wfc);
        underlying.addValue(rrTimeLine.getDnsLookupDuration(), Waterfall.DNS_LOOKUP, wfc);
        underlying.addValue(rrTimeLine.getInitialConnDuration(), Waterfall.INITIAL_CONNECTION, wfc);
        underlying.addValue(rrTimeLine.getSslNegotiationDuration(), Waterfall.SSL_NEGOTIATION, wfc);
        underlying.addValue(rrTimeLine.getRequestDuration(), Waterfall.REQUEST_TIME, wfc);
        underlying.addValue(rrTimeLine.getTimeToFirstByte(), Waterfall.TIME_TO_FIRST_BYTE, wfc);
        underlying.addValue(rrTimeLine.getContentDownloadDuration(), Waterfall.CONTENT_DOWNLOAD, wfc);
        underlying.addValue(null, Waterfall.HTTP_3XX_REDIRECTION, wfc);
        underlying.addValue(null, Waterfall.HTTP_4XX_CLIENTERROR, wfc);
        int code = wfc.getReqResp().getAssocReqResp().getStatusCode();
        double endTime = this.traceDuration - rrTimeLine.getStartTime() - rrTimeLine.getTotalTime();
        if (code >= 300 && code < 400) {
            underlying.addValue(endTime, Waterfall.AFTER_3XX, wfc);
        } else if (code >= 400) {
            underlying.addValue(endTime, Waterfall.AFTER_4XX, wfc);
        } else {
            underlying.addValue(endTime, Waterfall.AFTER, wfc);
        }
        cAxis.addCategoryLabelToolTip(wfc, wfc.getTooltip());
    }
    // Vertical scroll bar is used to scroll through data
    JScrollBar vScrollBar = getVerticalScroll();
    int count = underlying.getColumnCount();
    vScrollBar.setValue(0);
    vScrollBar.setMaximum(count);
    vScrollBar.setVisibleAmount(count > 0 ? this.dataset.getMaximumCategoryCount() - 1 / count : 1);
    // Add the dataset to the plot
    CategoryPlot plot = getChartPanel().getChart().getCategoryPlot();
    this.dataset = new SlidingCategoryDataset(underlying, 0, CATEGORY_MAX_COUNT);
    plot.setDataset(this.dataset);
    // Set the visible time range
    setTimeRange(startGraphRange, startGraphRange + 100);
    // Place proper colors on renderer for waterfall states
    final CategoryItemRenderer renderer = plot.getRenderer();
    for (Object obj : underlying.getRowKeys()) {
        Waterfall wFall = (Waterfall) obj;
        int index = underlying.getRowIndex(wFall);
        Color paint;
        switch(wFall) {
            case DNS_LOOKUP:
                paint = dnsLoolupColor;
                break;
            case INITIAL_CONNECTION:
                paint = initiaConnColor;
                break;
            case SSL_NEGOTIATION:
                paint = sslNegColor;
                break;
            case REQUEST_TIME:
                paint = requestTimeColor;
                break;
            case TIME_TO_FIRST_BYTE:
                paint = firstByteTimeColor;
                break;
            case CONTENT_DOWNLOAD:
                paint = contentDownloadColor;
                break;
            case INACTIVE:
                paint = inactiveConnectionColor;
                break;
            case AFTER_3XX:
                paint = noneColor;
                renderer.setSeriesItemLabelPaint(index, threexColor);
                renderer.setSeriesVisibleInLegend(index, false);
                break;
            case AFTER_4XX:
                paint = noneColor;
                renderer.setSeriesItemLabelPaint(index, fourxColor);
                renderer.setSeriesVisibleInLegend(index, false);
                break;
            case HTTP_3XX_REDIRECTION:
                paint = threexColor;
                break;
            case HTTP_4XX_CLIENTERROR:
                paint = fourxColor;
                break;
            default:
                renderer.setSeriesItemLabelPaint(index, Color.black);
                renderer.setSeriesVisibleInLegend(index, false);
                paint = noneColor;
        }
        renderer.setSeriesPaint(index, paint);
    }
    // Adding the label at the end of bars
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator() {

        private static final long serialVersionUID = 1L;

        @Override
        public String generateLabel(CategoryDataset dataset, int row, int column) {
            if (Waterfall.AFTER == dataset.getRowKey(row) || Waterfall.AFTER_3XX == dataset.getRowKey(row) || Waterfall.AFTER_4XX == dataset.getRowKey(row)) {
                WaterfallCategory waterfallItem = (WaterfallCategory) dataset.getColumnKey(column);
                RequestResponseTimeline waterfallInfos = waterfallItem.getReqResp().getWaterfallInfos();
                DecimalFormat formatter = new DecimalFormat("#.##");
                int code = waterfallItem.getReqResp().getAssocReqResp().getStatusCode();
                return MessageFormat.format(getMessageString("waterfall.totalTime"), formatter.format(waterfallInfos.getTotalTime()), code > 0 ? waterfallItem.getReqResp().getScheme() + " " + code : getMessageString("waterfall.unknownCode"));
            }
            return null;
        }
    });
    new Thread(() -> setCrosshairs(aModel)).start();
}
Also used : StandardCategoryItemLabelGenerator(org.jfree.chart.labels.StandardCategoryItemLabelGenerator) RequestResponseTimeline(com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) Color(java.awt.Color) DecimalFormat(java.text.DecimalFormat) ResourceBundleHelper.getMessageString(com.att.aro.ui.utils.ResourceBundleHelper.getMessageString) CategoryPlot(org.jfree.chart.plot.CategoryPlot) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) JScrollBar(javax.swing.JScrollBar) CategoryAxis(org.jfree.chart.axis.CategoryAxis) SlidingCategoryDataset(org.jfree.data.category.SlidingCategoryDataset) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) WaterfallCategory(com.att.aro.ui.model.waterfall.WaterfallCategory) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) 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