@Test public void runTest_resTypeIsFail() { Mockito.when(httpRequestInfo01.getVersion()).thenReturn(HttpRequestResponseInfo.HTTP10); Mockito.when(httpRequestInfo02.getVersion()).thenReturn(HttpRequestResponseInfo.HTTP10); List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>(); value.add(httpRequestInfo01); value.add(httpRequestInfo02); Mockito.when(session01.getRequestResponseInfo()).thenReturn(value); List<Session> sessionList = new ArrayList<Session>(); sessionList.add(session01); Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList); httpUsageImpl = (Http10UsageImpl) context.getBean("http10Usage"); AbstractBestPracticeResult result = httpUsageImpl.runTest(tracedata); assertEquals(BPResultType.WARNING, result.getResultType()); }
@Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http10UsageResult result = new Http10UsageResult(); int http10HeaderCount = 0; Session http10Session = null; for(Session session: tracedata.getSessionlist()){ for(HttpRequestResponseInfo httpreq: session.getRequestResponseInfo()){ if(HttpRequestResponseInfo.HTTP10.equals(httpreq.getVersion())){ ++http10HeaderCount; if(http10Session == null){ http10Session = session; } } } } result.setHttp10Session(http10Session); result.setHttp10HeaderCount(http10HeaderCount); if(http10HeaderCount == 0){ result.setResultType(BPResultType.PASS); result.setResultText(MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); }else{ result.setResultType(BPResultType.WARNING); result.setResultText(MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpHeaderDesc(exportAllHttpHeaderDesc); return result; }
Http10UsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http10UsageResult result = new Http10UsageResult(); int http10HeaderCount = 0; Session http10Session = null; for(Session session: tracedata.getSessionlist()){ for(HttpRequestResponseInfo httpreq: session.getRequestResponseInfo()){ if(HttpRequestResponseInfo.HTTP10.equals(httpreq.getVersion())){ ++http10HeaderCount; if(http10Session == null){ http10Session = session; } } } } result.setHttp10Session(http10Session); result.setHttp10HeaderCount(http10HeaderCount); if(http10HeaderCount == 0){ result.setResultType(BPResultType.PASS); result.setResultText(MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); }else{ result.setResultType(BPResultType.WARNING); result.setResultText(MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpHeaderDesc(exportAllHttpHeaderDesc); return result; } }
Http10UsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http10UsageResult result = new Http10UsageResult(); int http10HeaderCount = 0; Session http10Session = null; for(Session session: tracedata.getSessionlist()){ for(HttpRequestResponseInfo httpreq: session.getRequestResponseInfo()){ if(HttpRequestResponseInfo.HTTP10.equals(httpreq.getVersion())){ ++http10HeaderCount; if(http10Session == null){ http10Session = session; } } } } result.setHttp10Session(http10Session); result.setHttp10HeaderCount(http10HeaderCount); if(http10HeaderCount == 0){ result.setResultType(BPResultType.PASS); result.setResultText(MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); }else{ result.setResultType(BPResultType.WARNING); result.setResultText(MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpHeaderDesc(exportAllHttpHeaderDesc); return result; }  }
Http10UsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http10UsageResult result = new Http10UsageResult(); int http10HeaderCount = 0; Session http10Session = null; for(Session session: tracedata.getSessionlist()){ for(HttpRequestResponseInfo httpreq: session.getRequestResponseInfo()){ if(HttpRequestResponseInfo.HTTP10.equals(httpreq.getVersion())){ ++http10HeaderCount; if(http10Session == null){ http10Session = session; } } } } result.setHttp10Session(http10Session); result.setHttp10HeaderCount(http10HeaderCount); if(http10HeaderCount == 0){ result.setResultType(BPResultType.PASS); result.setResultText(MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); }else{ result.setResultType(BPResultType.WARNING); result.setResultText(MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpHeaderDesc(exportAllHttpHeaderDesc); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata); }
Http10UsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http10UsageResult result = new Http10UsageResult(); int http10HeaderCount = 0; Session http10Session = null; for(Session session: tracedata.getSessionlist()){ for(HttpRequestResponseInfo httpreq: session.getRequestResponseInfo()){ if(HttpRequestResponseInfo.HTTP10.equals(httpreq.getVersion())){ ++http10HeaderCount; if(http10Session == null){ http10Session = session; } } } } result.setHttp10Session(http10Session); result.setHttp10HeaderCount(http10HeaderCount); if(http10HeaderCount == 0){ result.setResultType(BPResultType.PASS); result.setResultText(MessageFormat.format(textResultPass, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); }else{ result.setResultType(BPResultType.WARNING); result.setResultText(MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), http10HeaderCount)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpHeaderDesc(exportAllHttpHeaderDesc); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata);  }