Search in sources :

Example 51 with Session

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

the class Http3xxCodeImplTest 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(304);
    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(304);
    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);
    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);
    http3xxCodeImpl = (Http3xxCodeImpl) context.getBean("http3xx");
    AbstractBestPracticeResult result = http3xxCodeImpl.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 52 with Session

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

the class HttpsUsageImplTest method sessionPacketsPayloadTestSetup.

private PacketAnalyzerResult sessionPacketsPayloadTestSetup(int payloadSize1, int payloadSize2, int payloadSize3, int payloadSize4) {
    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);
    InetAddress ipAddrC = mock(InetAddress.class);
    when(ipAddrA.getHostAddress()).thenReturn("157.56.19.80");
    when(ipAddrB.getHostAddress()).thenReturn("216.58.194.196");
    when(ipAddrC.getHostAddress()).thenReturn("216.58.194.198");
    when(session1.getRemoteIP()).thenReturn(ipAddrA);
    when(session1.getDomainName()).thenReturn("www.gstatic.com");
    when(session2.getRemoteIP()).thenReturn(ipAddrB);
    when(session2.getDomainName()).thenReturn("ssl.gstatic.com");
    when(session3.getRemoteIP()).thenReturn(ipAddrC);
    when(session3.getDomainName()).thenReturn("www.arotest.com");
    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(true);
    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.getPayloadLen()).thenReturn(payloadSize1);
    when(packetInfo1_1.getPacket()).thenReturn(tcpPacket1_1);
    when(packetInfo1_2.getPayloadLen()).thenReturn(payloadSize2);
    when(packetInfo1_2.getPacket()).thenReturn(tcpPacket1_2);
    when(packetInfo2.getPayloadLen()).thenReturn(payloadSize3);
    when(packetInfo2.getPacket()).thenReturn(tcpPacket2);
    when(packetInfo3.getPayloadLen()).thenReturn(payloadSize4);
    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);
    Statistic statistic = new Statistic();
    statistic.setTotalByte(123);
    statistic.setTotalHTTPSByte(123);
    statistic.setTotalHTTPSBytesNotAnalyzed(123);
    pktAnalyzerResult.setStatistic(statistic);
    pktAnalyzerResult.setSessionlist(sessions);
    return pktAnalyzerResult;
}
Also used : Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) 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 53 with Session

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

the class HttpsUsageImplTest method resultTestSetup.

/*
	 * 8 connections/sessions are set up in this method.
	 *
	 * Connections 1 - 3 share the same IP. Connections 4 - 7 share the same IP,
	 * different from the one shared by Connections 1 - 3. Connections 8 has a
	 * different IP than Connections 1 - 7.
	 *
	 * numHttpConn is expected to be any number between 1 and 8, inclusively. If
	 * it is not, then all connections/sessions will be set up as HTTPS.
	 *
	 * numHttpConn = 1 - C1 is HTTP Connection numHttpConn = 2 - C1, C2 are HTTP
	 * Connections numHttpConn = 3 - C1, C2, C3 are HTTP Connections numHttpConn
	 * = 4 - C1, C2, C3, C4 are HTTP Connections ... same logic follows till
	 * numHttpConn = 8
	 *
	 * Number of TCP Packets in each connection: C1 - 2 C2 - 3 C3 - 1 C4 - 1 C5
	 * - 1 C6 - 5 C7 - 1 C8 - 1
	 *
	 * Each TCP Packet is 50 bytes.
	 */
