1 16 package org.quartz; 17 18 import java.util.ArrayList ; 19 import java.util.Arrays ; 20 import java.util.HashSet ; 21 22 import junit.framework.TestCase; 23 24 27 public class JobDetailTest extends TestCase { 28 public void testAddJobListener() { 29 String [] listenerNames = new String [] {"X", "A", "B"}; 30 31 HashSet hashSet = new HashSet (Arrays.asList(listenerNames)); 34 assertFalse(Arrays.asList(listenerNames).equals(new ArrayList (hashSet))); 35 36 JobDetail jobDetail = new JobDetail(); 37 for (int i = 0; i < listenerNames.length; i++) { 38 jobDetail.addJobListener(listenerNames[i]); 39 } 40 41 assertEquals(Arrays.asList(listenerNames), 43 Arrays.asList(jobDetail.getJobListenerNames())); 44 45 for (int i = 0; i < listenerNames.length; i++) { 47 try { 48 jobDetail.addJobListener(listenerNames[i]); 49 fail(); 50 } catch (IllegalArgumentException e) { 51 } 52 } 53 } 54 55 public void testClone() { 56 JobDetail jobDetail = new JobDetail(); 57 jobDetail.addJobListener("A"); 58 59 JobDetail clonedJobDetail = (JobDetail)jobDetail.clone(); 60 assertEquals(Arrays.asList(clonedJobDetail.getJobListenerNames()), 61 Arrays.asList(jobDetail.getJobListenerNames())); 62 63 jobDetail.addJobListener("B"); 64 65 assertTrue(Arrays.asList(jobDetail.getJobListenerNames()).contains("A")); 67 assertTrue(Arrays.asList(jobDetail.getJobListenerNames()).contains("B")); 68 assertTrue(Arrays.asList(clonedJobDetail.getJobListenerNames()).contains("A")); 69 assertFalse(Arrays.asList(clonedJobDetail.getJobListenerNames()).contains("B")); 70 } 71 } 72 | Popular Tags |