fileInbound.start();
Session<FTPFile> session = mock(Session.class); when(sessionFactory.getSession()).thenReturn(session); fileInbound.start();
@Before public void beforeTest() throws IOException { smtpServer.getMessages().clear(); tearDown(); this.fileInboundChannelAdapter.start(); }
this.jmsInboundChannelAdapter.start();
@Override public void start() { if (this.adapter != null) { this.adapter.start(); } }
@Test public void testWithSPCADefaultErrorChannel() throws Exception { CountDownLatch errorLatch = new CountDownLatch(1); errorChannel.subscribe(message -> errorLatch.countDown()); inboundAdapterDefaultErrorChannel.start(); assertTrue(errorLatch.await(10, TimeUnit.SECONDS)); inboundAdapterDefaultErrorChannel.stop(); }
@Test public void testWithSPCAAssignedErrorChannel() throws Exception { CountDownLatch errorLatch = new CountDownLatch(1); assignedErrorChannel.subscribe(message -> errorLatch.countDown()); inboundAdapterAssignedErrorChannel.start(); assertTrue(errorLatch.await(10, TimeUnit.SECONDS)); inboundAdapterAssignedErrorChannel.stop(); }
@Test public void testWithErrorChannelAndHeader() { ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass()); SourcePollingChannelAdapter adapter = ac.getBean("withErrorChannelAndHeader", SourcePollingChannelAdapter.class); adapter.start(); PollableChannel errorChannel = ac.getBean("eChannel", PollableChannel.class); assertNotNull(errorChannel.receive(10000)); adapter.stop(); ac.close(); }
@Test public void testWithErrorChannel() throws Exception { ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass()); SourcePollingChannelAdapter adapter = ac.getBean("withErrorChannel", SourcePollingChannelAdapter.class); adapter.start(); PollableChannel errorChannel = ac.getBean("eChannel", PollableChannel.class); assertNotNull(errorChannel.receive(10000)); adapter.stop(); ac.close(); }
@Test public void pollDefaultAdapter() throws Exception { adapterDefault.start(); Message<?> result = channel1.receive(testTimeout); assertNotNull(result); assertEquals(HashMap.class, result.getPayload().getClass()); @SuppressWarnings("unchecked") Map<String, Object> beans = (Map<String, Object>) result.getPayload(); // test for a couple of MBeans assertTrue(beans.containsKey("java.lang:type=OperatingSystem")); assertTrue(beans.containsKey("java.lang:type=Runtime")); adapterDefault.stop(); }
@Test public void pollForAttribute() throws Exception { this.testBean.test("foo"); this.adapter.start(); Message<?> result = this.channel.receive(10000); assertNotNull(result); assertEquals("foo", result.getPayload()); }
@Test @MongoDbAvailable public void testWithStringQueryExpression() throws Exception { this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoInboundAdapterWithStringQueryExpression.start(); @SuppressWarnings("unchecked") Message<List<Person>> message = (Message<List<Person>>) replyChannel.receive(10000); assertNotNull(message); assertEquals("Bob", message.getPayload().get(0).getName()); this.mongoInboundAdapterWithStringQueryExpression.stop(); }
@Test @MongoDbAvailable public void testWithNamedCollection() throws Exception { this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoInboundAdapterWithNamedCollection.start(); @SuppressWarnings("unchecked") Message<List<Person>> message = (Message<List<Person>>) replyChannel.receive(10000); assertNotNull(message); assertEquals("Bob", message.getPayload().get(0).getName()); this.mongoInboundAdapterWithNamedCollection.stop(); this.replyChannel.purge(null); }
@Test @MongoDbAvailable public void testWithNamedCollectionExpression() throws Exception { this.mongoTemplate.save(this.createPerson("Bob"), "foo"); this.mongoInboundAdapterWithNamedCollectionExpression.start(); @SuppressWarnings("unchecked") Message<List<Person>> message = (Message<List<Person>>) replyChannel.receive(10000); assertNotNull(message); assertEquals("Bob", message.getPayload().get(0).getName()); this.mongoInboundAdapterWithNamedCollectionExpression.stop(); this.replyChannel.purge(null); }
@Test @MongoDbAvailable public void testWithNamedMongoFactory() throws Exception { this.mongoTemplate.save(this.createPerson("Bob"), "data"); this.mongoInboundAdapterNamedFactory.start(); @SuppressWarnings("unchecked") Message<List<Document>> message = (Message<List<Document>>) replyChannel.receive(10000); assertNotNull(message); assertEquals("Bob", message.getPayload().get(0).get("name")); this.mongoInboundAdapterNamedFactory.stop(); this.replyChannel.purge(null); }
@Test @MongoDbAvailable public void testWithDefaultMongoFactory() throws Exception { this.mongoTemplate.save(createPerson("Bob"), "data"); this.mongoInboundAdapter.start(); @SuppressWarnings("unchecked") Message<List<Person>> message = (Message<List<Person>>) replyChannel.receive(10000); assertNotNull(message); assertEquals("Bob", message.getPayload().get(0).getName()); assertNotNull(this.replyChannel.receive(10000)); this.mongoInboundAdapter.stop(); this.replyChannel.purge(null); }
@Test @MongoDbAvailable public void testWithMongoConverter() throws Exception { this.mongoTemplate.save(this.createPerson("Bob"), "data"); this.mongoInboundAdapterWithConverter.start(); @SuppressWarnings("unchecked") Message<List<Person>> message = (Message<List<Person>>) replyChannel.receive(10000); assertNotNull(message); assertEquals("Bob", message.getPayload().get(0).getName()); assertNotNull(replyChannel.receive(10000)); this.mongoInboundAdapterWithConverter.stop(); this.replyChannel.purge(null); }
@Test @MongoDbAvailable public void testWithMongoTemplate() throws Exception { this.mongoTemplate.save(this.createPerson("Bob"), "data"); this.mongoInboundAdapterWithTemplate.start(); @SuppressWarnings("unchecked") Message<Person> message = (Message<Person>) replyChannel.receive(10000); assertNotNull(message); assertEquals("Bob", message.getPayload().getName()); this.mongoInboundAdapterWithTemplate.stop(); this.replyChannel.purge(null); }
@Test @MongoDbAvailable public void testWithOnSuccessDisposition() throws Exception { this.mongoTemplate.save(createPerson("Bob"), "data"); this.inboundAdapterWithOnSuccessDisposition.start(); assertNotNull(replyChannel.receive(10000)); assertNull(replyChannel.receive(100)); assertNotNull(this.afterCommitChannel.receive(10000)); assertNull(this.mongoTemplate.findOne(new Query(Criteria.where("name").is("Bob")), Person.class, "data")); this.inboundAdapterWithOnSuccessDisposition.stop(); this.replyChannel.purge(null); }