58
58
import org .apache .commons .logging .Log ;
59
59
import org .junit .After ;
60
60
import org .junit .Before ;
61
- import org .junit .Ignore ;
62
- import org .junit .Rule ;
61
+ import org .junit .ClassRule ;
63
62
import org .junit .Test ;
64
63
import org .junit .runner .RunWith ;
65
64
import org .mockito .Mockito ;
102
101
@ DirtiesContext
103
102
public class ImapMailReceiverTests {
104
103
105
- private final ImapServer imapIdleServer = TestMailServer .imap (0 );
104
+ @ ClassRule
105
+ public static final LongRunningIntegrationTest longTests = new LongRunningIntegrationTest ();
106
106
107
- @ Rule
108
- public final LongRunningIntegrationTest longRunningIntegrationTest = new LongRunningIntegrationTest ();
109
-
110
- private final AtomicInteger failed = new AtomicInteger (0 );
107
+ private AtomicInteger failed ;
111
108
109
+ private ImapServer imapIdleServer ;
112
110
113
111
@ Autowired
114
112
private ApplicationContext context ;
115
113
116
114
@ Before
117
115
public void setup () throws InterruptedException {
116
+ failed = new AtomicInteger (0 );
117
+ this .imapIdleServer = TestMailServer .imap (0 );
118
118
int n = 0 ;
119
119
while (n ++ < 100 && (!this .imapIdleServer .isListening ())) {
120
120
Thread .sleep (100 );
@@ -182,7 +182,6 @@ public void testIdleWithServerGuts(ImapMailReceiver receiver, boolean mapped) th
182
182
}
183
183
184
184
public void testIdleWithServerGuts (ImapMailReceiver receiver , boolean mapped , boolean simple ) throws Exception {
185
- this .imapIdleServer .resetServer ();
186
185
Properties mailProps = new Properties ();
187
186
mailProps .put ("mail.debug" , "true" );
188
187
mailProps .put ("mail.imap.connectionpool.debug" , "true" );
@@ -458,7 +457,6 @@ public void receiveAndIgnoreMarkAsReadDontDelete() throws Exception {
458
457
}
459
458
460
459
@ Test
461
- @ Ignore
462
460
public void testMessageHistory () throws Exception {
463
461
ImapIdleChannelAdapter adapter = this .context .getBean ("simpleAdapter" , ImapIdleChannelAdapter .class );
464
462
adapter .setReconnectDelay (1 );
@@ -480,6 +478,7 @@ public void testMessageHistory() throws Exception {
480
478
DirectFieldAccessor accessor = new DirectFieldAccessor ((invocation .getMock ()));
481
479
IMAPFolder folder = mock (IMAPFolder .class );
482
480
accessor .setPropertyValue ("folder" , folder );
481
+ given (folder .isOpen ()).willReturn (true );
483
482
given (folder .hasNewMessages ()).willReturn (true );
484
483
return null ;
485
484
}).given (receiver ).openFolder ();
@@ -712,7 +711,6 @@ public void testConnectionException() throws Exception {
712
711
713
712
@ Test // see INT-1801
714
713
public void testImapLifecycleForRaceCondition () throws Exception {
715
-
716
714
for (int i = 0 ; i < 1000 ; i ++) {
717
715
final ImapMailReceiver receiver = new ImapMailReceiver ("imap://foo" );
718
716
Store store = mock (Store .class );
0 commit comments