1   /*
2    * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3    * Copyright (C) 2004-2010 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.assertEquals;
24  import static org.junit.Assert.assertFalse;
25  import static org.junit.Assert.assertNotSame;
26  import static org.junit.Assert.assertNull;
27  
28  import org.junit.Test;
29  
30  /**
31   * Tests for {@link ResourceTypeHandler}.
32   * 
33   * @version $Id: ResourceTypeTest.java 1585 2008-02-21 18:13:09Z th-schwarz $
34   */
35  public class ResourceTypeTest {
36  
37  	@Test
38  	public void getType01() throws Exception {
39  		assertNull(ResourceType.getResourceType("xyz"));
40  	}
41  
42  	@Test
43  	public void getType02() throws Exception {
44  		assertEquals(ResourceType.FILE, ResourceType.getResourceType("File"));
45  	}
46  
47  	@Test
48  	public void getType03() throws Exception {
49  		assertNotSame(ResourceType.IMAGE, ResourceType.getResourceType("ImaGe"));
50  	}
51  	
52  	@Test
53  	public void getType04() throws Exception {
54  		assertNull(ResourceType.getResourceType(null));
55  	}
56  	
57  	@Test
58  	public void getType05() throws Exception {
59  		assertNull(ResourceType.getResourceType(""));
60  	}
61  	
62  	@Test
63  	public void isValid01() throws Exception {
64  		assertFalse(ResourceType.isValidType("1234"));
65  	}
66  
67  	@Test
68  	public void isValid02() throws Exception {
69  		assertFalse(ResourceType.isValidType("fLash"));
70  	}
71  
72  	@Test
73  	public void isValid03() throws Exception {
74  		assertFalse(ResourceType.isValidType("MeDiA"));
75  	}
76  
77  	@Test
78  	public void getDefaultType01() throws Exception {
79  		assertEquals(ResourceType.FILE, ResourceType
80  				.getDefaultResourceType("wrong-type"));
81  	}
82  
83  	@Test
84  	public void getDefaultType02() throws Exception {
85  		assertNotSame(ResourceType.FLASH, ResourceType
86  				.getDefaultResourceType("flAsh"));
87  	}
88  	
89  	@Test
90  	public void getDefaultType03() throws Exception {
91  		assertEquals(ResourceType.FILE, ResourceType
92  				.getDefaultResourceType(null));
93  	}
94  	
95  	@Test
96  	public void getDefaultType04() throws Exception {
97  		assertEquals(ResourceType.FILE, ResourceType
98  				.getDefaultResourceType(""));
99  	}
100 	
101 	@Test
102 	public void getDefaultType05() throws Exception {
103 		assertNotSame(ResourceType.FILE, ResourceType
104 				.getDefaultResourceType("Image"));
105 	}
106 }