1 package org.jbpm.bpel.data.def; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 import org.jbpm.bpel.db.AbstractDbTestCase; 7 import org.jbpm.bpel.def.BpelDefinition; 8 import org.jbpm.bpel.def.While; 9 10 public class SnippetDbTest extends AbstractDbTestCase { 11 12 BpelDefinition processDefinition; 13 Snippet snippet; 14 15 public void setUp() { 16 super.setUp(); 17 processDefinition = new BpelDefinition(); 18 While whileBlock = new While("parent"); 19 snippet = new Snippet(); 20 snippet.setUse(Snippet.Use.EXPRESSION); 21 processDefinition.addNode(whileBlock); 22 whileBlock.setCondition(snippet); 23 } 24 25 public void testSnippet() { 26 snippet.setText("false()"); 27 28 processDefinition = saveAndReload(processDefinition); 29 30 snippet = ((While) processDefinition.getNode("parent")).getCondition(); 31 assertEquals("false()", snippet.getText()); 32 } 33 34 public void testLanguage() { 35 snippet.setLanguage("cobol"); 36 37 processDefinition = saveAndReload(processDefinition); 38 39 snippet = ((While) processDefinition.getNode("parent")).getCondition(); 40 assertEquals("cobol", snippet.getLanguage()); 41 } 42 43 public void testUse() { 44 snippet.setUse(Snippet.Use.JOIN_CONDITION); 45 46 processDefinition = saveAndReload(processDefinition); 47 48 snippet = ((While) processDefinition.getNode("parent")).getCondition(); 49 assertEquals(Snippet.Use.JOIN_CONDITION, snippet.getUse()); 50 } 51 52 public void testNamespaceDeclarations() { 53 Map declarations = new HashMap (); 54 declarations.put("jbpm", "http://www.jbpm.org"); 55 declarations.put("nme", "http://www.nme.com"); 56 snippet.setNamespaces(declarations); 57 58 processDefinition = saveAndReload(processDefinition); 59 60 snippet = ((While) processDefinition.getNode("parent")).getCondition(); 61 declarations = snippet.getNamespaces(); 62 63 assertEquals(2, declarations.size()); 64 assertEquals("http://www.jbpm.org", declarations.get("jbpm")); 65 assertEquals("http://www.nme.com", declarations.get("nme")); 66 } 67 } 68 | Popular Tags |