1 22 package org.jboss.test.aop.bean; 23 24 import org.jboss.aspects.patterns.observable.Observer; 25 import org.jboss.aspects.patterns.observable.Subject; 26 import org.jboss.system.ServiceMBeanSupport; 27 31 public class ObservableTester 32 extends ServiceMBeanSupport 33 implements ObservableTesterMBean 34 { 35 37 39 41 43 public ObservableTester() 44 { 45 } 46 47 49 public void testAll() throws Exception 50 { 51 Temperature temperature = new Temperature(); 52 LogUtil logUtil = new LogUtil(); 53 54 Subject subject = (Subject) temperature; 55 Observer observer = (Observer) logUtil; 56 57 subject.addObserver(observer); 58 59 temperature.setTemperature(10); 60 assertEquals("Temperature=10", logUtil.lastLog); 61 } 62 63 public void assertEquals(Object object1, Object object2) throws Exception 64 { 65 if (object1.equals(object2) == false) 66 throw new Exception ("Expected " + object1 + " got " + object2); 67 } 68 69 } 71 72 | Popular Tags |