Java Code Examples for org.wso2.carbon.integration.common.admin.client.LogViewerClient#clearLogs()

The following examples show how to use org.wso2.carbon.integration.common.admin.client.LogViewerClient#clearLogs() . 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: JmsClientAckInboundEndpointTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Test whether consuming message from a queue using client ack mode works
 *
 * @throws Exception if any error occurred while running tests
 */
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Test JMS client ack mode with inbound endpoint")
public void testJmsQueueToHttpWithInboundEndpoint() throws Exception {
    LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();

    //send a message to the queue
    sendMessage();

    //check for the log
    boolean assertValue = Utils.checkForLog(logViewerClient,
                                            "** jmsClientAckInboundEPSendInSequence was called **",
                                            5);

    Assert.assertTrue(assertValue, "Message was not received to the inbound EP in client ack mode.");
    Assert.assertTrue(Utils.isQueueEmpty(QUEUE_NAME),"Queue should be empty if ack was properly sent");
}
 
Example 2
Source File: JmsToBackendWithInboundEndpointTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Test whether consuming message from a queue and sending to a backend works (i.e. JMS -> HTTP)
 *
 * @throws Exception if any error occurred while running tests
 */
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Test JMS to HTTP communication with inbound endpoint")
public void testJmsQueueToHttpWithInboundEndpoint() throws Exception {
    LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();

    //send a message to the queue
    sendMessage();

    //check for the log
    boolean assertValue = Utils.assertIfSystemLogContains(logViewerClient,
                                                          "** testJmsQueueToHttpWithInboundEndpoint RESPONSE **");

    Assert.assertTrue(assertValue, "HTTP backend response did not receive with the inbound endpoint.");
}
 
Example 3
Source File: JmsTypeHeaderInboundEndpointTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Test whether JMSType header is ignored when transport.jms.ContentTypeProperty"
 *
 * @throws Exception if any error occurred while running tests
 */
@SetEnvironment(executionEnvironments = {ExecutionEnvironment.STANDALONE})
@Test(groups = {"wso2.esb"}, description = "Test JMSType header with inbound endpoint")
public void testJmsTypeHeaderWithInboundEndpoint() throws Exception {
    LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();

    //send a message to the queue
    sendMessage();

    //check for the log
    boolean assertValue = Utils.checkForLog(logViewerClient,
                                            "** jmsTypeHeaderInboundEPSendInSequence was called **",
                                            5);

    Assert.assertTrue(assertValue, "Message was not received to the inbound EP when JMSType was set.");
    Assert.assertTrue(Utils.isQueueEmpty(QUEUE_NAME),"Queue should be empty if message was properly received");
}
 
Example 4
Source File: CalloutJMSHeadersTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.esb" },
      description = "Callout JMS headers test case")
public void testCalloutJMSHeaders() throws Exception {
    LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();
    AxisServiceClient client = new AxisServiceClient();
    String payload = "<payload/>";
    AXIOMUtil.stringToOM(payload);
    client.sendRobust(AXIOMUtil.stringToOM(payload), getProxyServiceURLHttp("JMCalloutClientProxy"), "urn:mediate");

    long startTime = System.currentTimeMillis();
    boolean logFound = false;
    while (!logFound && (startTime + 60000 > System.currentTimeMillis())) {
        Thread.sleep(1000);
        LogEvent[] logs = logViewerClient.getAllRemoteSystemLogs();
        if(logs == null) {
            continue;
        }
        for (LogEvent item : logs) {
            if(item == null) {
                continue;
            } else if (item.getPriority().equals("INFO")) {
                String message = item.getMessage();
                if (message.contains("RequestHeaderVal")) {
                    logFound = true;
                    break;
                }
            }
        }
    }
    assertTrue(logFound, "Required log entry not found");

}
 
Example 5
Source File: Sample264TestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init();
    context = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN);

    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();
    Thread.sleep(2000);
    loadSampleESBConfiguration(264);

}
 
Example 6
Source File: DynamicallySettingWSAHeadersTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb",
      description = "Testing message Processor handling message when setting wsa headers dynamically")
public void testForwardingWithInMemoryStore() throws Exception {

    logViewer = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewer.clearLogs();
    Reader data = new StringReader("<request><element>Test</element></request>");
    Writer writer = new StringWriter();
    HttpURLConnectionClient
            .sendPostRequestAndReadResponse(data, new URL(getProxyServiceURLHttp("MessageProcessorWSATestProxy")),
                    writer, "application/xml");
    Assert.assertTrue(Utils.checkForLog(logViewer, "MessageProcessorWSAProxy Request Received", 20),
            "Message processor unable to handle the message!");
}
 
Example 7
Source File: ESBJAVA4863JMSTransactionRollbackTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: ESBJAVA4863JMSTransactionRollbackTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: ESBJAVA4883SynapseHandlerBlockingCallTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init();
    serverConfigurationManager = new ServerConfigurationManager(new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN));
    serverConfigurationManager.applyConfiguration(new File(getESBResourceLocation() + File.separator + "passthru" +
            File.separator + "transport" + File.separator + "ESBJAVA4883" + File.separator + "synapse-handlers.xml"));
    super.init();
    verifyProxyServiceExistence("SynapseHandlerTestProxy");
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();
}
 
