1 package org.jbpm.logging.exe; 2 3 import junit.framework.TestCase; 4 5 import org.jbpm.graph.def.ProcessDefinition; 6 import org.jbpm.graph.exe.ProcessInstance; 7 import org.jbpm.graph.exe.Token; 8 import org.jbpm.logging.log.CompositeLog; 9 import org.jbpm.logging.log.MessageLog; 10 import org.jbpm.logging.log.ProcessLog; 11 12 public class CompositeLogTest extends TestCase { 13 14 public void testCompositeLogs() { 15 ProcessDefinition processDefinition = new ProcessDefinition(); 16 ProcessInstance pi = new ProcessInstance(processDefinition); 17 Token root = pi.getRootToken(); 18 LoggingInstance li = (LoggingInstance) pi.getInstance(LoggingInstance.class); 19 20 ProcessLog one = new MessageLog(null); 21 li.addLog(one); 22 23 assertNull( one.getParent() ); 24 assertSame( one, li.getLogs().get(1) ); 25 assertEquals( 2, li.getLogs().size() ); 26 assertEquals( 0, li.getCompositeLogStack().size() ); 27 28 CompositeLog two = new CompositeLog(); 29 two.setToken(root); 30 li.startCompositeLog(two); 31 32 assertNull( two.getParent() ); 33 assertSame( two, li.getLogs().get(2) ); 34 assertEquals( 3, li.getLogs().size() ); 35 assertEquals( 1, li.getCompositeLogStack().size() ); 36 37 ProcessLog three = new MessageLog(null); 38 li.addLog(three); 39 40 assertSame( two, three.getParent() ); 41 assertSame( three, li.getLogs().get(3) ); 42 assertEquals( 4, li.getLogs().size() ); 43 assertEquals( 1, li.getCompositeLogStack().size() ); 44 45 CompositeLog four = new CompositeLog(); 46 four.setToken(root); 47 li.startCompositeLog(four); 48 49 assertSame( two, four.getParent() ); 50 assertSame( four, li.getLogs().get(4) ); 51 assertEquals( 5, li.getLogs().size() ); 52 assertEquals( 2, li.getCompositeLogStack().size() ); 53 54 ProcessLog five = new MessageLog(null); 55 li.addLog(five); 56 57 assertSame( four, five.getParent() ); 58 assertSame( two, five.getParent().getParent() ); 59 assertNull( five.getParent().getParent().getParent() ); 60 assertSame( five, li.getLogs().get(5) ); 61 assertEquals( 6, li.getLogs().size() ); 62 assertEquals( 2, li.getCompositeLogStack().size() ); 63 64 li.endCompositeLog(); 65 66 assertEquals( 1, li.getCompositeLogStack().size() ); 67 68 ProcessLog six = new MessageLog(null); 69 li.addLog(six); 70 71 assertSame( two, six.getParent() ); 72 assertNull( six.getParent().getParent() ); 73 assertSame( six, li.getLogs().get(6) ); 74 assertEquals( 7, li.getLogs().size() ); 75 assertEquals( 1, li.getCompositeLogStack().size() ); 76 77 li.endCompositeLog(); 78 79 assertEquals( 0, li.getCompositeLogStack().size() ); 80 } 81 } 82 | Popular Tags |