Fix MongoDbICAdapterIntTests race condition
Partial back port from c0a507c36c
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
query="{'name' : 'Bob'}"
|
||||
entity-class="java.lang.Object"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="100" />
|
||||
<int:poller fixed-delay="100" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterNamedFactory"
|
||||
@@ -26,7 +26,7 @@
|
||||
channel="replyChannel"
|
||||
query="{'name' : 'Bob'}"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="5000" />
|
||||
<int:poller fixed-delay="5000" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterWithTemplate"
|
||||
@@ -36,7 +36,7 @@
|
||||
expect-single-result="true"
|
||||
entity-class="org.springframework.integration.mongodb.rules.MongoDbAvailableTests.Person"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="5000" />
|
||||
<int:poller fixed-delay="5000" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterWithNamedCollection"
|
||||
@@ -46,7 +46,7 @@
|
||||
query="{'name' : 'Bob'}"
|
||||
entity-class="java.lang.Object"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="5000" />
|
||||
<int:poller fixed-delay="5000" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterWithStringQueryExpression"
|
||||
channel="replyChannel"
|
||||
@@ -55,7 +55,7 @@
|
||||
query-expression="new String('{''name'' : ''Bob''}')"
|
||||
entity-class="java.lang.Object"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="5000" />
|
||||
<int:poller fixed-delay="5000" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterWithQueryExpression"
|
||||
@@ -65,7 +65,7 @@
|
||||
query-expression="new BasicQuery('{''name'' : ''Bob''}').limit(1)"
|
||||
entity-class="java.lang.Object"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="5000" />
|
||||
<int:poller fixed-delay="5000" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterWithNamedCollectionExpression"
|
||||
@@ -75,7 +75,7 @@
|
||||
query="{'name' : 'Bob'}"
|
||||
entity-class="java.lang.Object"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="5000" />
|
||||
<int:poller fixed-delay="5000" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="inboundAdapterWithOnSuccessDisposition"
|
||||
@@ -83,7 +83,7 @@
|
||||
query="{'name' : 'Bob'}"
|
||||
auto-startup="false">
|
||||
|
||||
<int:poller fixed-rate="200" max-messages-per-poll="1">
|
||||
<int:poller fixed-delay="200" max-messages-per-poll="1">
|
||||
<int:advice-chain synchronization-factory="syncFactory">
|
||||
<bean
|
||||
class="org.springframework.integration.mongodb.config.MongoDbInboundChannelAdapterIntegrationTests.TestMessageSourceAdvice" />
|
||||
@@ -97,16 +97,21 @@
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<int:transaction-synchronization-factory id="syncFactory">
|
||||
<int:after-commit expression="@documentCleaner.remove(#mongoTemplate, payload, headers.mongo_collectionName)" />
|
||||
<int:before-commit expression="@documentCleaner.remove(#mongoTemplate, payload, headers.mongo_collectionName)"/>
|
||||
<int:after-commit channel="afterCommitChannel"/>
|
||||
</int:transaction-synchronization-factory>
|
||||
|
||||
<int:channel id="afterCommitChannel">
|
||||
<int:queue />
|
||||
</int:channel>
|
||||
|
||||
<int-mongodb:inbound-channel-adapter id="mongoInboundAdapterWithConverter"
|
||||
channel="replyChannel"
|
||||
query="{'name' : 'Bob'}"
|
||||
entity-class="java.lang.Object"
|
||||
mongo-converter="mongoConverter"
|
||||
auto-startup="false">
|
||||
<int:poller fixed-rate="100" />
|
||||
<int:poller fixed-delay="100" />
|
||||
</int-mongodb:inbound-channel-adapter>
|
||||
|
||||
<bean id="documentCleaner"
|
||||
|
||||
@@ -35,12 +35,12 @@ import org.springframework.data.mongodb.core.query.BasicQuery;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.integration.aop.AbstractMessageSourceAdvice;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailable;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailableTests;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -63,7 +63,10 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Autowired
|
||||
private PollableChannel replyChannel;
|
||||
private QueueChannel replyChannel;
|
||||
|
||||
@Autowired
|
||||
private QueueChannel afterCommitChannel;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mongoInboundAdapter")
|
||||
@@ -115,6 +118,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
assertNotNull(this.replyChannel.receive(10000));
|
||||
|
||||
this.mongoInboundAdapter.stop();
|
||||
this.replyChannel.purge(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,6 +134,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
assertEquals("Bob", message.getPayload().get(0).get("name"));
|
||||
|
||||
this.mongoInboundAdapterNamedFactory.stop();
|
||||
this.replyChannel.purge(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,6 +150,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
assertEquals("Bob", message.getPayload().getName());
|
||||
|
||||
this.mongoInboundAdapterWithTemplate.stop();
|
||||
this.replyChannel.purge(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,6 +166,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
assertEquals("Bob", message.getPayload().get(0).getName());
|
||||
|
||||
this.mongoInboundAdapterWithNamedCollection.stop();
|
||||
this.replyChannel.purge(null);
|
||||
}
|
||||
@Test
|
||||
@MongoDbAvailable
|
||||
@@ -199,6 +206,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
assertEquals("Bob", message.getPayload().get(0).getName());
|
||||
|
||||
this.mongoInboundAdapterWithNamedCollectionExpression.stop();
|
||||
this.replyChannel.purge(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -213,7 +221,10 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
|
||||
this.inboundAdapterWithOnSuccessDisposition.stop();
|
||||
|
||||
assertNotNull(this.afterCommitChannel.receive(10000));
|
||||
|
||||
assertNull(this.mongoTemplate.findOne(new Query(Criteria.where("name").is("Bob")), Person.class, "data"));
|
||||
this.replyChannel.purge(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -230,6 +241,7 @@ public class MongoDbInboundChannelAdapterIntegrationTests extends MongoDbAvailab
|
||||
assertNotNull(replyChannel.receive(10000));
|
||||
|
||||
this.mongoInboundAdapterWithConverter.stop();
|
||||
this.replyChannel.purge(null);
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
|
||||
Reference in New Issue
Block a user