Browse Source

Enforces static imports for JUnit 4 assertions and assumptions

This commit configures Checkstyle to enforces static imports for JUnit 4
assertions and assumptions.

See gh-22932
pull/22953/head
Sam Brannen 7 years ago
parent
commit
73dbd06361
  1. 3
      spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java
  2. 7
      spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java
  3. 3
      spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java
  4. 4
      spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java
  5. 4
      spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java
  6. 10
      spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/MultipartControllerTests.java
  7. 3
      spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java
  8. 4
      spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java
  9. 6
      spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java
  10. 24
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java
  11. 3
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java
  12. 9
      spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java
  13. 4
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java
  14. 14
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java
  15. 9
      spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java
  16. 2
      src/checkstyle/checkstyle.xml

3
spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java vendored

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
package org.springframework.cache.aspectj;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.cache.Cache;
@ -44,7 +43,7 @@ public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests { @@ -44,7 +43,7 @@ public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests {
public void testKeyStrategy() throws Exception {
AnnotationCacheAspect aspect = ctx.getBean(
"org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class);
Assert.assertSame(ctx.getBean("keyGenerator"), aspect.getKeyGenerator());
assertSame(ctx.getBean("keyGenerator"), aspect.getKeyGenerator());
}
@Override

7
spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java vendored

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -16,13 +16,14 @@ @@ -16,13 +16,14 @@
package org.springframework.cache.config;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.cache.interceptor.CacheInterceptor;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import static org.junit.Assert.assertSame;
/**
* @author Costin Leau
* @author Chris Beams
@ -38,7 +39,7 @@ public class CacheAdviceNamespaceTests extends AbstractCacheAnnotationTests { @@ -38,7 +39,7 @@ public class CacheAdviceNamespaceTests extends AbstractCacheAnnotationTests {
@Test
public void testKeyStrategy() throws Exception {
CacheInterceptor bean = this.ctx.getBean("cacheAdviceClass", CacheInterceptor.class);
Assert.assertSame(this.ctx.getBean("keyGenerator"), bean.getKeyGenerator());
assertSame(this.ctx.getBean("keyGenerator"), bean.getKeyGenerator());
}
}

3
spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java

@ -24,7 +24,6 @@ import java.sql.SQLException; @@ -24,7 +24,6 @@ import java.sql.SQLException;
import java.sql.Types;
import javax.sql.DataSource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -232,7 +231,7 @@ public class SimpleJdbcCallTests { @@ -232,7 +231,7 @@ public class SimpleJdbcCallTests {
private void verifyStatement(SimpleJdbcCall adder, String expected) {
Assert.assertEquals("Incorrect call statement", expected, adder.getCallString());
assertEquals("Incorrect call statement", expected, adder.getCallString());
}
private void initializeAddInvoiceWithoutMetaData(boolean isFunction) throws SQLException {

4
spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java

@ -19,7 +19,6 @@ package org.springframework.oxm.jibx; @@ -19,7 +19,6 @@ package org.springframework.oxm.jibx;
import java.io.StringWriter;
import javax.xml.transform.stream.StreamResult;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
@ -28,6 +27,7 @@ import org.springframework.oxm.AbstractMarshallerTests; @@ -28,6 +27,7 @@ import org.springframework.oxm.AbstractMarshallerTests;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
/**
@ -43,7 +43,7 @@ public class JibxMarshallerTests extends AbstractMarshallerTests<JibxMarshaller> @@ -43,7 +43,7 @@ public class JibxMarshallerTests extends AbstractMarshallerTests<JibxMarshaller>
@BeforeClass
public static void compilerAssumptions() {
// JiBX compiler is currently not compatible with JDK 9
Assume.assumeTrue(System.getProperty("java.version").startsWith("1.8."));
assumeTrue(System.getProperty("java.version").startsWith("1.8."));
}

4
spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java

@ -19,7 +19,6 @@ package org.springframework.oxm.jibx; @@ -19,7 +19,6 @@ package org.springframework.oxm.jibx;
import java.io.ByteArrayInputStream;
import javax.xml.transform.stream.StreamSource;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
@ -27,6 +26,7 @@ import org.springframework.oxm.AbstractUnmarshallerTests; @@ -27,6 +26,7 @@ import org.springframework.oxm.AbstractUnmarshallerTests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
/**
* NOTE: These tests fail under Eclipse/IDEA because JiBX binding does
@ -46,7 +46,7 @@ public class JibxUnmarshallerTests extends AbstractUnmarshallerTests<JibxMarshal @@ -46,7 +46,7 @@ public class JibxUnmarshallerTests extends AbstractUnmarshallerTests<JibxMarshal
@BeforeClass
public static void compilerAssumptions() {
// JiBX compiler is currently not compatible with JDK 9
Assume.assumeTrue(System.getProperty("java.version").startsWith("1.8."));
assumeTrue(System.getProperty("java.version").startsWith("1.8."));
}

10
spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/MultipartControllerTests.java

@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletRequestWrapper; @@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.http.MediaType;
@ -46,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestPart; @@ -46,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.multipart.MultipartFile;
import static org.junit.Assert.assertArrayEquals;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
@ -275,7 +275,7 @@ public class MultipartControllerTests { @@ -275,7 +275,7 @@ public class MultipartControllerTests {
if (file != null && file.length > 0) {
byte[] content = file[0].getBytes();
Assert.assertArrayEquals(content, file[1].getBytes());
assertArrayEquals(content, file[1].getBytes());
model.addAttribute("fileContent", content);
}
if (json != null) {
@ -291,7 +291,7 @@ public class MultipartControllerTests { @@ -291,7 +291,7 @@ public class MultipartControllerTests {
if (file != null && !file.isEmpty()) {
byte[] content = file.get(0).getBytes();
Assert.assertArrayEquals(content, file.get(1).getBytes());
assertArrayEquals(content, file.get(1).getBytes());
model.addAttribute("fileContent", content);
}
if (json != null) {
@ -319,7 +319,7 @@ public class MultipartControllerTests { @@ -319,7 +319,7 @@ public class MultipartControllerTests {
if (file.isPresent()) {
byte[] content = file.get()[0].getBytes();
Assert.assertArrayEquals(content, file.get()[1].getBytes());
assertArrayEquals(content, file.get()[1].getBytes());
model.addAttribute("fileContent", content);
}
model.addAttribute("jsonContent", json);
@ -333,7 +333,7 @@ public class MultipartControllerTests { @@ -333,7 +333,7 @@ public class MultipartControllerTests {
if (file.isPresent()) {
byte[] content = file.get().get(0).getBytes();
Assert.assertArrayEquals(content, file.get().get(1).getBytes());
assertArrayEquals(content, file.get().get(1).getBytes());
model.addAttribute("fileContent", content);
}
model.addAttribute("jsonContent", json);

3
spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java

@ -27,7 +27,6 @@ import java.util.concurrent.ExecutionException; @@ -27,7 +27,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
@ -315,7 +314,7 @@ public class AsyncRestTemplateIntegrationTests extends AbstractMockWebServerTest @@ -315,7 +314,7 @@ public class AsyncRestTemplateIntegrationTests extends AbstractMockWebServerTest
@Test
public void deleteCallbackWithLambdas() throws Exception {
ListenableFuture<?> deletedFuture = template.delete(new URI(baseUrl + "/delete"));
deletedFuture.addCallback(Assert::assertNull, ex -> fail(ex.getMessage()));
deletedFuture.addCallback(result -> assertNull(result), ex -> fail(ex.getMessage()));
waitTillDone(deletedFuture);
}

4
spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java

@ -29,7 +29,6 @@ import java.util.Optional; @@ -29,7 +29,6 @@ import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonView;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.util.IllegalReferenceCountException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
@ -67,6 +66,7 @@ import org.springframework.util.MultiValueMap; @@ -67,6 +66,7 @@ import org.springframework.util.MultiValueMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
/**
@ -436,7 +436,7 @@ public class BodyExtractorsTests { @@ -436,7 +436,7 @@ public class BodyExtractorsTests {
assertTrue(throwable instanceof UnsupportedMediaTypeException);
try {
buffer.release();
Assert.fail("releasing the buffer should have failed");
fail("releasing the buffer should have failed");
}
catch (IllegalReferenceCountException exc) {
}

6
spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java

@ -30,7 +30,6 @@ import java.util.Map; @@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonView;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
@ -71,6 +70,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; @@ -71,6 +70,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
/**
@ -127,7 +127,7 @@ public class BodyInsertersTests { @@ -127,7 +127,7 @@ public class BodyInsertersTests {
StepVerifier.create(response.getBody())
.consumeNextWith(buf -> {
String actual = DataBufferTestUtils.dumpString(buf, UTF_8);
Assert.assertEquals("foo", actual);
assertEquals("foo", actual);
})
.expectComplete()
.verify();
@ -173,7 +173,7 @@ public class BodyInsertersTests { @@ -173,7 +173,7 @@ public class BodyInsertersTests {
StepVerifier.create(response.getBody())
.consumeNextWith(buf -> {
String actual = DataBufferTestUtils.dumpString(buf, UTF_8);
Assert.assertEquals("foo", actual);
assertEquals("foo", actual);
})
.expectComplete()
.verify();

24
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation; @@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation;
import java.time.Duration;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import reactor.core.publisher.Flux;
@ -36,6 +35,9 @@ import org.springframework.web.reactive.function.client.WebClient; @@ -36,6 +35,9 @@ import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.protobuf.Msg;
import org.springframework.web.reactive.protobuf.SecondMsg;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Integration tests for Protobuf support.
*
@ -71,9 +73,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT @@ -71,9 +73,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
.uri("/message")
.exchange()
.doOnNext(response -> {
Assert.assertFalse(response.headers().contentType().get().getParameters().containsKey("delimited"));
Assert.assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
Assert.assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
assertFalse(response.headers().contentType().get().getParameters().containsKey("delimited"));
assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
})
.flatMap(response -> response.bodyToMono(Msg.class));
@ -88,9 +90,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT @@ -88,9 +90,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
.uri("/messages")
.exchange()
.doOnNext(response -> {
Assert.assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
Assert.assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
Assert.assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
})
.flatMapMany(response -> response.bodyToFlux(Msg.class));
@ -107,9 +109,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT @@ -107,9 +109,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
.uri("/message-stream")
.exchange()
.doOnNext(response -> {
Assert.assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
Assert.assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
Assert.assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
})
.flatMapMany(response -> response.bodyToFlux(Msg.class));

3
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java

@ -19,7 +19,6 @@ package org.springframework.web.reactive.result.method.annotation; @@ -19,7 +19,6 @@ package org.springframework.web.reactive.result.method.annotation;
import java.io.File;
import java.time.Duration;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@ -136,7 +135,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { @@ -136,7 +135,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
@Test
public void sseAsEvent() {
Assume.assumeTrue(server instanceof JettyHttpServer);
assumeTrue(server instanceof JettyHttpServer);
Flux<ServerSentEvent<Person>> result = this.webClient.get()
.uri("/event")

9
spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -16,11 +16,12 @@ @@ -16,11 +16,12 @@
package org.springframework.web.reactive.result.view.script;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import static org.junit.Assert.assertEquals;
/**
* Unit tests for {@link ScriptTemplateViewResolver}.
*
@ -31,10 +32,10 @@ public class ScriptTemplateViewResolverTests { @@ -31,10 +32,10 @@ public class ScriptTemplateViewResolverTests {
@Test
public void viewClass() throws Exception {
ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
Assert.assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
Assert.assertEquals(ScriptTemplateView.class, viewClass);
assertEquals(ScriptTemplateView.class, viewClass);
}
}

4
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java

@ -31,7 +31,6 @@ import org.eclipse.jetty.server.Server; @@ -31,7 +31,6 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -67,6 +66,7 @@ import org.springframework.web.servlet.DispatcherServlet; @@ -67,6 +66,7 @@ import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@ -239,7 +239,7 @@ public class RequestPartIntegrationTests { @@ -239,7 +239,7 @@ public class RequestPartIntegrationTests {
@RequestPart(name = "empty-data", required = false) TestData emptyData,
@RequestPart(name = "iso-8859-1-data") byte[] iso88591Data) {
Assert.assertArrayEquals(new byte[]{(byte) 0xC4}, iso88591Data);
assertArrayEquals(new byte[]{(byte) 0xC4}, iso88591Data);
String url = "http://localhost:8080/test/" + testData.getName() + "/" + file.get().getOriginalFilename();
HttpHeaders headers = new HttpHeaders();

14
spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@ -18,11 +18,13 @@ package org.springframework.web.servlet.view.groovy; @@ -18,11 +18,13 @@ package org.springframework.web.servlet.view.groovy;
import java.util.Locale;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* Unit tests for
* {@link org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver}.
@ -34,18 +36,18 @@ public class GroovyMarkupViewResolverTests { @@ -34,18 +36,18 @@ public class GroovyMarkupViewResolverTests {
@Test
public void viewClass() throws Exception {
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
Assert.assertEquals(GroovyMarkupView.class, resolver.requiredViewClass());
assertEquals(GroovyMarkupView.class, resolver.requiredViewClass());
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
Assert.assertEquals(GroovyMarkupView.class, viewClass);
assertEquals(GroovyMarkupView.class, viewClass);
}
@Test
public void cacheKey() throws Exception {
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
String cacheKey = (String) resolver.getCacheKey("test", Locale.US);
Assert.assertNotNull(cacheKey);
Assert.assertEquals("test_en_US", cacheKey);
assertNotNull(cacheKey);
assertEquals("test_en_US", cacheKey);
}
}

9
spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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,11 +16,12 @@ @@ -16,11 +16,12 @@
package org.springframework.web.servlet.view.script;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import static org.junit.Assert.assertEquals;
/**
* Unit tests for {@link ScriptTemplateViewResolver}.
*
@ -31,10 +32,10 @@ public class ScriptTemplateViewResolverTests { @@ -31,10 +32,10 @@ public class ScriptTemplateViewResolverTests {
@Test
public void viewClass() throws Exception {
ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
Assert.assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
Assert.assertEquals(ScriptTemplateView.class, viewClass);
assertEquals(ScriptTemplateView.class, viewClass);
}
}

2
src/checkstyle/checkstyle.xml

@ -97,7 +97,7 @@ @@ -97,7 +97,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
<property name="regexp" value="true" />
<property name="illegalClasses"
value="^reactor\.core\.support\.Assert,^junit\.framework\..+,^org\.junit\.Assert\.assertThat,^org\.junit\.Assume\.assumeThat,^org\.junit\.rules\.ExpectedException,^org\.slf4j\.LoggerFactory" />
value="^reactor\.core\.support\.Assert,^junit\.framework\..+,^org\.junit\.Assert$,^org\.junit\.Assume$,^org\.junit\.Assert\.assertThat,^org\.junit\.Assume\.assumeThat,^org\.junit\.rules\.ExpectedException,^org\.slf4j\.LoggerFactory" />
</module>
<!-- Javadoc Comments -->

Loading…
Cancel
Save