|
16 | 16 | import cucumber.runtime.java.spring.contexthierarchyconfig.WithDifferentContextHierarchyAnnotation;
|
17 | 17 | import cucumber.runtime.java.spring.dirtiescontextconfig.DirtiesContextBellyStepDefs;
|
18 | 18 | import cucumber.runtime.java.spring.metaconfig.dirties.DirtiesContextBellyMetaStepDefs;
|
| 19 | +import java.io.ByteArrayOutputStream; |
| 20 | +import java.io.PrintStream; |
19 | 21 | import org.junit.Rule;
|
20 | 22 | import org.junit.Test;
|
21 | 23 | import org.junit.rules.ExpectedException;
|
@@ -244,17 +246,37 @@ public void shouldUseCucumberXmlIfNoClassWithSpringAnnotationIsFound() {
|
244 | 246 | @Test
|
245 | 247 | public void shouldAllowClassesWithSameSpringAnnotations() {
|
246 | 248 | final ObjectFactory factory = new SpringFactory();
|
247 |
| - factory.addClass(WithSpringAnnotations.class); |
248 |
| - factory.addClass(BellyStepdefs.class); |
| 249 | + PrintStream originalErr = System.err; |
| 250 | + try { |
| 251 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 252 | + System.setErr(new PrintStream(baos)); |
| 253 | + factory.addClass(WithSpringAnnotations.class); |
| 254 | + factory.addClass(BellyStepdefs.class); |
| 255 | + assertEquals("WARNING: Having more than one glue class that configures " + |
| 256 | + "the spring context is deprecated. Found both class " + |
| 257 | + "cucumber.runtime.java.spring.contextconfig.BellyStepdefs and class " + |
| 258 | + "cucumber.runtime.java.spring.contextconfig.WithSpringAnnotations " + |
| 259 | + "that attempt to configure the spring context.\n", |
| 260 | + baos.toString()); |
| 261 | + } finally { |
| 262 | + System.setErr(originalErr); |
| 263 | + } |
249 | 264 | }
|
250 | 265 |
|
251 | 266 | @Test
|
252 | 267 | public void shouldFailIfClassesWithDifferentSpringAnnotationsAreFound() {
|
253 | 268 | expectedException.expect(CucumberException.class);
|
254 | 269 | expectedException.expectMessage("Annotations differs on glue classes found: cucumber.runtime.java.spring.contexthierarchyconfig.WithContextHierarchyAnnotation, cucumber.runtime.java.spring.contexthierarchyconfig.WithDifferentContextHierarchyAnnotation");
|
255 | 270 | final ObjectFactory factory = new SpringFactory();
|
256 |
| - factory.addClass(WithContextHierarchyAnnotation.class); |
257 |
| - factory.addClass(WithDifferentContextHierarchyAnnotation.class); |
| 271 | + PrintStream originalErr = System.err; |
| 272 | + try { |
| 273 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| 274 | + System.setErr(new PrintStream(baos)); |
| 275 | + factory.addClass(WithContextHierarchyAnnotation.class); |
| 276 | + factory.addClass(WithDifferentContextHierarchyAnnotation.class); |
| 277 | + } finally { |
| 278 | + System.setErr(originalErr); |
| 279 | + } |
258 | 280 | }
|
259 | 281 |
|
260 | 282 | @Test
|
|
0 commit comments