1 package net.sf.dozer.util.mapping; 2 3 import java.util.ArrayList ; 4 5 import net.sf.dozer.util.mapping.util.TestDataFactory; 6 import net.sf.dozer.util.mapping.vo.TestObject; 7 import net.sf.dozer.util.mapping.vo.TestObjectPrime; 8 import net.sf.dozer.util.mapping.vo.inheritance.AnotherSubClass; 9 import net.sf.dozer.util.mapping.vo.inheritance.AnotherSubClassPrime; 10 11 15 public class MultiThreadedTest extends DozerTestBase { 16 private MapperIF mapper; 17 18 public MultiThreadedTest() { 19 ArrayList list = new ArrayList (); 20 list.add("dozerBeanMapping.xml"); 21 mapper = new DozerBeanMapper(list); 22 } 23 24 27 public void testMultiThreadedMapping() throws Exception { 28 29 Runnable run = new Runnable () { 30 public void run() { 31 mapSomething(); 32 } 33 }; 34 Runnable run2 = new Runnable () { 35 public void run() { 36 mapSomething(); 37 } 38 }; 39 Runnable run3 = new Runnable () { 40 public void run() { 41 mapSomething(); 42 } 43 }; 44 Runnable run4 = new Runnable () { 45 public void run() { 46 mapSomething(); 47 } 48 }; 49 50 Thread t1 = new Thread (run, "Thread-1"); 51 Thread t2 = new Thread (run2, "Thread-2"); 52 Thread t3 = new Thread (run3, "Thread-3"); 53 Thread t4 = new Thread (run4, "Thread-4"); 54 55 t1.start(); 56 t2.start(); 57 t3.start(); 58 t4.start(); 59 t1.join(); 60 t2.join(); 61 t3.join(); 62 t4.join(); 63 } 64 65 private void mapSomething() { 66 TestObject src = TestDataFactory.getInputGeneralMappingTestObject(); 67 AnotherSubClass src2 = TestDataFactory.getAnotherSubClass(); 68 69 mapper.map(src, TestObjectPrime.class); 70 mapper.map(src2, AnotherSubClassPrime.class); 71 } 72 73 } | Popular Tags |