INT-681, INT-710, INT-1181 added more tests

This commit is contained in:
Mark Fisher
2010-06-16 19:37:32 +00:00
parent 7565773418
commit 0fe776d607
2 changed files with 48 additions and 0 deletions

View File

@@ -15,6 +15,10 @@
<service-activator input-channel="beanInvocationResultInput" expression="payload.concat(@testBean.caps('foo'))"/>
<service-activator input-channel="multipleLiteralArgsInput" expression="@testBean.concat('foo', 'bar')"/>
<service-activator input-channel="multipleArgsFromPayloadInput" expression="@testBean.concat(payload.firstName, payload.lastName)"/>
<beans:bean id="testBean" class="org.springframework.integration.config.xml.ServiceActivatorParserTests$TestBean"/>
</beans:beans>

View File

@@ -47,6 +47,12 @@ public class ServiceActivatorParserTests {
@Autowired
private MessageChannel beanInvocationResultInput;
@Autowired
private MessageChannel multipleLiteralArgsInput;
@Autowired
private MessageChannel multipleArgsFromPayloadInput;
@Test
public void literalExpression() {
@@ -72,6 +78,18 @@ public class ServiceActivatorParserTests {
assertEquals("helloFOO", result);
}
@Test
public void multipleLiteralArgs() {
Object result = this.sendAndReceive(multipleLiteralArgsInput, "hello");
assertEquals("foobar", result);
}
@Test
public void multipleArgsFromPayload() {
Object result = this.sendAndReceive(multipleArgsFromPayloadInput, new TestPerson("John", "Doe"));
assertEquals("JohnDoe", result);
}
private Object sendAndReceive(MessageChannel channel, Object payload) {
SimpleMessagingGateway gateway = new SimpleMessagingGateway();
@@ -86,6 +104,10 @@ public class ServiceActivatorParserTests {
public String caps(String s) {
return s.toUpperCase();
}
public String concat(String s1, String s2) {
return s1 + s2;
}
}
@@ -97,4 +119,26 @@ public class ServiceActivatorParserTests {
}
}
@SuppressWarnings("unused")
private static class TestPerson {
private String firstName;
private String lastName;
public TestPerson(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
}
}