KickJava   Java API By Example, From Geeks To Geeks.

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


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.api.MenuDescription;
32 import org.objectweb.util.explorer.core.menu.api.MenuSeparator;
33 import org.objectweb.util.explorer.core.menu.lib.BasicItemDescription;
34 import org.objectweb.util.explorer.core.menu.lib.BasicMenuDescription;
35 import org.objectweb.util.explorer.core.menu.lib.BasicMenuSeparator;
36
37 import junit.framework.Assert;
38 import junit.framework.TestCase;
39
40 /**
41  *
42  *
43  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
44  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
45  *
46  * @version 0.1
47  */

48 public class MenuDescriptionTest
49      extends TestCase
50 {
51
52     //==================================================================
53
//
54
// Internal States.
55
//
56
// ==================================================================
57

58     protected ItemDescription itemDesc1_ = null, itemDesc2_ = null, sameAsItemDesc1_ = null;
59     protected MenuSeparator menuSeparator_ = null;
60         
61     // ==================================================================
62
//
63
// Constructors.
64
//
65
// ==================================================================
66

67     // ==================================================================
68
//
69
// Internal method.
70
//
71
// ==================================================================
72

73     /*
74      * @see TestCase#setUp()
75      */

76     protected void setUp() throws Exception JavaDoc {
77         CodeDescription codeDesc = new BasicCodeDescription();
78         codeDesc.setLanguage("Java");
79         codeDesc.setCode("java.lang.Object");
80         
81         itemDesc1_ = new BasicItemDescription();
82         itemDesc1_.setLabel("item 1");
83         itemDesc1_.setCodeDescription(codeDesc);
84         
85         itemDesc2_ = new BasicItemDescription();
86         itemDesc2_.setLabel("item 2");
87         itemDesc2_.setCodeDescription(codeDesc);
88         
89         sameAsItemDesc1_ = new BasicItemDescription();
90         sameAsItemDesc1_.setLabel("item 1");
91         sameAsItemDesc1_.setCodeDescription(codeDesc);
92         
93         menuSeparator_ = new BasicMenuSeparator();
94     }
95     
96     // ==================================================================
97
//
98
// Public methods.
99
//
100
// ==================================================================
101

102     public void testEqualsMethod(){
103         MenuDescription menuDesc = new BasicMenuDescription();
104         MenuDescription expected = new BasicMenuDescription();
105         MenuDescription notExpected = new BasicMenuDescription();
106         
107         menuDesc.addMenuElement(itemDesc1_);
108         menuDesc.addMenuElement(menuSeparator_);
109         menuDesc.addMenuElement(itemDesc1_);
110         menuDesc.addMenuElement(itemDesc2_);
111         ItemDescription id = null;
112         menuDesc.addMenuElement(id);
113         menuDesc.addMenuElement(new BasicItemDescription());
114         menuDesc.addMenuElement(sameAsItemDesc1_);
115
116         notExpected.addMenuElement(itemDesc1_);
117         notExpected.addMenuElement(itemDesc2_);
118         notExpected.addMenuElement(menuSeparator_);
119         Assert.assertNotSame(notExpected, menuDesc);
120         
121         expected.addMenuElement(itemDesc1_);
122         expected.addMenuElement(menuSeparator_);
123         expected.addMenuElement(itemDesc2_);
124         Assert.assertEquals(expected, menuDesc);
125     }
126     
127     public void testIsEmptyMethod(){
128         MenuDescription menuDesc = new BasicMenuDescription();
129         Assert.assertTrue(menuDesc.isEmpty());
130         menuDesc.addMenuElement(new BasicItemDescription());
131         Assert.assertTrue(menuDesc.isEmpty());
132         menuDesc.addMenuElement(itemDesc1_);
133         Assert.assertFalse(menuDesc.isEmpty());
134     }
135     
136 }
137
138
Popular Tags