Skip to content

Commit

Permalink
fixed compilation error and xml configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ddossot committed Sep 1, 2010
1 parent 94cb3a7 commit d57eb68
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
@@ -1,3 +1,4 @@

package com.muleinaction.expressions;

import java.util.Collections;
Expand All @@ -20,104 +21,103 @@
/**
* @author David Dossot (david@dossot.net)
*/
public class ExpressionEvaluatorsTestCase extends FunctionalTestCase {
public class ExpressionEvaluatorsTestCase extends FunctionalTestCase
{

private CountDownLatch latch;

private final AtomicReference<MuleMessage> receivedMessage =
new AtomicReference<MuleMessage>();
private final AtomicReference<MuleMessage> receivedMessage = new AtomicReference<MuleMessage>();

private MuleClient muleClient;

@Override
protected String getConfigResources() {
protected String getConfigResources()
{
return "conf/expressions-config.xml";
}

@Override
protected void doSetUp() throws Exception {
protected void doSetUp() throws Exception
{
super.doSetUp();

receivedMessage.set(null);

latch = new CountDownLatch(1);

final EventCallback callback = new EventCallback() {
public void eventReceived(final MuleEventContext context,
final Object component) throws Exception {
final EventCallback callback = new EventCallback()
{
public void eventReceived(final MuleEventContext context, final Object component)
throws Exception
{

receivedMessage.set(context.getMessage());
latch.countDown();
}
};

final DefaultJavaComponent defaultComponent =
(DefaultJavaComponent) muleContext.getRegistry().lookupService(
"TargetService").getComponent();
final DefaultJavaComponent defaultComponent = (DefaultJavaComponent) muleContext.getRegistry()
.lookupService("TargetService")
.getComponent();

final FunctionalTestComponent testComponent =
(FunctionalTestComponent) defaultComponent.getObjectFactory().getInstance();
final FunctionalTestComponent testComponent = (FunctionalTestComponent) defaultComponent.getObjectFactory()
.getInstance(muleContext);

testComponent.setEventCallback(callback);

muleClient = new MuleClient(muleContext);
}

public void testAckingAsyncDispatcher() throws Exception {
@SuppressWarnings("unchecked")
public void testAckingAsyncDispatcher() throws Exception
{

final String id = UUID.randomUUID().toString();
final String payload = "fooPayload";

final MuleMessage message =
new DefaultMuleMessage(payload, Collections.EMPTY_MAP, muleContext);
final MuleMessage message = new DefaultMuleMessage(payload, Collections.EMPTY_MAP, muleContext);

message.setCorrelationId(id);

final MuleMessage response =
muleClient.send("vm://AckingAsyncDispatcher.IN", message);
final MuleMessage response = muleClient.send("vm://AckingAsyncDispatcher.IN", message);

assertEquals(id, response.getPayload());
assertEquals(payload, getMessageReceivedInTarget().getPayload());
}

public void testPayloadSizeFiltering() throws Exception {
public void testPayloadSizeFiltering() throws Exception
{
// send some noise
muleClient.dispatch("vm://PayloadSizeFiltering.IN",
RandomStringUtils.randomAlphanumeric(10), null);
muleClient.dispatch("vm://PayloadSizeFiltering.IN",
RandomStringUtils.randomAlphanumeric(100), null);
muleClient.dispatch("vm://PayloadSizeFiltering.IN",
RandomStringUtils.randomAlphanumeric(1000), null);
muleClient.dispatch("vm://PayloadSizeFiltering.IN", RandomStringUtils.randomAlphanumeric(10), null);
muleClient.dispatch("vm://PayloadSizeFiltering.IN", RandomStringUtils.randomAlphanumeric(100), null);
muleClient.dispatch("vm://PayloadSizeFiltering.IN", RandomStringUtils.randomAlphanumeric(1000), null);

final String acceptedPayload =
RandomStringUtils.randomAlphanumeric(1100);
final String acceptedPayload = RandomStringUtils.randomAlphanumeric(1100);

muleClient.dispatch("vm://PayloadSizeFiltering.IN", acceptedPayload,
null);
muleClient.dispatch("vm://PayloadSizeFiltering.IN", acceptedPayload, null);

assertEquals(acceptedPayload, getMessageReceivedInTarget().getPayload());
}

public void testExpressionParserComponent() throws Exception {
@SuppressWarnings("unchecked")
public void testExpressionParserComponent() throws Exception
{
final String id = UUID.randomUUID().toString();
final String payload = "fooPayload";

final MuleMessage message =
new DefaultMuleMessage(payload, Collections.EMPTY_MAP, muleContext);
final MuleMessage message = new DefaultMuleMessage(payload, Collections.EMPTY_MAP, muleContext);

message.setCorrelationId(id);

final MuleMessage response =
muleClient.send("vm://ExpressionParser.IN", message);
final MuleMessage response = muleClient.send("vm://ExpressionParser.IN", message);

final String payloadAsString = response.getPayloadAsString();
assertTrue(payloadAsString.startsWith(id));
assertTrue(StringUtils.substringAfter(payloadAsString, "@").matches(
"\\d{4}-\\d{2}-\\d{2}"));
assertTrue(StringUtils.substringAfter(payloadAsString, "@").matches("\\d{4}-\\d{2}-\\d{2}"));
}

private MuleMessage getMessageReceivedInTarget()
throws InterruptedException {
private MuleMessage getMessageReceivedInTarget() throws InterruptedException
{

latch.await(10, TimeUnit.SECONDS);
return receivedMessage.get();
Expand Down
Expand Up @@ -3,7 +3,7 @@
xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:test="http://www.mulesoft.org/schema/mule/test"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.0/mule-http.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.0/mule-http.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.0/mule-vm.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/3.0/mule-test.xsd">
Expand All @@ -16,18 +16,18 @@
<!-- <start id="ExprEval-Transformer" /> -->
<service name="AckingAsyncDispatcher">
<inbound>
<vm:inbound-endpoint path="AckingAsyncDispatcher.IN" synchronous="true">
<response-transformers>
<vm:inbound-endpoint path="AckingAsyncDispatcher.IN" exchange-pattern="request-response">
<response>
<expression-transformer>
<return-argument evaluator="message" expression="correlationId" />
</expression-transformer>
</response-transformers>
</response>
</vm:inbound-endpoint>
</inbound>

<outbound>
<pass-through-router>
<outbound-endpoint ref="TargetChannel" synchronous="false" />
<outbound-endpoint ref="TargetChannel" exchange-pattern="one-way" />
</pass-through-router>
</outbound>
</service>
Expand All @@ -53,7 +53,7 @@

<service name="ExpressionParser">
<inbound>
<vm:inbound-endpoint path="ExpressionParser.IN" synchronous="true" />
<vm:inbound-endpoint path="ExpressionParser.IN" exchange-pattern="request-response" />
</inbound>
<!-- <start id="ExprParser-Config" /> -->
<component>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -15,7 +15,7 @@
</scm>

<properties>
<mule-version>3.0.0-RC2-SNAPSHOT</mule-version>
<mule-version>3.0.0-RC2</mule-version>
<spring-version>3.0.3.RELEASE</spring-version>
</properties>

Expand Down

0 comments on commit d57eb68

Please sign in to comment.