@Test public void testAfterInitializationWithWrongType() throws Exception { // should be a no-op assertEquals("foo", processor.postProcessAfterInitialization("foo", "bar")); }
@Test public void testAfterInitializationWithDuplicate() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); JobSupport job = new JobSupport(); job.setBeanName("foo"); processor.postProcessAfterInitialization(job, "bar"); try { processor.postProcessAfterInitialization(job, "spam"); fail("Expected FatalBeanException"); } catch (FatalBeanException e) { // Expected assertTrue(e.getCause() instanceof DuplicateJobException); } }
@Test public void testAfterInitializationWithCorrectType() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); JobSupport job = new JobSupport(); job.setBeanName("foo"); assertNotNull(processor.postProcessAfterInitialization(job, "bar")); assertEquals("[foo]", registry.getJobNames().toString()); }
@Test public void testUnregisterOnDestroy() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); JobSupport job = new JobSupport(); job.setBeanName("foo"); assertNotNull(processor.postProcessAfterInitialization(job, "bar")); processor.destroy(); assertEquals("[]", registry.getJobNames().toString()); }
@Test public void testAfterInitializationWithGroupName() throws Exception { MapJobRegistry registry = new MapJobRegistry(); processor.setJobRegistry(registry); processor.setGroupName("jobs"); JobSupport job = new JobSupport(); job.setBeanName("foo"); assertNotNull(processor.postProcessAfterInitialization(job, "bar")); assertEquals("[jobs.foo]", registry.getJobNames().toString()); }