1 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 44 public class ItemDescriptionTest 45 extends TestCase 46 { 47 48 54 protected String l1_="label 1", l2_="label 2"; 55 protected CodeDescription codeDesc_ = null; 56 57 63 69 72 protected void setUp() throws Exception { 73 codeDesc_ = new BasicCodeDescription(); 74 codeDesc_.setLanguage("Java"); 75 codeDesc_.setCode("java.lang.Object"); 76 } 77 78 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 |