1 package org.jbpm.graph.exe; 2 3 import junit.framework.*; 4 5 import org.jbpm.graph.def.*; 6 7 public class TokenNameTest extends TestCase { 8 9 public void testFindRoot() { 10 ProcessDefinition pd = new ProcessDefinition( 11 new String []{"start-state start", 12 "fork f1", 13 "state a", 14 "fork f2", 15 "state b", 16 "state c"}, 17 new String []{"start --> f1", 18 "f1 --a--> a", 19 "f1 --f2--> f2", 20 "f2 --b--> b", 21 "f2 --c--> c"}); 22 23 ProcessInstance pi = new ProcessInstance(pd); 24 pi.signal(); 25 26 35 Token root = pi.getRootToken(); 36 Token tokenA = root.getChild("a"); 37 Token tokenF2 = root.getChild("f2"); 38 Token tokenF2B = tokenF2.getChild("b"); 39 Token tokenF2C = tokenF2.getChild("c"); 40 41 assertEquals("/", root.getFullName()); 42 assertEquals("/a", tokenA.getFullName()); 43 assertEquals("/f2", tokenF2.getFullName()); 44 assertEquals("/f2/b", tokenF2B.getFullName()); 45 assertEquals("/f2/c", tokenF2C.getFullName()); 46 47 assertSame( root, pi.findToken( "/" ) ); 48 assertSame( root, pi.findToken( "" ) ); 49 assertSame( root, pi.findToken( "." ) ); 50 assertSame( root, tokenA.findToken( ".." ) ); 51 assertSame( root, tokenA.findToken( "../." ) ); 52 53 assertSame( tokenA, pi.findToken( "/a" ) ); 54 assertSame( tokenA, tokenF2C.findToken( "/a" ) ); 55 assertSame( tokenA, pi.findToken( "a" ) ); 56 57 assertSame( tokenF2, pi.findToken( "f2" ) ); 58 assertSame( tokenF2, pi.findToken( "/f2" ) ); 59 assertSame( tokenF2, tokenF2C.findToken( ".." ) ); 60 61 assertSame( tokenF2B, pi.findToken( "f2/b" ) ); 62 assertSame( tokenF2B, pi.findToken( "/f2/b" ) ); 63 64 assertNull( pi.findToken( null ) ); 65 assertNull( pi.findToken( "non-existing-token-name" ) ); 66 assertNull( pi.findToken( "/a/non-existing-token-name" ) ); 67 assertNull( pi.findToken( ".." ) ); 68 assertNull( pi.findToken( "/.." ) ); 69 } 70 } 71 | Popular Tags |