Search in sources :

Example 91 with Session

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

the class CombineCsJssImplTest method runTest_resIsNoErrResultTypeIsFail.

@Test
public void runTest_resIsNoErrResultTypeIsFail() {
    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.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("text/css");
    Mockito.when(httpRequestInfo01.getFirstDataPacket()).thenReturn(pktInfo01);
    Mockito.when(httpRequestInfo01.getObjName()).thenReturn("test1.css");
    httpRequestInfo02 = Mockito.mock(HttpRequestResponseInfo.class);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo02.getContentType()).thenReturn("text/javascript");
    Mockito.when(httpRequestInfo02.getFirstDataPacket()).thenReturn(pktInfo02);
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    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.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)

Example 92 with Session

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

the class CombineCsJssImplTest method runTest_resIsNoErrResultTypeIsFailConsCssJsFirstPacket.

@Test
public void runTest_resIsNoErrResultTypeIsFailConsCssJsFirstPacket() {
    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.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("text/javascript");
    Mockito.when(httpRequestInfo01.getFirstDataPacket()).thenReturn(pktInfo01);
    Mockito.when(httpRequestInfo01.getObjName()).thenReturn("test2.css");
    httpRequestInfo02 = Mockito.mock(HttpRequestResponseInfo.class);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo02.getContentType()).thenReturn("application/x-javascript");
    Mockito.when(httpRequestInfo02.getFirstDataPacket()).thenReturn(pktInfo02);
    Mockito.when(httpRequestInfo02.getObjName()).thenReturn("test3.css");
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    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.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)

Example 93 with Session

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

the class FileCompressionImplTest method runTest_1.

/**
 * tests for a FAIL
 */
