INT-2916 - Upgrade to JUnit 4.11 in support of JDK7
For reference see: https://jira.springsource.org/browse/INT-2916 Changes: * INT-2919 - Upgrade Spring Data Gemfire to 1.2.2.RELEASE * Exclude Hamcrest transitive dependency from JUnit (as already explicitly declared) * Set sourceCompatibility in build.gradle to 1.6 * Set targetCompatibility in build.gradle to 1.6 * Upgrade Hamcrest to 1.3 and fix deprications - Corematcher is(*class) change to is(instanceOf(*class)) - Change org.junit.internal.matchers.TypeSafeMatcher to org.hamcrest.TypeSafeMatcher - Change import org.junit.matchers.JUnitMatchers.containsString to org.hamcrest.CoreMatchers.containsString - Change import org.junit.matchers.JUnitMatchers.both to org.hamcrest.CoreMatchers.both - Change import org.junit.matchers.JUnitMatchers.containsString to org.hamcrest.CoreMatchers.containsString * Fix JUnit deprecations - changed junit.framework.Assert to org.junit.Assert * Add few missing licenses headers to tests * Marked several test classes with: @DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD) - SplitterIntegrationTests - GatewayInvokingMessageHandlerTests - FileToChannelIntegrationTests - FileInboundChannelAdapterWithRecursiveDirectoryTests - JdbcMessageStoreChannelTests - ChatMessageInboundChannelAdapterParserTests * 3 Tests ignored (Still needs to be addressed): - testOperationOnPrototypeBean - testFailOperationWithCustomScope - testOperationOfControlBus * Update SQL script (test-failure): - spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/outboundSchema.sql - add drop table statements - add ignore-failures="DROPS" to "jdbcOutboundChannelAdapterCommonConfig.xml" INT-2916 - Code Review Changes INT-2916 - Fix ignored Tests Fix 3 previously ignored tests in *GroovyControlBusTests*: * testOperationOnPrototypeBean * testFailOperationWithCustomScope * testOperationOfControlBus INT-2916 - CI Build Testing INT-2963 - Remove JDK7 Compilation Warnings * Upgrade Mockito to 1.9.5 * Fix failing SubscribableJmsChannelTests INT-2916 - Standardize Hamcrest assertions Ensure Hamcrest assertions are standardized to: is(instanceOf(...))
This commit is contained in:
committed by
Gary Russell
parent
3c98b371fa
commit
0271acaf4c
@@ -30,12 +30,12 @@ import static org.hamcrest.CoreMatchers.is;
|
||||
/**
|
||||
* <h2>Are the {@link MessageHeaders} of a {@link Message} containing any entry
|
||||
* or multiple that match?</h2>
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* <h3>
|
||||
* For example using {@link Assert#assertThat(Object, Matcher)} for a single
|
||||
* entry:</h3>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* ANY_HEADER_KEY = "foo";
|
||||
* ANY_HEADER_VALUE = "bar";
|
||||
@@ -44,28 +44,28 @@ import static org.hamcrest.CoreMatchers.is;
|
||||
* assertThat(message, hasEntry(ANY_HEADER_KEY, notNullValue()));
|
||||
* assertThat(message, hasEntry(ANY_HEADER_KEY, is(ANY_HEADER_VALUE)));
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <h3>For multiple entries to match all:</h3>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* Map<String, Object> expectedInHeaderMap = new HashMap<String, Object>();
|
||||
* expectedInHeaderMap.put(ANY_HEADER_KEY, ANY_HEADER_VALUE);
|
||||
* expectedInHeaderMap.put(OTHER_HEADER_KEY, is(OTHER_HEADER_VALUE));
|
||||
* assertThat(message, HeaderMatcher.hasAllEntries(expectedInHeaderMap));
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <h3>
|
||||
* For a single key:</h3>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* ANY_HEADER_KEY = "foo";
|
||||
* assertThat(message, HeaderMatcher.hasKey(ANY_HEADER_KEY));
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Alex Peters
|
||||
* @author Iwein Fuld
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class HeaderMatcher extends TypeSafeMatcher<Message<?>> {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,33 +32,34 @@ import org.hamcrest.core.IsEqual;
|
||||
* <p>
|
||||
* It is possible to match a single entry by value or matcher like this:
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* assertThat(map, hasEntry(SOME_KEY, is(SOME_VALUE)));
|
||||
* assertThat(map, hasEntry(SOME_KEY, is(String.class)));
|
||||
* assertThat(map, hasEntry(SOME_KEY, notNullValue()));
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* It's also possible to match multiple entries in a map:
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* Map<String, Object> expectedInMap = new HashMap<String, Object>();
|
||||
* expectedInMap.put(SOME_KEY, SOME_VALUE);
|
||||
* expectedInMap.put(OTHER_KEY, is(OTHER_VALUE));
|
||||
* assertThat(map, hasAllEntries(expectedInMap));
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>If you only need to verify the existence of a key:</p>
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* assertThat(map, hasKey(SOME_KEY));
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author Alex Peters
|
||||
* @author Iwein Fuld
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
*
|
||||
*/
|
||||
public class MapContentMatchers<T, V> extends
|
||||
TypeSafeMatcher<Map<? super T, ? super V>> {
|
||||
@@ -123,7 +124,7 @@ public class MapContentMatchers<T, V> extends
|
||||
}
|
||||
|
||||
@Factory
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static <T, V> Matcher<Map<? super T, ? super V>> hasAllEntries(
|
||||
Map<T, V> entries) {
|
||||
List<Matcher<? extends Map<? super T, ? super V>>> matchers = new ArrayList<Matcher<? extends Map<? super T, ? super V>>>(
|
||||
@@ -137,6 +138,7 @@ public class MapContentMatchers<T, V> extends
|
||||
matchers.add(hasEntry(entry.getKey(), value));
|
||||
}
|
||||
}
|
||||
return AllOf.allOf(matchers);
|
||||
//return AllOf.allOf(matchers); //Does not work with Hamcrest 1.3
|
||||
return new AllOf(matchers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,13 @@
|
||||
|
||||
package org.springframework.integration.test.matcher;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.anything;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.any;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.integration.test.matcher.HeaderMatcher.hasAllHeaders;
|
||||
@@ -47,7 +49,8 @@ import org.springframework.integration.support.MessageBuilder;
|
||||
/**
|
||||
* @author Alex Peters
|
||||
* @author Iwein Fuld
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
*
|
||||
*/
|
||||
public class HeaderMatcherTests {
|
||||
|
||||
@@ -84,14 +87,14 @@ public class HeaderMatcherTests {
|
||||
|
||||
@Test
|
||||
public void hasEntry_withValidKeyAndMatcherValue_matches() throws Exception {
|
||||
assertThat(message, hasHeader(ANY_HEADER_KEY, is(String.class)));
|
||||
assertThat(message, hasHeader(ANY_HEADER_KEY, is(instanceOf(String.class))));
|
||||
assertThat(message, hasHeader(ANY_HEADER_KEY, notNullValue()));
|
||||
assertThat(message, hasHeader(ANY_HEADER_KEY, is(ANY_HEADER_VALUE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasEntry_withValidKeyAndMatcherValue_notMatching() throws Exception {
|
||||
assertThat(message, not(hasHeader(ANY_HEADER_KEY, is(Integer.class))));
|
||||
assertThat(message, not(hasHeader(ANY_HEADER_KEY, is(instanceOf(Integer.class)))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -186,11 +189,13 @@ public class HeaderMatcherTests {
|
||||
|
||||
@Test
|
||||
public void hasExpirationDate_() throws Exception {
|
||||
Matcher<Long> anyMatcher = anything();
|
||||
Matcher<Long> anyMatcher = any(Long.class);
|
||||
|
||||
assertThat(message, not(hasExpirationDate(anyMatcher)));
|
||||
Date expirationDate = new Date(System.currentTimeMillis() + 10000);
|
||||
message = MessageBuilder.fromMessage(message).setExpirationDate(expirationDate).build();
|
||||
assertThat(message, hasExpirationDate(expirationDate));
|
||||
assertThat(message, hasExpirationDate(not(is((System.currentTimeMillis())))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration.test.matcher;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
@@ -17,7 +33,8 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Alex Peters
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
*
|
||||
*/
|
||||
public class MapContainsTests {
|
||||
|
||||
@@ -64,14 +81,14 @@ public class MapContainsTests {
|
||||
|
||||
@Test
|
||||
public void hasEntry_withValidKeyAndMatcherValue_matches() throws Exception {
|
||||
assertThat(map, hasEntry(SOME_KEY, is(String.class)));
|
||||
assertThat(map, hasEntry(SOME_KEY, is(instanceOf(String.class))));
|
||||
assertThat(map, hasEntry(SOME_KEY, notNullValue()));
|
||||
assertThat(map, hasEntry(SOME_KEY, is(SOME_VALUE)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasEntry_withValidKeyAndMatcherValue_notMatching() throws Exception {
|
||||
assertThat(map, not(hasEntry(SOME_KEY, is(Integer.class))));
|
||||
assertThat(map, not(hasEntry(SOME_KEY, is(instanceOf(Integer.class)))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.integration.support.MessageBuilder;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -39,7 +40,8 @@ import static org.springframework.integration.test.matcher.MockitoMessageMatcher
|
||||
/**
|
||||
* @author Alex Peters
|
||||
* @author Iwein Fuld
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
*
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MockitoMessageMatchersTests {
|
||||
@@ -70,7 +72,7 @@ public class MockitoMessageMatchersTests {
|
||||
public void anyMatcher_withVerifyArgumentMatcherAndEqualPayload_matching() throws Exception {
|
||||
handler.handleMessage(message);
|
||||
verify(handler).handleMessage(messageWithPayload(SOME_PAYLOAD));
|
||||
verify(handler).handleMessage(messageWithPayload(is(Date.class)));
|
||||
verify(handler).handleMessage(messageWithPayload(is(instanceOf(Date.class))));
|
||||
}
|
||||
|
||||
@Test(expected = ArgumentsAreDifferent.class)
|
||||
@@ -87,7 +89,7 @@ public class MockitoMessageMatchersTests {
|
||||
|
||||
@Test
|
||||
public void anyMatcher_withWhenAndDifferentPayload_notMatching() throws Exception {
|
||||
when(channel.send(messageWithHeaderEntry(SOME_HEADER_KEY, is(Short.class)))).thenReturn(true);
|
||||
when(channel.send(messageWithHeaderEntry(SOME_HEADER_KEY, is(instanceOf(Short.class))))).thenReturn(true);
|
||||
assertThat(channel.send(message), is(false));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.integration.test.matcher;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -31,6 +32,7 @@ import org.springframework.integration.support.MessageBuilder;
|
||||
/**
|
||||
* @author Alex Peters
|
||||
* @author Iwein Fuld
|
||||
* @author Gunnar Hillert
|
||||
*/
|
||||
public class PayloadMatcherTests {
|
||||
|
||||
@@ -50,17 +52,17 @@ public class PayloadMatcherTests {
|
||||
|
||||
@Test
|
||||
public void hasPayload_withMatcher_matches() throws Exception {
|
||||
assertThat(message,
|
||||
hasPayload(is(BigDecimal.class)));
|
||||
assertThat(message,
|
||||
hasPayload(is(instanceOf(BigDecimal.class))));
|
||||
assertThat(message, hasPayload(notNullValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasPayload_withNotMatchingMatcher_notMatching()
|
||||
throws Exception {
|
||||
assertThat(message, not((hasPayload(is(String.class)))));
|
||||
assertThat(message, not((hasPayload(is(instanceOf(String.class))))));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void readableException() throws Exception {
|
||||
try {
|
||||
|
||||
@@ -1,48 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:i="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<i:channel id="in"/>
|
||||
<int:channel id="in" />
|
||||
|
||||
<i:chain input-channel="in" output-channel="out">
|
||||
<i:filter expression="payload == 'singleAnnotatedMethodOnClass'"/>
|
||||
<i:service-activator ref="singleAnnotatedMethodOnClass"/>
|
||||
</i:chain>
|
||||
<bean id="singleAnnotatedMethodOnClass" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg
|
||||
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleAnnotatedMethodOnClass"/>
|
||||
</bean>
|
||||
<int:chain input-channel="in" output-channel="out">
|
||||
<int:filter expression="payload == 'singleAnnotatedMethodOnClass'" throw-exception-on-rejection="true"/>
|
||||
<int:service-activator ref="singleAnnotatedMethodOnClass" />
|
||||
</int:chain>
|
||||
|
||||
<i:chain input-channel="in" output-channel="out">
|
||||
<i:filter expression="payload == 'SingleMethodOnClass'"/>
|
||||
<i:service-activator ref="singleMethodOnClass"/>
|
||||
</i:chain>
|
||||
<bean id="singleMethodOnClass" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg
|
||||
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleMethodOnClass"/>
|
||||
</bean>
|
||||
<bean id="singleAnnotatedMethodOnClass" class="org.mockito.Mockito"
|
||||
factory-method="mock">
|
||||
<constructor-arg
|
||||
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleAnnotatedMethodOnClass" />
|
||||
</bean>
|
||||
|
||||
<i:chain input-channel="in" output-channel="out">
|
||||
<i:filter expression="payload == 'SingleMethodAcceptingHeaderOnClass'"/>
|
||||
<i:service-activator ref="singleMethodAcceptingHeaderOnClass"/>
|
||||
</i:chain>
|
||||
<bean id="singleMethodAcceptingHeaderOnClass" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg
|
||||
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleMethodAcceptingHeaderOnClass"/>
|
||||
</bean>
|
||||
<int:chain input-channel="in" output-channel="out">
|
||||
<int:filter expression="payload == 'SingleMethodOnClass'" throw-exception-on-rejection="true"/>
|
||||
<int:service-activator ref="singleMethodOnClass" />
|
||||
</int:chain>
|
||||
|
||||
<i:channel id="out">
|
||||
<i:queue capacity="10"/>
|
||||
</i:channel>
|
||||
<bean id="singleMethodOnClass" class="org.mockito.Mockito"
|
||||
factory-method="mock">
|
||||
<constructor-arg
|
||||
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleMethodOnClass" />
|
||||
</bean>
|
||||
|
||||
<int:chain input-channel="in" output-channel="out">
|
||||
<int:filter expression="payload == 'SingleMethodAcceptingHeaderOnClass'" throw-exception-on-rejection="true"/>
|
||||
<int:service-activator ref="singleMethodAcceptingHeaderOnClass" />
|
||||
</int:chain>
|
||||
|
||||
<bean id="singleMethodAcceptingHeaderOnClass" class="org.mockito.Mockito"
|
||||
factory-method="mock">
|
||||
<constructor-arg
|
||||
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleMethodAcceptingHeaderOnClass" />
|
||||
</bean>
|
||||
|
||||
<int:channel id="out">
|
||||
<int:queue capacity="10" />
|
||||
</int:channel>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.test.mockito;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -28,67 +30,66 @@ import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Gunnar Hillert
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class ServiceActivatorOnMockitoMockTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("in")
|
||||
MessageChannel in;
|
||||
@Autowired
|
||||
@Qualifier("in")
|
||||
MessageChannel in;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("out")
|
||||
PollableChannel out;
|
||||
@Autowired
|
||||
@Qualifier("out")
|
||||
PollableChannel out;
|
||||
|
||||
public static class SingleAnnotatedMethodOnClass {
|
||||
@ServiceActivator
|
||||
public String move(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
public static class SingleAnnotatedMethodOnClass {
|
||||
@ServiceActivator
|
||||
public String move(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
SingleAnnotatedMethodOnClass singleAnnotatedMethodOnClass;
|
||||
@Autowired
|
||||
SingleAnnotatedMethodOnClass singleAnnotatedMethodOnClass;
|
||||
|
||||
@Test
|
||||
public void shouldInvokeMockedSingleAnnotatedMethodOnClass() {
|
||||
in.send(MessageBuilder.withPayload("singleAnnotatedMethodOnClass").build());
|
||||
verify(singleAnnotatedMethodOnClass).move("singleAnnotatedMethodOnClass");
|
||||
}
|
||||
@Test
|
||||
public void shouldInvokeMockedSingleAnnotatedMethodOnClass() {
|
||||
in.send(MessageBuilder.withPayload("singleAnnotatedMethodOnClass").build());
|
||||
verify(singleAnnotatedMethodOnClass).move("singleAnnotatedMethodOnClass");
|
||||
}
|
||||
|
||||
public static class SingleMethodOnClass {
|
||||
public String move(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
public static class SingleMethodOnClass {
|
||||
public String move(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
SingleMethodOnClass singleMethodOnClass;
|
||||
@Autowired
|
||||
SingleMethodOnClass singleMethodOnClass;
|
||||
|
||||
@Test
|
||||
public void shouldInvokeMockedSingleMethodOnClass() {
|
||||
in.send(MessageBuilder.withPayload("SingleMethodOnClass").build());
|
||||
verify(singleMethodOnClass).move("SingleMethodOnClass");
|
||||
}
|
||||
@Test
|
||||
public void shouldInvokeMockedSingleMethodOnClass() {
|
||||
in.send(MessageBuilder.withPayload("SingleMethodOnClass").build());
|
||||
verify(singleMethodOnClass).move("SingleMethodOnClass");
|
||||
}
|
||||
|
||||
public static class SingleMethodAcceptingHeaderOnClass {
|
||||
public String move(@Header("s") String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
public static class SingleMethodAcceptingHeaderOnClass {
|
||||
public String move(@Header("s") String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
SingleMethodAcceptingHeaderOnClass singleMethodAcceptingHeaderOnClass;
|
||||
@Autowired
|
||||
SingleMethodAcceptingHeaderOnClass singleMethodAcceptingHeaderOnClass;
|
||||
|
||||
@Test
|
||||
public void shouldInvokeMockedSingleMethodAcceptingHeaderOnClass() {
|
||||
in.send(MessageBuilder.withPayload("SingleMethodAcceptingHeaderOnClass").setHeader("s", "SingleMethodAcceptingHeaderOnClass").build());
|
||||
verify(singleMethodAcceptingHeaderOnClass).move("SingleMethodAcceptingHeaderOnClass");
|
||||
}
|
||||
@Test
|
||||
public void shouldInvokeMockedSingleMethodAcceptingHeaderOnClass() {
|
||||
in.send(MessageBuilder.withPayload("SingleMethodAcceptingHeaderOnClass").setHeader("s", "SingleMethodAcceptingHeaderOnClass").build());
|
||||
verify(singleMethodAcceptingHeaderOnClass).move("SingleMethodAcceptingHeaderOnClass");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.integration.test.util;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
log4j.rootCategory=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%c{1}: %m%n
|
||||
|
||||
log4j.category.org.springframework.integration=WARN
|
||||
Reference in New Issue
Block a user