Java Code Examples for org.wso2.carbon.integration.common.admin.client.LogViewerClient#getAllRemoteSystemLogs()
The following examples show how to use
org.wso2.carbon.integration.common.admin.client.LogViewerClient#getAllRemoteSystemLogs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CAppDeploymentOrderTest.java From product-ei with Apache License 2.0 | 6 votes |
private boolean checkLogOrder(LogViewerClient logViewerClient) throws RemoteException { LogEvent[] systemLogs; systemLogs = logViewerClient.getAllRemoteSystemLogs(); //Create a stack to store the intended logs in order Stack<String> logStack = new Stack<>(); logStack.push("Sequence named 'test-sequence' has been deployed from file"); logStack.push("Inbound Endpoint named 'inbound-endpoint' has been deployed from file"); //Check whether the logs are in the stack's order if (systemLogs != null) { for (LogEvent logEvent : systemLogs) { if (logEvent == null) { continue; } if(logStack.size() != 0 && logEvent.getMessage().contains(logStack.peek())){ logStack.pop(); } } } return logStack.size() == 0; }
Example 2
Source File: Utils.java From product-ei with Apache License 2.0 | 6 votes |
/** * Get set of logs with expected string and given priority * * @param logViewerClient LogViewerClient object * @param priority priority level * @param expected expected string * @return set of logs with expected string and given priority * @throws RemoteException */ public static ArrayList<LogEvent> getLogsWithExpectedValue(LogViewerClient logViewerClient, String priority, String expected) throws RemoteException { LogEvent[] allLogs; allLogs = logViewerClient.getAllRemoteSystemLogs(); ArrayList<LogEvent> systemLogs = new ArrayList<>(); int i = 0; if (allLogs != null) { for (LogEvent logEvent : allLogs) { if (logEvent == null) { continue; } if (logEvent.getPriority().equals(priority) && logEvent.getMessage().contains(expected)) { systemLogs.add(logEvent); } } } return systemLogs; }
Example 3
Source File: MSMPCronForwarderCase.java From product-ei with Apache License 2.0 | 6 votes |
private Callable<Boolean> isLogWritten() { return new Callable<Boolean>() { @Override public Boolean call() throws Exception { LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs(); boolean success = false; int msgCount = 0; for (int i = 0; i < logEvents.length; i++) { if (logEvents[i].getMessage().contains("Jack")) { msgCount = ++msgCount; if (NUMBER_OF_MESSAGES == msgCount) { success = true; break; } } } return success; } }; }
Example 4
Source File: ESBJAVA2824MissingResponseTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = { "wso2.esb" }, description = "Test Sending message to a jms endpoint and check for response") public void testJmsResponse() throws Exception { try { axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), null, "IBM"); } catch (AxisFault fault) { String errMsg=fault.getMessage(); Assert.assertEquals(errMsg,"Send timeout", "JMS Client did not receive Send timeout"); LogViewerClient cli = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); LogEvent[] logs = cli.getAllRemoteSystemLogs(); Assert.assertNotNull(logs, "No logs found"); Assert.assertTrue(logs.length > 0, "No logs found"); boolean errorMsgTrue = Utils.checkForLogsWithPriority(cli,"ERROR", logLine0, 10); Assert.assertTrue(errorMsgTrue, "Axis Fault Did not receive"); } }
Example 5
Source File: ESBJAVA4565TestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = "wso2.esb", description = "Analyze carbon logs to find NPE due to unresolved tenant domain.") public void checkErrorLog() throws Exception { LogViewerClient cli = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); LogEvent[] logs = cli.getAllRemoteSystemLogs(); Assert.assertNotNull(logs, "No logs found"); Assert.assertTrue(logs.length > 0, "No logs found"); boolean hasErrorLog = false; for (LogEvent logEvent : logs) { String msg = logEvent.getMessage(); if (msg.contains("java.lang.NullPointerException: Tenant domain has not been set in CarbonContext")) { hasErrorLog = true; break; } } Assert.assertFalse(hasErrorLog, "Tenant domain not resolved when registry resource is accessed inside " + "a scheduled task"); }
Example 6
Source File: Sample364TestCase.java From product-ei with Apache License 2.0 | 6 votes |
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.PLATFORM }) @Test(groups = {"wso2.esb"}, description = "testDBMediator ") public void testDBMediator() throws Exception { LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewerClient.clearLogs(); AxisServiceClient client = new AxisServiceClient(); client.sendRobust(Utils.getStockQuoteRequest("IBM") , getMainSequenceURL(), "getQuote"); LogEvent[] getLogsInfo = logViewerClient.getAllRemoteSystemLogs(); boolean assertValue = false; for (LogEvent event : getLogsInfo) { if (event.getMessage().contains("Stock Prize")) { assertValue = true; break; } } Assert.assertTrue(assertValue, "db lookup failed"); }
Example 7
Source File: SynapseArtifactsHotDeploymentTestCase.java From product-ei with Apache License 2.0 | 6 votes |
private boolean searchInLogs(LogViewerClient logViewerClient, String searchString) throws RemoteException, InterruptedException { boolean logFound = false; for (int i = 0; i < 60; i++) { LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs(); if (logEvents != null) { for (LogEvent logEvent : logEvents) { if (logEvent == null) { continue; } if (logEvent.getMessage().contains(searchString)) { logFound = true; break; } } } if (logFound) { break; } Thread.sleep(500); } return logFound; }
Example 8
Source File: FaviconTest.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "Test for ClosedChannel Exception") public void faviconTest() throws Exception { HttpsResponse response = HttpsURLConnectionClient. getRequest("https://localhost:8443/" + "favicon.ico", null); Assert.assertEquals(response.getResponseCode(), 301, "Response code mismatch"); LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); LogEvent[] logs = logViewerClient.getAllRemoteSystemLogs(); boolean exceptionFound = false; for (LogEvent item : logs) { String message = item.getMessage(); if (message.contains("ClosedChannelException")) { exceptionFound = true; break; } } Assert.assertTrue(!exceptionFound, "ClosedChannelException occurred while retrieving favicon.ico"); }
Example 9
Source File: LogMediatorLevelsAndCategoryTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { super.init(); logAdmin = new LoggingAdminClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewer = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewer.clearLogs(); verifyProxyServiceExistence("LogMediatorLevelAndCategoryTestProxy"); logAdmin.updateLoggerData("org.apache.synapse.mediators.builtin", LoggingAdminClient.LogLevel.TRACE.name(),true, false); response = axis2Client .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("LogMediatorLevelAndCategoryTestProxy"), null, "WSO2"); Assert.assertTrue(response.toString().contains("WSO2"),"Did not receive the expected response"); logs = logViewer.getAllRemoteSystemLogs(); }
Example 10
Source File: CallTemplateIntegrationParamsWithValuesTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = { "wso2.esb" }, description = "Call Template Mediator Sample Parameters with" + " values assigned test") public void testTemplatesParameter() throws Exception { logViewer = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewer.clearLogs(); OMElement response = axis2Client .sendSimpleStockQuoteRequest(getProxyServiceURLHttp("StockQuoteProxy"), null, "IBM"); boolean requestLog = false; boolean responseLog = false; long startTime = System.currentTimeMillis(); while (startTime + 30000 > System.currentTimeMillis()) { LogEvent[] logs = logViewer.getAllRemoteSystemLogs(); for (LogEvent log : logs) { if (log.getMessage().contains("REQUEST PARAM VALUE")) { requestLog = true; continue; } else if(log.getMessage().contains("RESPONSE PARAM VALUE")) { responseLog = true; continue; } } if(requestLog && requestLog) { break; } } Assert.assertTrue((requestLog && responseLog), "Relevant log not found in carbon logs"); }
Example 11
Source File: ESBJAVA4863JMSTransactionRollbackTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = {"wso2.esb"}, description = "Test transaction rollback : ESBJAVA-4863 and ESBJAVA-4293") public void transactionRolBackWhenErrorTest() throws Exception { logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewerClient.clearLogs(); JMSTopicMessagePublisher mbTopicMessageProducer = new JMSTopicMessagePublisher( MessageBrokerConfigurationProvider.getBrokerConfig()); mbTopicMessageProducer.connect("MyNewTopic"); mbTopicMessageProducer.publish("<message>Hi</message>"); mbTopicMessageProducer.disconnect(); int rollbackCount = 0; long startTime = System.currentTimeMillis(); while (rollbackCount < 10 && (System.currentTimeMillis() - startTime) < 30000) { LogEvent[] logs = logViewerClient.getAllRemoteSystemLogs(); if(logs == null){ continue; } rollbackCount = 0; for (LogEvent event : logs) { if(log != null) { String message = event.getMessage(); if (message.contains("### I am Event subscriber (inbound endpoint) ###")) { rollbackCount++; } } } Thread.sleep(1000); } //if the message failed to mediate ESB rollback the message. Then message broker try 10 times //to send the message again. So total count is 11 including the first try Assert.assertEquals(rollbackCount, 11, "ESB does not process message again after rollback"); }
Example 12
Source File: ESBJAVA4863JMSTransactionRollbackTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = {"wso2.esb"}, description = "Test fault sequence on error : ESBJAVA-4864") public void faultSequenceOnErrorTest() throws Exception { logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewerClient.clearLogs(); JMSQueueMessageProducer mbQueueMessageProducer = new JMSQueueMessageProducer( MessageBrokerConfigurationProvider.getBrokerConfig()); mbQueueMessageProducer.connect("playground"); mbQueueMessageProducer.pushMessage("{\n" + " \"msg\": {\n" + " \"getQuote1\": {\n" + " \"request\": {\n" + " \"symbol\": \"WSO2\"\n" + " }\n" + " }\n" + " }\n" + "}"); mbQueueMessageProducer.disconnect(); boolean faultSequenceInvoked = false; long startTime = System.currentTimeMillis(); while (!faultSequenceInvoked && (System.currentTimeMillis() - startTime) < 15000) { LogEvent[] logs = logViewerClient.getAllRemoteSystemLogs(); if (logs == null) { continue; } for (LogEvent event : logs) { String message = event.getMessage(); if (message.contains("Fault sequence invoked")) { faultSequenceInvoked = true; break; } } Thread.sleep(1000); } Assert.assertTrue(faultSequenceInvoked, "Fault Sequence not invoked on error while building the message"); }
Example 13
Source File: ESBJAVA4821WSDLProxyServiceDeploymentTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = "wso2.esb", description = "Test the deployment of WSDL proxy which wsdl does not respond until timeout") public void testWSDLBasedProxyDeployment() throws Exception { LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewerClient.clearLogs(); File source = new File(getESBResourceLocation() + File.separator + "proxyconfig" + File.separator + "proxy" + File.separator + "wsdlBasedProxy" + File.separator + "wsdl-fault-proxy.xml"); FileManager.copyFile(source, targetProxyPath); long startTime = Calendar.getInstance().getTimeInMillis(); boolean logFound = false; while (!logFound && (Calendar.getInstance().getTimeInMillis() - startTime) < 200000) { LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs(); if (logEvents != null) { for (LogEvent log : logEvents) { if (log == null) { continue; } if (log.getMessage().contains("IOError when getting a stream from given url")) { logFound = true; } } } Thread.sleep(3000); } Assert.assertTrue(logFound, "Error message not found. Deployment not failed due to read timeout of wsdl"); }
Example 14
Source File: SetPropertyMessageBuilderInvokedWithEmptyContentTypeTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = {"wso2.esb"}, description = "Test whether the msg builder invoked property is set when the content" + " type is empty") public void testMsgBuilderInvokedPropertyWhenContentTypeisEmpty() throws Exception { boolean isErrorFound = false; int port = 8090; String expectedResponse = "HTTP/1.0 200 OK\r\n" + "Server: CERN/3.0 libwww/2.17\r\n" + "Date: Tue, 16 Nov 1994 08:12:31 GMT\r\n" + "\r\n" + "<HTML>\n" + "<!DOCTYPE HTML PUBLIC " + "\"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" + "<HEAD>\n" + " <TITLE>Test Server Results</TITLE>\n" + "</HEAD>\n" + "\n" + "<BODY BGCOLOR=\"#FDF5E6\">\n" + "<H1 ALIGN=\"CENTER\"> Results</H1>\n" + "Here is the request line and request headers\n" + "sent by your browser:\n" + "<PRE>"; simpleSocketServer = new SimpleSocketServer(port, expectedResponse); simpleSocketServer.start(); final String jsonPayload = "{\"album\":\"Hello\",\"singer\":\"Peter\"}"; String apiEp = getApiInvocationURL("setMessageBuilderInvokedWithEmptyContentType"); jsonclient.sendUserDefineRequest(apiEp, jsonPayload.trim()); logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); Assert.assertTrue(Utils.checkForLog(logViewerClient, "messageBuilderInvokedValue = true", 20)); LogEvent[] logs = logViewerClient.getAllRemoteSystemLogs(); for (LogEvent logEvent : logs) { String message = logEvent.getMessage(); if (message.contains(EXPECTED_ERROR_MESSAGE)) { isErrorFound = true; } } Assert.assertFalse(isErrorFound); }
Example 15
Source File: JMSOutOnlyTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@BeforeClass(alwaysRun = true) protected void init() throws Exception { super.init(); OMElement synapse = esbUtils.loadResource("/artifacts/ESB/jms/transport/jms_out_only_proxy.xml"); updateESBConfiguration(JMSEndpointManager.setConfigurations(synapse)); logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); //to clear the logs old logs logViewerClient.getAllRemoteSystemLogs(); logViewerClient.clearLogs(); }
Example 16
Source File: ESBJAVA5094SetOperationContextWithInboundEndpointTestCase.java From product-ei with Apache License 2.0 | 5 votes |
/** * Test whether the operation context of axis2 message is set when it is null with inbound endpoint * * @throws Exception */ @SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE}) @Test(groups = {"wso2.esb"}, description = "Test for the operation context of axis2 context with inbound endpoint") public void settingOperationContextWithInboundTest() throws Exception { LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewerClient.clearLogs(); //send a message to testInboundQueue queue sendMessage(); //check for the log boolean assertValue = false; long startTime = System.currentTimeMillis(); LogEvent[] systemLogs; while (!assertValue && (System.currentTimeMillis() - startTime) < 10000) { systemLogs = logViewerClient.getAllRemoteSystemLogs(); if (systemLogs != null) { for (LogEvent logEvent : systemLogs) { if (logEvent.getMessage().contains("In second sequence !!")) { assertValue = true; break; } } } } Assert.assertTrue(assertValue, "Operation context becomes null with the inbound endpoint."); }
Example 17
Source File: ESBJAVA4852URITemplateWithCompleteURLTestCase.java From product-ei with Apache License 2.0 | 5 votes |
@Test(groups = {"wso2.esb"}, description = "Sending complete URL to API and for dispatching") public void testCompleteURLWithHTTPMethod() throws Exception { 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); Assert.assertEquals(delete.getStatusLine().getStatusCode(), 202, "Response code mismatched"); } finally { 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"); }
Example 18
Source File: Sample18TestCase.java From product-ei with Apache License 2.0 | 4 votes |
@Test(groups = {"wso2.esb"}, description = "Transforming a Message Using ForEachMediator") public void testTransformWithForEachMediator() throws Exception { LogViewerClient logViewer = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewer.clearLogs(); String request = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:m0=\"http://services.samples\" xmlns:xsd=\"http://services.samples/xsd\">\n" + " <soap:Header/>\n" + " <soap:Body>\n" + " <m0:getQuote>\n" + " <m0:request><m0:symbol>IBM</m0:symbol></m0:request>\n" + " <m0:request><m0:symbol>WSO2</m0:symbol></m0:request>\n" + " <m0:request><m0:symbol>MSFT</m0:symbol></m0:request>\n" + " </m0:getQuote>\n" + " </soap:Body>\n" + "</soap:Envelope>\n"; sendRequest(getMainSequenceURL(), request); LogEvent[] getLogsInfo = logViewer.getAllRemoteSystemLogs(); for (LogEvent event : getLogsInfo) { if (event.getMessage().contains("<m0:getQuote>")) { assertTrue(true, "Payload not found"); String payload = event.getMessage(); String search = "<m0:getQuote>(.*)</m0:getQuote>"; Pattern pattern = Pattern.compile(search, Pattern.DOTALL); Matcher matcher = pattern.matcher(payload); boolean matchFound = matcher.find(); assertTrue(matchFound, "getQuote element not found"); if (matchFound) { int start = matcher.start(); int end = matcher.end(); String quote = payload.substring(start, end); assertTrue(quote.contains( "<m0:checkPriceRequest><m0:code>IBM</m0:code></m0:checkPriceRequest>"), "IBM Element not found"); assertTrue(quote.contains( "<m0:checkPriceRequest><m0:code>WSO2</m0:code></m0:checkPriceRequest>"), "WSO2 Element not found"); assertTrue(quote.contains( "<m0:checkPriceRequest><m0:code>MSFT</m0:code></m0:checkPriceRequest>"), "MSTF Element not found"); } } } }
Example 19
Source File: ForEachJSONPayloadTestCase.java From product-ei with Apache License 2.0 | 4 votes |
@Test(groups = {"wso2.esb"}, description = "Test ForEach mediator with JSON payload") public void testForEachMediatorWithJSONPayload() throws Exception { LogViewerClient logViewer = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewer.clearLogs(); String request = "{\"getQuote\":{\"request\":[{\"symbol\":\"IBM\"},{\"symbol\":\"WSO2\"},{\"symbol\":\"MSFT\"}]}}"; sendRequest(getProxyServiceURLHttp("foreachJSONTestProxy"), request); boolean reachedEnd = false; LogEvent[] getLogsInfo = logViewer.getAllRemoteSystemLogs(); for (LogEvent event : getLogsInfo) { if (event.getMessage().contains("STATE = END")) { reachedEnd = true; String payload = event.getMessage(); String search = "<jsonObject><getQuote>(.*)</getQuote></jsonObject>"; Pattern pattern = Pattern.compile(search, Pattern.DOTALL); Matcher matcher = pattern.matcher(payload); boolean matchFound = matcher.find(); assertTrue(matchFound, "getQuote element not found"); int start = matcher.start(); int end = matcher.end(); String quote = payload.substring(start, end); assertTrue(quote.contains( "<checkPriceRequest xmlns=\"http://ws.apache.org/ns/synapse\"><code>IBM</code></checkPriceRequest>"), "IBM Element not found"); assertTrue(quote.contains( "<checkPriceRequest xmlns=\"http://ws.apache.org/ns/synapse\"><code>WSO2</code></checkPriceRequest>"), "WSO2 Element not found"); assertTrue(quote.contains( "<checkPriceRequest xmlns=\"http://ws.apache.org/ns/synapse\"><code>MSFT</code></checkPriceRequest>"), "MSTF Element not found"); } } assertTrue(reachedEnd, "Transformed json payload"); }
Example 20
Source File: Sample381TestCase.java From product-ei with Apache License 2.0 | 3 votes |
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE}) @Test(groups = {"wso2.esb"}, description = "Test JMS broker with topic") public void JMSBrokerTopicTest() throws Exception { int numberOfMsgToExpect = 5; LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie()); logViewerClient.clearLogs(); Thread.sleep(5000); MDDProducer mddProducerMSTF = new MDDProducer(); for (int i = 0; i < numberOfMsgToExpect; i++) { mddProducerMSTF.sendMessage("MSTF", "dynamicQueues/JMSBinaryProxy"); } Thread.sleep(5000); boolean isRequestLogFound = false; LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs(); for (LogEvent event : logEvents) { if (event.getMessage().contains("MSTF")) { isRequestLogFound = true; break; } } Assert.assertTrue(isRequestLogFound, "Request log not found"); }