Fix ESBJAVA4852URITemplateWithCompleteURLTestCase failure
@@ -20,38 +20,33 @@ package org.wso2.carbon.esb.rest.test.api;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.wso2.carbon.integration.common.admin.client.LogViewerClient;
-import org.wso2.carbon.logging.view.stub.types.carbon.LogEvent;
+import org.wso2.esb.integration.common.utils.CarbonLogReader;
import org.wso2.esb.integration.common.utils.ESBIntegrationTest;
-import java.io.File;
-
/**
- * https://wso2.org/jira/browse/ESBJAVA-4852
- * This test cass will test the URITemplate dispatcher when HTTP method having complete url with
- * query parameters.
+ * https://wso2.org/jira/browse/ESBJAVA-4852 This test cass will test the URITemplate dispatcher when HTTP method having
+ * complete url with query parameters.
*/
public class ESBJAVA4852URITemplateWithCompleteURLTestCase extends ESBIntegrationTest {
+
+ private CarbonLogReader logReader;
+
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
super.init();
- loadESBConfigurationFromClasspath(
- File.separator + "artifacts" + File.separator + "ESB" + File.separator + "synapseconfig"
- + File.separator + "rest" + File.separator + "ESBJAVA4852APIConfig.xml");
+ logReader = new CarbonLogReader();
}
@Test(groups = {"wso2.esb"}, description = "Sending complete URL to API and for dispatching")
public void testCompleteURLWithHTTPMethod() throws Exception {
+ logReader.start();
DeleteMethod delete = new DeleteMethod(getApiInvocationURL(
"myApi1/order/21441/item/17440079" + "?message_id=41ec2ec4-e629-4e04-9fdf-c32e97b35bd1"));
HttpClient httpClient = new HttpClient();
- LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
- logViewerClient.clearLogs();
try {
httpClient.executeMethod(delete);
@@ -60,21 +55,9 @@ public class ESBJAVA4852URITemplateWithCompleteURLTestCase extends ESBIntegratio
delete.releaseConnection();
}
- LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs();
- boolean isLogMessageFound = false;
-
- for (LogEvent log : logEvents) {
- if (log != null && log.getMessage().contains("order API INVOKED")) {
- isLogMessageFound = true;
- break;
- }
- }
- Assert.assertTrue(isLogMessageFound, "Request Not Dispatched to API when HTTP method having full url");
-
- }
+ Assert.assertTrue(logReader.assertIfLogExists("order API INVOKED"),
+ "Request Not Dispatched to API when HTTP method having full url");
- @AfterClass(alwaysRun = true)
- public void destroy() throws Exception {
- super.cleanup();
+ logReader.stop();
}
}
