KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > logging > log > ProcessLogDbTest


1 package org.jbpm.logging.log;
2
3 import java.util.Date JavaDoc;
4 import java.util.Iterator JavaDoc;
5
6 import org.jbpm.db.AbstractDbTestCase;
7 import org.jbpm.graph.exe.Token;
8
9 public class ProcessLogDbTest extends AbstractDbTestCase {
10
11   public void testMessageLogMessage() {
12     MessageLog messageLog = new MessageLog("piece of cake");
13     messageLog = (MessageLog) saveAndReload(messageLog);
14     assertEquals("piece of cake", messageLog.getMessage());
15   }
16
17   public void testProcessLogDate() {
18     Date JavaDoc now = new Date JavaDoc();
19     ProcessLog processLog = new MessageLog();
20     processLog.setDate(now);
21     processLog = saveAndReload(processLog);
22     assertEquals(now, processLog.getDate());
23   }
24
25   public void testProcessLogToken() {
26     Token token = new Token();
27     jbpmSession.getSession().save(token);
28     ProcessLog processLog = new MessageLog();
29     processLog.setToken(token);
30     processLog = saveAndReload(processLog);
31     assertNotNull(processLog.getToken());
32   }
33   
34   public void testParentChildRelation() {
35     CompositeLog compositeLog = new CompositeLog();
36     ProcessLog processLog = new MessageLog("one");
37     jbpmSession.getSession().save(processLog);
38     compositeLog.addChild(processLog);
39     processLog = new MessageLog("two");
40     jbpmSession.getSession().save(processLog);
41     compositeLog.addChild(processLog);
42     processLog = new MessageLog("three");
43     jbpmSession.getSession().save(processLog);
44     compositeLog.addChild(processLog);
45     
46     compositeLog = (CompositeLog) saveAndReload(compositeLog);
47     assertEquals(3, compositeLog.getChildren().size());
48     
49     Iterator JavaDoc iter = compositeLog.getChildren().iterator();
50     while (iter.hasNext()) {
51       ProcessLog childLog = (ProcessLog) iter.next();
52       assertSame(compositeLog, childLog.getParent());
53     }
54   }
55
56 }
57
Popular Tags