Search in sources :

Example 11 with Burst

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

the class UnnecessaryConnectionImplTest method runTest_resTypeIsPass.

@Test
public void runTest_resTypeIsPass() {
    when(burstArray[0].getBurstCategory()).thenReturn(BurstCategory.SCREEN_ROTATION);
    when(burstArray[0].getBeginTime()).thenReturn(1.0);
    when(burstArray[0].getEndTime()).thenReturn(5.0);
    when(burstArray[1].getBurstCategory()).thenReturn(BurstCategory.CPU);
    when(burstArray[1].getEndTime()).thenReturn(6.0);
    List<Burst> burstCollection = new ArrayList<Burst>();
    burstCollection.add(burstArray[0]);
    burstCollection.add(burstArray[1]);
    Mockito.when(burstCollectionAnalysisData.getBurstCollection()).thenReturn(burstCollection);
    Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData);
    unConnImpl = (UnnecessaryConnectionImpl) context.getBean("unnecessaryConnection");
    unConnImpl.runTest(tracedata);
    AbstractBestPracticeResult result = unConnImpl.runTest(tracedata);
    assertEquals(BPResultType.PASS, result.getResultType());
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 12 with Burst

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

the class UnnecessaryConnectionImplTest method runTest_resTypeIsFail.

@Test
public void runTest_resTypeIsFail() {
    Date date = new Date();
    for (int j = 0; j < 20; j++) {
        double timeLine = 0.0;
        when(burstArray[j].getBurstCategory()).thenReturn(BurstCategory.TCP_LOSS_OR_DUP);
        when(burstArray[j].getBeginTime()).thenReturn((date.getTime() / 1000) + 4.0 + timeLine);
        when(burstArray[j].getEndTime()).thenReturn((date.getTime() / 1000) + 10.0 + timeLine);
        when(burstArray[j + 1].getBurstCategory()).thenReturn(BurstCategory.PERIODICAL);
        when(burstArray[j + 1].getBeginTime()).thenReturn((date.getTime() / 1000) + 11.0 + timeLine);
        when(burstArray[j + 1].getEndTime()).thenReturn((date.getTime() / 1000) + 23.0 + timeLine);
        when(burstArray[j + 2].getBurstCategory()).thenReturn(BurstCategory.LONG);
        when(burstArray[j + 2].getBeginTime()).thenReturn((date.getTime() / 1000) + 25.0 + timeLine);
        when(burstArray[j + 2].getEndTime()).thenReturn((date.getTime() / 1000) + 40.0 + timeLine);
        when(burstArray[j + 3].getBurstCategory()).thenReturn(BurstCategory.CPU);
        when(burstArray[j + 3].getBeginTime()).thenReturn((date.getTime() / 1000) + 41.0 + timeLine);
        when(burstArray[j + 3].getEndTime()).thenReturn((date.getTime() / 1000) + 50.0 + timeLine);
        when(burstArray[j + 4].getBurstCategory()).thenReturn(BurstCategory.SERVER_NET_DELAY);
        when(burstArray[j + 4].getBeginTime()).thenReturn((date.getTime() / 1000) + 51.0 + timeLine);
        when(burstArray[j + 4].getEndTime()).thenReturn((date.getTime() / 1000) + 65.0 + timeLine);
        j = j + 5;
        timeLine = timeLine + 20.0;
    }
    List<Burst> burstCollection = new ArrayList<Burst>();
    for (int i = 0; i < 26; i++) {
        burstCollection.add(burstArray[i]);
    }
    Mockito.when(burstCollectionAnalysisData.getBurstCollection()).thenReturn(burstCollection);
    Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData);
    unConnImpl = (UnnecessaryConnectionImpl) context.getBean("unnecessaryConnection");
    unConnImpl.runTest(tracedata);
    AbstractBestPracticeResult result = unConnImpl.runTest(tracedata);
    assertEquals(BPResultType.FAIL, result.getResultType());
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Date(java.util.Date) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 13 with Burst

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

the class ScreenRotationImplTest method runTest_resIsNoErr_Fail.

@Test
public void runTest_resIsNoErr_Fail() {
    tracedata = Mockito.mock(PacketAnalyzerResult.class);
    burstCollectionAnalysisData = Mockito.mock(BurstCollectionAnalysisData.class);
    burst01 = mock(Burst.class);
    Mockito.when(burst01.getBurstCategory()).thenReturn(BurstCategory.SCREEN_ROTATION);
    Mockito.when(burst01.getBeginTime()).thenReturn(1.0);
    List<Burst> burstCollection = new ArrayList<Burst>();
    burstCollection.add(burst01);
    Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData);
    Mockito.when(burstCollectionAnalysisData.getBurstCollection()).thenReturn(burstCollection);
    screenRotationImpl = (ScreenRotationImpl) context.getBean("screenRotation");
    AbstractBestPracticeResult result = screenRotationImpl.runTest(tracedata);
    assertEquals(BPResultType.FAIL, result.getResultType());
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 14 with Burst

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

