use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class TransmissionPrivateDataTest method getPacketAnalyzerResult.
private PacketAnalyzerResult getPacketAnalyzerResult(Map<String, String> keywords, String text) {
Session session = mock(Session.class);
InetAddress address = mock(InetAddress.class);
String ipAddress = "127.0.0.1";
when(address.getHostAddress()).thenReturn(ipAddress);
int port = 8080;
byte[] storage = text.getBytes();
when(session.getStorageUl()).thenReturn(storage);
when(session.getRemoteIP()).thenReturn(address);
when(session.getRemotePort()).thenReturn(port);
List<Session> sessions = new ArrayList<>();
sessions.add(session);
packetAnalyzerResult.setSessionlist(sessions);
packetAnalyzerResult.setDeviceKeywords(keywords);
return packetAnalyzerResult;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class FileCompressionImplTest method runTest_2.
/**
* tests for PASS
*/
@Test
public void runTest_2() {
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(1);
// condition 3 & 4
// "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
Mockito.when(req.getContentType()).thenReturn("application/.something.xml");
Mockito.when(req.getContentEncoding()).thenReturn("identity");
FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
AbstractBestPracticeResult 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 0 text files above 850 bytes 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("PASS", result.getResultType().toString());
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class FileCompressionImplTest method runTest_3.
/**
* tests for WARNING
*/
@Test
public void runTest_3() {
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(900);
// condition 3 & 4
// "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
Mockito.when(req.getContentType()).thenReturn("application/.something.xml");
Mockito.when(req.getContentEncoding()).thenReturn("identity");
FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
AbstractBestPracticeResult 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% (0KB of 0KB) 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("WARNING", result.getResultType().toString());
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ForwardSecrecyImplTest method getPacketAnalyzerResult.
private PacketAnalyzerResult getPacketAnalyzerResult(String cipherSuite) {
Session session = mock(Session.class);
PacketInfo info = mock(PacketInfo.class);
TCPPacket tcpPacket = mock(TCPPacket.class);
InetAddress address = mock(InetAddress.class);
String ipAddress = "127.0.0.1";
int port = 8080;
List<Session> sessions = new ArrayList<>();
sessions.add(session);
List<PacketInfo> packetInfos = new LinkedList<>();
packetInfos.add(info);
packetAnalyzerResult.setSessionlist(sessions);
when(session.getTcpPackets()).thenReturn(packetInfos);
when(info.getPacket()).thenReturn(tcpPacket);
when(tcpPacket.getSelectedCipherSuite()).thenReturn(cipherSuite);
when(address.getHostAddress()).thenReturn(ipAddress);
when(session.getRemoteIP()).thenReturn(address);
when(session.getRemotePort()).thenReturn(port);
return packetAnalyzerResult;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class Http3xxCodeImplTest method runTest_resTypeIsPass.
@Test
public void runTest_resTypeIsPass() {
Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo01.getScheme()).thenReturn(HttpRequestResponseInfo.HTTP_SCHEME);
Mockito.when(httpRequestInfo01.getStatusCode()).thenReturn(200);
Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
value.add(httpRequestInfo01);
value.add(httpRequestInfo02);
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.PASS, result.getResultType());
}
Aggregations