use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class MinificationImplTest method runTest_3.
/**
* tests css compression
*/
@Test
public void runTest_3() {
List<Session> sessionlist;
Session session_1;
HttpRequestResponseInfo req_1;
HttpRequestResponseInfo rr_2;
session_1 = mock(Session.class);
sessionlist = new ArrayList<Session>();
sessionlist.add(session_1);
req_1 = mock(HttpRequestResponseInfo.class);
rr_2 = mock(HttpRequestResponseInfo.class);
List<HttpRequestResponseInfo> reqList_1 = new ArrayList<HttpRequestResponseInfo>();
reqList_1.add(req_1);
reqList_1.add(rr_2);
Mockito.when((TraceDirectoryResult) tracedata.getTraceresult()).thenReturn(dirdata);
Mockito.when(dirdata.getTraceResultType()).thenReturn(TraceResultType.TRACE_DIRECTORY);
Mockito.when(session_1.getRequestResponseInfo()).thenReturn(reqList_1);
Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
Mockito.when(req_1.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(req_1.getContentLength()).thenReturn(5);
MinificationImpl = (MinificationImpl) context.getBean("minify");
Mockito.when(rr_2.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(req_1.getContentType()).thenReturn("text/css");
Mockito.when(rr_2.getAssocReqResp()).thenReturn(req_1);
Mockito.when(rr_2.getContentLength()).thenReturn(5);
Mockito.when(req_1.getAssocReqResp()).thenReturn(rr_2);
Mockito.when(rr_2.getObjName()).thenReturn("/images/travel_buying_guide1.jpg");
IHttpRequestResponseHelper reqhelper = mock(IHttpRequestResponseHelper.class);
MinificationImpl.setHttpRequestResponseHelper(reqhelper);
try {
String aSession = "GET /style.css HTTP/1.1\nHost: searchinsidevideo.com\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13" + "\nAccept: text/css,*/*;q=0.1" + "\nReferer: http://searchinsidevideo.com/\nAccept-Language: en-us\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\n\nHTTP/1.1 200 OK\nDate: Tue, 04 Jun 2013 20:24:38 GMT\nServer: Apache\nLast-Modified: Fri, 28 Dec 2012 06:49:57 GMT\nETag: \"161827b-122c-4d1e41252af40\"\nAccept-Ranges: bytes\nContent-Length: 4652\nConnection: close\nContent-Type: text/css\n\n@charset \"UTF-8\";\r\n\r\nbody,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,\r\nform,fieldset,input,textarea,p,blockquote,th,td{\r\npadding:0;\r\nmargin:0;\r\n}\r\n\r\ntable{\r\nborder-collapse: collapse;\r\nborder-spacing:0;\r\n}\r\nimg{\r\nborder:0;\r\nline-height:0;\r\n}\r\nol,ul{\r\nlist-style:none;\r\n}\r\n\r\nbody{\r\nfont:12px/1.5 \"������������\",\"Meiryo\",arial,\"������������������ Pro W3\",\"Hiragino Kaku Gothic Pro\",Osaka,\"������ ���������������\",\"MS PGothic\",Sans-Serif;\r\ncolor:#333;\r\n}\r\n\r\n\r\na:link,a:visited{color:#438918;text-decoration:none;}\r\na:hover{color:#367f93;}\r\na:active, a:focus {outline:0;}\r\nimg{border:0;}\r\n\r\n\r\n\r\n/*******************************\r\n���������������\r\n*******************************/\r\n#header, #mainNav, #wrapper,#footer ul{\r\nmargin:0 auto;\r\nwidth:880px;\r\nclear:both;\r\n}\r\n\r\n#sidebar{\r\nfloat:left;\r\nwidth:233px;\r\npadding:22px 0 50px;\r\n}\r\n\r\n#main{\r\nfloat:right;\r\nwidth:627px;\r\npadding:22px 0 50px;\r\n}\r\n\r\n\r\n/*******************************\r\n/* ������������\r\n*******************************/\r\n#headerWrap{\r\nheight:147px;\r\nbackground:#fff url(images/wall.jpg) repeat-x 0 0;\r\n}\r\n\r\n#header{\r\nposition:relative;\r\nheight:147px;\r\n}\r\n\r\n#header h1,#header h2,#header p{\r\nposition:absolute;\r\ntop:31px;\r\nfont-size:10px;\r\nfont-weight:normal;\r\nline-height:22px;\r\n}\r\n\r\n/* ��������������� */\r\n#header h1{\r\ntop:2px;\r\nleft:0;\r\ncolor:#555;\r\n}\r\n\r\n/* ������ */\r\n#header h2{\r\nleft:0;\r\n}\r\n\r\n/* ������ */\r\n#header p{\r\nright:0;\r\n}\r\n\r\n\r\n/************************************\r\n/* ������������������������������\r\n************************************/\r\nul#mainNav{\r\nposition:absolute;\r\ntop:102px;\r\nheight:45px;\r\nbackground:url(images/mainNavBg.png) no-repeat 0 0;\r\n}\r\n\r\nul#mainNav li{\r\ntext-indent: -5000px;\r\nfloat:left;\r\n}\r\n\r\nul#mainNav a{\r\ndisplay: block;\r\nwidth: 176px;\r\nheight: 45px;\r\nbackground:url(images/mainNav1.jpg) no-repeat 0 0;\r\n}\r\n\r\nul#mainNav li.current_page_item a,ul#mainNav li.current-menu-item a,ul#mainNav li a:hover{background-position:0 -45px;}\r\n\r\nul#mainNav li.menu-item-2 a{background-image:url(images/mainNav2.jpg);}\r\nul#mainNav li.menu-item-3 a{background-image:url(images/mainNav3.jpg);}\r\nul#mainNav li.menu-item-4 a{background-image:url(images/mainNav4.jpg);}\r\nul#mainNav li.menu-item-5 a{background-image:url(images/mainNav5.jpg);} \r\n\r\n\r\n\r\n/*******************************\r\n/* ���������\r\n*******************************/\r\n#mainImg{margin-bottom:20px;}\r\n\r\nh3.heading{\r\nclear:both;\r\npadding-left:30px;\r\nline-height:34px;\r\nfont-size:16px;\r\nfont-weight:normal;\r\ncolor:#438918;\r\nbackground:url(images/headingBg.png) no-repeat 0 0;\r\n}\r\n\r\n.article{\r\nborder:0;\r\nmargin:0 0 20px 0;\r\npadding: 0 10px 0 10px;\r\nbackground:none;\r\nborder:1px solid #dcdcdc;\r\n}\r\n\r\n.article_cell{\r\nclear:both;\r\npadding:20px 0 25px;\r\nborder-bottom:1px dashed #dcdcdc;\r\n}\r\n\r\n.main{\r\npadding:20px 10px 20px 10px;\r\nmargin:0 0 20px 0;\r\nborder:0;\r\nbackground:none;\r\nborder:1px solid #dcdcdc;\r\n}\r\n\r\n.last{border-bottom:none;}\r\n\r\n.main h4{\r\nmargin:0 0 10px 10px;\r\nfont-size:16px;\r\nfont-weight:normal;\r\ncolor:#438918;\r\n}\r\n\r\n.article h4{\r\nmargin:0 0 10px 10px;\r\nfont-size:16px;\r\nfont-weight:normal;\r\ncolor:#438918;\r\n}\r\n\r\n.alignleft{\r\nfloat:left;\r\npadding:0 15px 15px 10px;\r\n}\r\n\r\n.alignright{\r\nfloat:right;\r\npadding: 0 10px 15px 15px;\r\n}\r\n\r\n.aligncenter{\r\npadding: 20px 0 20px 0;\r\ntext-align: center;\r\n}\r\n\r\n.main p{\r\npadding:0 10px 0 10px;\r\n}\r\n\r\n.article p{\r\npadding:0 10px 0 10px;\r\n}\r\n\r\n.picture{\r\nwidth:193px;\r\nfloat:left;\r\ntext-align:center;\r\nbackground-color:#ffffff;\r\nborder-top:1px solid #eaeaea;\r\nborder-right:1px solid #ddd;\r\nborder-bottom:1px solid #ccc;\r\nborder-left:1px solid #eaeaea;\r\npadding:5px 0 5px 0;\r\nmargin:5px 0 0 5px;\r\n}\r\n\r\n.picture:hover{\r\nbackground-color:#fffaef;\r\n}\r\n\r\n\r\n/*******************************\r\n/* ���������������\r\n*******************************/\r\n#sidebar h3{\r\nclear:both;\r\npadding-left:30px;\r\nline-height:34px;\r\nfont-size:16px;\r\nfont-weight:normal;\r\ncolor:#438918;\r\nbackground:url(images/side_headingBg.png) no-repeat 0 0;\r\n}\r\n\r\nul.info{\r\noverflow:hidden;\r\npadding:0 0 10px 17px;\r\nborder:1px solid #dcdcdc;\r\nmargin-bottom:20px;\r\n}\r\n\r\nul.info li{\r\nline-height:0;\r\npadding:10px 0;\r\nmargin-right:15px;\r\nborder-bottom:1px dashed #dcdcdc;\r\n}\r\n\r\nul.info a:link,ul.info a:visited{\r\ndisplay: block;\r\npadding-left:12px;\r\nline-height:normal;\r\ntext-decoration:none;\r\ncolor:#313131;\r\nbackground:url(images/linkArrow.gif) no-repeat 0 50%;\r\n}\r\n\r\nul.info a:hover, ul.info li.current_page_item a, ul.info li.current-menu-item a{color:#438918;}\r\n\r\nul.info li.last{border-bottom:none;}\r\n\r\n#sidebar p{margin-bottom:20px;}\r\n\r\n/*******************************\r\n/* ������������\r\n*******************************/\r\n#footer{\r\nclear:both;\r\nbackground:#a2ae52;\r\n}\r\n\r\n#footer ul{\r\npadding:25px 0;\r\ntext-align:center;\r\n}\r\n\r\n#footer li{\r\ndisplay: inline;\r\npadding: 5px 16px;\r\nborder-left:1px dotted #e2f0d9;\r\n}\r\n\r\n#footer li a{\r\ntext-decoration:none;\r\ncolor:#fff;\r\n}\r\n\r\n#footer li a:hover{color:#e2f0d9;}\r\n\r\np#copy{\r\npadding:10px 0 37px;\r\ntext-align:center;\r\ncolor:#fff;\r\nfont-size:10px;\r\n}" + "";
Mockito.when(reqhelper.isJavaScript("text/javascript")).thenReturn(false);
Mockito.when(reqhelper.isCss("text/css")).thenReturn(true);
Mockito.when(reqhelper.getContentString(rr_2, session_1)).thenReturn(aSession);
Mockito.when(reqhelper.getContentString(req_1, session_1)).thenReturn(aSession);
Mockito.when(req_1.getObjName()).thenReturn("/en/top100-css-websites.html");
Mockito.when(session_1.getDomainName()).thenReturn("www.google.com");
} catch (Exception e) {
e.printStackTrace();
}
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("MINIFICATION", result.getBestPracticeType().toString());
assertEquals("FAIL", result.getResultType().toString());
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class MinificationImplTest method runTest_5.
/**
* tests JSON compression
*/
@Test
public void runTest_5() {
List<Session> sessionlist;
Session session_1;
HttpRequestResponseInfo req_1;
HttpRequestResponseInfo rr_2;
session_1 = mock(Session.class);
sessionlist = new ArrayList<Session>();
sessionlist.add(session_1);
req_1 = mock(HttpRequestResponseInfo.class);
rr_2 = mock(HttpRequestResponseInfo.class);
List<HttpRequestResponseInfo> reqList_1 = new ArrayList<HttpRequestResponseInfo>();
reqList_1.add(req_1);
reqList_1.add(rr_2);
Mockito.when((TraceDirectoryResult) tracedata.getTraceresult()).thenReturn(dirdata);
Mockito.when(dirdata.getTraceResultType()).thenReturn(TraceResultType.TRACE_DIRECTORY);
Mockito.when(session_1.getRequestResponseInfo()).thenReturn(reqList_1);
Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
Mockito.when(req_1.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(req_1.getContentLength()).thenReturn(5);
MinificationImpl = (MinificationImpl) context.getBean("minify");
Mockito.when(rr_2.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(req_1.getContentType()).thenReturn("application/json");
Mockito.when(rr_2.getAssocReqResp()).thenReturn(req_1);
Mockito.when(rr_2.getContentLength()).thenReturn(5);
Mockito.when(req_1.getAssocReqResp()).thenReturn(rr_2);
Mockito.when(rr_2.getObjName()).thenReturn("/images/travel_buying_guide1.jpg");
IHttpRequestResponseHelper reqhelper = mock(IHttpRequestResponseHelper.class);
MinificationImpl.setHttpRequestResponseHelper(reqhelper);
try {
String aSession = "[\n {\n \"name\": \"Dow Jones Industrial Average\",\n \"display_name\": \"Dow Jones Industrial Average\",\n \"symbol\": \"^DJI\",\n \"price\": \"15,291.36\",\n \"change\": \"-96.22\",\n \"per_change\": \"-0.63%\",\n \"chart_uri\": \"http://chart.finance.yahoo.com/instrument/1.0/^DJI/chart;range=1d/image;size=170x65?region=US&lang=en-US\"\n },\n {\n \"name\": \"S&P 500\",\n \"display_name\": \"S&P 500\",\n \"symbol\": \"^GSPC\",\n \"price\": \"1,651.56\",\n \"change\": \"-17.60\",\n \"per_change\": \"-1.05%\",\n \"chart_uri\": \"http://chart.finance.yahoo.com/instrument/1.0/^GSPC/chart;range=1d/image;size=170x65?region=US&lang=en-US\"\n },\n {\n \"name\": \"NASDAQ Composite\",\n \"display_name\": \"NASDAQ Composite\",\n \"symbol\": \"^IXIC\",\n \"price\": \"3,451.57\",\n \"change\": \"-50.55\",\n \"per_change\": \"-1.44%\",\n \"chart_uri\": \"http://chart.finance.yahoo.com/instrument/1.0/^IXIC/chart;range=1d/image;size=170x65?region=US&lang=en-US\"\n },\n {\n \"name\": \"FTSE 100\",\n \"display_name\": \"FTSE 100\",\n \"symbol\": \"^FTSE\",\n \"price\": \"6,840.27\",\n \"change\": \"36.40\",\n \"per_change\": \"+0.53%\",\n \"chart_uri\": \"http://chart.finance.yahoo.com/instrument/1.0/^FTSE/chart;range=1d/image;size=170x65?region=US&lang=en-US\"\n }\n]";
Mockito.when(reqhelper.isJSON("application/json")).thenReturn(true);
Mockito.when(reqhelper.isCss("text/css")).thenReturn(false);
Mockito.when(reqhelper.getContentString(rr_2, session_1)).thenReturn(aSession);
Mockito.when(reqhelper.getContentString(req_1, session_1)).thenReturn(aSession);
Mockito.when(req_1.getObjName()).thenReturn("/en/top100-css-websites.html");
Mockito.when(session_1.getDomainName()).thenReturn("www.google.com");
} catch (Exception e) {
e.printStackTrace();
}
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("MINIFICATION", result.getBestPracticeType().toString());
assertEquals("PASS", result.getResultType().toString());
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ScriptsImplTest method runTest_resIsPass.
@Test
public void runTest_resIsPass() {
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(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(reqhelper.isHtml(any(String.class))).thenReturn(false);
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);
scriptImpl.setHttpRequestResponseHelper(reqhelper);
AbstractBestPracticeResult testResult = scriptImpl.runTest(tracedata);
scriptImpl.setHttpRequestResponseHelper(null);
assertEquals(BPResultType.PASS, testResult.getResultType());
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ScriptsImplTest 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);
scriptImpl.setHttpRequestResponseHelper(reqhelper);
AbstractBestPracticeResult testResult = scriptImpl.runTest(tracedata);
scriptImpl.setHttpRequestResponseHelper(null);
assertEquals(BPResultType.PASS, testResult.getResultType());
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ScriptsImplTest 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(htmlString);
} 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);
scriptImpl.setHttpRequestResponseHelper(reqhelper);
AbstractBestPracticeResult testResult = scriptImpl.runTest(tracedata);
scriptImpl.setHttpRequestResponseHelper(null);
assertEquals(BPResultType.FAIL, testResult.getResultType());
}
Aggregations