說實話對整個系統都不是瞭解的很清楚,想要講一下ssm和bigs的區別我都覺得有點分不清楚,可能就是兩種不同的方式來爬取資料,到後面其實是有要做一個compare的功能的,但現在瞭解這些也沒有用,先慢慢看邏輯吧。
最近的task是,要在原有QA工具上面,新增功能:在xlsx上新加4個row

QA工具整體程式碼看起來不多,但是我覺得比較困難的部分,就是每一次他都會配置一些環境,匯入properties,現在對那些properties分別代表什麼,有什麼用,都不是很清楚,只能直接用,看到不清楚的東西就感覺很不安啊。
而且這也是我第一次要bat包來跑程式,很酷炫,之前一直是在本地放在tomcat跑或者是直接在myeclise上面,可能到後面,我們寫完的程式,都會像我們之前所說的,打包成jar包,然後可以直接跑,酷炫。

我們要跑的應該是這個,這個包的功能就是把對應的Excel裡面填的東西,轉換成request,像模擬之前手工測vessel和route一樣把請求傳送到solr,然後返回的response給存到本地。其實他會把Excel裡面的東西,加到我們預先配置好的model裡面,其實就是一個xml,裡面是一些寫死了的格式,而Excel表格裡面你只要填上一些必要的搜尋資訊就行了。
現在就慢慢看一下整個程式碼的邏輯把。

main方法進來以後,跟我之前所說的一樣,就是會先配置環境,匯入這個properties。
進入這個方法

在這個方法裡面獲取properties裡面的內容,放到configuration裡面。
獲取到properties裡面EnvironmentList的值,顧名思義就是環境的list,之後可能會有不同的環境,目前list裡面就只有一個。如果後期list裡面有別的,就會分割然後存到options這個陣列裡面。

把list裡面的內容顯示在Joption讓人選,然後選擇的環境返回。
再回到main方法,宣告一個File放我們開啟跑的Excel。

獲取他的絕對路徑。
這個checkExcelAvailable方法要驗證Excel的有效性,但裡面是這樣子驗證的:

它用了file的renameto方法,

重新命名為它本身,但是他會先進行一個驗證,他會先找這個檔案是否存在,不存在就會返回false。
我有點疑惑 為什麼這裡不直接用exist方法呢?
驗證成功以後,會將檔案備份,其實就是生成一個新的Excel,然後copy。


獲取Excel的輸入流,XSSFworkbook是Excel的工具類。


這裡就獲取到表格。

rowCount是所有行數,是通過Excel工具類的getLastRowNum獲取的,在這裡它遍歷每一行,把每一行的資料都放入recordModel中,再放入一個recordModelList。但我這裡有點不明白,為什麼這裡也要把整個Excel放到recordModel這個物件裡面。
判斷recordModelList不為空之後,就是開拼接request了。
首先連結資料庫

傳入env環境下連結資料庫的所需要的資料。

拼接testCase

他會根據carrier_scac加上時間生成一個Id。

生成各種引數,這裡還會根據根據scac和por生成資料夾,然後把資料夾路徑存在testCodeFolder,後面生成的input和output就會放在這裡。

根據選擇的引數會生成對應的input的檔案。
其實就是把recordModel裡面的資料放進json物件裡面。(或者是jms)

傳送request
我看了一下,就是把生成的input裡面的東西傳送到對應的連結就行了,跟手工測試差不多。
後面就是Compare的事情了 就大致看了一下了。