From 08f3a7982192e3f1aee9f31c61fb98022fc3b0ac Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 10 Jan 2015 22:30:06 +0100 Subject: [PATCH] Fix broken test in EnableSchedulingTests Commit 65d163e changed the textual message of an exception thrown by ScheduledAnnotationBeanPostProcessor.afterSingletonsInstantiated(), and this in turn caused the withAmbiguousTaskSchedulers_andSingleTask() method in EnableSchedulingTests to start failing (albeit only during 'Performance' builds). This commit updates the assertion to match the current implementation of ScheduledAnnotationBeanPostProcessor. --- .../scheduling/annotation/EnableSchedulingTests.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java index 646f1cd366..81ca65946f 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import static org.junit.Assert.*; * Tests use of @EnableScheduling on @Configuration classes. * * @author Chris Beams + * @author Sam Brannen * @since 3.1 */ public class EnableSchedulingTests { @@ -142,6 +143,9 @@ public class EnableSchedulingTests { assertThat(ex.getMessage(), startsWith("More than one TaskScheduler")); throw ex; } + finally { + ctx.close(); + } } @EnableScheduling @Configuration @@ -236,6 +240,7 @@ public class EnableSchedulingTests { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(SchedulingEnabled_withAmbiguousTaskSchedulers_butNoActualTasks.class); ctx.refresh(); + ctx.close(); } @@ -266,9 +271,12 @@ public class EnableSchedulingTests { try { ctx.refresh(); } catch (IllegalStateException ex) { - assertThat(ex.getMessage(), startsWith("More than one TaskScheduler and/or")); + assertThat(ex.getMessage(), startsWith("More than one TaskScheduler exists within the context")); throw ex; } + finally { + ctx.close(); + } }