1   /*
2    * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3    * Copyright (C) 2003-2008 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.tool;
22  
23  import static org.junit.Assert.*;
24  
25  import org.junit.Test;
26  
27  /**
28   * Tests for {@link XHtmlTagTool}.
29   *
30   * @version $Id: XHtmlTagToolTest.java 1679 2008-03-04 13:12:31Z mosipov $
31   */
32  public class XHtmlTagToolTest {
33  
34  	@Test
35  	public void testClosingTag01() throws Exception {
36  	    XHtmlTagTool tag = new XHtmlTagTool("test");
37  	    assertEquals("<test />", tag.toString());
38      }
39  	
40  	@Test
41  	public void testClosingTag02() throws Exception {
42  	    XHtmlTagTool tag = new XHtmlTagTool("test", "");
43  	    assertEquals("<test />", tag.toString());
44      }
45  
46  	@Test
47  	public void testClosingTag03() throws Exception {
48  	    XHtmlTagTool tag = new XHtmlTagTool("test", "val");
49  	    assertEquals("<test>val</test>", tag.toString());
50      }
51  	
52  	@Test
53  	public void testClosingTag04() throws Exception {
54  	    XHtmlTagTool tag = new XHtmlTagTool("test", XHtmlTagTool.SPACE);
55  	    assertEquals("<test> </test>", tag.toString());
56      }
57  	
58  	@Test
59  	public void deepEquals01() throws Exception {
60  		XHtmlTagTool expected = new XHtmlTagTool("tag", "some text");
61  		XHtmlTagTool actual = new XHtmlTagTool("tag", "some text");
62  		assertEquals(expected, actual);
63  	}
64  	
65  	@Test
66  	public void deepEquals02() throws Exception {
67  		XHtmlTagTool unexpected = new XHtmlTagTool("tag", "");
68  		XHtmlTagTool actual = new XHtmlTagTool("tag", XHtmlTagTool.SPACE);
69  		assertNotSame(unexpected, actual);
70  	}
71  	
72  	@Test
73  	public void deepEquals03() throws Exception {
74  		XHtmlTagTool expected = new XHtmlTagTool("tag", "some text");
75  		expected.addAttribute("id", "some_tag_id");
76  		expected.addAttribute("class", "grayShadow");
77  		expected.addAttribute("style", "color: red");
78  		
79  		XHtmlTagTool actual = new XHtmlTagTool("tag", "some text");
80  		
81  		actual.addAttribute("style", "color: red");
82  		actual.addAttribute("id", "some_tag_id");
83  		actual.addAttribute("class", "grayShadow");
84  		
85  		assertEquals(expected, actual);
86  	}
87  	
88  	@Test
89  	public void deepEquals04() throws Exception {
90  		XHtmlTagTool unexpected = new XHtmlTagTool("tag");
91  		unexpected.addAttribute("id", "some_tag_id");
92  		unexpected.addAttribute("class", "grayShadow");
93  		unexpected.addAttribute("style", "color: red");
94  		
95  		XHtmlTagTool actual = new XHtmlTagTool("tag");
96  		
97  		actual.addAttribute("id", "some_tag_id");
98  		actual.addAttribute("class", "grayShadow");
99  		actual.addAttribute("style", "color: blue");
100 		
101 		assertNotSame(unexpected, actual);
102 	}
103 }