From 47fe05066d987aa6d523a399b6fe832daf1fef75 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 22 Oct 2018 12:46:32 +0200 Subject: [PATCH] Add error stream tests for Jaxb2XmlDecoderTests Issue: SPR-17418 --- .../http/codec/xml/Jaxb2XmlDecoderTests.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java index b4f19fb6034..177cb8e7be8 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -38,9 +38,7 @@ import org.springframework.http.codec.xml.jaxb.XmlType; import org.springframework.http.codec.xml.jaxb.XmlTypeWithName; import org.springframework.http.codec.xml.jaxb.XmlTypeWithNameAndNamespace; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** * @author Sebastien Deleuze @@ -207,6 +205,19 @@ public class Jaxb2XmlDecoderTests extends AbstractDataBufferAllocatingTestCase { .verify(); } + @Test + public void decodeError() throws Exception { + Flux source = Flux.just(stringBuffer("")) + .concatWith(Flux.error(new RuntimeException())); + + Mono output = this.decoder.decodeToMono(source, ResolvableType.forClass(Pojo.class), + null, Collections.emptyMap()); + + StepVerifier.create(output) + .expectError(RuntimeException.class) + .verify(); + } + @Test public void toExpectedQName() { assertEquals(new QName("pojo"), this.decoder.toQName(Pojo.class));