Question

I am trying to write a unit test for a Mule flow that uses the Quartz connector. However, I receive the following XML error stating that Mule doesn't know how to parse the "quartz-connector" tag when running the unit test. However, quartz-2.0.2.jar and quartz-1.8.5.jar are both in my classpath, and as you can see below, I have added quartz as part of the XML namespace and the XSD to to the root tag. I have searched on many forums, including this one, but I can't find the solution to my error. Please tell me what I am doing incorrectly. I am using Mule Studio 3.5.0 and JDK 1.7 to run this unit test.

Error

org.mule.api.config.ConfigurationException: Line 9 in XML document from URL [file:/C:/Users/smith/Development/MuleStudio_Workspace/funnel-mule-app/funnel-mule-app-batch/funnel-mule-app-batch-int/src/main/app/log_cleanup.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 89; cvc-complex-type.2.4.a: Invalid content was found starting with element 'quartz:connector'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":description, "http://www.springframework.org/schema/beans":beans, "http://www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/context":property-placeholder, "http://www.springframework.org/schema/beans":ref, "http://www.mulesoft.org/schema/mule/core":global-property, "http://www.mulesoft.org/schema/mule/core":configuration, "http://www.mulesoft.org/schema/mule/core":notifications, "http://www.mulesoft.org/schema/mule/core":abstract-extension, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-extension, "http://www.mulesoft.org/schema/mule/core":abstract-agent, "http://www.mulesoft.org/schema/mule/core":abstract-security-manager, "http://www.mulesoft.org/schema/mule/core":abstract-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-connector, "http://www.mulesoft.org/schema/mule/core":abstract-global-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy, "http://www.mulesoft.org/schema/mule/core":abstract-flow-construct, "http://www.mulesoft.org/schema/mule/core":flow, "http://www.mulesoft.org/schema/mule/core":sub-flow, "http://www.mulesoft.org/schema/mule/core":abstract-model, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-filter, "http://www.mulesoft.org/schema/mule/core":abstract-transformer, "http://www.mulesoft.org/schema/mule/core":processor-chain, "http://www.mulesoft.org/schema/mule/core":custom-processor, "http://www.mulesoft.org/schema/mule/core":invoke, "http://www.mulesoft.org/schema/mule/core":abstract-global-intercepting-message-processor, "http://www.mulesoft.org/schema/mule/core":custom-queue-store, "http://www.mulesoft.org/schema/mule/core":abstract-processing-strategy}' is expected. (org.mule.api.lifecycle.InitialisationException)
    at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:52)
    at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:78)
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:84)
    at org.mule.tck.junit4.AbstractMuleContextTestCase.createMuleContext(AbstractMuleContextTestCase.java:203)
    at org.mule.tck.junit4.AbstractMuleContextTestCase.setUpMuleContext(AbstractMuleContextTestCase.java:133)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:46)
    at org.junit.internal.runners.statements.FailOnTimeout$1.run(FailOnTimeout.java:28)

Mule Flow

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <quartz:connector name="TimeToStart2" validateConnections="true" doc:name="Quartz"/>    
    <flow name="cleanup_flow" doc:name="cleanup_flow">
        <quartz:inbound-endpoint name="LogCleanUpStart" jobName="LogCleanUp" cronExpression="${log.cleanup.cron.start}" repeatInterval="0" responseTimeout="10000" connector-ref="TimeToStart2" doc:name="Scheduler">
            <quartz:event-generator-job/>
        </quartz:inbound-endpoint>
        <set-variable variableName="#['failCounter']" value="#[0]" doc:name="Init Fail Counter"/>
        <logger message="Log Cleanup Started" level="INFO" doc:name="StartLogger"/>
        <flow-ref name="cleanup_for_loop_body" doc:name="cleanup_for_loop_body_ref"/>
    </flow> 
</mule>

Mule Unit Test

import static com.jayway.restassured.RestAssured.expect;
import static com.xebialabs.restito.builder.stub.StubHttp.whenHttp;
import static com.xebialabs.restito.builder.verify.VerifyHttp.verifyHttp;
import static com.xebialabs.restito.semantics.Action.status;
import static com.xebialabs.restito.semantics.Action.stringContent;
import static com.xebialabs.restito.semantics.Condition.method;
import static com.xebialabs.restito.semantics.Condition.post;
import static com.xebialabs.restito.semantics.Condition.delete;
import static com.xebialabs.restito.semantics.Condition.uri;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;


import org.glassfish.grizzly.http.Method;
import org.glassfish.grizzly.http.util.HttpStatus;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;

import org.mule.api.MuleMessage;
import org.mule.api.client.MuleClient;
import org.mule.tck.junit4.FunctionalTestCase;

import com.xebialabs.restito.server.StubServer;

public class LogCleanupTest extends FunctionalTestCase 
{

    private StubServer server;

    @Before
    public void start()
    {
        server = new StubServer().run();
    }

    @After
    public void stop()
    {
        server.stop();
    }

    @Override
    /**
     * Return the list of flow names that will be tested
     */
    protected String getConfigResources() 
    {
        String flowNames = "src/main/app/log_cleanup.xml, src/test/resources/batch_global_test_config_internal.xml";
        return flowNames;
    }

    /**
     * Make sure that a successful cleanup response does not increment the retry counter.
     */
    @Test
    public void testLCSuccessResponse() throws Exception
    {
        MuleClient client = muleContext.getClient();
        String logURL = "/api/log/cleanup/XYZ/";

        //When a Delete request is made to this Log URL, return an OK response.
        whenHttp(server).match(delete(logURL)).then(stringContent("String response"), status(HttpStatus.OK_200));

    }

}
Was it helpful?

Solution

There are JAR dependencies missing.

Instead of adding the JARs by hand, you'd rather use Maven to bring the Mule Quartz Transport JAR into your project, which will bring all its needed dependencies. Just make sure to scope the transport as provided.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top