Browse Source

Polishing

pull/1463/merge
Juergen Hoeller 8 years ago
parent
commit
140542e8b1
  1. 14
      spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java
  2. 7
      spring-jms/src/test/java/org/springframework/jms/support/converter/MarshallingMessageConverterTests.java
  3. 18
      spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java

14
spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java

@ -90,14 +90,13 @@ public class SpelCompiler implements Opcodes { @@ -90,14 +90,13 @@ public class SpelCompiler implements Opcodes {
/**
* Attempt compilation of the supplied expression. A check is
* made to see if it is compilable before compilation proceeds. The
* check involves visiting all the nodes in the expression Ast and
* ensuring enough state is known about them that bytecode can
* be generated for them.
* Attempt compilation of the supplied expression. A check is made to see
* if it is compilable before compilation proceeds. The check involves
* visiting all the nodes in the expression Ast and ensuring enough state
* is known about them that bytecode can be generated for them.
* @param expression the expression to compile
* @return an instance of the class implementing the compiled expression, or null
* if compilation is not possible
* @return an instance of the class implementing the compiled expression,
* or {@code null} if compilation is not possible
*/
@Nullable
public CompiledExpression compile(SpelNodeImpl expression) {
@ -193,7 +192,6 @@ public class SpelCompiler implements Opcodes { @@ -193,7 +192,6 @@ public class SpelCompiler implements Opcodes {
* because they anchor compiled classes in memory and prevent GC. If you have expressions
* continually recompiling over time then by replacing the classloader periodically
* at least some of the older variants can be garbage collected.
*
* @param name name of the class
* @param bytes bytecode for the class
* @return the Class object for the compiled expression

7
spring-jms/src/test/java/org/springframework/jms/support/converter/MarshallingMessageConverterTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 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.
@ -44,14 +44,16 @@ public class MarshallingMessageConverterTests { @@ -44,14 +44,16 @@ public class MarshallingMessageConverterTests {
private Session sessionMock;
@Before
public void setUp() throws Exception {
public void setup() throws Exception {
marshallerMock = mock(Marshaller.class);
unmarshallerMock = mock(Unmarshaller.class);
sessionMock = mock(Session.class);
converter = new MarshallingMessageConverter(marshallerMock, unmarshallerMock);
}
@Test
public void toBytesMessage() throws Exception {
BytesMessage bytesMessageMock = mock(BytesMessage.class);
@ -102,4 +104,5 @@ public class MarshallingMessageConverterTests { @@ -102,4 +104,5 @@ public class MarshallingMessageConverterTests {
Object result = converter.fromMessage(textMessageMock);
assertEquals("Invalid result", result, unmarshalled);
}
}

18
spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java

@ -186,7 +186,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle @@ -186,7 +186,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
@Test
public void supportsPackagesToScan() throws Exception {
marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(new String[] {CONTEXT_PATH});
marshaller.setPackagesToScan(CONTEXT_PATH);
marshaller.afterPropertiesSet();
testSupports();
}
@ -306,11 +306,10 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle @@ -306,11 +306,10 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
verify(mimeContainer, times(3)).addAttachment(isA(String.class), isA(DataHandler.class));
}
@Test
@Test // SPR-10714
public void marshalAWrappedObjectHoldingAnXmlElementDeclElement() throws Exception {
// SPR-10714
marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(new String[]{"org.springframework.oxm.jaxb"});
marshaller.setPackagesToScan("org.springframework.oxm.jaxb");
marshaller.afterPropertiesSet();
Airplane airplane = new Airplane();
airplane.setName("test");
@ -323,11 +322,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle @@ -323,11 +322,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
isSimilarTo("<airplane><name>test</name></airplane>").withDifferenceEvaluator(ev));
}
// SPR-10806
@Test
@Test // SPR-10806
public void unmarshalStreamSourceWithXmlOptions() throws Exception {
final javax.xml.bind.Unmarshaller unmarshaller = mock(javax.xml.bind.Unmarshaller.class);
Jaxb2Marshaller marshaller = new Jaxb2Marshaller() {
@Override
@ -360,11 +356,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle @@ -360,11 +356,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
assertEquals(true, result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities"));
}
// SPR-10806
@Test
@Test // SPR-10806
public void unmarshalSaxSourceWithXmlOptions() throws Exception {
final javax.xml.bind.Unmarshaller unmarshaller = mock(javax.xml.bind.Unmarshaller.class);
Jaxb2Marshaller marshaller = new Jaxb2Marshaller() {
@Override
@ -421,4 +414,5 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle @@ -421,4 +414,5 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
private JAXBElement<DummyType> createDummyType() {
return null;
}
}

Loading…
Cancel
Save