private PacketAnalyzerResult resultTestSetup(int numHttpConn) {
    boolean containsSSLRecord_1a = (numHttpConn >= 1 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_1b = (numHttpConn >= 1 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_2a = (numHttpConn >= 2 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_2b = (numHttpConn >= 2 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_2c = (numHttpConn >= 2 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_3 = (numHttpConn >= 3 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_4 = (numHttpConn >= 4 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_5 = (numHttpConn >= 5 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_6a = (numHttpConn >= 6 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_6b = (numHttpConn >= 6 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_6c = (numHttpConn >= 6 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_6d = (numHttpConn >= 6 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_6e = (numHttpConn >= 6 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_7 = (numHttpConn >= 7 && numHttpConn <= 8) ? false : true;
    boolean containsSSLRecord_8 = (numHttpConn == 8) ? false : true;
    Session session1 = mock(Session.class);
    Session session2 = mock(Session.class);
    Session session3 = mock(Session.class);
    Session session4 = mock(Session.class);
    Session session5 = mock(Session.class);
    Session session6 = mock(Session.class);
    Session session7 = mock(Session.class);
    Session session8 = mock(Session.class);
    InetAddress ipAddrA = mock(InetAddress.class);
    InetAddress ipAddrB = mock(InetAddress.class);
    InetAddress ipAddrC = mock(InetAddress.class);
    when(ipAddrA.getHostAddress()).thenReturn("157.56.19.80");
    when(ipAddrB.getHostAddress()).thenReturn("216.58.194.196");
    when(ipAddrC.getHostAddress()).thenReturn("72.21.92.82");
    when(session1.getRemoteIP()).thenReturn(ipAddrA);
    when(session1.getDomainName()).thenReturn("www.hotmail.com");
    when(session2.getRemoteIP()).thenReturn(ipAddrA);
    when(session2.getDomainName()).thenReturn("www.hotmail.com");
    when(session3.getRemoteIP()).thenReturn(ipAddrA);
    when(session3.getDomainName()).thenReturn("www.hotmail.com");
    when(session4.getRemoteIP()).thenReturn(ipAddrB);
    when(session4.getDomainName()).thenReturn("www.arotest.com");
    when(session5.getRemoteIP()).thenReturn(ipAddrB);
    when(session5.getDomainName()).thenReturn("www.arotest.com");
    when(session6.getRemoteIP()).thenReturn(ipAddrB);
    when(session6.getDomainName()).thenReturn("www.arotest.com");
    when(session7.getRemoteIP()).thenReturn(ipAddrB);
    when(session7.getDomainName()).thenReturn("www.arotest.com");
    when(session8.getRemoteIP()).thenReturn(ipAddrC);
    when(session8.getDomainName()).thenReturn("www.att.com");
    TCPPacket tcpPacket1a = mock(TCPPacket.class);
    TCPPacket tcpPacket1b = mock(TCPPacket.class);
    TCPPacket tcpPacket2a = mock(TCPPacket.class);
    TCPPacket tcpPacket2b = mock(TCPPacket.class);
    TCPPacket tcpPacket2c = mock(TCPPacket.class);
    TCPPacket tcpPacket3 = mock(TCPPacket.class);
    TCPPacket tcpPacket4 = mock(TCPPacket.class);
    TCPPacket tcpPacket5 = mock(TCPPacket.class);
    TCPPacket tcpPacket6a = mock(TCPPacket.class);
    TCPPacket tcpPacket6b = mock(TCPPacket.class);
    TCPPacket tcpPacket6c = mock(TCPPacket.class);
    TCPPacket tcpPacket6d = mock(TCPPacket.class);
    TCPPacket tcpPacket6e = mock(TCPPacket.class);
    TCPPacket tcpPacket7 = mock(TCPPacket.class);
    TCPPacket tcpPacket8 = mock(TCPPacket.class);
    when(tcpPacket1a.containsSSLRecord()).thenReturn(containsSSLRecord_1a);
    when(tcpPacket1b.containsSSLRecord()).thenReturn(containsSSLRecord_1b);
    when(tcpPacket2a.containsSSLRecord()).thenReturn(containsSSLRecord_2a);
    when(tcpPacket2b.containsSSLRecord()).thenReturn(containsSSLRecord_2b);
    when(tcpPacket2c.containsSSLRecord()).thenReturn(containsSSLRecord_2c);
    when(tcpPacket3.containsSSLRecord()).thenReturn(containsSSLRecord_3);
    when(tcpPacket4.containsSSLRecord()).thenReturn(containsSSLRecord_4);
    when(tcpPacket5.containsSSLRecord()).thenReturn(containsSSLRecord_5);
    when(tcpPacket6a.containsSSLRecord()).thenReturn(containsSSLRecord_6a);
    when(tcpPacket6b.containsSSLRecord()).thenReturn(containsSSLRecord_6b);
    when(tcpPacket6c.containsSSLRecord()).thenReturn(containsSSLRecord_6c);
    when(tcpPacket6d.containsSSLRecord()).thenReturn(containsSSLRecord_6d);
    when(tcpPacket6e.containsSSLRecord()).thenReturn(containsSSLRecord_6e);
    when(tcpPacket7.containsSSLRecord()).thenReturn(containsSSLRecord_7);
    when(tcpPacket8.containsSSLRecord()).thenReturn(containsSSLRecord_8);
    PacketInfo packetInfo1a = mock(PacketInfo.class);
    PacketInfo packetInfo1b = mock(PacketInfo.class);
    PacketInfo packetInfo2a = mock(PacketInfo.class);
    PacketInfo packetInfo2b = mock(PacketInfo.class);
    PacketInfo packetInfo2c = mock(PacketInfo.class);
    PacketInfo packetInfo3 = mock(PacketInfo.class);
    PacketInfo packetInfo4 = mock(PacketInfo.class);
    PacketInfo packetInfo5 = mock(PacketInfo.class);
    PacketInfo packetInfo6a = mock(PacketInfo.class);
    PacketInfo packetInfo6b = mock(PacketInfo.class);
    PacketInfo packetInfo6c = mock(PacketInfo.class);
    PacketInfo packetInfo6d = mock(PacketInfo.class);
    PacketInfo packetInfo6e = mock(PacketInfo.class);
    PacketInfo packetInfo7 = mock(PacketInfo.class);
    PacketInfo packetInfo8 = mock(PacketInfo.class);
    when(packetInfo1a.getLen()).thenReturn(50);
    when(packetInfo1a.getPayloadLen()).thenReturn(10);
    when(packetInfo1a.getPacket()).thenReturn(tcpPacket1a);
    when(packetInfo1b.getLen()).thenReturn(50);
    when(packetInfo1b.getPayloadLen()).thenReturn(10);
    when(packetInfo1b.getPacket()).thenReturn(tcpPacket1b);
    when(packetInfo2a.getLen()).thenReturn(50);
    when(packetInfo2a.getPayloadLen()).thenReturn(10);
    when(packetInfo2a.getPacket()).thenReturn(tcpPacket2a);
    when(packetInfo2b.getLen()).thenReturn(50);
    when(packetInfo2b.getPayloadLen()).thenReturn(10);
    when(packetInfo2b.getPacket()).thenReturn(tcpPacket2b);
    when(packetInfo2c.getLen()).thenReturn(50);
    when(packetInfo2c.getPayloadLen()).thenReturn(10);
    when(packetInfo2c.getPacket()).thenReturn(tcpPacket2c);
    when(packetInfo3.getLen()).thenReturn(50);
    when(packetInfo3.getPayloadLen()).thenReturn(10);
    when(packetInfo3.getPacket()).thenReturn(tcpPacket3);
    when(packetInfo4.getLen()).thenReturn(50);
    when(packetInfo4.getPayloadLen()).thenReturn(10);
    when(packetInfo4.getPacket()).thenReturn(tcpPacket4);
    when(packetInfo5.getLen()).thenReturn(50);
    when(packetInfo5.getPayloadLen()).thenReturn(10);
    when(packetInfo5.getPacket()).thenReturn(tcpPacket5);
    when(packetInfo6a.getLen()).thenReturn(50);
    when(packetInfo6a.getPayloadLen()).thenReturn(10);
    when(packetInfo6a.getPacket()).thenReturn(tcpPacket6a);
    when(packetInfo6b.getLen()).thenReturn(50);
    when(packetInfo6b.getPayloadLen()).thenReturn(10);
    when(packetInfo6b.getPacket()).thenReturn(tcpPacket6b);
    when(packetInfo6c.getLen()).thenReturn(50);
    when(packetInfo6c.getPayloadLen()).thenReturn(10);
    when(packetInfo6c.getPacket()).thenReturn(tcpPacket6c);
    when(packetInfo6d.getLen()).thenReturn(50);
    when(packetInfo6d.getPayloadLen()).thenReturn(10);
    when(packetInfo6d.getPacket()).thenReturn(tcpPacket6d);
    when(packetInfo6e.getLen()).thenReturn(50);
    when(packetInfo6e.getPayloadLen()).thenReturn(10);
    when(packetInfo6e.getPacket()).thenReturn(tcpPacket6e);
    when(packetInfo7.getLen()).thenReturn(50);
    when(packetInfo7.getPayloadLen()).thenReturn(10);
    when(packetInfo7.getPacket()).thenReturn(tcpPacket7);
    when(packetInfo8.getLen()).thenReturn(50);
    when(packetInfo8.getPayloadLen()).thenReturn(10);
    when(packetInfo8.getPacket()).thenReturn(tcpPacket8);
    List<PacketInfo> packetsInfo1 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo2 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo3 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo4 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo5 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo6 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo7 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo8 = new ArrayList<PacketInfo>();
    packetsInfo1.add(packetInfo1a);
    packetsInfo1.add(packetInfo1b);
    packetsInfo2.add(packetInfo2a);
    packetsInfo2.add(packetInfo2b);
    packetsInfo2.add(packetInfo2c);
    packetsInfo3.add(packetInfo3);
    packetsInfo4.add(packetInfo4);
    packetsInfo5.add(packetInfo5);
    packetsInfo6.add(packetInfo6a);
    packetsInfo6.add(packetInfo6b);
    packetsInfo6.add(packetInfo6c);
    packetsInfo6.add(packetInfo6d);
    packetsInfo6.add(packetInfo6e);
    packetsInfo7.add(packetInfo7);
    packetsInfo8.add(packetInfo8);
    when(session1.getTcpPackets()).thenReturn(packetsInfo1);
    when(session2.getTcpPackets()).thenReturn(packetsInfo2);
    when(session3.getTcpPackets()).thenReturn(packetsInfo3);
    when(session4.getTcpPackets()).thenReturn(packetsInfo4);
    when(session5.getTcpPackets()).thenReturn(packetsInfo5);
    when(session6.getTcpPackets()).thenReturn(packetsInfo6);
    when(session7.getTcpPackets()).thenReturn(packetsInfo7);
    when(session8.getTcpPackets()).thenReturn(packetsInfo8);
    List<Session> sessions = new ArrayList<Session>();
    sessions.add(session1);
    sessions.add(session2);
    sessions.add(session3);
    sessions.add(session4);
    sessions.add(session5);
    sessions.add(session6);
    sessions.add(session7);
    sessions.add(session8);
    Statistic statistic = new Statistic();
    statistic.setTotalByte(123);
    statistic.setTotalHTTPSByte(123);
    statistic.setTotalHTTPSBytesNotAnalyzed(123);
    pktAnalyzerResult.setStatistic(statistic);
    pktAnalyzerResult.setSessionlist(sessions);
    return pktAnalyzerResult;
}
Also used : Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) 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 54 with Session

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

the class HttpsUsageImplTest method testDomainNameFieldShowsBlankWhenDomainNameIsIP.

@Test
public void testDomainNameFieldShowsBlankWhenDomainNameIsIP() {
    Session session1 = mock(Session.class);
    Session session2 = mock(Session.class);
    InetAddress ipv4 = mock(InetAddress.class);
    when(ipv4.getHostAddress()).thenReturn("157.56.19.80");
    InetAddress ipv6 = mock(InetAddress.class);
    when(ipv6.getHostAddress()).thenReturn("2001:cdba:0000:0000:0000:0000:3257:9652");
    when(session1.getRemoteIP()).thenReturn(ipv4);
    when(session1.getDomainName()).thenReturn("www.hotmail.com");
    when(session2.getRemoteIP()).thenReturn(ipv6);
    when(session2.getDomainName()).thenReturn("2001:cdba:0000:0000:0000:0000:3257:9652");
    TCPPacket tcpPacket1 = mock(TCPPacket.class);
    TCPPacket tcpPacket2 = mock(TCPPacket.class);
    when(tcpPacket1.containsSSLRecord()).thenReturn(false);
    when(tcpPacket2.containsSSLRecord()).thenReturn(false);
    PacketInfo packetInfo1 = mock(PacketInfo.class);
    PacketInfo packetInfo2 = mock(PacketInfo.class);
    when(packetInfo1.getPayloadLen()).thenReturn(1);
    when(packetInfo1.getPacket()).thenReturn(tcpPacket1);
    when(packetInfo2.getPayloadLen()).thenReturn(1);
    when(packetInfo2.getPacket()).thenReturn(tcpPacket2);
    List<PacketInfo> packetsInfo1 = new ArrayList<PacketInfo>();
    List<PacketInfo> packetsInfo2 = new ArrayList<PacketInfo>();
    packetsInfo1.add(packetInfo1);
    packetsInfo2.add(packetInfo2);
    when(session1.getTcpPackets()).thenReturn(packetsInfo1);
    when(session2.getTcpPackets()).thenReturn(packetsInfo2);
    List<Session> sessions = new ArrayList<Session>();
    sessions.add(session1);
    sessions.add(session2);
    pktAnalyzerResult.setSessionlist(sessions);
    Statistic statistic = new Statistic();
    statistic.setTotalByte(123);
    statistic.setTotalHTTPSByte(123);
    statistic.setTotalHTTPSBytesNotAnalyzed(123);
    pktAnalyzerResult.setStatistic(statistic);
    httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult);
    httpsUsageEntries = httpsUsageResult.getResults();
    assertEquals(2, httpsUsageEntries.size());
    if (httpsUsageEntries.get(0).getIPAddress().equals("157.56.19.80")) {
        assertEquals("hotmail.com", httpsUsageEntries.get(0).getParentDomainName());
        assertEquals("", httpsUsageEntries.get(1).getParentDomainName());
    } else {
        assertEquals("", httpsUsageEntries.get(0).getParentDomainName());
        assertEquals("hotmail.com", httpsUsageEntries.get(1).getParentDomainName());
    }
}
Also used : Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) 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) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 55 with Session

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

the class EmptyUrlImplTest method getContentStringIsNullThrowException.

@Test
public void getContentStringIsNullThrowException() throws Exception {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("html");
    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.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo03.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo04.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo04.getContentLength()).thenReturn(3);
    Mockito.when(reqhelper.isHtml(any(String.class))).thenReturn(true);
    Mockito.when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenThrow(new Exception());
    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)

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