@Test
public void runTest_1() {
    tracedata = mock(PacketAnalyzerResult.class);
    session = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session);
    req = mock(HttpRequestResponseInfo.class);
    req.setDirection(HttpDirection.REQUEST);
    List<HttpRequestResponseInfo> reqList = new ArrayList<HttpRequestResponseInfo>();
    reqList.add(req);
    Mockito.when(session.getRequestResponseInfo()).thenReturn(reqList);
    Mockito.when(session.getDomainName()).thenReturn("mock.domain.name");
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    // HttpDirection.REQUEST
    Mockito.when(req.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(req.getObjName()).thenReturn("mock.obj.name");
    // condition 1
    Mockito.when(req.getPacketDirection()).thenReturn(PacketDirection.DOWNLINK);
    // condition 2
    Mockito.when(req.getContentLength()).thenReturn(1001024);
    // condition 3 & 4
    // "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
    Mockito.when(req.getContentType()).thenReturn("message/http");
    Mockito.when(req.getContentEncoding()).thenReturn("identity");
    FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
    AbstractBestPracticeResult result = FileCompressionImpl.runTest(tracedata);
    result = FileCompressionImpl.runTest(tracedata);
    assertEquals("Sending compressed files over the network will speed delivery, and unzipping files on a device is a very low overhead operation. Ensure that all your text files are compressed while being sent over the network.", result.getAboutText());
    assertEquals("FILE_COMPRESSION", result.getBestPracticeType().toString());
    assertEquals("Text File Compression", result.getDetailTitle());
    assertEquals("File Download: Text File Compression", result.getOverviewTitle());
    assertEquals(ApplicationConfig.getInstance().getAppShortName() + " detected 100% (977KB of 977KB) of text files were sent without compression. Adding compression will speed the delivery of your content to your customers. (Note: Only files larger than 850 bytes are flagged.)", result.getResultText());
    assertEquals("FAIL", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 94 with Session

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

the class HttpsUsageImplTest method domainNameTestSetup.

private PacketAnalyzerResult domainNameTestSetup(String ipAddressA, String ipAddressB, String sessionDomainName1, String sessionDomainName2, String sessionDomainName3) {
    Session session1 = mock(Session.class);
    Session session2 = mock(Session.class);
    Session session3 = mock(Session.class);
    InetAddress ipAddrA = mock(InetAddress.class);
    InetAddress ipAddrB = mock(InetAddress.class);
    when(ipAddrA.getHostAddress()).thenReturn(ipAddressA);
    when(ipAddrB.getHostAddress()).thenReturn(ipAddressB);
    when(session1.getRemoteIP()).thenReturn(ipAddrA);
    when(session1.getDomainName()).thenReturn(sessionDomainName1);
    when(session2.getRemoteIP()).thenReturn(ipAddrA);
    when(session2.getDomainName()).thenReturn(sessionDomainName2);
    when(session3.getRemoteIP()).thenReturn(ipAddrB);
    when(session3.getDomainName()).thenReturn(sessionDomainName3);
    TCPPacket tcpPacket1_1 = mock(TCPPacket.class);
    TCPPacket tcpPacket1_2 = mock(TCPPacket.class);
    TCPPacket tcpPacket2 = mock(TCPPacket.class);
    TCPPacket tcpPacket3 = mock(TCPPacket.class);
    when(tcpPacket1_1.containsSSLRecord()).thenReturn(false);
    when(tcpPacket1_2.containsSSLRecord()).thenReturn(false);
    when(tcpPacket2.containsSSLRecord()).thenReturn(false);
    when(tcpPacket3.containsSSLRecord()).thenReturn(false);
    PacketInfo packetInfo1_1 = mock(PacketInfo.class);
    PacketInfo packetInfo1_2 = mock(PacketInfo.class);
    PacketInfo packetInfo2 = mock(PacketInfo.class);
    PacketInfo packetInfo3 = mock(PacketInfo.class);
    when(packetInfo1_1.getLen()).thenReturn(2);
    when(packetInfo1_1.getPayloadLen()).thenReturn(1);
    when(packetInfo1_1.getPacket()).thenReturn(tcpPacket1_1);
    when(packetInfo1_2.getLen()).thenReturn(2);
    when(packetInfo1_2.getPayloadLen()).thenReturn(1);
    when(packetInfo1_2.getPacket()).thenReturn(tcpPacket1_2);
    when(packetInfo2.getLen()).thenReturn(2);
    when(packetInfo2.getPayloadLen()).thenReturn(1);
    when(packetInfo2.getPacket()).thenReturn(tcpPacket2);
    when(packetInfo3.getLen()).thenReturn(2);
    when(packetInfo3.getPayloadLen()).thenReturn(1);
    when(packetInfo3.getPacket()).thenReturn(tcpPacket3);
    List<PacketInfo> packetsInfo1 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo2 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo3 = new ArrayList<PacketInfo>();
    packetsInfo1.add(packetInfo1_1);
    packetsInfo1.add(packetInfo1_2);
    packetsInfo2.add(packetInfo2);
    packetsInfo3.add(packetInfo3);
    when(session1.getTcpPackets()).thenReturn(packetsInfo1);
    when(session2.getTcpPackets()).thenReturn(packetsInfo2);
    when(session3.getTcpPackets()).thenReturn(packetsInfo3);
    List<Session> sessions = new ArrayList<Session>();
    sessions.add(session1);
    sessions.add(session2);
    sessions.add(session3);
    pktAnalyzerResult.setSessionlist(sessions);
    return pktAnalyzerResult;
}
Also used : TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 95 with Session

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

the class MinificationImplTest method runTest_1.

/**
 * tests with empty session
 */
@Test
public void runTest_1() {
    List<Session> sessionlist;
    Session session_1;
    session_1 = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session_1);
    MinificationImpl = (MinificationImpl) context.getBean("minify");
    result = MinificationImpl.runTest(tracedata);
    assertEquals("Many text files contain excess whitespace to allow for better human coding. Run these files through a minifier to remove the whitespace in order to reduce file size.", result.getAboutText());
    assertEquals("Minify CSS, JS and HTML", result.getDetailTitle());
    assertEquals("File Download: Minify CSS, JS and HTML", result.getOverviewTitle());
    assertEquals("Your trace passes.", result.getResultText());
    assertEquals("MINIFICATION", result.getBestPracticeType().toString());
    assertEquals("PASS", result.getResultType().toString());
}
Also used : Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

Session (com.att.aro.core.packetanalysis.pojo.Session)130 ArrayList (java.util.ArrayList)86 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)74 BaseTest (com.att.aro.core.BaseTest)49 Test (org.junit.Test)49 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)32 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)31 InetAddress (java.net.InetAddress)26 HashMap (java.util.HashMap)19 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)17 HashSet (java.util.HashSet)11 TreeMap (java.util.TreeMap)11 List (java.util.List)10 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)9 File (java.io.File)9 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)8 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)8 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)7 HttpRequestResponseInfoWithSession (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession)7 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)7