diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index be10b7fecdb..a0e88fef268 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 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. @@ -78,7 +78,7 @@ import static org.xmlunit.diff.DifferenceEvaluators.downgradeDifferencesToEqual; * @author Biju Kunjummen * @author Sam Brannen */ -public class Jaxb2MarshallerTests extends AbstractMarshallerTests { +class Jaxb2MarshallerTests extends AbstractMarshallerTests { private static final String CONTEXT_PATH = "org.springframework.oxm.jaxb.test"; @@ -104,7 +104,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTestssingletonMap(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, - Boolean.TRUE)); + Collections.singletonMap(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE)); marshaller.afterPropertiesSet(); } @Test - public void noContextPathOrClassesToBeBound() throws Exception { + void noContextPathOrClassesToBeBound() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); - assertThatIllegalArgumentException().isThrownBy( - marshaller::afterPropertiesSet); + assertThatIllegalArgumentException().isThrownBy(marshaller::afterPropertiesSet); } @Test - public void testInvalidContextPath() throws Exception { + void testInvalidContextPath() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath("ab"); - assertThatExceptionOfType(UncategorizedMappingException.class).isThrownBy( - marshaller::afterPropertiesSet); + assertThatExceptionOfType(UncategorizedMappingException.class).isThrownBy(marshaller::afterPropertiesSet); } @Test - public void marshalInvalidClass() throws Exception { + void marshalInvalidClass() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(FlightType.class); marshaller.afterPropertiesSet(); Result result = new StreamResult(new StringWriter()); Flights flights = new Flights(); - assertThatExceptionOfType(XmlMappingException.class).isThrownBy(() -> - marshaller.marshal(flights, result)); + assertThatExceptionOfType(XmlMappingException.class).isThrownBy(() -> marshaller.marshal(flights, result)); } @Test - public void supportsContextPath() throws Exception { + void supportsContextPath() throws Exception { testSupports(); } @Test - public void supportsClassesToBeBound() throws Exception { + void supportsClassesToBeBound() throws Exception { marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(Flights.class, FlightType.class); marshaller.afterPropertiesSet(); @@ -186,7 +182,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests { Type returnType = method.getGenericReturnType(); - assertThat(marshaller.supports(returnType)).as("Jaxb2Marshaller does not support JAXBElement<" + method.getName().substring(9) + ">").isTrue(); + assertThat(marshaller.supports(returnType)) + .as("Jaxb2Marshaller does not support JAXBElement<" + method.getName().substring(9) + ">") + .isTrue(); try { // make sure the marshalling does not result in errors Object returnValue = method.invoke(primitives); @@ -237,22 +233,18 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests method.getName().startsWith("primitive") + ); } private void testSupportsStandardClasses() throws Exception { final StandardClasses standardClasses = new StandardClasses(); - ReflectionUtils.doWithMethods(StandardClasses.class, new ReflectionUtils.MethodCallback() { - @Override - public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { + ReflectionUtils.doWithMethods(StandardClasses.class, method -> { Type returnType = method.getGenericReturnType(); - assertThat(marshaller.supports(returnType)).as("Jaxb2Marshaller does not support JAXBElement<" + method.getName().substring(13) + ">").isTrue(); + assertThat(marshaller.supports(returnType)) + .as("Jaxb2Marshaller does not support JAXBElement<" + method.getName().substring(13) + ">") + .isTrue(); try { // make sure the marshalling does not result in errors Object returnValue = method.invoke(standardClasses); @@ -261,17 +253,13 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests method.getName().startsWith("standardClass") + ); } @Test - public void supportsXmlRootElement() throws Exception { + void supportsXmlRootElement() throws Exception { marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(DummyRootElement.class, DummyType.class); marshaller.afterPropertiesSet(); @@ -284,7 +272,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests