View Javadoc

1   package com.google.code.jetm.maven.util;
2   
3   import static org.fest.assertions.Assertions.*;
4   import static org.mockito.Mockito.mock;
5   import static org.mockito.Mockito.when;
6   
7   import java.io.File;
8   
9   import org.junit.Test;
10  
11  /**
12   * Unit tests for {@link XmlIOFileFilter}.
13   * 
14   * @author jrh3k5
15   * 
16   */
17  
18  public class XmlIOFileFilterTest {
19      /**
20       * Test that {@link XmlIOFileFilter#accept(File)} only accepts XML files.
21       */
22      @Test
23      public void testAcceptFile() {
24          final XmlIOFileFilter fileFilter = new XmlIOFileFilter();
25  
26          final String xmlFileName = "me.xml";
27          final File xmlFile = mock(File.class);
28          when(xmlFile.getAbsolutePath()).thenReturn(xmlFileName);
29          assertThat(fileFilter.accept(xmlFile)).isTrue();
30  
31          final String txtFileName = "you.txt";
32          final File txtFile = mock(File.class);
33          when(txtFile.getAbsolutePath()).thenReturn(txtFileName);
34          assertThat(fileFilter.accept(txtFile)).isFalse();
35      }
36  
37  }