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.module.atom.event.EntryReceiver;
10  import org.mule.tck.junit4.FunctionalTestCase;
11  
12  import java.io.File;
13  import java.io.FileOutputStream;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  
19  public class FileAtomFeedConsumeTestCase extends FunctionalTestCase
20  {
21  
22      @Override
23      protected String getConfigResources()
24      {
25          return "file-atom-consume.xml";
26      }
27  
28      @Test
29      public void testConsumeFeedEntries() throws Exception
30      {
31          FileOutputStream fos = new FileOutputStream(new File(muleContext.getConfiguration().getWorkingDirectory(), "sample-feed.atom"));
32          String feed = loadResourceAsString("sample-feed.atom");
33          fos.write(feed.getBytes("UTF-8"));
34          fos.close();
35  
36          //allow the file connector to poll a couple of times to ensure we only get the same 25 entries
37          Thread.sleep(5000);
38          EntryReceiver component = (EntryReceiver)getComponent("feedSplitterConsumer");
39          assertEquals(25, component.getCount());
40      }
41  
42  }