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
This commit is contained in:
@@ -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;
|
||||
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 {
|
||||
@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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
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 {
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 @@
|
||||
|
||||
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 {
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user