Last active
December 15, 2015 14:29
-
-
Save mcantrell/5274726 to your computer and use it in GitHub Desktop.
Confluex Dojo Lesson: mule-application-structure. See http://dojo.confluex.com/courses/intro-to-mule/getting-started-with-mule/mule-application-structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<mule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://www.mulesoft.org/schema/mule/core" | |
xmlns:vm="http://www.mulesoft.org/schema/mule/vm" | |
xmlns:http="http://www.mulesoft.org/schema/mule/http" | |
xsi:schemaLocation=" | |
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.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/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd | |
"> | |
<vm:endpoint name="vmHello" path="hello.mule"/> | |
<http:endpoint name="httpHello" host="localhost" port="9001" path="/hello/mule" method="POST"/> | |
<flow name="Hello_Mule"> | |
<composite-source> | |
<inbound-endpoint ref="vmHello" exchange-pattern="request-response"/> | |
<inbound-endpoint ref="httpHello"/> | |
</composite-source> | |
<object-to-string-transformer/> | |
<component class="com.confluex.training.hello.HelloComponent"/> | |
</flow> | |
</mule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.confluex.training.hello; | |
import com.sun.jersey.api.client.Client; | |
import com.sun.jersey.api.client.WebResource; | |
import junit.framework.Assert; | |
import org.junit.Test; | |
import org.mule.DefaultMuleMessage; | |
import org.mule.api.MuleException; | |
import org.mule.api.MuleMessage; | |
import org.mule.api.client.LocalMuleClient; | |
import org.mule.tck.junit4.FunctionalTestCase; | |
import javax.ws.rs.core.MediaType; | |
public class HelloMuleIntegrationTest extends FunctionalTestCase { | |
@Override | |
protected String getConfigResources() { | |
return "example-mule-config.xml"; | |
} | |
@Test | |
public void shouldPrefixPayloadWithHelloUsingVmTransport() throws Exception { | |
LocalMuleClient client = muleContext.getClient(); | |
MuleMessage message = client.send("vm://hello.mule", new DefaultMuleMessage("World", muleContext)); | |
Assert.assertEquals("Hello World", message.getPayloadAsString()); | |
} | |
@Test | |
public void shouldPrefixPayloadWithHelloUsingHttpTransport() throws Exception { | |
Client c = Client.create(); | |
WebResource service = c.resource("http://localhost:9001/hello/mule"); | |
String message = service.type("text/plain").post(String.class, "World"); | |
Assert.assertEquals("Hello World", message); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.confluex.training</groupId> | |
<artifactId>using-mule-with-intellij</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>Using Mule with IntelliJ</name> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | |
<jdk.version>1.6</jdk.version> | |
<mule.deploy>false</mule.deploy> | |
<mule.version>3.3.1</mule.version> | |
</properties> | |
<build> | |
<testResources> | |
<testResource> | |
<directory>src/main/app</directory> | |
</testResource> | |
<testResource> | |
<directory>src/test/resources</directory> | |
</testResource> | |
</testResources> | |
<plugins> | |
<!-- | |
This plugin will create your deployable .zip file. | |
See the docs here: | |
http://www.mulesoft.org/extensions/maven-mule-plugin | |
--> | |
<plugin> | |
<groupId>org.mule.tools</groupId> | |
<artifactId>maven-mule-plugin</artifactId> | |
<version>1.6</version> | |
<extensions>true</extensions> | |
<configuration> | |
<copyToAppsDirectory>${mule.deploy}</copyToAppsDirectory> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>2.3.2</version> | |
<configuration> | |
<source>${jdk.version}</source> | |
<target>${jdk.version}</target> | |
<encoding>ISO-8859-1</encoding> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-install-plugin</artifactId> | |
<version>2.3.1</version> | |
</plugin> | |
</plugins> | |
<extensions> | |
<extension> | |
<groupId>org.apache.maven.wagon</groupId> | |
<artifactId>wagon-webdav</artifactId> | |
<version>1.0-beta-2</version> | |
</extension> | |
</extensions> | |
</build> | |
<dependencies> | |
<!-- Mule Config --> | |
<dependency> | |
<groupId>org.mule</groupId> | |
<artifactId>mule-core</artifactId> | |
<version>${mule.version}</version> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.mule.modules</groupId> | |
<artifactId>mule-module-spring-config</artifactId> | |
<version>${mule.version}</version> | |
<scope>provided</scope> | |
</dependency> | |
<!-- | |
Mule Transports: Add more as you need them. | |
--> | |
<dependency> | |
<groupId>org.mule.transports</groupId> | |
<artifactId>mule-transport-vm</artifactId> | |
<version>${mule.version}</version> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.mule.transports</groupId> | |
<artifactId>mule-transport-http</artifactId> | |
<version>${mule.version}</version> | |
<scope>provided</scope> | |
</dependency> | |
<!-- Mule Modules: Add more as needed --> | |
<dependency> | |
<groupId>org.mule.modules</groupId> | |
<artifactId>mule-module-annotations</artifactId> | |
<version>${mule.version}</version> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.mule.modules</groupId> | |
<artifactId>mule-module-boot</artifactId> | |
<version>${mule.version}</version> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.mule.modules</groupId> | |
<artifactId>mule-module-client</artifactId> | |
<version>${mule.version}</version> | |
<scope>provided</scope> | |
</dependency> | |
<!-- Mule Test: This provides the client API which is useful in functional testing. --> | |
<dependency> | |
<groupId>org.mule.tests</groupId> | |
<artifactId>mule-tests-functional</artifactId> | |
<version>${mule.version}</version> | |
<scope>test</scope> | |
</dependency> | |
<!-- Testing --> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.9</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.mockito</groupId> | |
<artifactId>mockito-core</artifactId> | |
<version>1.9.5</version> | |
<scope>test</scope> | |
</dependency> | |
<!-- Useful for HTTP requests from test cases --> | |
<dependency> | |
<groupId>com.sun.jersey</groupId> | |
<artifactId>jersey-client</artifactId> | |
<version>1.6</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment