SPR-8309 - Spring OXM schema improvement for CastorMarshaller
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright ${YEAR} the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -17,18 +17,24 @@
|
||||
package org.springframework.oxm.config;
|
||||
|
||||
import org.apache.xmlbeans.XmlOptions;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.oxm.castor.CastorMarshaller;
|
||||
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
||||
import org.springframework.oxm.jibx.JibxMarshaller;
|
||||
import org.springframework.oxm.xmlbeans.XmlBeansMarshaller;
|
||||
|
||||
public class OxmNamespaceHandlerTest {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests the {@link OxmNamespaceHandler} class.
|
||||
*
|
||||
* @author Arjen Poustma
|
||||
* @author Jakub Narloch
|
||||
*/
|
||||
public class OxmNamespaceHandlerTests {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@@ -37,12 +43,6 @@ public class OxmNamespaceHandlerTest {
|
||||
applicationContext = new ClassPathXmlApplicationContext("oxmNamespaceHandlerTest.xml", getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void jibxMarshaller() throws Exception {
|
||||
applicationContext.getBean("jibxMarshaller", JibxMarshaller.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlBeansMarshaller() throws Exception {
|
||||
XmlBeansMarshaller marshaller = applicationContext.getBean("xmlBeansMarshaller", XmlBeansMarshaller.class);
|
||||
@@ -54,12 +54,37 @@ public class OxmNamespaceHandlerTest {
|
||||
|
||||
@Test
|
||||
public void jaxb2ContextPathMarshaller() throws Exception {
|
||||
applicationContext.getBean("contextPathMarshaller", Jaxb2Marshaller.class);
|
||||
Jaxb2Marshaller jaxb2Marshaller = applicationContext.getBean("jaxb2ContextPathMarshaller", Jaxb2Marshaller.class);
|
||||
assertNotNull(jaxb2Marshaller);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jaxb2ClassesToBeBoundMarshaller() throws Exception {
|
||||
applicationContext.getBean("classesMarshaller", Jaxb2Marshaller.class);
|
||||
Jaxb2Marshaller jaxb2Marshaller = applicationContext.getBean("jaxb2ClassesMarshaller", Jaxb2Marshaller.class);
|
||||
assertNotNull(jaxb2Marshaller);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void castorEncodingMarshaller() throws Exception {
|
||||
CastorMarshaller castorMarshaller = applicationContext.getBean("castorEncodingMarshaller", CastorMarshaller.class);
|
||||
assertNotNull(castorMarshaller);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void castorTargetClassMarshaller() throws Exception {
|
||||
CastorMarshaller castorMarshaller = applicationContext.getBean("castorTargetClassMarshaller", CastorMarshaller.class);
|
||||
assertNotNull(castorMarshaller);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void castorTargetPackageMarshaller() throws Exception {
|
||||
CastorMarshaller castorMarshaller = applicationContext.getBean("castorTargetPackageMarshaller", CastorMarshaller.class);
|
||||
assertNotNull(castorMarshaller);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void castorMappingLocationMarshaller() throws Exception {
|
||||
CastorMarshaller castorMarshaller = applicationContext.getBean("castorMappingLocationMarshaller", CastorMarshaller.class);
|
||||
assertNotNull(castorMarshaller);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:oxm="http://www.springframework.org/schema/oxm"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">
|
||||
<!--<oxm:jibx-marshaller id="jibxMarshaller" target-class="org.springframework.oxm.jibx.Flights"/>-->
|
||||
<oxm:xmlbeans-marshaller id="xmlBeansMarshaller" options="xmlBeansOptions"/>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd">
|
||||
|
||||
<bean id="xmlBeansOptions" class="org.springframework.oxm.xmlbeans.XmlOptionsFactoryBean">
|
||||
<property name="options">
|
||||
<props>
|
||||
<prop key="SAVE_PRETTY_PRINT">true</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
<!-- XMLBeans -->
|
||||
<oxm:xmlbeans-marshaller id="xmlBeansMarshaller"
|
||||
options="xmlBeansOptions" />
|
||||
|
||||
<oxm:jaxb2-marshaller id="contextPathMarshaller" contextPath="org.springframework.oxm.jaxb.test"/>
|
||||
<oxm:jaxb2-marshaller id="classesMarshaller">
|
||||
<oxm:class-to-be-bound name="org.springframework.oxm.jaxb.test.Flights"/>
|
||||
<oxm:class-to-be-bound name="org.springframework.oxm.jaxb.test.FlightType"/>
|
||||
<bean id="xmlBeansOptions" class="org.springframework.oxm.xmlbeans.XmlOptionsFactoryBean">
|
||||
<property name="options">
|
||||
<props>
|
||||
<prop key="SAVE_PRETTY_PRINT">true</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- JAXB2 -->
|
||||
<oxm:jaxb2-marshaller id="jaxb2ContextPathMarshaller"
|
||||
contextPath="org.springframework.oxm.jaxb.test" />
|
||||
|
||||
<oxm:jaxb2-marshaller id="jaxb2ClassesMarshaller">
|
||||
<oxm:class-to-be-bound name="org.springframework.oxm.jaxb.test.Flights" />
|
||||
<oxm:class-to-be-bound name="org.springframework.oxm.jaxb.test.FlightType" />
|
||||
</oxm:jaxb2-marshaller>
|
||||
|
||||
<!-- Castor -->
|
||||
|
||||
<oxm:castor-marshaller id="castorEncodingMarshaller" encoding="ISO-8859-1" />
|
||||
|
||||
<oxm:castor-marshaller id="castorTargetClassMarshaller" target-class="org.springframework.oxm.castor.Flight" />
|
||||
|
||||
<oxm:castor-marshaller id="castorTargetPackageMarshaller" target-package="org.springframework.oxm.castor" />
|
||||
|
||||
<oxm:castor-marshaller id="castorMappingLocationMarshaller"
|
||||
mapping-location="classpath:org/springframework/oxm/castor/mapping.xml" />
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user