File tree 2 files changed +18
-1
lines changed
org.springframework.oxm/src
main/java/org/springframework/oxm/jaxb
test/java/org/springframework/oxm/jaxb
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 63
63
64
64
import org .springframework .beans .factory .BeanClassLoaderAware ;
65
65
import org .springframework .beans .factory .InitializingBean ;
66
+ import org .springframework .core .annotation .AnnotationUtils ;
66
67
import org .springframework .core .io .Resource ;
67
68
import org .springframework .oxm .MarshallingFailureException ;
68
69
import org .springframework .oxm .UncategorizedMappingException ;
@@ -369,7 +370,7 @@ public boolean supports(Class<?> clazz) {
369
370
if (JAXBElement .class .isAssignableFrom (clazz )) {
370
371
return true ;
371
372
}
372
- else if (clazz . getAnnotation ( XmlRootElement .class ) != null ) {
373
+ else if (AnnotationUtils . findAnnotation ( clazz , XmlRootElement .class ) != null ) {
373
374
return true ;
374
375
}
375
376
if (StringUtils .hasLength (this .contextPath )) {
Original file line number Diff line number Diff line change @@ -184,4 +184,20 @@ public void marshalAttachments() throws Exception {
184
184
verify (mimeContainer );
185
185
assertTrue ("No XML written" , writer .toString ().length () > 0 );
186
186
}
187
+
188
+ @ Test
189
+ public void subclass () throws Exception {
190
+ assertTrue ("Flights subclass is not supported" , marshaller .supports (FlightsSubclass .class ));
191
+ FlightType flight = new FlightType ();
192
+ flight .setNumber (42L );
193
+ FlightsSubclass flights = new FlightsSubclass ();
194
+ flights .getFlight ().add (flight );
195
+ StringWriter writer = new StringWriter ();
196
+ marshaller .marshal (flights , new StreamResult (writer ));
197
+ assertXMLEqual ("Marshaller writes invalid StreamResult" , EXPECTED_STRING , writer .toString ());
198
+ }
199
+
200
+ private static class FlightsSubclass extends Flights {
201
+
202
+ }
187
203
}
You can’t perform that action at this time.
0 commit comments