From 8a7467020f11f95bd47c55f54abc454278788407 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 15 Dec 2016 15:44:16 +0100 Subject: [PATCH] Polishing --- .../util/xml/AbstractStaxHandlerTestCase.java | 38 +++++++++---------- .../util/xml/StaxEventHandlerTests.java | 5 +-- .../util/xml/StaxStreamHandlerTests.java | 5 +-- .../method/AbstractHandlerMethodMapping.java | 3 +- .../handler/AbstractHandlerMethodMapping.java | 6 +-- 5 files changed, 25 insertions(+), 32 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java index 026dd5ffcf..b2ba4227f8 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.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,6 +16,16 @@ package org.springframework.util.xml; +import java.io.StringReader; +import java.io.StringWriter; +import java.net.Socket; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.transform.Result; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.stream.StreamResult; + import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -26,19 +36,8 @@ import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; import org.xmlunit.util.Predicate; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.transform.Result; -import javax.xml.transform.dom.DOMResult; -import javax.xml.transform.stream.StreamResult; -import java.io.StringReader; -import java.io.StringWriter; -import java.net.Socket; - -import static org.junit.Assert.assertThat; -import static org.xmlunit.matchers.CompareMatcher.isSimilarTo; - +import static org.junit.Assert.*; +import static org.xmlunit.matchers.CompareMatcher.*; /** * @author Arjen Poutsma @@ -57,17 +56,18 @@ public abstract class AbstractStaxHandlerTestCase { "content" + ""; + private static final Predicate nodeFilter = (n -> n.getNodeType() != Node.COMMENT_NODE && + n.getNodeType() != Node.DOCUMENT_TYPE_NODE && n.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE); private XMLReader xmlReader; - private Predicate nodeFilter = n -> n.getNodeType() != Node.COMMENT_NODE - && n.getNodeType() != Node.DOCUMENT_TYPE_NODE && n.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE; @Before public void createXMLReader() throws Exception { xmlReader = XMLReaderFactory.createXMLReader(); } + @Test public void noNamespacePrefixes() throws Exception { Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible()); @@ -114,8 +114,7 @@ public abstract class AbstractStaxHandlerTestCase { @Test public void noNamespacePrefixesDom() throws Exception { - DocumentBuilderFactory documentBuilderFactory = - DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); @@ -136,8 +135,7 @@ public abstract class AbstractStaxHandlerTestCase { @Test public void namespacePrefixesDom() throws Exception { - DocumentBuilderFactory documentBuilderFactory = - DocumentBuilderFactory.newInstance(); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java index d2c44d66b6..2ad1ae9a43 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 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. @@ -27,8 +27,7 @@ import javax.xml.transform.Result; public class StaxEventHandlerTests extends AbstractStaxHandlerTestCase { @Override - protected AbstractStaxHandler createStaxHandler(Result result) - throws XMLStreamException { + protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException { XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(result); return new StaxEventHandler(eventWriter); diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java index a039826bed..116aec625e 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 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. @@ -27,8 +27,7 @@ import javax.xml.transform.Result; public class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase { @Override - protected AbstractStaxHandler createStaxHandler(Result result) - throws XMLStreamException { + protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException { XMLOutputFactory outputFactory = XMLOutputFactory.newFactory(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(result); return new StaxStreamHandler(streamWriter); diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java index f76cbf88be..d541c01d59 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java @@ -439,8 +439,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap private final MultiValueMap urlLookup = new LinkedMultiValueMap<>(); - private final Map corsLookup = - new ConcurrentHashMap<>(); + private final Map corsLookup = new ConcurrentHashMap<>(); private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index 7831703ce8..671b2d323a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -480,11 +480,9 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap private final MultiValueMap urlLookup = new LinkedMultiValueMap<>(); - private final Map> nameLookup = - new ConcurrentHashMap<>(); + private final Map> nameLookup = new ConcurrentHashMap<>(); - private final Map corsLookup = - new ConcurrentHashMap<>(); + private final Map corsLookup = new ConcurrentHashMap<>(); private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();