-
Notifications
You must be signed in to change notification settings - Fork 33
HttpSniffer test changes
anandbagmar edited this page Jul 22, 2011
·
1 revision
/*
Import packages
*/
import com.thoughtworks.webanalyticsautomation.common.BROWSER;
import com.thoughtworks.webanalyticsautomation.plugins.WebAnalyticTool;
import static com.thoughtworks.webanalyticsautomation.Controller.getInstance;
import static com.thoughtworks.webanalyticsautomation.common.Utils.currentDirectory;
import static com.thoughtworks.webanalyticsautomation.common.Utils.fileSeparator;
/*
Define & provide parameter values
*/
private Engine engine;
private String baseURL = "http://essenceoftesting.blogspot.com";
private String navigateToURL = baseURL + "/2010/12/waat-web-analytics-automation-testing.html";
private String[] urlPatterns = new String[] {"GET /ps/ifr?container=friendconnect&mid=0"};
private int minimumNumberOfPackets = 1;
private String actionName = " OpenWAATArticleOnBlog_HttpSniffer";
private WebAnalyticTool webAnalyticTool = WebAnalyticTool.HTTP_SNIFFER;
private IputFileType inputFileType = InputFileType.XML;
private boolean keepLoadedFileInMemory = true;
private String log4jPropertiesAbsoluteFilePath = currentDirectory() + fileSeparator() + "resources" + fileSeparator() + "log4j.properties";
private String inputDataFileName = currentDirectory() + fileSeparator() + "test" + fileSeparator() + "sampledata" + fileSeparator() + "TestData.xml";
/*
Initialize Engine
*/
engine = getInstance(webAnalyticTool, inputFileType, keepLoadedFileInMemory, log4jPropertiesAbsoluteFilePath);
/*
Enable Web Analytics Testing
*/
engine.enableWebAnalyticsTesting();
/*
Verify Web Analytics Reporting using WAAT
*/
Result verificationResult = engine.verifyWebAnalyticsData (inputDataFileName, actionName, urlPatterns, minimumNumberOfPackets);
/*
Sample validations
*/
assertNotNull(verificationResult.getVerificationStatus(), "Verification status should NOT be NULL");
assertNotNull(verificationResult.getListOfErrors(), "Failure details should NOT be NULL");
logVerificationErrors(verificationResult);
assertEquals(verificationResult.getVerificationStatus(), Status.PASS, "Verification status should be PASS");
assertEquals(verificationResult.getListOfErrors().size(), 0, "Failure details should be empty");
/*
Disable Web Analytics Testing
*/
/*
* If using TestNG, override the @AfterMethod annotation
* If using JUnit, override the @After annotation
* and add the following line in it:
* engine.disableWebAnalyticsTesting();
* See the example shown below
*/
@AfterMethod
public void tearDown() throws Exception {
engine.disableWebAnalyticsTesting();
}