1 4 package org.oddjob.monitor.control; 5 6 import java.util.Map ; 7 8 import junit.framework.TestCase; 9 10 import org.oddjob.monitor.model.DetailModel; 11 import org.oddjob.monitor.model.ExplorerContext; 12 import org.oddjob.monitor.model.ExplorerModel; 13 import org.oddjob.monitor.model.PropertyModel; 14 15 public class PropertyPollingTest extends TestCase { 16 17 public static class Comp { 18 public String getFruit() { 19 return "apples"; 20 } 21 } 22 23 28 public void testSelected() { 29 30 PropertyModel model = new PropertyModel(); 31 32 PropertyPolling test = new PropertyPolling(this); 33 test.setPropertyModel(model); 34 35 DetailModel detailModel = new DetailModel(); 36 detailModel.addObserver(test); 37 detailModel.setTabSelected(DetailModel.PROPERTIES_TAB); 38 39 Comp sample = new Comp(); 40 ExplorerModel em = new ExplorerModel(); 41 em.setRoot(sample); 42 ExplorerContext ec = new ExplorerContext(em); 43 detailModel.select(ec, sample); 44 45 test.poll(); 46 47 String result = (String ) model.getProperties().get("fruit"); 48 assertEquals("apples", result); 49 } 50 51 56 public void testNotSelected() { 57 58 PropertyModel model = new PropertyModel(); 59 60 PropertyPolling test = new PropertyPolling(this); 61 test.setPropertyModel(model); 62 63 DetailModel detailModel = new DetailModel(); 64 detailModel.addObserver(test); 65 66 Object root = new Object (); 67 ExplorerModel em = new ExplorerModel(); 68 em.setRoot(root); 69 ExplorerContext ec = new ExplorerContext(em); 70 detailModel.select(ec, null); 71 72 test.poll(); 73 74 Map props = model.getProperties(); 75 assertEquals(0, props.size()); 76 } 77 78 } 79 | Popular Tags |