From 6d089cdc08e54091224cf2ec61ca4c81a6c40ca2 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 30 Jun 2016 13:48:41 -0400 Subject: [PATCH] Move remaining JAXB2 test files from core to http --- .../codec/support/CharSequenceEncoder.java | 51 +++++++++++++++++++ .../http/codec/xml/Jaxb2DecoderTests.java | 12 ++--- .../http/codec/xml/XmlEventDecoderTests.java | 1 - .../codec/xml}/XmlRootElement.java | 2 +- .../codec/xml}/XmlRootElementWithName.java | 2 +- .../XmlRootElementWithNameAndNamespace.java | 2 +- .../jaxb => http/codec/xml}/XmlType.java | 2 +- .../codec/xml}/XmlTypeWithName.java | 2 +- .../xml}/XmlTypeWithNameAndNamespace.java | 2 +- .../jaxb => http/codec/xml}/package-info.java | 2 +- 10 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 spring-web-reactive/src/main/java/org/springframework/core/codec/support/CharSequenceEncoder.java rename spring-web-reactive/src/test/java/org/springframework/{core/codec/support/jaxb => http/codec/xml}/XmlRootElement.java (93%) rename spring-web-reactive/src/test/java/org/springframework/{core/codec/support/jaxb => http/codec/xml}/XmlRootElementWithName.java (93%) rename spring-web-reactive/src/test/java/org/springframework/{core/codec/support/jaxb => http/codec/xml}/XmlRootElementWithNameAndNamespace.java (93%) rename spring-web-reactive/src/test/java/org/springframework/{core/codec/support/jaxb => http/codec/xml}/XmlType.java (93%) rename spring-web-reactive/src/test/java/org/springframework/{core/codec/support/jaxb => http/codec/xml}/XmlTypeWithName.java (93%) rename spring-web-reactive/src/test/java/org/springframework/{core/codec/support/jaxb => http/codec/xml}/XmlTypeWithNameAndNamespace.java (93%) rename spring-web-reactive/src/test/java/org/springframework/{core/codec/support/jaxb => http/codec/xml}/package-info.java (53%) diff --git a/spring-web-reactive/src/main/java/org/springframework/core/codec/support/CharSequenceEncoder.java b/spring-web-reactive/src/main/java/org/springframework/core/codec/support/CharSequenceEncoder.java new file mode 100644 index 0000000000..372645cca6 --- /dev/null +++ b/spring-web-reactive/src/main/java/org/springframework/core/codec/support/CharSequenceEncoder.java @@ -0,0 +1,51 @@ +/* + * Copyright 2002-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.core.codec.support; + +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; + +import org.springframework.core.ResolvableType; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.util.MimeType; + +/** + * + * @author Rossen Stoyanchev + */ +public class CharSequenceEncoder extends AbstractEncoder { + + private final StringEncoder stringEncoder; + + + public CharSequenceEncoder(StringEncoder encoder) { + super(encoder.getEncodableMimeTypes().toArray(new MimeType[encoder.getEncodableMimeTypes().size()])); + this.stringEncoder = encoder; + } + + + @Override + public Flux encode(Publisher inputStream, + DataBufferFactory bufferFactory, ResolvableType elementType, + MimeType mimeType, Object... hints) { + + return this.stringEncoder.encode( + Flux.from(inputStream).map(CharSequence::toString), + bufferFactory, elementType, mimeType, hints); + } + +} diff --git a/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/Jaxb2DecoderTests.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/Jaxb2DecoderTests.java index 3b36689720..40c19a6840 100644 --- a/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/Jaxb2DecoderTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/Jaxb2DecoderTests.java @@ -25,20 +25,14 @@ import reactor.core.publisher.Flux; import reactor.core.test.TestSubscriber; import org.springframework.core.ResolvableType; -import org.springframework.core.codec.support.jaxb.XmlRootElement; -import org.springframework.core.codec.support.jaxb.XmlRootElementWithName; -import org.springframework.core.codec.support.jaxb.XmlRootElementWithNameAndNamespace; -import org.springframework.core.codec.support.jaxb.XmlType; -import org.springframework.core.codec.support.jaxb.XmlTypeWithName; -import org.springframework.core.codec.support.jaxb.XmlTypeWithNameAndNamespace; import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.http.MediaType; import org.springframework.http.codec.Pojo; -import org.springframework.http.codec.xml.Jaxb2Decoder; -import org.springframework.http.codec.xml.XmlEventDecoder; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * @author Sebastien Deleuze diff --git a/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java index fa942c9b94..09a82eb9ac 100644 --- a/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java @@ -23,7 +23,6 @@ import reactor.core.publisher.Flux; import reactor.core.test.TestSubscriber; import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase; -import org.springframework.http.codec.xml.XmlEventDecoder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElement.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElement.java similarity index 93% rename from spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElement.java rename to spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElement.java index 92470a5876..497ade650f 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElement.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElement.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec.support.jaxb; +package org.springframework.http.codec.xml; /** * @author Arjen Poutsma diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElementWithName.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElementWithName.java similarity index 93% rename from spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElementWithName.java rename to spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElementWithName.java index deb7929916..ac8dca6501 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElementWithName.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElementWithName.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec.support.jaxb; +package org.springframework.http.codec.xml; import javax.xml.bind.annotation.XmlRootElement; diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElementWithNameAndNamespace.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElementWithNameAndNamespace.java similarity index 93% rename from spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElementWithNameAndNamespace.java rename to spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElementWithNameAndNamespace.java index e4330da2bc..2dc4afd0b1 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlRootElementWithNameAndNamespace.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlRootElementWithNameAndNamespace.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec.support.jaxb; +package org.springframework.http.codec.xml; import javax.xml.bind.annotation.XmlRootElement; diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlType.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlType.java similarity index 93% rename from spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlType.java rename to spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlType.java index 49d158674c..f9b73eae39 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlType.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlType.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec.support.jaxb; +package org.springframework.http.codec.xml; /** * @author Arjen Poutsma diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlTypeWithName.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlTypeWithName.java similarity index 93% rename from spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlTypeWithName.java rename to spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlTypeWithName.java index f62be41835..0efa8dff31 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlTypeWithName.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlTypeWithName.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec.support.jaxb; +package org.springframework.http.codec.xml; import javax.xml.bind.annotation.XmlType; diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlTypeWithNameAndNamespace.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlTypeWithNameAndNamespace.java similarity index 93% rename from spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlTypeWithNameAndNamespace.java rename to spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlTypeWithNameAndNamespace.java index 4cf7cb6f6b..c1ad65bde7 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/XmlTypeWithNameAndNamespace.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/XmlTypeWithNameAndNamespace.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.core.codec.support.jaxb; +package org.springframework.http.codec.xml; import javax.xml.bind.annotation.XmlType; diff --git a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/package-info.java b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/package-info.java similarity index 53% rename from spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/package-info.java rename to spring-web-reactive/src/test/java/org/springframework/http/codec/xml/package-info.java index e02f2405c1..2f5da29e85 100644 --- a/spring-web-reactive/src/test/java/org/springframework/core/codec/support/jaxb/package-info.java +++ b/spring-web-reactive/src/test/java/org/springframework/http/codec/xml/package-info.java @@ -1,2 +1,2 @@ @javax.xml.bind.annotation.XmlSchema(namespace = "namespace") -package org.springframework.core.codec.support.jaxb; +package org.springframework.http.codec.xml;