KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > monitor > model > LogModelTest


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.monitor.model;
5
6 import java.util.Observable JavaDoc;
7 import java.util.Observer JavaDoc;
8
9 import org.oddjob.logging.LogEvent;
10 import org.oddjob.logging.LogLevel;
11
12 import junit.framework.TestCase;
13
14 /**
15  *
16  */

17 public class LogModelTest extends TestCase implements LogEventProcessor {
18
19     String JavaDoc message;
20     
21     public void testMessage() {
22         class MyOb implements Observer JavaDoc {
23             public void update(Observable JavaDoc o, Object JavaDoc arg) {
24                 ((LogAction) arg).accept(LogModelTest.this);
25             }
26         }
27         MyOb ob = new MyOb();
28         
29         LogModel test = new LogModel();
30         test.addObserver(ob);
31         test.logEvent(new LogEvent("foo", 2, LogLevel.DEBUG, "Hello"));
32         assertEquals("Hello", message);
33     }
34     
35     /* (non-Javadoc)
36      * @see org.oddjob.monitor.model.LogEventProcessor#onClear()
37      */

38     public void onClear() {
39         // TODO Auto-generated method stub
40

41     }
42     /* (non-Javadoc)
43      * @see org.oddjob.monitor.model.LogEventProcessor#onEvent(java.lang.String, org.oddjob.logging.LogLevel)
44      */

45     public void onEvent(String JavaDoc text, LogLevel level) {
46         message = text;
47     }
48     
49     /* (non-Javadoc)
50      * @see org.oddjob.monitor.model.LogEventProcessor#onUnavailable()
51      */

52     public void onUnavailable() {
53         // TODO Auto-generated method stub
54

55     }
56 }
57
58
Popular Tags