KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > core > menu > ItemDescriptionTest


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.explorer.core.menu;
27
28 import org.objectweb.util.explorer.core.code.api.CodeDescription;
29 import org.objectweb.util.explorer.core.code.lib.BasicCodeDescription;
30 import org.objectweb.util.explorer.core.menu.api.ItemDescription;
31 import org.objectweb.util.explorer.core.menu.lib.BasicItemDescription;
32
33 import junit.framework.Assert;
34 import junit.framework.TestCase;
35
36 /**
37  *
38  *
39  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
40  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
41  *
42  * @version 0.1
43  */

44 public class ItemDescriptionTest
45      extends TestCase
46 {
47
48     //==================================================================
49
//
50
// Internal States.
51
//
52
// ==================================================================
53

54     protected String JavaDoc l1_="label 1", l2_="label 2";
55     protected CodeDescription codeDesc_ = null;
56     
57     // ==================================================================
58
//
59
// Constructors.
60
//
61
// ==================================================================
62

63     // ==================================================================
64
//
65
// Internal method.
66
//
67
// ==================================================================
68

69     /*
70      * @see TestCase#setUp()
71      */

72     protected void setUp() throws Exception JavaDoc {
73         codeDesc_ = new BasicCodeDescription();
74         codeDesc_.setLanguage("Java");
75         codeDesc_.setCode("java.lang.Object");
76     }
77     
78     // ==================================================================
79
//
80
// Public methods.
81
//
82
// ==================================================================
83

84     public void testEqualsMethod(){
85         ItemDescription item1 = new BasicItemDescription();
86         ItemDescription expected = new BasicItemDescription();
87         Assert.assertEquals(expected,item1);
88         expected.setCodeDescription(null);
89         Assert.assertEquals(expected,item1);
90         item1.setLabel(l1_);
91         Assert.assertNotSame(expected, item1);
92         expected.setLabel(l2_);
93         Assert.assertNotSame(expected,item1);
94         expected.setLabel(l1_);
95         Assert.assertEquals(expected,item1);
96         item1.setCodeDescription(codeDesc_);
97         Assert.assertNotSame(expected, item1);
98         expected.setCodeDescription(codeDesc_);
99         Assert.assertEquals(expected,item1);
100     }
101     
102     public void testIsEmptyMethod(){
103         ItemDescription itemDesc = new BasicItemDescription();
104         Assert.assertTrue(itemDesc.isEmpty());
105         itemDesc.setLabel(l1_);
106         Assert.assertTrue(itemDesc.isEmpty());
107         itemDesc.setLabel("");
108         itemDesc.setCodeDescription(codeDesc_);
109         Assert.assertTrue(itemDesc.isEmpty());
110         itemDesc.setLabel(l1_);
111         Assert.assertFalse(itemDesc.isEmpty());
112     }
113     
114 }
115
116
117
Popular Tags