the class ConnectionClosingImplTest method runTest_resIsNoErrTypeIsFail.

@Test
public void runTest_resIsNoErrTypeIsFail() {
    Mockito.when(burst01.getBurstCategory()).thenReturn(BurstCategory.TCP_PROTOCOL);
    Mockito.when(burst01.getEnergy()).thenReturn(1.0);
    Mockito.when(burst01.getBeginTime()).thenReturn(2.0);
    List<Burst> burstCollection = new ArrayList<Burst>();
    burstCollection.add(burst01);
    Mockito.when(burstCollectionAnalysisData.getBurstCollection()).thenReturn(burstCollection);
    Mockito.when(burstCollectionAnalysisData.getTotalEnergy()).thenReturn(1.0);
    Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData);
    connClsImpl = (ConnectionClosingImpl) context.getBean("connectionClosing");
    AbstractBestPracticeResult result = connClsImpl.runTest(tracedata);
    assertEquals(BPResultType.FAIL, result.getResultType());
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 15 with Burst

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

the class BurstPlot method populate.

public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis != null) {
        burstDataCollection.removeAllSeries();
        Map<BurstCategory, XYIntervalSeries> seriesMap = new EnumMap<BurstCategory, XYIntervalSeries>(BurstCategory.class);
        final Map<BurstCategory, List<Burst>> burstMap = new HashMap<BurstCategory, List<Burst>>();
        for (BurstCategory eventType : BurstCategory.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            burstDataCollection.addSeries(series);
            burstMap.put(eventType, new ArrayList<Burst>());
        }
        final List<Burst> burstStates = analysis.getAnalyzerResult().getBurstCollectionAnalysisData().getBurstCollection();
        Iterator<Burst> iter = burstStates.iterator();
        while (iter.hasNext()) {
            Burst currEvent = iter.next();
            if (currEvent != null) {
                BurstCategory burstState = currEvent.getBurstCategory();
                if (burstState != null) {
                    seriesMap.get(burstState).add(currEvent.getBeginTime(), currEvent.getBeginTime(), currEvent.getEndTime(), 0.5, 0, 1);
                    burstMap.get(burstState).add(currEvent);
                }
            }
        }
        Color myGreen = new Color(34, 177, 76);
        Color lightGreen = new Color(134, 232, 162);
        XYItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_PROTOCOL), Color.blue);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_LOSS_OR_DUP), Color.black);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.USER_INPUT), myGreen);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SCREEN_ROTATION), lightGreen);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CLIENT_APP), Color.red);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SERVER_NET_DELAY), Color.yellow);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.LONG), Color.gray);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.PERIODICAL), Color.magenta);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CPU), Color.cyan);
        renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.UNKNOWN), Color.darkGray);
        // Assign ToolTip to renderer
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                BurstCategory eventType = (BurstCategory) burstDataCollection.getSeries(series).getKey();
                Burst b;
                int size = burstMap.get(eventType).size();
                if (size > item) {
                    b = burstMap.get(eventType).get(item);
                } else {
                    b = burstMap.get(eventType).get(size);
                }
                final String PREFIX = "BurstCategory.";
                return MessageFormat.format(ResourceBundleHelper.getMessageString(PREFIX + eventType.ordinal()), b.getPackets().size(), b.getBurstBytes(), b.getBurstThroughPut());
            }
        });
    }
    plot.setDataset(burstDataCollection);
// return plot;
}
Also used : HashMap(java.util.HashMap) Color(java.awt.Color) BurstCategory(com.att.aro.core.packetanalysis.pojo.BurstCategory) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) List(java.util.List) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) EnumMap(java.util.EnumMap)

Aggregations

Burst (com.att.aro.core.packetanalysis.pojo.Burst)22 ArrayList (java.util.ArrayList)11 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)8 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)8 BaseTest (com.att.aro.core.BaseTest)7 Test (org.junit.Test)7 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)5 BurstCategory (com.att.aro.core.packetanalysis.pojo.BurstCategory)4 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 Session (com.att.aro.core.packetanalysis.pojo.Session)3 Packet (com.att.aro.core.packetreader.pojo.Packet)3 InetAddress (java.net.InetAddress)3 Profile3G (com.att.aro.core.configuration.pojo.Profile3G)2 BurstAnalysisInfo (com.att.aro.core.packetanalysis.pojo.BurstAnalysisInfo)2 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)2 UnknownHostException (java.net.UnknownHostException)2 Date (java.util.Date)2 EnumMap (java.util.EnumMap)2 HashSet (java.util.HashSet)2 ConnectionClosingResult (com.att.aro.core.bestpractice.pojo.ConnectionClosingResult)1