Search in sources :

Example 51 with HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo 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 HttpRequestResponseInfo

use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo 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)

Example 53 with HttpRequestResponseInfo

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

the class EmptyUrlImplTest method runTest_resIsFail.

@Test
public void runTest_resIsFail() {
    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);
    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(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.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 54 with HttpRequestResponseInfo

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

the class FileOrderImplTest method runTest_resultIsFail.

@Test
public void runTest_resultIsFail() {
    fileOrderImpl.setHttpRequestResponseHelper(reqhelper);
    when(httpRequestResponseInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    when(httpRequestResponseInfo01.getContentType()).thenReturn("text/css");
    when(httpRequestResponseInfo01.getContentLength()).thenReturn(1);
    when(httpRequestResponseInfo01.getObjName()).thenReturn(htmlString2);
    when(httpRequestResponseInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    when(httpRequestResponseInfo02.getContentType()).thenReturn("script");
    when(httpRequestResponseInfo02.getContentLength()).thenReturn(2);
    when(httpRequestResponseInfo02.getObjName()).thenReturn(htmlString2);
    when(httpRequestResponseInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    when(httpRequestResponseInfo03.getContentType()).thenReturn("text/css");
    when(httpRequestResponseInfo03.getContentLength()).thenReturn(1);
    when(httpRequestResponseInfo03.getObjName()).thenReturn(htmlString2);
    when(httpRequestResponseInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    when(httpRequestResponseInfo04.getContentType()).thenReturn("text/css");
    when(httpRequestResponseInfo04.getContentLength()).thenReturn(2);
    when(httpRequestResponseInfo04.getObjName()).thenReturn(htmlString);
    when(httpRequestResponseInfo05.getDirection()).thenReturn(HttpDirection.RESPONSE);
    when(httpRequestResponseInfo05.getContentType()).thenReturn("text/css");
    when(httpRequestResponseInfo05.getContentLength()).thenReturn(2);
    when(httpRequestResponseInfo05.getObjName()).thenReturn(htmlString);
    when(httpRequestResponseInfo06.getDirection()).thenReturn(HttpDirection.RESPONSE);
    when(httpRequestResponseInfo06.getContentType()).thenReturn("script");
    when(httpRequestResponseInfo06.getContentLength()).thenReturn(4);
    when(httpRequestResponseInfo06.getObjName()).thenReturn(htmlString2);
    try {
        when(reqhelper.isHtml(any(String.class))).thenReturn(true);
        when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenReturn(htmlString2);
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestResponseInfo01);
    value.add(httpRequestResponseInfo02);
    value.add(httpRequestResponseInfo03);
    value.add(httpRequestResponseInfo04);
    value.add(httpRequestResponseInfo05);
    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 = fileOrderImpl.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 55 with HttpRequestResponseInfo

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

the class FileOrderImplTest method runTest_resultIsPass.

@Test
public void runTest_resultIsPass() {
    fileOrderImpl.setHttpRequestResponseHelper(reqhelper);
    when(httpRequestResponseInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    when(httpRequestResponseInfo01.getContentType()).thenReturn("text/css");
    when(httpRequestResponseInfo01.getContentLength()).thenReturn(1);
    when(httpRequestResponseInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    when(httpRequestResponseInfo02.getContentType()).thenReturn("script");
    when(httpRequestResponseInfo02.getContentLength()).thenReturn(2);
    try {
        when(reqhelper.isHtml(any(String.class))).thenReturn(true);
        when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenReturn(htmlString);
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestResponseInfo01);
    value.add(httpRequestResponseInfo02);
    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 = fileOrderImpl.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

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