1   /*
2    * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3    * Copyright (C) 2003-2007 Frederico Caldeira Knabben
4    * 
5    * == BEGIN LICENSE ==
6    * 
7    * Licensed under the terms of any of the following licenses at your
8    * choice:
9    * 
10   *  - GNU General Public License Version 2 or later (the "GPL")
11   *    http://www.gnu.org/licenses/gpl.html
12   * 
13   *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14   *    http://www.gnu.org/licenses/lgpl.html
15   * 
16   *  - Mozilla Public License Version 1.1 or later (the "MPL")
17   *    http://www.mozilla.org/MPL/MPL-1.1.html
18   * 
19   * == END LICENSE ==
20   */
21  package net.fckeditor.handlers;
22  
23  import static org.junit.Assert.assertFalse;
24  import static org.junit.Assert.assertTrue;
25  
26  import org.junit.Test;
27  
28  /**
29   * Tests for {@link ExtensionsHandler}.
30   *
31   * @version $Id: ExtensionsHandlerTest.java 2168 2008-07-03 21:47:29Z mosipov $
32   */
33  public class ExtensionsHandlerTest {
34  	
35  	@Test
36  	public void testIsAllowed01() {
37  		ResourceTypeHandler type = ResourceTypeHandler.FILE;
38  		ExtensionsHandler.setExtensionsAllowed(type, "a");
39  		ExtensionsHandler.setExtensionsDenied(type, "b");
40  		assertTrue(ExtensionsHandler.getExtensionsAllowed(type).isEmpty());
41  		assertTrue(ExtensionsHandler.getExtensionsDenied(type).contains("b"));
42  		assertFalse(ExtensionsHandler.isAllowed(type, "b"));
43  		assertTrue(ExtensionsHandler.isAllowed(type, "a"));
44  		assertTrue(ExtensionsHandler.isAllowed(type, "c"));
45  	}
46  	
47  	@Test
48  	public void testIsAllowed02() {
49  		ResourceTypeHandler type = ResourceTypeHandler.FILE;
50  		ExtensionsHandler.setExtensionsAllowed(type, "a|b|c");
51  		assertTrue(ExtensionsHandler.isAllowed(type, "a"));
52  		assertTrue(ExtensionsHandler.isAllowed(type, "b"));
53  		assertTrue(ExtensionsHandler.isAllowed(type, "c"));
54  		assertFalse(ExtensionsHandler.isAllowed(type, "d"));
55  	}
56  
57  }