1 4 package org.oddjob.designer.components; 5 6 import junit.framework.TestCase; 7 8 import org.apache.log4j.Logger; 9 import org.oddjob.designer.DesignerXMLParser; 10 import org.oddjob.designer.elements.MultiLineTextDE; 11 import org.oddjob.designer.model.DesignDefinition; 12 import org.oddjob.designer.model.ElementField; 13 import org.oddjob.designer.model.FieldGroup; 14 import org.oddjob.designer.model.FieldSelection; 15 import org.oddjob.designer.model.StandardForm; 16 17 20 public class ScriptDCTest extends TestCase { 21 private static final Logger logger = Logger.getLogger(ScriptDCTest.class); 22 23 public void setUp() { 24 logger.debug("========================== " + getName() + "===================" ); 25 } 26 27 public void testCreate() { 28 29 String xml = "<script name='Test Script' language='groovy'>"+ 30 "<text>println Hello</text>" + 31 "</script>"; 32 33 Object dc = DesignerXMLParser.buildComponent(xml); 34 assertNotNull("created", dc); 35 assertTrue("not unkonwn", dc instanceof ScriptDC); 36 ScriptDC script = (ScriptDC) dc; 37 assertNotNull(script.getText()); 38 } 39 40 String text; 41 42 public void testForm() { 43 44 MultiLineTextDE text = new MultiLineTextDE(); 45 text.setValue("Hello\nWorld"); 46 47 final ScriptDC dc = new ScriptDC(); 48 dc.setText(text); 49 50 StandardForm f = (StandardForm) dc.form(); 51 FieldGroup g = (FieldGroup) f.getDesignDefinition(1); 52 53 FieldSelection fs = (FieldSelection) g.get(1); 54 ElementField ef = (ElementField) fs.get(0); 55 56 assertTrue(ef.isPopulated()); 57 assertEquals(text, ef.getDesignElement()); 58 59 DesignDefinition dd = fs.get(1); 60 assertFalse(dd.isPopulated()); 61 62 dd = fs.get(2); 63 assertFalse(dd.isPopulated()); 64 } 65 } 66 | Popular Tags |