Example 10
Source File: ESBJAVA4913HandleExceptionTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void deployService() throws Exception {
    // Initializing server configuration
    super.init();
    verifyAPIExistence("ESBJAVA4913testapi");
    // Initialize log viewer client
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    // Clear all system logs
    logViewerClient.clearLogs();
}
 
Example 11
Source File: HandlerTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {
    super.init();
    serverConfigurationManager = new ServerConfigurationManager(context);
    copyToComponentConf(getClass().getResource(LOCATION + "/" + CONF_NAME).getPath(), CONF_NAME);
    serverConfigurationManager.restartForcefully();
    super.init();
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();
}
 
Example 12
Source File: Sample264TestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
    super.init();
    context = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN);

    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();
    Thread.sleep(2000);
    loadSampleESBConfiguration(264);

}
 
Example 13
Source File: ESBJAVA4821WSDLProxyServiceDeploymentTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@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: ESBJAVA4792AggregateTimeoutTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "Make sure that on complete is not triggered when message received after " +
                                         "aggregator timeout when clone is used")
public void checkOnCompleteExecutionInClone() throws Exception {
    LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(),getSessionCookie());
    logViewerClient.clearLogs();
    OMElement payload = getSleepOperationRequest();
    OMElement response = axis2Client.send(getProxyServiceURLHttps("timeoutClone"), null, "sleepOperation", payload);
    Assert.assertEquals(countLoadElement(response), 2, "Response must have two aggregated responses");
    //wait a last response to come to aggregator
    boolean logFound = Utils.checkForLog(logViewerClient,
            "On Complete Triggered in Clone for ESBJAVA4792AggregateTimeoutTestCase", 10);
    Assert.assertTrue(logFound, "OnComplete has been triggered more than expecting");
}
 
Example 15
Source File: ESBJAVA4519TestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@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 + "ESBJAVA4519synapseConfig.xml");
	logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
	logViewerClient.clearLogs();
}
 
Example 16
Source File: MQTTInboundMessagePollingTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@BeforeClass(alwaysRun = true)
protected void init() throws Exception {
    ActiveMQServerExtension.stopMQServer();
    activeMQServer = new JMSBroker("MQTTBroker", JMSBrokerConfigurationProvider.getInstance()
            .getTransportConnectors());
    activeMQServer.start();
    super.init();
    loadESBConfigurationFromClasspath(
            File.separator + "artifacts" + File.separator + "ESB" + File.separator + "mqtt"
                    + File.separator + "inbound" + File.separator + "transport" + File.separator
                    + "simple_mqtt_inboud_transport_config.xml");
    logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();
}
 
Example 17
Source File: ESBJAVA4540PinnedServerParameterTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "Editing a proxy service when the pinnedServer is having" +
                                         " another instance name")
public void modifyProxyService() throws Exception {
    ProxyServiceAdminClient proxyAdmin = new ProxyServiceAdminClient(contextUrls.getBackEndUrl()
            , getSessionCookie());
    ProxyData proxyData = proxyAdmin.getProxyDetails(proxyServiceNameEditProxy);
    proxyData.setPinnedServers(new String[] {"invalidPinnedServer"});

    LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), getSessionCookie());
    logViewerClient.clearLogs();

    proxyAdmin.updateProxy(proxyData);

    LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs();
    boolean isLogMessageFound = false;

    for (LogEvent log : logEvents) {
        if (log != null && log.getMessage().contains("not in pinned servers list. Not deploying " +
                                                     "Proxy service : EditProxyWithPinnedServer")) {
            isLogMessageFound = true;
            break;
        }
    }
    Assert.assertTrue(isLogMessageFound, "Log message not found in the console log");
    //proxy service should not be deployed since the pinnedServer does not contain this server name
    Assert.assertFalse(esbUtils.isProxyDeployed(contextUrls.getBackEndUrl(), getSessionCookie()
            , proxyServiceName), "Proxy service deployed successfully");
}
 
Example 18
Source File: ESBJAVA5094SetOperationContextWithInboundEndpointTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * 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 19
Source File: ESBJAVA4792AggregateTimeoutTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = "wso2.esb", description = "Make sure that on complete is not triggered when message received after " +
                                         "aggregator timeout when iterator is used")
public void checkOnCompleteExecutionInIterator() throws Exception {
    LogViewerClient logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(),getSessionCookie());
    logViewerClient.clearLogs();
    OMElement payload = getSleepOperationRequestForIterator();
    OMElement response = axis2Client.send(getProxyServiceURLHttp("timeoutIterator"), null, "sleepOperation", payload);
    Assert.assertEquals(countLoadElement(response), 2, "Response must have two aggregated responses");
    //wait a last response to come to aggregator
    boolean logFound = Utils.checkForLog(logViewerClient,
            "On Complete Triggered in Iterator for ESBJAVA4792AggregateTimeoutTestCase", 10);
    Assert.assertTrue(logFound, "OnComplete has been triggered more than expecting");
}
 
Example 20
Source File: LogMediatorLevelsAndCategoryTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@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();
}