1 package org.drools.semantics.python; 2 3 import org.drools.rule.Declaration; 4 import org.drools.spi.MockTuple; 5 import org.drools.semantics.java.ClassObjectType; 6 7 import junit.framework.TestCase; 8 9 public class ExecTest extends TestCase 10 { 11 private Exec exec; 12 private Declaration testDecl; 13 14 private boolean poked; 15 private boolean prodded; 16 17 public ExecTest(String name) 18 { 19 super( name ); 20 } 21 22 public void setUp() 23 { 24 this.exec = new Exec(); 25 this.testDecl = new Declaration( new ClassObjectType( ExecTest.class ), 26 "test" ); 27 28 this.poked = false; 29 this.prodded = false; 30 } 31 32 public void tearDown() 33 { 34 this.exec = null; 35 this.testDecl = null; 36 this.poked = false; 37 this.prodded = false; 38 } 39 40 public void testSetText() 41 { 42 this.exec.setText( "42 + 42" ); 43 44 assertNotNull( this.exec.getCode() ); 45 } 46 47 public void testExecute() 48 { 49 MockTuple tuple = new MockTuple(); 50 51 tuple.put( this.testDecl, 52 this ); 53 54 this.exec.setText( "test.poke()\ntest.prod()\n" ); 55 56 this.exec.execute( tuple ); 57 58 assertTrue( this.poked ); 59 assertTrue( this.prodded ); 60 } 61 62 public void poke() 63 { 64 this.poked = true; 65 } 66 67 public void prod() 68 { 69 this.prodded = true; 70 } 71 } 72

This page was automatically generated by Maven