View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.atom;
8   
9   import org.mule.tck.functional.CounterCallback;
10  import org.mule.tck.functional.FunctionalTestComponent;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertEquals;
16  import static org.junit.Assert.assertTrue;
17  
18  public class HttpOnlyFeedConsumeAndSplitTestCase extends FunctionalTestCase
19  {
20  
21      private static final long SLEEP_TIME = 10000;
22  
23      private final CounterCallback counter = new CounterCallback();
24  
25      @Override
26      protected String getConfigResources()
27      {
28          return "http-only-consume-and-split.xml";
29      }
30  
31      @Override
32      protected void doSetUp() throws Exception
33      {
34          FunctionalTestComponent comp = (FunctionalTestComponent)getComponent("feedConsumer");
35          comp.setEventCallback(counter);
36      }
37  
38      @Test
39      public void testConsume() throws Exception
40      {
41          // wait until the polling kicks in
42          Thread.sleep(SLEEP_TIME);
43  
44          int count = counter.getCallbackCount();
45          assertTrue("did not receive any artices from feed", count > 0);
46  
47          // wait a bit more for the connector to poll again
48          Thread.sleep(SLEEP_TIME);
49          //We should only receive entries once
50          assertEquals(count, counter.getCallbackCount());
51      }
52  
53  }