MessageEndpoint no longer extends the MessageTarget interface.
This commit is contained in:
@@ -1,9 +1,24 @@
|
||||
/*
|
||||
* Copyright 2002-2008 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.adapter.mail;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import javax.mail.internet.MimeMessage;
|
||||
@@ -12,15 +27,13 @@ import org.easymock.classextension.EasyMock;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageTarget;
|
||||
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jonas Partner
|
||||
*
|
||||
*/
|
||||
public class SubscribableMailSourceTests {
|
||||
|
||||
@@ -34,24 +47,19 @@ public class SubscribableMailSourceTests {
|
||||
@Test
|
||||
public void testReceive() throws Exception {
|
||||
javax.mail.Message message = EasyMock.createMock(MimeMessage.class);
|
||||
StubFolderConnection folderConnection = new StubFolderConnection(
|
||||
message);
|
||||
StubTarget target = new StubTarget();
|
||||
|
||||
SubscribableMailSource mailSource = new SubscribableMailSource(
|
||||
folderConnection, executor);
|
||||
mailSource.subscribe(target);
|
||||
StubFolderConnection folderConnection = new StubFolderConnection(message);
|
||||
QueueChannel channel = new QueueChannel();
|
||||
SubscribableMailSource mailSource = new SubscribableMailSource(folderConnection, executor);
|
||||
mailSource.setOutputChannel(channel);
|
||||
mailSource.setConverter(new StubMessageConvertor());
|
||||
|
||||
mailSource.start();
|
||||
Thread.sleep(1000);
|
||||
Message<?> result = channel.receive(1000);
|
||||
mailSource.stop();
|
||||
|
||||
assertEquals("Wrong message count", 1, target.messages.size());
|
||||
assertEquals("Wrong payload", message, target.messages.get(0)
|
||||
.getPayload());
|
||||
assertNotNull(result);
|
||||
assertEquals("Wrong payload", message, result.getPayload());
|
||||
}
|
||||
|
||||
|
||||
private static class StubFolderConnection implements FolderConnection {
|
||||
|
||||
ConcurrentLinkedQueue<javax.mail.Message> messages = new ConcurrentLinkedQueue<javax.mail.Message>();
|
||||
@@ -73,25 +81,12 @@ public class SubscribableMailSourceTests {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class StubTarget implements MessageTarget {
|
||||
|
||||
List<Message<?>> messages = new ArrayList<Message<?>>();
|
||||
|
||||
public boolean send(Message<?> message) {
|
||||
messages.add(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class StubMessageConvertor implements MailMessageConverter {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user