1 22 package org.jboss.test.jca.inflow; 23 24 import java.util.Timer ; 25 import java.util.TimerTask ; 26 27 import javax.resource.spi.endpoint.MessageEndpoint ; 28 29 35 public class TestResourceAdapterTimer 36 { 37 TestResourceAdapter adapter; 38 public TestResourceAdapterTimer(TestResourceAdapter adapter) 39 { 40 this.adapter = adapter; 41 } 42 43 public TestResourceAdapterTimerResults run() throws Exception 44 { 45 TestResourceAdapterTimerResults results = new TestResourceAdapterTimerResults(); 46 try 47 { 48 basicTest(); 49 results.basicTest.pass(); 50 } 51 catch (Throwable t) 52 { 53 results.basicTest.fail(t); 54 } 55 56 return results; 57 } 58 59 public void basicTest() throws Exception 60 { 61 Timer timer = adapter.ctx.createTimer(); 62 TestTimerTask task = new TestTimerTask(); 63 timer.schedule(task, 5000l); 64 Thread.sleep(10000); 65 if (task.complete == false) 66 throw new Exception ("Task was not run"); 67 } 68 69 public class TestTimerTask extends TimerTask 70 { 71 public boolean complete = false; 72 73 public void run() 74 { 75 complete = true; 76 } 77 } 78 } 79 | Popular Tags |