diff --git a/spring-oxm/oxm.gradle b/spring-oxm/oxm.gradle
index 140b35130e..0940ce2ed8 100644
--- a/spring-oxm/oxm.gradle
+++ b/spring-oxm/oxm.gradle
@@ -1,14 +1,12 @@
configurations {
castor
xjc
- xmlbeans
jibx
}
dependencies {
castor "org.codehaus.castor:castor-anttasks:1.4.1"
castor "org.apache.velocity:velocity:1.7"
xjc "com.sun.xml.bind:jaxb-xjc:2.1.17"
- xmlbeans "org.apache.xmlbeans:xmlbeans:2.6.0"
jibx "org.jibx:jibx-bind:1.2.6"
jibx "bcel:bcel:5.1"
}
@@ -39,7 +37,7 @@ task genCastor {
castor(types: "j2", warnings: false, file: orderSchema, todir: sourcesDir,
package: "org.springframework.oxm.castor", properties: castorBuilderProperties)
- javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
+ javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true,
debugLevel: "lines,vars,source", classpath: configurations.castor.asPath) {
src(path: sourcesDir)
include(name: "**/*.java")
@@ -74,7 +72,7 @@ task genJaxb {
produces(dir: sourcesDir, includes: "**/*.java")
}
- javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
+ javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true,
debugLevel: "lines,vars,source",
classpath: configurations.castor.asPath) {
src(path: sourcesDir)
@@ -91,25 +89,6 @@ task genJaxb {
}
}
-task genXmlbeans {
- ext.classesDir = "${buildDir}/classes/xmlbeans"
-
- inputs.files flightSchema
- outputs.dir classesDir
-
- doLast() {
- project.ant {
- taskdef name: "xmlbeans",
- classname: "org.apache.xmlbeans.impl.tool.XMLBean",
- classpath: configurations.xmlbeans.asPath
-
- xmlbeans(classgendir: classesDir, schema: flightSchema,
- compiler: "modern", verbose: "false",
- classpath: configurations.xmlbeans.asPath)
- }
- }
-}
-
// add jibx binding to the normal test compilation process
// INCOMPATIBLE WITH OPENJDK 8 b89+
def jibxEnabled = project.properties.get("testGroups")?.toLowerCase()?.split(",")?.contains("custom_compilation")
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java b/spring-oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java
index ba97301167..a8978a2f2e 100644
--- a/spring-oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java
+++ b/spring-oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * 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.
@@ -28,12 +28,10 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
public class OxmNamespaceHandler extends NamespaceHandlerSupport {
@Override
- @SuppressWarnings("deprecation")
public void init() {
registerBeanDefinitionParser("jaxb2-marshaller", new Jaxb2MarshallerBeanDefinitionParser());
registerBeanDefinitionParser("jibx-marshaller", new JibxMarshallerBeanDefinitionParser());
registerBeanDefinitionParser("castor-marshaller", new CastorMarshallerBeanDefinitionParser());
- registerBeanDefinitionParser("xmlbeans-marshaller", new XmlBeansMarshallerBeanDefinitionParser());
}
}
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/config/XmlBeansMarshallerBeanDefinitionParser.java b/spring-oxm/src/main/java/org/springframework/oxm/config/XmlBeansMarshallerBeanDefinitionParser.java
deleted file mode 100644
index e5a6e02574..0000000000
--- a/spring-oxm/src/main/java/org/springframework/oxm/config/XmlBeansMarshallerBeanDefinitionParser.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2002-2013 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.oxm.config;
-
-import org.w3c.dom.Element;
-
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.util.StringUtils;
-
-/**
- * Parser for the {@code } element.
- *
- * @author Arjen Poutsma
- * @since 3.0
- * @deprecated as of Spring 4.2, following the XMLBeans retirement at Apache
- */
-@Deprecated
-class XmlBeansMarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
-
- @Override
- protected String getBeanClassName(Element element) {
- return "org.springframework.oxm.xmlbeans.XmlBeansMarshaller";
- }
-
- @Override
- protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
- String optionsName = element.getAttribute("options");
- if (StringUtils.hasText(optionsName)) {
- beanDefinitionBuilder.addPropertyReference("xmlOptions", optionsName);
- }
- }
-
-}
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.java
deleted file mode 100644
index af0599431f..0000000000
--- a/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Copyright 2002-2014 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.oxm.xmlbeans;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.ref.WeakReference;
-import java.nio.CharBuffer;
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLEventWriter;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.xmlbeans.XMLStreamValidationException;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlSaxHandler;
-import org.apache.xmlbeans.XmlValidationError;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.ext.LexicalHandler;
-
-import org.springframework.oxm.Marshaller;
-import org.springframework.oxm.MarshallingFailureException;
-import org.springframework.oxm.UncategorizedMappingException;
-import org.springframework.oxm.UnmarshallingFailureException;
-import org.springframework.oxm.ValidationFailureException;
-import org.springframework.oxm.XmlMappingException;
-import org.springframework.oxm.support.AbstractMarshaller;
-import org.springframework.util.xml.StaxUtils;
-
-/**
- * Implementation of the {@link Marshaller} interface for Apache XMLBeans.
- *
- *
Options can be set by setting the {@code xmlOptions} property.
- * The {@link XmlOptionsFactoryBean} is provided to easily set up an {@link XmlOptions} instance.
- *
- *
Unmarshalled objects can be validated by setting the {@code validating} property,
- * or by calling the {@link #validate(XmlObject)} method directly. Invalid objects will
- * result in an {@link ValidationFailureException}.
- *
- *
NOTE: Due to the nature of XMLBeans, this marshaller requires
- * all passed objects to be of type {@link XmlObject}.
- *
- * @author Arjen Poutsma
- * @since 3.0
- * @see #setValidating
- * @see #setXmlOptions
- * @see XmlOptionsFactoryBean
- * @deprecated as of Spring 4.2, following the XMLBeans retirement at Apache
- */
-@Deprecated
-public class XmlBeansMarshaller extends AbstractMarshaller {
-
- private XmlOptions xmlOptions;
-
- private boolean validating = false;
-
-
- /**
- * Set the {@code XmlOptions}.
- * @see XmlOptionsFactoryBean
- */
- public void setXmlOptions(XmlOptions xmlOptions) {
- this.xmlOptions = xmlOptions;
- }
-
- /**
- * Return the {@code XmlOptions}.
- */
- public XmlOptions getXmlOptions() {
- return this.xmlOptions;
- }
-
- /**
- * Set whether this marshaller should validate in- and outgoing documents.
- * Default is {@code false}.
- */
- public void setValidating(boolean validating) {
- this.validating = validating;
- }
-
- /**
- * Return whether this marshaller should validate in- and outgoing documents.
- */
- public boolean isValidating() {
- return this.validating;
- }
-
-
- /**
- * This implementation returns true if the given class is an implementation of {@link XmlObject}.
- */
- @Override
- public boolean supports(Class> clazz) {
- return XmlObject.class.isAssignableFrom(clazz);
- }
-
-
- @Override
- protected void marshalDomNode(Object graph, Node node) throws XmlMappingException {
- Document document = (node.getNodeType() == Node.DOCUMENT_NODE ? (Document) node : node.getOwnerDocument());
- Node xmlBeansNode = ((XmlObject) graph).newDomNode(getXmlOptions());
- NodeList xmlBeansChildNodes = xmlBeansNode.getChildNodes();
- for (int i = 0; i < xmlBeansChildNodes.getLength(); i++) {
- Node xmlBeansChildNode = xmlBeansChildNodes.item(i);
- Node importedNode = document.importNode(xmlBeansChildNode, true);
- node.appendChild(importedNode);
- }
- }
-
- @Override
- protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) {
- ContentHandler contentHandler = StaxUtils.createContentHandler(eventWriter);
- LexicalHandler lexicalHandler = null;
- if (contentHandler instanceof LexicalHandler) {
- lexicalHandler = (LexicalHandler) contentHandler;
- }
- marshalSaxHandlers(graph, contentHandler, lexicalHandler);
- }
-
- @Override
- protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
- ContentHandler contentHandler = StaxUtils.createContentHandler(streamWriter);
- LexicalHandler lexicalHandler = null;
- if (contentHandler instanceof LexicalHandler) {
- lexicalHandler = (LexicalHandler) contentHandler;
- }
- marshalSaxHandlers(graph, contentHandler, lexicalHandler);
- }
-
- @Override
- protected void marshalSaxHandlers(Object graph, ContentHandler contentHandler, LexicalHandler lexicalHandler)
- throws XmlMappingException {
- try {
- ((XmlObject) graph).save(contentHandler, lexicalHandler, getXmlOptions());
- }
- catch (SAXException ex) {
- throw convertXmlBeansException(ex, true);
- }
- }
-
- @Override
- protected void marshalOutputStream(Object graph, OutputStream outputStream)
- throws XmlMappingException, IOException {
-
- ((XmlObject) graph).save(outputStream, getXmlOptions());
- }
-
- @Override
- protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
- ((XmlObject) graph).save(writer, getXmlOptions());
- }
-
-
- @Override
- protected Object unmarshalDomNode(Node node) throws XmlMappingException {
- try {
- XmlObject object = XmlObject.Factory.parse(node, getXmlOptions());
- validate(object);
- return object;
- }
- catch (XmlException ex) {
- throw convertXmlBeansException(ex, false);
- }
- }
-
- @Override
- protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException {
- XMLReader reader = StaxUtils.createXMLReader(eventReader);
- try {
- return unmarshalSaxReader(reader, new InputSource());
- }
- catch (IOException ex) {
- throw convertXmlBeansException(ex, false);
- }
- }
-
- @Override
- protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) throws XmlMappingException {
- try {
- XmlObject object = XmlObject.Factory.parse(streamReader, getXmlOptions());
- validate(object);
- return object;
- }
- catch (XmlException ex) {
- throw convertXmlBeansException(ex, false);
- }
- }
-
- @Override
- protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource)
- throws XmlMappingException, IOException {
-
- XmlSaxHandler saxHandler = XmlObject.Factory.newXmlSaxHandler(getXmlOptions());
- xmlReader.setContentHandler(saxHandler.getContentHandler());
- try {
- xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", saxHandler.getLexicalHandler());
- }
- catch (SAXNotRecognizedException ex) {
- // ignore
- }
- catch (SAXNotSupportedException ex) {
- // ignore
- }
- try {
- xmlReader.parse(inputSource);
- XmlObject object = saxHandler.getObject();
- validate(object);
- return object;
- }
- catch (SAXException ex) {
- throw convertXmlBeansException(ex, false);
- }
- catch (XmlException ex) {
- throw convertXmlBeansException(ex, false);
- }
- }
-
- @Override
- protected Object unmarshalInputStream(InputStream inputStream) throws XmlMappingException, IOException {
- try {
- InputStream nonClosingInputStream = new NonClosingInputStream(inputStream);
- XmlObject object = XmlObject.Factory.parse(nonClosingInputStream, getXmlOptions());
- validate(object);
- return object;
- }
- catch (XmlException ex) {
- throw convertXmlBeansException(ex, false);
- }
- }
-
- @Override
- protected Object unmarshalReader(Reader reader) throws XmlMappingException, IOException {
- try {
- Reader nonClosingReader = new NonClosingReader(reader);
- XmlObject object = XmlObject.Factory.parse(nonClosingReader, getXmlOptions());
- validate(object);
- return object;
- }
- catch (XmlException ex) {
- throw convertXmlBeansException(ex, false);
- }
- }
-
-
- /**
- * Validate the given {@code XmlObject}.
- * @param object the xml object to validate
- * @throws ValidationFailureException if the given object is not valid
- */
- protected void validate(XmlObject object) throws ValidationFailureException {
- if (isValidating() && object != null) {
- XmlOptions validateOptions = getXmlOptions();
- if (validateOptions == null) {
- // Create temporary XmlOptions just for validation
- validateOptions = new XmlOptions();
- }
- List errorsList = new ArrayList();
- validateOptions.setErrorListener(errorsList);
- if (!object.validate(validateOptions)) {
- StringBuilder sb = new StringBuilder("Failed to validate XmlObject: ");
- boolean first = true;
- for (XmlError error : errorsList) {
- if (error instanceof XmlValidationError) {
- if (!first) {
- sb.append("; ");
- }
- sb.append(error.toString());
- first = false;
- }
- }
- throw new ValidationFailureException("XMLBeans validation failure",
- new XmlException(sb.toString(), null, errorsList));
- }
- }
- }
-
- /**
- * Convert the given XMLBeans exception to an appropriate exception from the
- * {@code org.springframework.oxm} hierarchy.
- * A boolean flag is used to indicate whether this exception occurs during marshalling or
- * unmarshalling, since XMLBeans itself does not make this distinction in its exception hierarchy.
- * @param ex XMLBeans Exception that occured
- * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
- * or unmarshalling ({@code false})
- * @return the corresponding {@code XmlMappingException}
- */
- protected XmlMappingException convertXmlBeansException(Exception ex, boolean marshalling) {
- if (ex instanceof XMLStreamValidationException) {
- return new ValidationFailureException("XMLBeans validation exception", ex);
- }
- else if (ex instanceof XmlException || ex instanceof SAXException) {
- if (marshalling) {
- return new MarshallingFailureException("XMLBeans marshalling exception", ex);
- }
- else {
- return new UnmarshallingFailureException("XMLBeans unmarshalling exception", ex);
- }
- }
- else {
- // fallback
- return new UncategorizedMappingException("Unknown XMLBeans exception", ex);
- }
- }
-
-
- private static class NonClosingInputStream extends InputStream {
-
- private final WeakReference in;
-
- public NonClosingInputStream(InputStream in) {
- this.in = new WeakReference(in);
- }
-
- private InputStream getInputStream() {
- return this.in.get();
- }
-
- @Override
- public int read() throws IOException {
- InputStream in = getInputStream();
- return (in != null ? in.read() : -1);
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- InputStream in = getInputStream();
- return (in != null ? in.read(b) : -1);
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- InputStream in = getInputStream();
- return (in != null ? in.read(b, off, len) : -1);
- }
-
- @Override
- public long skip(long n) throws IOException {
- InputStream in = getInputStream();
- return (in != null ? in.skip(n) : 0);
- }
-
- @Override
- public boolean markSupported() {
- InputStream in = getInputStream();
- return (in != null && in.markSupported());
- }
-
- @Override
- public void mark(int readlimit) {
- InputStream in = getInputStream();
- if (in != null) {
- in.mark(readlimit);
- }
- }
-
- @Override
- public void reset() throws IOException {
- InputStream in = getInputStream();
- if (in != null) {
- in.reset();
- }
- }
-
- @Override
- public int available() throws IOException {
- InputStream in = getInputStream();
- return (in != null ? in.available() : 0);
- }
-
- @Override
- public void close() throws IOException {
- InputStream in = getInputStream();
- if (in != null) {
- this.in.clear();
- }
- }
- }
-
-
- private static class NonClosingReader extends Reader {
-
- private final WeakReference reader;
-
- public NonClosingReader(Reader reader) {
- this.reader = new WeakReference(reader);
- }
-
- private Reader getReader() {
- return this.reader.get();
- }
-
- @Override
- public int read(CharBuffer target) throws IOException {
- Reader rdr = getReader();
- return (rdr != null ? rdr.read(target) : -1);
- }
-
- @Override
- public int read() throws IOException {
- Reader rdr = getReader();
- return (rdr != null ? rdr.read() : -1);
- }
-
- @Override
- public int read(char[] cbuf) throws IOException {
- Reader rdr = getReader();
- return (rdr != null ? rdr.read(cbuf) : -1);
- }
-
- @Override
- public int read(char[] cbuf, int off, int len) throws IOException {
- Reader rdr = getReader();
- return (rdr != null ? rdr.read(cbuf, off, len) : -1);
- }
-
- @Override
- public long skip(long n) throws IOException {
- Reader rdr = getReader();
- return (rdr != null ? rdr.skip(n) : 0);
- }
-
- @Override
- public boolean ready() throws IOException {
- Reader rdr = getReader();
- return (rdr != null && rdr.ready());
- }
-
- @Override
- public boolean markSupported() {
- Reader rdr = getReader();
- return (rdr != null && rdr.markSupported());
- }
-
- @Override
- public void mark(int readAheadLimit) throws IOException {
- Reader rdr = getReader();
- if (rdr != null) {
- rdr.mark(readAheadLimit);
- }
- }
-
- @Override
- public void reset() throws IOException {
- Reader rdr = getReader();
- if (rdr != null) {
- rdr.reset();
- }
- }
-
- @Override
- public void close() throws IOException {
- Reader rdr = getReader();
- if (rdr != null) {
- this.reader.clear();
- }
- }
- }
-
-}
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlOptionsFactoryBean.java b/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlOptionsFactoryBean.java
deleted file mode 100644
index 12a7fdab52..0000000000
--- a/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/XmlOptionsFactoryBean.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2002-2014 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.oxm.xmlbeans;
-
-import java.util.Map;
-
-import org.apache.xmlbeans.XmlOptions;
-
-import org.springframework.beans.factory.FactoryBean;
-
-/**
- * {@link FactoryBean} that configures an XMLBeans {@code XmlOptions} object
- * and provides it as a bean reference.
- *
- * Typical usage will be to set XMLBeans options on this bean, and refer to it
- * in the {@link XmlBeansMarshaller}.
- *
- * @author Arjen Poutsma
- * @author Juergen Hoeller
- * @since 3.0
- * @see XmlOptions
- * @see #setOptions(java.util.Map)
- * @see XmlBeansMarshaller#setXmlOptions(XmlOptions)
- */
-public class XmlOptionsFactoryBean implements FactoryBean {
-
- private XmlOptions xmlOptions = new XmlOptions();
-
-
- /**
- * Set options on the underlying {@code XmlOptions} object.
- * The keys of the supplied map should be one of the String constants
- * defined in {@code XmlOptions}, the values vary per option.
- * @see XmlOptions#put(Object, Object)
- * @see XmlOptions#SAVE_PRETTY_PRINT
- * @see XmlOptions#LOAD_STRIP_COMMENTS
- */
- public void setOptions(Map optionsMap) {
- this.xmlOptions = new XmlOptions();
- if (optionsMap != null) {
- for (Map.Entry option : optionsMap.entrySet()) {
- this.xmlOptions.put(option.getKey(), option.getValue());
- }
- }
- }
-
-
- @Override
- public XmlOptions getObject() {
- return this.xmlOptions;
- }
-
- @Override
- public Class extends XmlOptions> getObjectType() {
- return XmlOptions.class;
- }
-
- @Override
- public boolean isSingleton() {
- return true;
- }
-
-}
diff --git a/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/package-info.java b/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/package-info.java
deleted file mode 100644
index e7910a93e9..0000000000
--- a/spring-oxm/src/main/java/org/springframework/oxm/xmlbeans/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * Package providing integration of XMLBeans
- * with Spring's O/X Mapping support.
- */
-package org.springframework.oxm.xmlbeans;
diff --git a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java
index 9595d8087e..98c86013ee 100644
--- a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java
+++ b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * 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.
@@ -16,8 +16,6 @@
package org.springframework.oxm.config;
-import org.apache.xmlbeans.XmlOptions;
-
import org.junit.Test;
import org.springframework.context.ApplicationContext;
@@ -37,18 +35,9 @@ import static org.junit.Assert.*;
@SuppressWarnings("deprecation")
public class OxmNamespaceHandlerTests {
- private final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
- "oxmNamespaceHandlerTest.xml", getClass());
+ private final ApplicationContext applicationContext =
+ new ClassPathXmlApplicationContext("oxmNamespaceHandlerTest.xml", getClass());
- @Test
- public void xmlBeansMarshaller() throws Exception {
- org.springframework.oxm.xmlbeans.XmlBeansMarshaller marshaller = applicationContext.getBean(
- org.springframework.oxm.xmlbeans.XmlBeansMarshaller.class);
- XmlOptions options = marshaller.getXmlOptions();
- assertNotNull("Options not set", options);
- assertTrue("option not set", options.hasOption("SAVE_PRETTY_PRINT"));
- assertEquals("option not set", "true", options.get("SAVE_PRETTY_PRINT"));
- }
@Test
public void jaxb2ContextPathMarshaller() throws Exception {
@@ -85,4 +74,5 @@ public class OxmNamespaceHandlerTests {
CastorMarshaller castorMarshaller = applicationContext.getBean("castorMappingLocationMarshaller", CastorMarshaller.class);
assertNotNull(castorMarshaller);
}
-}
\ No newline at end of file
+
+}
diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansMarshallerTests.java
deleted file mode 100644
index 4a7507520e..0000000000
--- a/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansMarshallerTests.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.
- * 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.oxm.xmlbeans;
-
-import java.io.ByteArrayOutputStream;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.xmlbeans.XmlObject;
-
-import org.junit.Test;
-
-import org.springframework.oxm.AbstractMarshallerTests;
-import org.springframework.samples.flight.FlightType;
-import org.springframework.samples.flight.FlightsDocument;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Arjen Poutsma
- * @author Sam Brannen
- */
-@SuppressWarnings("deprecation")
-public class XmlBeansMarshallerTests extends
- AbstractMarshallerTests {
-
- @Override
- protected XmlBeansMarshaller createMarshaller() throws Exception {
- return new XmlBeansMarshaller();
- }
-
- @Override
- protected Object createFlights() {
- FlightsDocument flightsDocument = FlightsDocument.Factory.newInstance();
- FlightsDocument.Flights flights = flightsDocument.addNewFlights();
- FlightType flightType = flights.addNewFlight();
- flightType.setNumber(42L);
- return flightsDocument;
- }
-
- @Test(expected = ClassCastException.class)
- public void marshalNonXmlObject() throws Exception {
- marshaller.marshal(new Object(), new StreamResult(new ByteArrayOutputStream()));
- }
-
- @Test
- public void supports() throws Exception {
- assertTrue("XmlBeansMarshaller does not support XmlObject", marshaller.supports(XmlObject.class));
- assertFalse("XmlBeansMarshaller supports other objects", marshaller.supports(Object.class));
- assertTrue("XmlBeansMarshaller does not support FlightsDocument", marshaller.supports(FlightsDocument.class));
- assertTrue("XmlBeansMarshaller does not support Flights", marshaller.supports(FlightsDocument.Flights.class));
- assertTrue("XmlBeansMarshaller does not support FlightType", marshaller.supports(FlightType.class));
- }
-
-}
diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansUnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansUnmarshallerTests.java
deleted file mode 100644
index 4a6fe9215f..0000000000
--- a/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlBeansUnmarshallerTests.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.
- * 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.oxm.xmlbeans;
-
-import java.io.StringReader;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-
-import org.junit.Test;
-
-import org.springframework.oxm.AbstractUnmarshallerTests;
-import org.springframework.oxm.ValidationFailureException;
-import org.springframework.samples.flight.FlightDocument;
-import org.springframework.samples.flight.FlightType;
-import org.springframework.samples.flight.FlightsDocument;
-import org.springframework.util.xml.StaxUtils;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Arjen Poutsma
- */
-@SuppressWarnings("deprecation")
-public class XmlBeansUnmarshallerTests extends
- AbstractUnmarshallerTests {
-
- @Override
- protected XmlBeansMarshaller createUnmarshaller() throws Exception {
- return new XmlBeansMarshaller();
- }
-
- @Override
- protected void testFlights(Object o) {
- FlightsDocument flightsDocument = (FlightsDocument) o;
- assertNotNull("FlightsDocument is null", flightsDocument);
- FlightsDocument.Flights flights = flightsDocument.getFlights();
- assertEquals("Invalid amount of flight elements", 1, flights.sizeOfFlightArray());
- testFlight(flights.getFlightArray(0));
- }
-
- @Override
- protected void testFlight(Object o) {
- FlightType flight = null;
- if (o instanceof FlightType) {
- flight = (FlightType) o;
- }
- else if (o instanceof FlightDocument) {
- FlightDocument flightDocument = (FlightDocument) o;
- flight = flightDocument.getFlight();
- }
- assertNotNull("Flight is null", flight);
- assertEquals("Number is invalid", 42L, flight.getNumber());
- }
-
- @Test
- @Override
- public void unmarshalPartialStaxSourceXmlStreamReader() throws Exception {
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
- XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
- streamReader.nextTag(); // skip to flights
- assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flights"),
- streamReader.getName());
- streamReader.nextTag(); // skip to flight
- assertEquals("Invalid element", new QName("http://samples.springframework.org/flight", "flight"),
- streamReader.getName());
- Source source = StaxUtils.createStaxSource(streamReader);
- Object flight = unmarshaller.unmarshal(source);
- testFlight(flight);
- }
-
- @Test(expected = ValidationFailureException.class)
- public void validate() throws Exception {
- unmarshaller.setValidating(true);
- String invalidInput = "" +
- "abc";
- unmarshaller.unmarshal(new StreamSource(new StringReader(invalidInput)));
- }
-
-}
diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlOptionsFactoryBeanTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlOptionsFactoryBeanTests.java
deleted file mode 100644
index ac594ffb68..0000000000
--- a/spring-oxm/src/test/java/org/springframework/oxm/xmlbeans/XmlOptionsFactoryBeanTests.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2002-2012 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.oxm.xmlbeans;
-
-import java.util.Collections;
-
-import org.apache.xmlbeans.XmlOptions;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Arjen Poutsma
- */
-public class XmlOptionsFactoryBeanTests {
-
- private XmlOptionsFactoryBean factoryBean = new XmlOptionsFactoryBean();
-
- @Test
- public void xmlOptionsFactoryBean() throws Exception {
- factoryBean.setOptions(Collections.singletonMap(XmlOptions.SAVE_PRETTY_PRINT, Boolean.TRUE));
- XmlOptions xmlOptions = factoryBean.getObject();
- assertNotNull("No XmlOptions returned", xmlOptions);
- assertTrue("Option not set", xmlOptions.hasOption(XmlOptions.SAVE_PRETTY_PRINT));
- assertFalse("Invalid option set", xmlOptions.hasOption(XmlOptions.LOAD_LINE_NUMBERS));
- }
-
-}
diff --git a/spring-oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml b/spring-oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml
index bf4450fd93..89e76aa79d 100644
--- a/spring-oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml
+++ b/spring-oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml
@@ -4,17 +4,6 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd">
-
-
-
-
-
-
- true
-
-
-
-