Prevent improper use of testing framework APIs
Prior to this commit, a lot of work had been done to prevent improper
use of testing Framework APIs throughout the codebase; however, there
were still some loopholes.
This commit addresses these loopholes by introducing additional
Checkstyle rules (and modifying existing rules) to prevent improper use
of testing framework APIs in production code as well as in test code.
- Checkstyle rules for banned imports have been refactored into
multiple rules specific to JUnit 3, JUnit 4, JUnit Jupiter, and
TestNG.
- Accidental usage of org.junit.Assume has been switched to
org.junit.jupiter.api.Assumptions.
- All test classes now reside under org.springframework packages.
- All test classes (including abstract test classes) now conform to the
`*Tests` naming convention.
- As an added bonus, tests in the renamed
ScenariosForSpringSecurityExpressionTests are now included in the
build.
- Dead JUnit 4 parameterized code has been removed from
DefaultServerWebExchangeCheckNotModifiedTests.
Closes gh-22962
This commit is contained in:
parent
92d3f7e7d7
commit
30cff46e7f
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -14,12 +14,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.foo;
|
package org.springframework.beans.factory.xml;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Component {
|
public class Component {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private List<Component> components = new ArrayList<>();
|
private List<Component> components = new ArrayList<>();
|
||||||
|
|
||||||
|
|
@ -39,4 +40,5 @@ public class Component {
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.foo;
|
package org.springframework.beans.factory.xml;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -24,8 +24,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
import org.springframework.beans.factory.support.ManagedList;
|
import org.springframework.beans.factory.support.ManagedList;
|
||||||
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.xml.DomUtils;
|
import org.springframework.util.xml.DomUtils;
|
||||||
|
|
||||||
|
|
@ -14,52 +14,49 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.foo;
|
package org.springframework.beans.factory.xml;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
|
||||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Costin Leau
|
* @author Costin Leau
|
||||||
*/
|
*/
|
||||||
public class ComponentBeanDefinitionParserTests {
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
class ComponentBeanDefinitionParserTests {
|
||||||
|
|
||||||
|
private final DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||||
|
|
||||||
private static DefaultListableBeanFactory bf;
|
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUpBeforeClass() throws Exception {
|
void setUp() throws Exception {
|
||||||
bf = new DefaultListableBeanFactory();
|
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(new ClassPathResource("com/foo/component-config.xml"));
|
new ClassPathResource("component-config.xml", ComponentBeanDefinitionParserTests.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
public static void tearDownAfterClass() throws Exception {
|
void tearDown() {
|
||||||
bf.destroySingletons();
|
bf.destroySingletons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component getBionicFamily() {
|
|
||||||
return bf.getBean("bionic-family", Component.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBionicBasic() throws Exception {
|
void testBionicBasic() {
|
||||||
Component cp = getBionicFamily();
|
Component cp = getBionicFamily();
|
||||||
assertThat("Bionic-1").isEqualTo(cp.getName());
|
assertThat("Bionic-1").isEqualTo(cp.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBionicFirstLevelChildren() throws Exception {
|
void testBionicFirstLevelChildren() {
|
||||||
Component cp = getBionicFamily();
|
Component cp = getBionicFamily();
|
||||||
List<Component> components = cp.getComponents();
|
List<Component> components = cp.getComponents();
|
||||||
assertThat(2).isEqualTo(components.size());
|
assertThat(2).isEqualTo(components.size());
|
||||||
|
|
@ -68,11 +65,17 @@ public class ComponentBeanDefinitionParserTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBionicSecondLevelChildren() throws Exception {
|
void testBionicSecondLevelChildren() {
|
||||||
Component cp = getBionicFamily();
|
Component cp = getBionicFamily();
|
||||||
List<Component> components = cp.getComponents().get(0).getComponents();
|
List<Component> components = cp.getComponents().get(0).getComponents();
|
||||||
assertThat(2).isEqualTo(components.size());
|
assertThat(2).isEqualTo(components.size());
|
||||||
assertThat("Karate-1").isEqualTo(components.get(0).getName());
|
assertThat("Karate-1").isEqualTo(components.get(0).getName());
|
||||||
assertThat("Sport-1").isEqualTo(components.get(1).getName());
|
assertThat("Sport-1").isEqualTo(components.get(1).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Component getBionicFamily() {
|
||||||
|
return bf.getBean("bionic-family", Component.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -14,13 +14,14 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.foo;
|
package org.springframework.beans.factory.xml;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
||||||
public class ComponentFactoryBean implements FactoryBean<Component> {
|
public class ComponentFactoryBean implements FactoryBean<Component> {
|
||||||
|
|
||||||
private Component parent;
|
private Component parent;
|
||||||
private List<Component> children;
|
private List<Component> children;
|
||||||
|
|
||||||
|
|
@ -51,4 +52,5 @@ public class ComponentFactoryBean implements FactoryBean<Component> {
|
||||||
public boolean isSingleton() {
|
public boolean isSingleton() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2019 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.
|
||||||
|
|
@ -14,14 +14,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.foo;
|
package org.springframework.beans.factory.xml;
|
||||||
|
|
||||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
|
||||||
|
|
||||||
public class ComponentNamespaceHandler extends NamespaceHandlerSupport {
|
public class ComponentNamespaceHandler extends NamespaceHandlerSupport {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
registerBeanDefinitionParser("component",
|
registerBeanDefinitionParser("component", new ComponentBeanDefinitionParser());
|
||||||
new ComponentBeanDefinitionParser());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
http\://www.foo.example/schema/component=com.foo.ComponentNamespaceHandler
|
http\://www.foo.example/schema/component=org.springframework.beans.factory.xml.ComponentNamespaceHandler
|
||||||
|
|
@ -1 +1 @@
|
||||||
http\://www.foo.example/schema/component/component.xsd=com/foo/component.xsd
|
http\://www.foo.example/schema/component/component.xsd=org/springframework/beans/factory/xml/component.xsd
|
||||||
|
|
@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIOException;
|
import static org.assertj.core.api.Assertions.assertThatIOException;
|
||||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rob Harrop
|
* @author Rob Harrop
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||||
* @since 5.1.3
|
* @since 5.1.3
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ProtectedField")
|
@SuppressWarnings("ProtectedField")
|
||||||
public abstract class AbstractDecoderTestCase<D extends Decoder<?>> extends AbstractLeakCheckingTestCase {
|
public abstract class AbstractDecoderTests<D extends Decoder<?>> extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The decoder to test.
|
* The decoder to test.
|
||||||
|
|
@ -52,10 +52,10 @@ public abstract class AbstractDecoderTestCase<D extends Decoder<?>> extends Abst
|
||||||
protected D decoder;
|
protected D decoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new {@code AbstractDecoderTestCase} for the given decoder.
|
* Construct a new {@code AbstractDecoderTests} instance for the given decoder.
|
||||||
* @param decoder the decoder
|
* @param decoder the decoder
|
||||||
*/
|
*/
|
||||||
protected AbstractDecoderTestCase(D decoder) {
|
protected AbstractDecoderTests(D decoder) {
|
||||||
Assert.notNull(decoder, "Encoder must not be null");
|
Assert.notNull(decoder, "Encoder must not be null");
|
||||||
|
|
||||||
this.decoder = decoder;
|
this.decoder = decoder;
|
||||||
|
|
@ -25,7 +25,7 @@ import reactor.core.publisher.Flux;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
@ -45,7 +45,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
||||||
* @since 5.1.3
|
* @since 5.1.3
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("ProtectedField")
|
@SuppressWarnings("ProtectedField")
|
||||||
public abstract class AbstractEncoderTestCase<E extends Encoder<?>> extends AbstractLeakCheckingTestCase {
|
public abstract class AbstractEncoderTests<E extends Encoder<?>> extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The encoder to test.
|
* The encoder to test.
|
||||||
|
|
@ -57,7 +57,7 @@ public abstract class AbstractEncoderTestCase<E extends Encoder<?>> extends Abst
|
||||||
* Construct a new {@code AbstractEncoderTestCase} for the given parameters.
|
* Construct a new {@code AbstractEncoderTestCase} for the given parameters.
|
||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
*/
|
*/
|
||||||
protected AbstractEncoderTestCase(E encoder) {
|
protected AbstractEncoderTests(E encoder) {
|
||||||
|
|
||||||
Assert.notNull(encoder, "Encoder must not be null");
|
Assert.notNull(encoder, "Encoder must not be null");
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
class ByteArrayDecoderTests extends AbstractDecoderTestCase<ByteArrayDecoder> {
|
class ByteArrayDecoderTests extends AbstractDecoderTests<ByteArrayDecoder> {
|
||||||
|
|
||||||
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
class ByteArrayEncoderTests extends AbstractEncoderTestCase<ByteArrayEncoder> {
|
class ByteArrayEncoderTests extends AbstractEncoderTests<ByteArrayEncoder> {
|
||||||
|
|
||||||
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
class ByteBufferDecoderTests extends AbstractDecoderTestCase<ByteBufferDecoder> {
|
class ByteBufferDecoderTests extends AbstractDecoderTests<ByteBufferDecoder> {
|
||||||
|
|
||||||
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
class ByteBufferEncoderTests extends AbstractEncoderTestCase<ByteBufferEncoder> {
|
class ByteBufferEncoderTests extends AbstractEncoderTests<ByteBufferEncoder> {
|
||||||
|
|
||||||
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
class CharSequenceEncoderTests extends AbstractEncoderTestCase<CharSequenceEncoder> {
|
class CharSequenceEncoderTests extends AbstractEncoderTests<CharSequenceEncoder> {
|
||||||
|
|
||||||
private final String foo = "foo";
|
private final String foo = "foo";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
class DataBufferDecoderTests extends AbstractDecoderTestCase<DataBufferDecoder> {
|
class DataBufferDecoderTests extends AbstractDecoderTests<DataBufferDecoder> {
|
||||||
|
|
||||||
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
class DataBufferEncoderTests extends AbstractEncoderTestCase<DataBufferEncoder> {
|
class DataBufferEncoderTests extends AbstractEncoderTests<DataBufferEncoder> {
|
||||||
|
|
||||||
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import static org.springframework.core.ResolvableType.forClass;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
class ResourceDecoderTests extends AbstractDecoderTestCase<ResourceDecoder> {
|
class ResourceDecoderTests extends AbstractDecoderTests<ResourceDecoder> {
|
||||||
|
|
||||||
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
class ResourceEncoderTests extends AbstractEncoderTestCase<ResourceEncoder> {
|
class ResourceEncoderTests extends AbstractEncoderTests<ResourceEncoder> {
|
||||||
|
|
||||||
private final byte[] bytes = "foo".getBytes(UTF_8);
|
private final byte[] bytes = "foo".getBytes(UTF_8);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
|
class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
|
||||||
|
|
||||||
private static final ResolvableType TYPE = ResolvableType.forClass(String.class);
|
private static final ResolvableType TYPE = ResolvableType.forClass(String.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import org.junit.jupiter.api.AfterEach;
|
||||||
* @since 5.1.3
|
* @since 5.1.3
|
||||||
* @see LeakAwareDataBufferFactory
|
* @see LeakAwareDataBufferFactory
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLeakCheckingTestCase {
|
public abstract class AbstractLeakCheckingTests {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data buffer factory.
|
* The data buffer factory.
|
||||||
|
|
@ -35,7 +35,7 @@ import org.springframework.util.Assert;
|
||||||
* Implementation of the {@code DataBufferFactory} interface that keeps track of
|
* Implementation of the {@code DataBufferFactory} interface that keeps track of
|
||||||
* memory leaks.
|
* memory leaks.
|
||||||
* <p>Useful for unit tests that handle data buffers. Simply inherit from
|
* <p>Useful for unit tests that handle data buffers. Simply inherit from
|
||||||
* {@link AbstractLeakCheckingTestCase} or call {@link #checkForLeaks()} in
|
* {@link AbstractLeakCheckingTests} or call {@link #checkForLeaks()} in
|
||||||
* a JUnit <em>after</em> method yourself, and any buffers that have not been
|
* a JUnit <em>after</em> method yourself, and any buffers that have not been
|
||||||
* released will result in an {@link AssertionError}.
|
* released will result in an {@link AssertionError}.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
abstract class AbstractStaxHandlerTestCase {
|
abstract class AbstractStaxHandlerTests {
|
||||||
|
|
||||||
private static final String COMPLEX_XML =
|
private static final String COMPLEX_XML =
|
||||||
"<?xml version='1.0' encoding='UTF-8'?>" +
|
"<?xml version='1.0' encoding='UTF-8'?>" +
|
||||||
|
|
@ -54,7 +54,7 @@ import static org.mockito.Mockito.mock;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
abstract class AbstractStaxXMLReaderTestCase {
|
abstract class AbstractStaxXMLReaderTests {
|
||||||
|
|
||||||
protected static XMLInputFactory inputFactory;
|
protected static XMLInputFactory inputFactory;
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ import javax.xml.transform.Result;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
class StaxEventHandlerTests extends AbstractStaxHandlerTestCase {
|
class StaxEventHandlerTests extends AbstractStaxHandlerTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
|
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
class StaxEventXMLReaderTests extends AbstractStaxXMLReaderTestCase {
|
class StaxEventXMLReaderTests extends AbstractStaxXMLReaderTests {
|
||||||
|
|
||||||
public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import javax.xml.transform.Result;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase {
|
class StaxStreamHandlerTests extends AbstractStaxHandlerTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
|
protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
class StaxStreamXMLReaderTests extends AbstractStaxXMLReaderTestCase {
|
class StaxStreamXMLReaderTests extends AbstractStaxXMLReaderTests {
|
||||||
|
|
||||||
public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
public static final String CONTENT = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*
|
*
|
||||||
* @author Andy Clement
|
* @author Andy Clement
|
||||||
*/
|
*/
|
||||||
public class ScenariosForSpringSecurity extends AbstractExpressionTests {
|
public class ScenariosForSpringSecurityExpressionTests extends AbstractExpressionTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScenario01_Roles() throws Exception {
|
public void testScenario01_Roles() throws Exception {
|
||||||
|
|
@ -27,7 +27,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
|
@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class FormHttpMessageReaderTests extends AbstractLeakCheckingTestCase {
|
public class FormHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private final FormHttpMessageReader reader = new FormHttpMessageReader();
|
private final FormHttpMessageReader reader = new FormHttpMessageReader();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
||||||
|
|
@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class FormHttpMessageWriterTests extends AbstractLeakCheckingTestCase {
|
public class FormHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private final FormHttpMessageWriter writer = new FormHttpMessageWriter();
|
private final FormHttpMessageWriter writer = new FormHttpMessageWriter();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
||||||
|
|
@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingTestCase {
|
public class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private ServerSentEventHttpMessageReader messageReader =
|
private ServerSentEventHttpMessageReader messageReader =
|
||||||
new ServerSentEventHttpMessageReader(new Jackson2JsonDecoder());
|
new ServerSentEventHttpMessageReader(new Jackson2JsonDecoder());
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.AbstractDecoderTestCase;
|
import org.springframework.core.codec.AbstractDecoderTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.codec.Pojo;
|
import org.springframework.http.codec.Pojo;
|
||||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
|
@ -41,7 +41,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class Jackson2CborDecoderTests extends AbstractDecoderTestCase<Jackson2CborDecoder> {
|
public class Jackson2CborDecoderTests extends AbstractDecoderTests<Jackson2CborDecoder> {
|
||||||
|
|
||||||
private final static MimeType CBOR_MIME_TYPE = new MimeType("application", "cbor");
|
private final static MimeType CBOR_MIME_TYPE = new MimeType("application", "cbor");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
||||||
import org.springframework.http.codec.Pojo;
|
import org.springframework.http.codec.Pojo;
|
||||||
|
|
@ -43,7 +43,7 @@ import static org.springframework.http.MediaType.APPLICATION_XML;
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class Jackson2CborEncoderTests extends AbstractLeakCheckingTestCase {
|
public class Jackson2CborEncoderTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private final static MimeType CBOR_MIME_TYPE = new MimeType("application", "cbor");
|
private final static MimeType CBOR_MIME_TYPE = new MimeType("application", "cbor");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.AbstractDecoderTestCase;
|
import org.springframework.core.codec.AbstractDecoderTests;
|
||||||
import org.springframework.core.codec.CodecException;
|
import org.springframework.core.codec.CodecException;
|
||||||
import org.springframework.core.codec.DecodingException;
|
import org.springframework.core.codec.DecodingException;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
|
|
@ -61,7 +61,7 @@ import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
*/
|
*/
|
||||||
public class Jackson2JsonDecoderTests extends AbstractDecoderTestCase<Jackson2JsonDecoder> {
|
public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonDecoder> {
|
||||||
|
|
||||||
private Pojo pojo1 = new Pojo("f1", "b1");
|
private Pojo pojo1 = new Pojo("f1", "b1");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.AbstractEncoderTestCase;
|
import org.springframework.core.codec.AbstractEncoderTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
|
@ -55,7 +55,7 @@ import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class Jackson2JsonEncoderTests extends AbstractEncoderTestCase<Jackson2JsonEncoder> {
|
public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder> {
|
||||||
|
|
||||||
public Jackson2JsonEncoderTests() {
|
public Jackson2JsonEncoderTests() {
|
||||||
super(new Jackson2JsonEncoder());
|
super(new Jackson2JsonEncoder());
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.AbstractDecoderTestCase;
|
import org.springframework.core.codec.AbstractDecoderTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.codec.Pojo;
|
import org.springframework.http.codec.Pojo;
|
||||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
|
@ -40,7 +40,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class Jackson2SmileDecoderTests extends AbstractDecoderTestCase<Jackson2SmileDecoder> {
|
public class Jackson2SmileDecoderTests extends AbstractDecoderTests<Jackson2SmileDecoder> {
|
||||||
|
|
||||||
private final static MimeType SMILE_MIME_TYPE = new MimeType("application", "x-jackson-smile");
|
private final static MimeType SMILE_MIME_TYPE = new MimeType("application", "x-jackson-smile");
|
||||||
private final static MimeType STREAM_SMILE_MIME_TYPE = new MimeType("application", "stream+x-jackson-smile");
|
private final static MimeType STREAM_SMILE_MIME_TYPE = new MimeType("application", "stream+x-jackson-smile");
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.AbstractEncoderTestCase;
|
import org.springframework.core.codec.AbstractEncoderTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
import org.springframework.core.io.buffer.support.DataBufferTestUtils;
|
||||||
import org.springframework.http.codec.Pojo;
|
import org.springframework.http.codec.Pojo;
|
||||||
|
|
@ -45,7 +45,7 @@ import static org.springframework.http.MediaType.APPLICATION_XML;
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class Jackson2SmileEncoderTests extends AbstractEncoderTestCase<Jackson2SmileEncoder> {
|
public class Jackson2SmileEncoderTests extends AbstractEncoderTests<Jackson2SmileEncoder> {
|
||||||
|
|
||||||
private final static MimeType SMILE_MIME_TYPE = new MimeType("application", "x-jackson-smile");
|
private final static MimeType SMILE_MIME_TYPE = new MimeType("application", "x-jackson-smile");
|
||||||
private final static MimeType STREAM_SMILE_MIME_TYPE = new MimeType("application", "stream+x-jackson-smile");
|
private final static MimeType STREAM_SMILE_MIME_TYPE = new MimeType("application", "stream+x-jackson-smile");
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import reactor.core.publisher.Flux;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.codec.DecodingException;
|
import org.springframework.core.codec.DecodingException;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
@ -45,7 +45,7 @@ import static java.util.Collections.singletonList;
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
*/
|
*/
|
||||||
public class Jackson2TokenizerTests extends AbstractLeakCheckingTestCase {
|
public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private JsonFactory jsonFactory;
|
private JsonFactory jsonFactory;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.StringDecoder;
|
import org.springframework.core.codec.StringDecoder;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||||
|
|
@ -52,7 +52,7 @@ import static org.mockito.Mockito.mock;
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
*/
|
*/
|
||||||
public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTestCase {
|
public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private final MultipartHttpMessageWriter writer =
|
private final MultipartHttpMessageWriter writer =
|
||||||
new MultipartHttpMessageWriter(ClientCodecConfigurer.create().getWriters());
|
new MultipartHttpMessageWriter(ClientCodecConfigurer.create().getWriters());
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.AbstractDecoderTestCase;
|
import org.springframework.core.codec.AbstractDecoderTests;
|
||||||
import org.springframework.core.codec.DecodingException;
|
import org.springframework.core.codec.DecodingException;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
|
|
@ -46,7 +46,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class ProtobufDecoderTests extends AbstractDecoderTestCase<ProtobufDecoder> {
|
public class ProtobufDecoderTests extends AbstractDecoderTests<ProtobufDecoder> {
|
||||||
|
|
||||||
private final static MimeType PROTOBUF_MIME_TYPE = new MimeType("application", "x-protobuf");
|
private final static MimeType PROTOBUF_MIME_TYPE = new MimeType("application", "x-protobuf");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.core.codec.AbstractEncoderTestCase;
|
import org.springframework.core.codec.AbstractEncoderTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
import org.springframework.core.io.buffer.DataBufferUtils;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
|
@ -41,7 +41,7 @@ import static org.springframework.core.ResolvableType.forClass;
|
||||||
*
|
*
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class ProtobufEncoderTests extends AbstractEncoderTestCase<ProtobufEncoder> {
|
public class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder> {
|
||||||
|
|
||||||
private final static MimeType PROTOBUF_MIME_TYPE = new MimeType("application", "x-protobuf");
|
private final static MimeType PROTOBUF_MIME_TYPE = new MimeType("application", "x-protobuf");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.codec.Pojo;
|
import org.springframework.http.codec.Pojo;
|
||||||
|
|
@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
*/
|
*/
|
||||||
public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTestCase {
|
public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private static final String POJO_ROOT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
private static final String POJO_ROOT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||||
"<pojo>" +
|
"<pojo>" +
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.core.codec.AbstractEncoderTestCase;
|
import org.springframework.core.codec.AbstractEncoderTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.codec.Pojo;
|
import org.springframework.http.codec.Pojo;
|
||||||
|
|
@ -43,7 +43,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
public class Jaxb2XmlEncoderTests extends AbstractEncoderTestCase<Jaxb2XmlEncoder> {
|
public class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder> {
|
||||||
|
|
||||||
public Jaxb2XmlEncoderTests() {
|
public Jaxb2XmlEncoderTests() {
|
||||||
super(new Jaxb2XmlEncoder());
|
super(new Jaxb2XmlEncoder());
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import org.springframework.core.io.buffer.AbstractLeakCheckingTestCase;
|
import org.springframework.core.io.buffer.AbstractLeakCheckingTests;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
public class XmlEventDecoderTests extends AbstractLeakCheckingTestCase {
|
public class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||||
|
|
||||||
private static final String XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
private static final String XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||||
"<pojo>" +
|
"<pojo>" +
|
||||||
|
|
|
||||||
|
|
@ -16,20 +16,15 @@
|
||||||
|
|
||||||
package org.springframework.web.server.adapter;
|
package org.springframework.web.server.adapter;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runners.Parameterized.Parameter;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||||
import org.springframework.mock.web.test.server.MockServerWebExchange;
|
import org.springframework.mock.web.test.server.MockServerWebExchange;
|
||||||
|
|
@ -42,37 +37,23 @@ import static org.springframework.mock.http.server.reactive.test.MockServerHttpR
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
*/
|
*/
|
||||||
public class DefaultServerWebExchangeCheckNotModifiedTests {
|
class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
|
|
||||||
private static final String CURRENT_TIME = "Wed, 09 Apr 2014 09:57:42 GMT";
|
private static final String CURRENT_TIME = "Wed, 09 Apr 2014 09:57:42 GMT";
|
||||||
|
|
||||||
|
private final Instant currentDate = Instant.now().truncatedTo(ChronoUnit.SECONDS);
|
||||||
|
|
||||||
private SimpleDateFormat dateFormat;
|
private SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||||
|
|
||||||
private Instant currentDate;
|
|
||||||
|
|
||||||
@Parameter
|
|
||||||
public HttpMethod method;
|
|
||||||
|
|
||||||
@Parameters(name = "{0}")
|
|
||||||
static public Iterable<Object[]> safeMethods() {
|
|
||||||
return Arrays.asList(new Object[][] {
|
|
||||||
{HttpMethod.GET},
|
|
||||||
{HttpMethod.HEAD}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() throws URISyntaxException {
|
void setup() {
|
||||||
this.currentDate = Instant.now().truncatedTo(ChronoUnit.SECONDS);
|
|
||||||
this.dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
|
||||||
this.dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
this.dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedNon2xxStatus() {
|
void checkNotModifiedNon2xxStatus() {
|
||||||
MockServerHttpRequest request = get("/").ifModifiedSince(this.currentDate.toEpochMilli()).build();
|
MockServerHttpRequest request = get("/").ifModifiedSince(this.currentDate.toEpochMilli()).build();
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||||
exchange.getResponse().setStatusCode(HttpStatus.NOT_MODIFIED);
|
exchange.getResponse().setStatusCode(HttpStatus.NOT_MODIFIED);
|
||||||
|
|
@ -83,7 +64,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-14559
|
@Test // SPR-14559
|
||||||
public void checkNotModifiedInvalidIfNoneMatchHeader() {
|
void checkNotModifiedInvalidIfNoneMatchHeader() {
|
||||||
String eTag = "\"etagvalue\"";
|
String eTag = "\"etagvalue\"";
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch("missingquotes"));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch("missingquotes"));
|
||||||
assertThat(exchange.checkNotModified(eTag)).isFalse();
|
assertThat(exchange.checkNotModified(eTag)).isFalse();
|
||||||
|
|
@ -92,7 +73,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedHeaderAlreadySet() {
|
void checkNotModifiedHeaderAlreadySet() {
|
||||||
MockServerHttpRequest request = get("/").ifModifiedSince(currentDate.toEpochMilli()).build();
|
MockServerHttpRequest request = get("/").ifModifiedSince(currentDate.toEpochMilli()).build();
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||||
exchange.getResponse().getHeaders().add("Last-Modified", CURRENT_TIME);
|
exchange.getResponse().getHeaders().add("Last-Modified", CURRENT_TIME);
|
||||||
|
|
@ -104,7 +85,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedTimestamp() throws Exception {
|
void checkNotModifiedTimestamp() throws Exception {
|
||||||
MockServerHttpRequest request = get("/").ifModifiedSince(currentDate.toEpochMilli()).build();
|
MockServerHttpRequest request = get("/").ifModifiedSince(currentDate.toEpochMilli()).build();
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||||
|
|
||||||
|
|
@ -115,7 +96,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkModifiedTimestamp() {
|
void checkModifiedTimestamp() {
|
||||||
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
||||||
MockServerHttpRequest request = get("/").ifModifiedSince(oneMinuteAgo.toEpochMilli()).build();
|
MockServerHttpRequest request = get("/").ifModifiedSince(oneMinuteAgo.toEpochMilli()).build();
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||||
|
|
@ -127,7 +108,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedETag() {
|
void checkNotModifiedETag() {
|
||||||
String eTag = "\"Foo\"";
|
String eTag = "\"Foo\"";
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(eTag));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(eTag));
|
||||||
|
|
||||||
|
|
@ -138,7 +119,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedETagWithSeparatorChars() {
|
void checkNotModifiedETagWithSeparatorChars() {
|
||||||
String eTag = "\"Foo, Bar\"";
|
String eTag = "\"Foo, Bar\"";
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(eTag));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(eTag));
|
||||||
|
|
||||||
|
|
@ -148,9 +129,8 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
assertThat(exchange.getResponse().getHeaders().getETag()).isEqualTo(eTag);
|
assertThat(exchange.getResponse().getHeaders().getETag()).isEqualTo(eTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkModifiedETag() {
|
void checkModifiedETag() {
|
||||||
String currentETag = "\"Foo\"";
|
String currentETag = "\"Foo\"";
|
||||||
String oldEtag = "Bar";
|
String oldEtag = "Bar";
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(oldEtag));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(oldEtag));
|
||||||
|
|
@ -162,7 +142,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedUnpaddedETag() {
|
void checkNotModifiedUnpaddedETag() {
|
||||||
String eTag = "Foo";
|
String eTag = "Foo";
|
||||||
String paddedEtag = String.format("\"%s\"", eTag);
|
String paddedEtag = String.format("\"%s\"", eTag);
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(paddedEtag));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(paddedEtag));
|
||||||
|
|
@ -174,7 +154,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkModifiedUnpaddedETag() {
|
void checkModifiedUnpaddedETag() {
|
||||||
String currentETag = "Foo";
|
String currentETag = "Foo";
|
||||||
String oldEtag = "Bar";
|
String oldEtag = "Bar";
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(oldEtag));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(oldEtag));
|
||||||
|
|
@ -186,7 +166,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedWildcardIsIgnored() {
|
void checkNotModifiedWildcardIsIgnored() {
|
||||||
String eTag = "\"Foo\"";
|
String eTag = "\"Foo\"";
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch("*"));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch("*"));
|
||||||
assertThat(exchange.checkNotModified(eTag)).isFalse();
|
assertThat(exchange.checkNotModified(eTag)).isFalse();
|
||||||
|
|
@ -196,7 +176,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedETagAndTimestamp() {
|
void checkNotModifiedETagAndTimestamp() {
|
||||||
String eTag = "\"Foo\"";
|
String eTag = "\"Foo\"";
|
||||||
long time = currentDate.toEpochMilli();
|
long time = currentDate.toEpochMilli();
|
||||||
MockServerHttpRequest request = get("/").ifNoneMatch(eTag).ifModifiedSince(time).build();
|
MockServerHttpRequest request = get("/").ifNoneMatch(eTag).ifModifiedSince(time).build();
|
||||||
|
|
@ -211,7 +191,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
|
|
||||||
// SPR-14224
|
// SPR-14224
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedETagAndModifiedTimestamp() {
|
void checkNotModifiedETagAndModifiedTimestamp() {
|
||||||
String eTag = "\"Foo\"";
|
String eTag = "\"Foo\"";
|
||||||
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/")
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/")
|
||||||
|
|
@ -227,7 +207,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkModifiedETagAndNotModifiedTimestamp() throws Exception {
|
void checkModifiedETagAndNotModifiedTimestamp() throws Exception {
|
||||||
String currentETag = "\"Foo\"";
|
String currentETag = "\"Foo\"";
|
||||||
String oldEtag = "\"Bar\"";
|
String oldEtag = "\"Bar\"";
|
||||||
long time = currentDate.toEpochMilli();
|
long time = currentDate.toEpochMilli();
|
||||||
|
|
@ -242,7 +222,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedETagWeakStrong() {
|
void checkNotModifiedETagWeakStrong() {
|
||||||
String eTag = "\"Foo\"";
|
String eTag = "\"Foo\"";
|
||||||
String weakEtag = String.format("W/%s", eTag);
|
String weakEtag = String.format("W/%s", eTag);
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(eTag));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(eTag));
|
||||||
|
|
@ -254,7 +234,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedETagStrongWeak() {
|
void checkNotModifiedETagStrongWeak() {
|
||||||
String eTag = "\"Foo\"";
|
String eTag = "\"Foo\"";
|
||||||
MockServerHttpRequest request = get("/").ifNoneMatch(String.format("W/%s", eTag)).build();
|
MockServerHttpRequest request = get("/").ifNoneMatch(String.format("W/%s", eTag)).build();
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
MockServerWebExchange exchange = MockServerWebExchange.from(request);
|
||||||
|
|
@ -266,7 +246,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedMultipleETags() {
|
void checkNotModifiedMultipleETags() {
|
||||||
String eTag = "\"Bar\"";
|
String eTag = "\"Bar\"";
|
||||||
String multipleETags = String.format("\"Foo\", %s", eTag);
|
String multipleETags = String.format("\"Foo\", %s", eTag);
|
||||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(multipleETags));
|
MockServerWebExchange exchange = MockServerWebExchange.from(get("/").ifNoneMatch(multipleETags));
|
||||||
|
|
@ -278,7 +258,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedTimestampWithLengthPart() throws Exception {
|
void checkNotModifiedTimestampWithLengthPart() throws Exception {
|
||||||
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
|
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
|
||||||
String header = "Wed, 09 Apr 2014 09:57:42 GMT; length=13774";
|
String header = "Wed, 09 Apr 2014 09:57:42 GMT; length=13774";
|
||||||
MockServerHttpRequest request = get("/").header("If-Modified-Since", header).build();
|
MockServerHttpRequest request = get("/").header("If-Modified-Since", header).build();
|
||||||
|
|
@ -291,7 +271,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkModifiedTimestampWithLengthPart() throws Exception {
|
void checkModifiedTimestampWithLengthPart() throws Exception {
|
||||||
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
|
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
|
||||||
String header = "Tue, 08 Apr 2014 09:57:42 GMT; length=13774";
|
String header = "Tue, 08 Apr 2014 09:57:42 GMT; length=13774";
|
||||||
MockServerHttpRequest request = get("/").header("If-Modified-Since", header).build();
|
MockServerHttpRequest request = get("/").header("If-Modified-Since", header).build();
|
||||||
|
|
@ -304,7 +284,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedTimestampConditionalPut() throws Exception {
|
void checkNotModifiedTimestampConditionalPut() throws Exception {
|
||||||
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
||||||
long millis = currentDate.toEpochMilli();
|
long millis = currentDate.toEpochMilli();
|
||||||
MockServerHttpRequest request = MockServerHttpRequest.put("/").ifUnmodifiedSince(millis).build();
|
MockServerHttpRequest request = MockServerHttpRequest.put("/").ifUnmodifiedSince(millis).build();
|
||||||
|
|
@ -316,7 +296,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkNotModifiedTimestampConditionalPutConflict() throws Exception {
|
void checkNotModifiedTimestampConditionalPutConflict() throws Exception {
|
||||||
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
Instant oneMinuteAgo = currentDate.minusSeconds(60);
|
||||||
long millis = oneMinuteAgo.toEpochMilli();
|
long millis = oneMinuteAgo.toEpochMilli();
|
||||||
MockServerHttpRequest request = MockServerHttpRequest.put("/").ifUnmodifiedSince(millis).build();
|
MockServerHttpRequest request = MockServerHttpRequest.put("/").ifUnmodifiedSince(millis).build();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
<!-- global -->
|
<!-- global -->
|
||||||
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="AnnotationLocation|AnnotationUseStyle|AtclauseOrder|AvoidNestedBlocks|FinalClass|HideUtilityClassConstructor|InnerTypeLast|JavadocStyle|JavadocType|JavadocVariable|LeftCurly|MultipleVariableDeclarations|NeedBraces|OneTopLevelClass|OuterTypeFilename|RequireThis|SpringCatch|SpringJavadoc|SpringNoThis" />
|
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="AnnotationLocation|AnnotationUseStyle|AtclauseOrder|AvoidNestedBlocks|FinalClass|HideUtilityClassConstructor|InnerTypeLast|JavadocStyle|JavadocType|JavadocVariable|LeftCurly|MultipleVariableDeclarations|NeedBraces|OneTopLevelClass|OuterTypeFilename|RequireThis|SpringCatch|SpringJavadoc|SpringNoThis" />
|
||||||
|
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/].+(Tests|Suite)" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
||||||
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="SpringJUnit5" message="should not be public" />
|
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="SpringJUnit5" message="should not be public" />
|
||||||
|
|
||||||
<!-- spring-beans -->
|
<!-- spring-beans -->
|
||||||
|
|
@ -24,6 +25,7 @@
|
||||||
<suppress files="ByteArrayEncoder" checks="SpringLambda" />
|
<suppress files="ByteArrayEncoder" checks="SpringLambda" />
|
||||||
<suppress files="SocketUtils" checks="HideUtilityClassConstructor" />
|
<suppress files="SocketUtils" checks="HideUtilityClassConstructor" />
|
||||||
<suppress files="ResolvableType" checks="FinalClass" />
|
<suppress files="ResolvableType" checks="FinalClass" />
|
||||||
|
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]tests[\\/].+" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
||||||
|
|
||||||
<!-- spring-expression -->
|
<!-- spring-expression -->
|
||||||
<suppress files="ExpressionException" checks="MutableException" />
|
<suppress files="ExpressionException" checks="MutableException" />
|
||||||
|
|
@ -58,39 +60,27 @@
|
||||||
<suppress files="TransactionSystemException" checks="MutableException" />
|
<suppress files="TransactionSystemException" checks="MutableException" />
|
||||||
<suppress files="TransactionTemplate" checks="EqualsHashCode" />
|
<suppress files="TransactionTemplate" checks="EqualsHashCode" />
|
||||||
|
|
||||||
<!-- spring-test -->
|
<!-- spring-test - main and test -->
|
||||||
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]jdbc[\\/]MergedSqlConfig" checks="JavadocStyle" />
|
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]junit4[\\/].+" checks="IllegalImport" id="bannedJUnit4Imports" />
|
||||||
|
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]junit[\\/]jupiter[\\/].+" checks="IllegalImport" id="bannedJUnitJupiterImports" />
|
||||||
|
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]testng[\\/].+" checks="IllegalImport" id="bannedTestNGImports" />
|
||||||
|
<!-- spring-test - main -->
|
||||||
|
<suppress files="src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]context[\\/]jdbc[\\/]MergedSqlConfig" checks="JavadocStyle" />
|
||||||
|
<suppress files="src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]util[\\/].+Helper" checks="IllegalImport" id="bannedHamcrestImports" />
|
||||||
|
<suppress files="src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]web[\\/]client[\\/]match[\\/].+Matchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
||||||
|
<suppress files="src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]web[\\/]reactive[\\/]server[\\/].+" checks="IllegalImport" id="bannedHamcrestImports" />
|
||||||
|
<suppress files="src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]web[\\/]servlet[\\/]result[\\/].+Matchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
||||||
|
<!-- spring-test - test -->
|
||||||
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/].+TestNGTests" checks="IllegalImport" id="bannedTestNGImports" />
|
||||||
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]context[\\/]junit[\\/]jupiter[\\/]web[\\/].+Tests" checks="IllegalImport" id="bannedHamcrestImports" />
|
||||||
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]util[\\/].+Tests" checks="IllegalImport" id="bannedHamcrestImports" />
|
||||||
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]web[\\/](client|reactive|servlet)[\\/].+Tests" checks="IllegalImport" id="bannedHamcrestImports" />
|
||||||
|
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]context[\\/]junit4" checks="SpringJUnit5" />
|
||||||
|
<suppress files="ContextHierarchyDirtiesContextTests|ClassLevelDirtiesContextTests|ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests|ContextConfigurationWithPropertiesExtendingPropertiesTests|DirtiesContextInterfaceTests|.+WacTests|JUnit4SpringContextWebTests" checks="SpringJUnit5" />
|
||||||
|
<suppress files=".+TestSuite|ContextHierarchyDirtiesContextTests|ClassLevelDirtiesContextTests|ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests|ContextConfigurationWithPropertiesExtendingPropertiesTests|DirtiesContextInterfaceTests|.+WacTests|JUnit4SpringContextWebTests" checks="IllegalImport" id="bannedJUnit4Imports" />
|
||||||
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]junit4[\\/]ExpectedExceptionSpringRunnerTests" checks="RegexpSinglelineJava" id="expectedExceptionAnnotation" />
|
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]junit4[\\/]ExpectedExceptionSpringRunnerTests" checks="RegexpSinglelineJava" id="expectedExceptionAnnotation" />
|
||||||
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]junit4[\\/]StandardJUnit4FeaturesTests" checks="RegexpSinglelineJava" id="expectedExceptionAnnotation" />
|
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]junit4[\\/]StandardJUnit4FeaturesTests" checks="RegexpSinglelineJava" id="expectedExceptionAnnotation" />
|
||||||
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]testng[\\/]transaction[\\/]programmatic/ProgrammaticTxMgmtTestNGTests" checks="RegexpSinglelineJava" id="expectedExceptionAnnotation" />
|
<suppress files="org[\\/]springframework[\\/]test[\\/]context[\\/]testng[\\/]transaction[\\/]programmatic/ProgrammaticTxMgmtTestNGTests" checks="RegexpSinglelineJava" id="expectedExceptionAnnotation" />
|
||||||
<suppress files="org[\\/]springframework[\\/]test[\\/].+Tests" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="ContentRequestMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="ContentResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="CookieResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="DefaultWebTestClient" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="FlashAttributeResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="HandlerResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="HeaderAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="HeaderResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="JsonPathAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="JsonPathExpectationsHelper" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="JsonPathRequestMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="JsonPathResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="MockMvcResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="MockRestRequestMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="ModelResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="RequestResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="StatusAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="StatusResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="ViewResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="WebTestClient" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="XmlExpectationsHelper" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="XpathAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="XpathExpectationsHelper" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="XpathRequestMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="XpathResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
|
|
||||||
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]context[\\/]junit4" checks="SpringJUnit5" />
|
|
||||||
<suppress files="ContextHierarchyDirtiesContextTests|ClassLevelDirtiesContextTests|ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests|ContextConfigurationWithPropertiesExtendingPropertiesTests|DirtiesContextInterfaceTests|.*WacTests|JUnit4SpringContextWebTests" checks="SpringJUnit5" />
|
|
||||||
|
|
||||||
<!-- spring-web -->
|
<!-- spring-web -->
|
||||||
<suppress files="SpringHandlerInstantiator" checks="JavadocStyle" />
|
<suppress files="SpringHandlerInstantiator" checks="JavadocStyle" />
|
||||||
|
|
|
||||||
|
|
@ -100,13 +100,33 @@
|
||||||
<property name="id" value="bannedImports"/>
|
<property name="id" value="bannedImports"/>
|
||||||
<property name="regexp" value="true" />
|
<property name="regexp" value="true" />
|
||||||
<property name="illegalClasses"
|
<property name="illegalClasses"
|
||||||
value="^reactor\.core\.support\.Assert,^junit\.framework\..+,^org\.junit\.Assert$,^org\.junit\.Assume$,^org\.junit\.jupiter\.api\.Assertions$,^org\.junit\.Assert\.assertThat,^org\.junit\.Assume\.assumeThat,^org\.testng\.Assert$,^org\.testng\.AssertJUnit$,^org\.junit\.rules\.ExpectedException,^org\.slf4j\.LoggerFactory" />
|
value="^reactor\.core\.support\.Assert,^org\.slf4j\.LoggerFactory" />
|
||||||
|
</module>
|
||||||
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||||
|
<property name="id" value="bannedJUnit3Imports"/>
|
||||||
|
<property name="regexp" value="true" />
|
||||||
|
<property name="illegalClasses" value="^junit\.framework\..+" />
|
||||||
|
</module>
|
||||||
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||||
|
<property name="id" value="bannedJUnit4Imports"/>
|
||||||
|
<property name="regexp" value="true" />
|
||||||
|
<property name="illegalClasses"
|
||||||
|
value="^org\.junit\.(Test|BeforeClass|AfterClass|Before|After|Ignore|FixMethodOrder|Rule|ClassRule|Assert|Assume)$,^org\.junit\.(Assert|Assume)\..+,^org\.junit\.(experimental|internal|matchers|rules|runner|runners|validator)\..+" />
|
||||||
|
</module>
|
||||||
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||||
|
<property name="id" value="bannedJUnitJupiterImports"/>
|
||||||
|
<property name="regexp" value="true" />
|
||||||
|
<property name="illegalClasses" value="^org\.junit\.jupiter\..+" />
|
||||||
|
</module>
|
||||||
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||||
|
<property name="id" value="bannedTestNGImports"/>
|
||||||
|
<property name="regexp" value="true" />
|
||||||
|
<property name="illegalClasses" value="^org\.testng\..+," />
|
||||||
</module>
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||||
<property name="id" value="bannedHamcrestImports"/>
|
<property name="id" value="bannedHamcrestImports"/>
|
||||||
<property name="regexp" value="true" />
|
<property name="regexp" value="true" />
|
||||||
<property name="illegalClasses"
|
<property name="illegalClasses" value="^org\.hamcrest\..+" />
|
||||||
value="^org\.hamcrest\..+" />
|
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<!-- Javadoc Comments -->
|
<!-- Javadoc Comments -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue