1

I'm trying to run a simple Functional test in Mule 3.3. Below is my sample code:

import java.util.Map;    
import org.junit.Test;
import org.mule.api.MuleMessage;
import org.mule.api.client.MuleClient;
import org.mule.tck.junit4.FunctionalTestCase;
import static org.junit.Assert.*;

public class SoapServiceTest extends FunctionalTestCase {

    @Override
    protected String getConfigResources() {
        return "mule-config.xml,core-config.xml";
    }       

    @Test
    public void testSend() throws Exception
    {
        MuleClient client = muleContext.getClient();
        String payload = "foo";
        Map<String, Object> properties = null;
        MuleMessage result = client.send("http://localhost:61005/service", payload, properties);
        assertNotNull(result.getPayloadAsString());
    }    
}

But it complains java.lang.NoClassDefFoundError: org/junit/rules/TestRule. I've junit4.8.1.jar in my classpath but that doesn't have TestRule class which guess is junit4.9 onwards.

Does Mule needs this class? I'm not using any of the annotations of TestRule

Simulant
  • 19,190
  • 8
  • 63
  • 98
Charu Khurana
  • 4,511
  • 8
  • 47
  • 81

1 Answers1

4

From Mule's parent POM:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.9</version>
</dependency>

So yes, Mule relies on JUnit 4.9, whether you depend on it directly or not.

When you add:

<dependency>
    <groupId>org.mule.tests</groupId>
    <artifactId>mule-tests-functional</artifactId>
    <version>3.3.1</version>
    <scope>test</scope>
</dependency>

to your project's POM, JUnit 4.9 should be pulled in for you.

David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Thanks David for your response and pom link. My project is using `Mule 3.3.0` and I have the above mentioned dependency in my project pom but also separate dependency defined for `junit4.8.1`. Why do we need to define a separate dependency for junit when mule can pull it up. I see same trend in this sample [pom](https://github.com/ddossot/mule-in-action-2e/blob/master/chapter01/pom.xml), though this defines `junit4.9` – Charu Khurana Jan 31 '13 at 23:03
  • 1
    You don't need to add JUnit in the POM if you add `mule-tests-functional`. It's an oversight of us to have added it in chapter 1's POM you're pointing to. I've removed it. – David Dossot Jan 31 '13 at 23:18
  • Thank you for clear explanation. Wish I could upvote more than once – Charu Khurana Jan 31 '13 at 23:43