Polishing
This commit is contained in:
parent
37c734ec90
commit
8a7467020f
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -16,6 +16,16 @@
|
||||||
|
|
||||||
package org.springframework.util.xml;
|
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.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -26,19 +36,8 @@ import org.xml.sax.XMLReader;
|
||||||
import org.xml.sax.helpers.XMLReaderFactory;
|
import org.xml.sax.helpers.XMLReaderFactory;
|
||||||
import org.xmlunit.util.Predicate;
|
import org.xmlunit.util.Predicate;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import static org.junit.Assert.*;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import static org.xmlunit.matchers.CompareMatcher.*;
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
|
|
@ -57,17 +56,18 @@ public abstract class AbstractStaxHandlerTestCase {
|
||||||
"<?pi content?><root xmlns='namespace'><prefix:child xmlns:prefix='namespace2' prefix:attr='value'>content</prefix:child>" +
|
"<?pi content?><root xmlns='namespace'><prefix:child xmlns:prefix='namespace2' prefix:attr='value'>content</prefix:child>" +
|
||||||
"</root>";
|
"</root>";
|
||||||
|
|
||||||
|
private static final Predicate<Node> nodeFilter = (n -> n.getNodeType() != Node.COMMENT_NODE &&
|
||||||
|
n.getNodeType() != Node.DOCUMENT_TYPE_NODE && n.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE);
|
||||||
|
|
||||||
private XMLReader xmlReader;
|
private XMLReader xmlReader;
|
||||||
|
|
||||||
private Predicate<Node> nodeFilter = n -> n.getNodeType() != Node.COMMENT_NODE
|
|
||||||
&& n.getNodeType() != Node.DOCUMENT_TYPE_NODE && n.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void createXMLReader() throws Exception {
|
public void createXMLReader() throws Exception {
|
||||||
xmlReader = XMLReaderFactory.createXMLReader();
|
xmlReader = XMLReaderFactory.createXMLReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noNamespacePrefixes() throws Exception {
|
public void noNamespacePrefixes() throws Exception {
|
||||||
Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible());
|
Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible());
|
||||||
|
|
@ -114,8 +114,7 @@ public abstract class AbstractStaxHandlerTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void noNamespacePrefixesDom() throws Exception {
|
public void noNamespacePrefixesDom() throws Exception {
|
||||||
DocumentBuilderFactory documentBuilderFactory =
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilderFactory.newInstance();
|
|
||||||
documentBuilderFactory.setNamespaceAware(true);
|
documentBuilderFactory.setNamespaceAware(true);
|
||||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||||
|
|
||||||
|
|
@ -136,8 +135,7 @@ public abstract class AbstractStaxHandlerTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void namespacePrefixesDom() throws Exception {
|
public void namespacePrefixesDom() throws Exception {
|
||||||
DocumentBuilderFactory documentBuilderFactory =
|
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilderFactory.newInstance();
|
|
||||||
documentBuilderFactory.setNamespaceAware(true);
|
documentBuilderFactory.setNamespaceAware(true);
|
||||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public class StaxEventHandlerTests extends AbstractStaxHandlerTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStaxHandler createStaxHandler(Result result)
|
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
|
||||||
throws XMLStreamException {
|
|
||||||
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
|
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
|
||||||
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(result);
|
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(result);
|
||||||
return new StaxEventHandler(eventWriter);
|
return new StaxEventHandler(eventWriter);
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
public class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStaxHandler createStaxHandler(Result result)
|
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
|
||||||
throws XMLStreamException {
|
|
||||||
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
|
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
|
||||||
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(result);
|
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(result);
|
||||||
return new StaxStreamHandler(streamWriter);
|
return new StaxStreamHandler(streamWriter);
|
||||||
|
|
|
||||||
|
|
@ -439,8 +439,7 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||||
|
|
||||||
private final MultiValueMap<String, T> urlLookup = new LinkedMultiValueMap<>();
|
private final MultiValueMap<String, T> urlLookup = new LinkedMultiValueMap<>();
|
||||||
|
|
||||||
private final Map<HandlerMethod, CorsConfiguration> corsLookup =
|
private final Map<HandlerMethod, CorsConfiguration> corsLookup = new ConcurrentHashMap<>();
|
||||||
new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -480,11 +480,9 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
|
||||||
|
|
||||||
private final MultiValueMap<String, T> urlLookup = new LinkedMultiValueMap<>();
|
private final MultiValueMap<String, T> urlLookup = new LinkedMultiValueMap<>();
|
||||||
|
|
||||||
private final Map<String, List<HandlerMethod>> nameLookup =
|
private final Map<String, List<HandlerMethod>> nameLookup = new ConcurrentHashMap<>();
|
||||||
new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
private final Map<HandlerMethod, CorsConfiguration> corsLookup =
|
private final Map<HandlerMethod, CorsConfiguration> corsLookup = new ConcurrentHashMap<>();
|
||||||
new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue