Polishing

This commit is contained in:
Sam Brannen 2023-11-30 19:04:59 +01:00
parent 8ff687b68c
commit 6ea9fdbf77
36 changed files with 126 additions and 120 deletions

View File

@ -29,7 +29,6 @@ import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -47,7 +46,7 @@ public class CaffeineReactiveCachingTests {
@ParameterizedTest
@ValueSource(classes = {AsyncCacheModeConfig.class, AsyncCacheModeConfig.class})
void cacheHitDetermination(Class<?> configClass) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(configClass, ReactiveCacheableService.class);
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(configClass, ReactiveCacheableService.class);
ReactiveCacheableService service = ctx.getBean(ReactiveCacheableService.class);
Object key = new Object();
@ -103,6 +102,8 @@ public class CaffeineReactiveCachingTests {
assertThat(r1).isNotNull();
assertThat(r1).isSameAs(r2).isSameAs(r3);
ctx.close();
}

View File

@ -1056,7 +1056,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
return NOT_HANDLED;
}
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
@Nullable
public Object findInCaches(CacheOperationContext context, Cache cache, Object key,
CacheOperationInvoker invoker, Method method, CacheOperationContexts contexts) {

View File

@ -842,7 +842,7 @@ class XmlBeanFactoryTests {
DependenciesBean rod5 = (DependenciesBean) xbf.getBean("rod5");
// Should not have been autowired
assertThat((Object) rod5.getSpouse()).isNull();
assertThat(rod5.getSpouse()).isNull();
BeanFactory appCtx = (BeanFactory) xbf.getBean("childAppCtx");
assertThat(appCtx.containsBean("rod1")).isTrue();
@ -944,7 +944,7 @@ class XmlBeanFactoryTests {
catch (BeanCreationException ex) {
ex.printStackTrace();
assertThat(ex.toString()).contains("touchy");
assertThat((Object) ex.getRelatedCauses()).isNull();
assertThat(ex.getRelatedCauses()).isNull();
}
}

View File

@ -29,7 +29,6 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.concurrent.ConcurrentMapCache;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -51,7 +50,7 @@ public class ReactiveCachingTests {
LateCacheHitDeterminationConfig.class,
LateCacheHitDeterminationWithValueWrapperConfig.class})
void cacheHitDetermination(Class<?> configClass) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(configClass, ReactiveCacheableService.class);
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(configClass, ReactiveCacheableService.class);
ReactiveCacheableService service = ctx.getBean(ReactiveCacheableService.class);
Object key = new Object();
@ -107,6 +106,8 @@ public class ReactiveCachingTests {
assertThat(r1).isNotNull();
assertThat(r1).isSameAs(r2).isSameAs(r3);
ctx.close();
}

View File

@ -187,10 +187,10 @@ class AutowiredConfigurationTests {
System.clearProperty("myProp");
TestBean testBean = context.getBean("testBean", TestBean.class);
assertThat((Object) testBean.getName()).isNull();
assertThat(testBean.getName()).isNull();
testBean = context.getBean("testBean2", TestBean.class);
assertThat((Object) testBean.getName()).isNull();
assertThat(testBean.getName()).isNull();
System.setProperty("myProp", "foo");
@ -203,10 +203,10 @@ class AutowiredConfigurationTests {
System.clearProperty("myProp");
testBean = context.getBean("testBean", TestBean.class);
assertThat((Object) testBean.getName()).isNull();
assertThat(testBean.getName()).isNull();
testBean = context.getBean("testBean2", TestBean.class);
assertThat((Object) testBean.getName()).isNull();
assertThat(testBean.getName()).isNull();
}
@Test

View File

@ -57,7 +57,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
String key = createRandomKey();
Object value = "george";
assertThat((Object) cache.get(key)).isNull();
assertThat(cache.get(key)).isNull();
assertThat(cache.get(key, String.class)).isNull();
assertThat(cache.get(key, Object.class)).isNull();
@ -96,7 +96,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
String key = createRandomKey();
Object value = "george";
assertThat((Object) cache.get(key)).isNull();
assertThat(cache.get(key)).isNull();
cache.put(key, value);
}
@ -104,13 +104,13 @@ public abstract class AbstractCacheTests<T extends Cache> {
public void testCacheClear() throws Exception {
T cache = getCache();
assertThat((Object) cache.get("enescu")).isNull();
assertThat(cache.get("enescu")).isNull();
cache.put("enescu", "george");
assertThat((Object) cache.get("vlaicu")).isNull();
assertThat(cache.get("vlaicu")).isNull();
cache.put("vlaicu", "aurel");
cache.clear();
assertThat((Object) cache.get("vlaicu")).isNull();
assertThat((Object) cache.get("enescu")).isNull();
assertThat(cache.get("vlaicu")).isNull();
assertThat(cache.get("enescu")).isNull();
}
@Test
@ -128,7 +128,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
String key = createRandomKey();
assertThat((Object) cache.get(key)).isNull();
assertThat(cache.get(key)).isNull();
Object value = cache.get(key, () -> returnValue);
assertThat(value).isEqualTo(returnValue);
assertThat(cache.get(key).get()).isEqualTo(value);
@ -161,7 +161,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
T cache = getCache();
String key = createRandomKey();
assertThat((Object) cache.get(key)).isNull();
assertThat(cache.get(key)).isNull();
try {
cache.get(key, () -> {

View File

@ -66,7 +66,7 @@ class GenericTypeResolverTests {
@Test
void nullIfNotResolvable() {
GenericClass<String> obj = new GenericClass<>();
assertThat((Object) resolveTypeArgument(obj.getClass(), GenericClass.class)).isNull();
assertThat(resolveTypeArgument(obj.getClass(), GenericClass.class)).isNull();
}
@Test
@ -148,13 +148,13 @@ class GenericTypeResolverTests {
@Test // SPR-11030
void getGenericsCannotBeResolved() {
Class<?>[] resolved = GenericTypeResolver.resolveTypeArguments(List.class, Iterable.class);
assertThat((Object) resolved).isNull();
assertThat(resolved).isNull();
}
@Test // SPR-11052
void getRawMapTypeCannotBeResolved() {
Class<?>[] resolved = GenericTypeResolver.resolveTypeArguments(Map.class, Map.class);
assertThat((Object) resolved).isNull();
assertThat(resolved).isNull();
}
@Test // SPR-11044
@ -377,16 +377,16 @@ class GenericTypeResolverTests {
interface IdFixingRepository<T> extends Repository<T, Long> {
}
interface First<F extends Number> {
interface First<N extends Number> {
default void foo(F f) {
default void foo(N f) {
// ...
}
}
interface Second<B> {
interface Second<T> {
default void bar(B b) {
default void bar(T b) {
// ...
}
}

View File

@ -321,8 +321,8 @@ class AnnotationUtilsTests {
@Test
void findAnnotationDeclaringClassForAllScenarios() {
// no class-level annotation
assertThat((Object) findAnnotationDeclaringClass(Transactional.class, NonAnnotatedInterface.class)).isNull();
assertThat((Object) findAnnotationDeclaringClass(Transactional.class, NonAnnotatedClass.class)).isNull();
assertThat(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedInterface.class)).isNull();
assertThat(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedClass.class)).isNull();
// inherited class-level annotation; note: @Transactional is inherited
assertThat(findAnnotationDeclaringClass(Transactional.class, InheritedAnnotationInterface.class)).isEqualTo(InheritedAnnotationInterface.class);
@ -342,8 +342,8 @@ class AnnotationUtilsTests {
void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
// no class-level annotation
List<Class<? extends Annotation>> transactionalCandidateList = Collections.singletonList(Transactional.class);
assertThat((Object) findAnnotationDeclaringClassForTypes(transactionalCandidateList, NonAnnotatedInterface.class)).isNull();
assertThat((Object) findAnnotationDeclaringClassForTypes(transactionalCandidateList, NonAnnotatedClass.class)).isNull();
assertThat(findAnnotationDeclaringClassForTypes(transactionalCandidateList, NonAnnotatedInterface.class)).isNull();
assertThat(findAnnotationDeclaringClassForTypes(transactionalCandidateList, NonAnnotatedClass.class)).isNull();
// inherited class-level annotation; note: @Transactional is inherited
assertThat(findAnnotationDeclaringClassForTypes(transactionalCandidateList, InheritedAnnotationInterface.class)).isEqualTo(InheritedAnnotationInterface.class);
@ -365,8 +365,8 @@ class AnnotationUtilsTests {
List<Class<? extends Annotation>> candidates = asList(Transactional.class, Order.class);
// no class-level annotation
assertThat((Object) findAnnotationDeclaringClassForTypes(candidates, NonAnnotatedInterface.class)).isNull();
assertThat((Object) findAnnotationDeclaringClassForTypes(candidates, NonAnnotatedClass.class)).isNull();
assertThat(findAnnotationDeclaringClassForTypes(candidates, NonAnnotatedInterface.class)).isNull();
assertThat(findAnnotationDeclaringClassForTypes(candidates, NonAnnotatedClass.class)).isNull();
// inherited class-level annotation; note: @Transactional is inherited
assertThat(findAnnotationDeclaringClassForTypes(candidates, InheritedAnnotationInterface.class)).isEqualTo(InheritedAnnotationInterface.class);

View File

@ -862,7 +862,7 @@ class DefaultConversionServiceTests {
void convertObjectToObjectFinderMethodWithNull() {
TestEntity entity = (TestEntity) conversionService.convert(null,
TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(TestEntity.class));
assertThat((Object) entity).isNull();
assertThat(entity).isNull();
}
@Test

View File

@ -99,12 +99,12 @@ class MutablePropertySourcesTests {
assertThat(sources).hasSize(6);
assertThat(sources.contains("a")).isFalse();
assertThat((Object) sources.remove("a")).isNull();
assertThat(sources.remove("a")).isNull();
assertThat(sources).hasSize(6);
String bogusPS = "bogus";
assertThatIllegalArgumentException().isThrownBy(() ->
sources.addAfter(bogusPS, new MockPropertySource("h")))
assertThatIllegalArgumentException()
.isThrownBy(() -> sources.addAfter(bogusPS, new MockPropertySource("h")))
.withMessageContaining("does not exist");
sources.addFirst(new MockPropertySource("a"));
@ -121,16 +121,16 @@ class MutablePropertySourcesTests {
sources.replace("a-replaced", new MockPropertySource("a"));
assertThatIllegalArgumentException().isThrownBy(() ->
sources.replace(bogusPS, new MockPropertySource("bogus-replaced")))
assertThatIllegalArgumentException()
.isThrownBy(() -> sources.replace(bogusPS, new MockPropertySource("bogus-replaced")))
.withMessageContaining("does not exist");
assertThatIllegalArgumentException().isThrownBy(() ->
sources.addBefore("b", new MockPropertySource("b")))
assertThatIllegalArgumentException()
.isThrownBy(() -> sources.addBefore("b", new MockPropertySource("b")))
.withMessageContaining("cannot be added relative to itself");
assertThatIllegalArgumentException().isThrownBy(() ->
sources.addAfter("b", new MockPropertySource("b")))
assertThatIllegalArgumentException()
.isThrownBy(() -> sources.addAfter("b", new MockPropertySource("b")))
.withMessageContaining("cannot be added relative to itself");
}
@ -149,8 +149,7 @@ class MutablePropertySourcesTests {
assertThat(it.hasNext()).isTrue();
assertThat(it.next().getName()).isEqualTo("test");
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
it::remove);
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(it::remove);
assertThat(it.hasNext()).isFalse();
}

View File

@ -522,10 +522,6 @@ class ConcurrentReferenceHashMapTests {
super(initialCapacity, loadFactor, concurrencyLevel);
}
public TestWeakConcurrentCache(int initialCapacity, int concurrencyLevel) {
super(initialCapacity, concurrencyLevel);
}
@Override
protected int getHash(@Nullable Object o) {
// For testing we want more control of the hash

View File

@ -73,7 +73,7 @@ class ReflectionUtilsTests {
assertThat(testBean.getName()).isEqualTo("FooBar");
ReflectionUtils.setField(field, testBean, null);
assertThat((Object) testBean.getName()).isNull();
assertThat(testBean.getName()).isNull();
}
@Test

View File

@ -221,7 +221,7 @@ class SettableListenableFutureTests {
@Test
void nullIsAcceptedAsValueToSet() throws ExecutionException, InterruptedException {
settableListenableFuture.set(null);
assertThat((Object) settableListenableFuture.get()).isNull();
assertThat(settableListenableFuture.get()).isNull();
assertThat(settableListenableFuture.isCancelled()).isFalse();
assertThat(settableListenableFuture.isDone()).isTrue();
}

View File

@ -66,7 +66,7 @@ class StaxSourceTests {
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(XML));
StaxSource source = new StaxSource(streamReader);
assertThat(source.getXMLStreamReader()).as("Invalid streamReader returned").isEqualTo(streamReader);
assertThat((Object) source.getXMLEventReader()).as("EventReader returned").isNull();
assertThat(source.getXMLEventReader()).as("EventReader returned").isNull();
StringWriter writer = new StringWriter();
transformer.transform(source, new StreamResult(writer));
assertThat(XmlContent.from(writer)).as("Invalid result").isSimilarTo(XML);
@ -77,7 +77,7 @@ class StaxSourceTests {
XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(XML));
StaxSource source = new StaxSource(streamReader);
assertThat(source.getXMLStreamReader()).as("Invalid streamReader returned").isEqualTo(streamReader);
assertThat((Object) source.getXMLEventReader()).as("EventReader returned").isNull();
assertThat(source.getXMLEventReader()).as("EventReader returned").isNull();
Document expected = documentBuilder.parse(new InputSource(new StringReader(XML)));
Document result = documentBuilder.newDocument();
@ -89,7 +89,7 @@ class StaxSourceTests {
void eventReaderSourceToStreamResult() throws Exception {
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML));
StaxSource source = new StaxSource(eventReader);
assertThat((Object) source.getXMLEventReader()).as("Invalid eventReader returned").isEqualTo(eventReader);
assertThat(source.getXMLEventReader()).as("Invalid eventReader returned").isEqualTo(eventReader);
assertThat(source.getXMLStreamReader()).as("StreamReader returned").isNull();
StringWriter writer = new StringWriter();
transformer.transform(source, new StreamResult(writer));
@ -100,7 +100,7 @@ class StaxSourceTests {
void eventReaderSourceToDOMResult() throws Exception {
XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML));
StaxSource source = new StaxSource(eventReader);
assertThat((Object) source.getXMLEventReader()).as("Invalid eventReader returned").isEqualTo(eventReader);
assertThat(source.getXMLEventReader()).as("Invalid eventReader returned").isEqualTo(eventReader);
assertThat(source.getXMLStreamReader()).as("StreamReader returned").isNull();
Document expected = documentBuilder.parse(new InputSource(new StringReader(XML)));
@ -108,4 +108,5 @@ class StaxSourceTests {
transformer.transform(source, new DOMResult(result));
assertThat(XmlContent.of(result)).as("Invalid result").isSimilarTo(expected);
}
}

View File

@ -33,13 +33,14 @@ import static org.mockito.Mockito.verify;
* @author Juergen Hoeller
* @since 6.1.2
*/
public class SingleConnectionDataSourceTests {
class SingleConnectionDataSourceTests {
private final Connection connection = mock();
@Test
public void plainConnection() throws Exception {
@SuppressWarnings("resource")
void plainConnection() throws Exception {
SingleConnectionDataSource ds = new SingleConnectionDataSource(connection, false);
ds.getConnection().close();
@ -47,7 +48,7 @@ public class SingleConnectionDataSourceTests {
}
@Test
public void withAutoCloseable() throws Exception {
void withAutoCloseable() throws Exception {
try (SingleConnectionDataSource ds = new SingleConnectionDataSource(connection, false)) {
ds.getConnection();
}
@ -56,7 +57,8 @@ public class SingleConnectionDataSourceTests {
}
@Test
public void withSuppressClose() throws Exception {
@SuppressWarnings("resource")
void withSuppressClose() throws Exception {
SingleConnectionDataSource ds = new SingleConnectionDataSource(connection, true);
ds.getConnection().close();
@ -70,7 +72,8 @@ public class SingleConnectionDataSourceTests {
}
@Test
public void withRollbackBeforeClose() throws Exception {
@SuppressWarnings("resource")
void withRollbackBeforeClose() throws Exception {
SingleConnectionDataSource ds = new SingleConnectionDataSource(connection, true);
ds.setRollbackBeforeClose(true);
@ -80,7 +83,8 @@ public class SingleConnectionDataSourceTests {
}
@Test
public void withEnforcedAutoCommit() throws Exception {
@SuppressWarnings("resource")
void withEnforcedAutoCommit() throws Exception {
SingleConnectionDataSource ds = new SingleConnectionDataSource() {
@Override
protected Connection getConnectionFromDriverManager(String url, Properties props) {

View File

@ -225,7 +225,7 @@ public class MessageBrokerConfigurationTests {
assertThat(handlers.contains(context.getBean(UserDestinationMessageHandler.class))).isTrue();
assertThat(handlers.contains(context.getBean(SimpleBrokerMessageHandler.class))).isTrue();
assertThat((Object) channel.getExecutor()).isNull();
assertThat(channel.getExecutor()).isNull();
}
@Test
@ -479,7 +479,7 @@ public class MessageBrokerConfigurationTests {
assertThat(registry.getClass()).isNotEqualTo(MultiServerUserRegistry.class);
UserDestinationMessageHandler handler = context.getBean(UserDestinationMessageHandler.class);
assertThat((Object) handler.getBroadcastDestination()).isNull();
assertThat(handler.getBroadcastDestination()).isNull();
Object nullBean = context.getBean("userRegistryMessageHandler");
assertThat(nullBean.equals(null)).isTrue();

View File

@ -586,7 +586,7 @@ public class DefaultStompSessionTests {
receivedHeaders.set(receiptHeaders);
});
assertThat((Object) received.get()).isNull();
assertThat(received.get()).isNull();
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
accessor.setReceiptId("my-receipt");
@ -656,7 +656,7 @@ public class DefaultStompSessionTests {
Runnable scheduledTask = taskCaptor.getValue();
assertThat(scheduledTask).isNotNull();
assertThat((Object) notReceived.get()).isNull();
assertThat(notReceived.get()).isNull();
scheduledTask.run();
assertThat(notReceived.get()).isTrue();

View File

@ -205,8 +205,8 @@ public class StompHeaderAccessorTests {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.create(StompCommand.SEND);
MessageHeaders headers = headerAccessor.getMessageHeaders();
assertThat((Object) headers.getId()).isNull();
assertThat((Object) headers.getTimestamp()).isNull();
assertThat(headers.getId()).isNull();
assertThat(headers.getTimestamp()).isNull();
}
@Test

View File

@ -265,7 +265,7 @@ public class MessageHeaderAccessorTests {
@Test
public void timestampDefaultBehavior() {
MessageHeaderAccessor accessor = new MessageHeaderAccessor();
assertThat((Object) accessor.getMessageHeaders().getTimestamp()).isNull();
assertThat(accessor.getMessageHeaders().getTimestamp()).isNull();
}
@Test
@ -291,8 +291,8 @@ public class MessageHeaderAccessorTests {
accessor.setLeaveMutable(true);
MessageHeaders headers = accessor.getMessageHeaders();
assertThat((Object) headers.getId()).isNull();
assertThat((Object) headers.getTimestamp()).isNull();
assertThat(headers.getId()).isNull();
assertThat(headers.getTimestamp()).isNull();
final UUID id = new UUID(0L, 23L);
accessor.setIdGenerator(() -> id);

View File

@ -253,6 +253,7 @@ public class LocalContainerEntityManagerFactoryBeanTests extends AbstractEntityM
createEntityManagerFactoryBean("org/springframework/orm/jpa/domain/persistence.xml", null, "call me Bob"));
}
@SuppressWarnings("unchecked")
protected LocalContainerEntityManagerFactoryBean createEntityManagerFactoryBean(
String persistenceXml, Properties props, String entityManagerName) throws Exception {
@ -273,7 +274,7 @@ public class LocalContainerEntityManagerFactoryBeanTests extends AbstractEntityM
assertThat(actualPui.getPersistenceUnitName()).isEqualTo(entityManagerName);
if (props != null) {
assertThat((Object) actualProps).isEqualTo(props);
assertThat(actualProps).isEqualTo(props);
}
//checkInvariants(containerEmfb);

View File

@ -57,6 +57,7 @@ public class LocalEntityManagerFactoryBeanTests extends AbstractEntityManagerFac
testValidUsage(new Properties());
}
@SuppressWarnings("unchecked")
protected void testValidUsage(Properties props) throws Exception {
// This will be set by DummyPersistenceProvider
actualName = null;
@ -74,7 +75,7 @@ public class LocalEntityManagerFactoryBeanTests extends AbstractEntityManagerFac
assertThat(actualName).isSameAs(entityManagerName);
if (props != null) {
assertThat((Object) actualProps).isEqualTo(props);
assertThat(actualProps).isEqualTo(props);
}
checkInvariants(lemfb);

View File

@ -208,7 +208,7 @@ class ResponseEntityTests {
assertThat(responseHeaders.getFirst(HttpHeaders.CONTENT_LENGTH)).isEqualTo(String.valueOf(contentLength));
assertThat(responseHeaders.getFirst(HttpHeaders.CONTENT_TYPE)).isEqualTo(contentType.toString());
assertThat((Object) responseEntity.getBody()).isNull();
assertThat(responseEntity.getBody()).isNull();
}
@Test

View File

@ -209,7 +209,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
@Test
public void undefinedObjectType() {
assertThat((Object) this.factory.getObjectType()).isNull();
assertThat(this.factory.getObjectType()).isNull();
}
private static SerializerFactoryConfig getSerializerFactoryConfig(ObjectMapper objectMapper) {

View File

@ -68,7 +68,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN)).isFalse();
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -84,7 +84,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN)).isFalse();
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -106,7 +106,7 @@ public class DefaultCorsProcessorTests {
ServerHttpResponse response = exchange.getResponse();
assertThat(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN)).isFalse();
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -122,7 +122,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().containsKey(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS)).isFalse();
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -141,7 +141,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().getFirst(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS)).isEqualTo("true");
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -162,7 +162,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().getFirst(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS)).isEqualTo("true");
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -172,7 +172,7 @@ public class DefaultCorsProcessorTests {
this.processor.process(this.conf, exchange);
ServerHttpResponse response = exchange.getResponse();
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
assertThat(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN)).isTrue();
}
@ -186,7 +186,7 @@ public class DefaultCorsProcessorTests {
this.processor.process(this.conf, exchange);
ServerHttpResponse response = exchange.getResponse();
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
assertThat(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN)).isTrue();
}
@ -206,7 +206,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().getFirst(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS)).contains("header2");
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -219,7 +219,7 @@ public class DefaultCorsProcessorTests {
ServerHttpResponse response = exchange.getResponse();
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@ -244,7 +244,7 @@ public class DefaultCorsProcessorTests {
this.processor.process(this.conf, exchange);
ServerHttpResponse response = exchange.getResponse();
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat(response.getHeaders().getFirst(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS)).isEqualTo("GET,HEAD");
@ -312,7 +312,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().containsKey(HttpHeaders.ACCESS_CONTROL_MAX_AGE)).isFalse();
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -336,7 +336,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().getFirst(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS)).isEqualTo("true");
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -361,7 +361,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().getFirst(ACCESS_CONTROL_ALLOW_ORIGIN)).isEqualTo("https://domain2.com");
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -385,7 +385,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().getFirst(ACCESS_CONTROL_ALLOW_HEADERS)).doesNotContain("Header3");
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -407,7 +407,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().getFirst(ACCESS_CONTROL_ALLOW_HEADERS)).doesNotContain("*");
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test
@ -426,7 +426,7 @@ public class DefaultCorsProcessorTests {
assertThat(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_HEADERS)).isFalse();
assertThat(response.getHeaders().get(VARY)).contains(ORIGIN,
ACCESS_CONTROL_REQUEST_METHOD, ACCESS_CONTROL_REQUEST_HEADERS);
assertThat((Object) response.getStatusCode()).isNull();
assertThat(response.getStatusCode()).isNull();
}
@Test

View File

@ -45,12 +45,13 @@ public class DelegatingPhaseListenerTests {
}
};
@SuppressWarnings("unchecked")
@Test
public void beforeAndAfterPhaseWithSingleTarget() {
TestListener target = new TestListener();
beanFactory.addBean("testListener", target);
assertThat((Object) delPhaseListener.getPhaseId()).isEqualTo(PhaseId.ANY_PHASE);
assertThat(delPhaseListener.getPhaseId()).isEqualTo(PhaseId.ANY_PHASE);
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle());
delPhaseListener.beforePhase(event);
@ -60,6 +61,7 @@ public class DelegatingPhaseListenerTests {
assertThat(target.afterCalled).isTrue();
}
@SuppressWarnings("unchecked")
@Test
public void beforeAndAfterPhaseWithMultipleTargets() {
TestListener target1 = new TestListener();
@ -67,7 +69,7 @@ public class DelegatingPhaseListenerTests {
beanFactory.addBean("testListener1", target1);
beanFactory.addBean("testListener2", target2);
assertThat((Object) delPhaseListener.getPhaseId()).isEqualTo(PhaseId.ANY_PHASE);
assertThat(delPhaseListener.getPhaseId()).isEqualTo(PhaseId.ANY_PHASE);
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle());
delPhaseListener.beforePhase(event);

View File

@ -361,10 +361,10 @@ public class PathPatternTests {
@Test
public void pathRemainingCornerCases_spr15336() {
// No match when the literal path element is a longer form of the segment in the pattern
assertThat((Object) parse("/foo").matchStartOfPath(toPathContainer("/footastic/bar"))).isNull();
assertThat((Object) parse("/f?o").matchStartOfPath(toPathContainer("/footastic/bar"))).isNull();
assertThat((Object) parse("/f*o*p").matchStartOfPath(toPathContainer("/flooptastic/bar"))).isNull();
assertThat((Object) parse("/{abc}abc").matchStartOfPath(toPathContainer("/xyzabcbar/bar"))).isNull();
assertThat(parse("/foo").matchStartOfPath(toPathContainer("/footastic/bar"))).isNull();
assertThat(parse("/f?o").matchStartOfPath(toPathContainer("/footastic/bar"))).isNull();
assertThat(parse("/f*o*p").matchStartOfPath(toPathContainer("/flooptastic/bar"))).isNull();
assertThat(parse("/{abc}abc").matchStartOfPath(toPathContainer("/xyzabcbar/bar"))).isNull();
// With a /** on the end have to check if there is any more data post
// 'the match' it starts with a separator
@ -614,7 +614,7 @@ public class PathPatternTests {
pp = parse("/*/{foo}/b*");
pri = getPathRemaining(pp, "/foo");
assertThat((Object) pri).isNull();
assertThat(pri).isNull();
pri = getPathRemaining(pp, "/abc/def/bhi");
assertThat(pri.getPathRemaining().value()).isEmpty();
assertThat(pri.getUriVariables()).containsEntry("foo", "def");
@ -838,8 +838,8 @@ public class PathPatternTests {
checkCapture("/A-{B}-C", "/A-b-C", "B", "b");
checkCapture("/{name}.{extension}", "/test.html", "name", "test", "extension", "html");
assertThat((Object) checkCapture("/{one}/", "//")).isNull();
assertThat((Object) checkCapture("", "/abc")).isNull();
assertThat(checkCapture("/{one}/", "//")).isNull();
assertThat(checkCapture("", "/abc")).isNull();
assertThat(checkCapture("", "").getUriVariables()).isEmpty();
checkCapture("{id}", "99", "id", "99");
@ -1043,8 +1043,8 @@ public class PathPatternTests {
paths.add(null);
paths.add(null);
paths.sort(comparator);
assertThat((Object) paths.get(0)).isNull();
assertThat((Object) paths.get(1)).isNull();
assertThat(paths.get(0)).isNull();
assertThat(paths.get(1)).isNull();
paths.clear();
paths.add(null);

View File

@ -75,7 +75,7 @@ class ResourceHandlerRegistryTests {
@Test
void noResourceHandlers() {
this.registry = new ResourceHandlerRegistry(new GenericApplicationContext());
assertThat((Object) this.registry.getHandlerMapping()).isNull();
assertThat(this.registry.getHandlerMapping()).isNull();
}
@Test

View File

@ -495,7 +495,7 @@ class ResourceWebHandlerTests {
setBestMachingPattern(exchange, "/**");
this.handler.handle(exchange).block(TIMEOUT);
assertThat((Object) exchange.getResponse().getStatusCode()).isNull();
assertThat(exchange.getResponse().getStatusCode()).isNull();
assertResponseBody(exchange, "h1 { color:red; }");
}
@ -522,7 +522,7 @@ class ResourceWebHandlerTests {
setPathWithinHandlerMapping(exchange, "foo.css");
setBestMachingPattern(exchange, "/**");
this.handler.handle(exchange).block(TIMEOUT);
assertThat((Object) exchange.getResponse().getStatusCode()).isNull();
assertThat(exchange.getResponse().getStatusCode()).isNull();
assertResponseBody(exchange, "h1 { color:red; }");
}

View File

@ -84,7 +84,7 @@ class VersionResourceResolverTests {
.resolveResourceInternal(null, file, this.locations, this.chain)
.block(Duration.ofMillis(5000));
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.chain, times(1)).resolveResource(null, file, this.locations);
}
@ -99,7 +99,7 @@ class VersionResourceResolverTests {
.resolveResourceInternal(null, file, this.locations, this.chain)
.block(Duration.ofMillis(5000));
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.chain, times(1)).resolveResource(null, file, this.locations);
verify(this.versionStrategy, times(1)).extractVersion(file);
}
@ -119,7 +119,7 @@ class VersionResourceResolverTests {
.resolveResourceInternal(null, versionFile, this.locations, this.chain)
.block(Duration.ofMillis(5000));
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.versionStrategy, times(1)).removeVersion(versionFile, version);
}
@ -140,7 +140,7 @@ class VersionResourceResolverTests {
.resolveResourceInternal(null, versionFile, this.locations, this.chain)
.block(Duration.ofMillis(5000));
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.versionStrategy, times(1)).getResourceVersion(expected);
}

View File

@ -686,7 +686,7 @@ public class DispatcherServletTests {
assertThat(myServlet.getServletConfig().getServletName()).isEqualTo("complex");
assertThat(myServlet.getServletConfig().getServletContext()).isEqualTo(getServletContext());
complexDispatcherServlet.destroy();
assertThat((Object) myServlet.getServletConfig()).isNull();
assertThat(myServlet.getServletConfig()).isNull();
}
@Test

View File

@ -540,7 +540,7 @@ public class MvcNamespaceTests {
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView mv = adapter.handle(request, response, chain.getHandler());
assertThat((Object) mv).isNull();
assertThat(mv).isNull();
}
@Test
@ -566,7 +566,7 @@ public class MvcNamespaceTests {
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView mv = adapter.handle(request, response, chain.getHandler());
assertThat((Object) mv).isNull();
assertThat(mv).isNull();
}
@Test
@ -624,7 +624,7 @@ public class MvcNamespaceTests {
assertThat(chain.getInterceptorList().get(2)).isInstanceOf(LocaleChangeInterceptor.class);
assertThat(chain.getInterceptorList().get(3)).isInstanceOf(ThemeChangeInterceptor.class);
ModelAndView mv = adapter.handle(request, new MockHttpServletResponse(), chain.getHandler());
assertThat((Object) mv.getViewName()).isNull();
assertThat(mv.getViewName()).isNull();
request = new MockHttpServletRequest("GET", "/myapp/app/bar");
request.setContextPath("/myapp");

View File

@ -84,7 +84,7 @@ public class ResourceHandlerRegistryTests {
@Test
public void noResourceHandlers() {
this.registry = new ResourceHandlerRegistry(new GenericWebApplicationContext(), new MockServletContext());
assertThat((Object) this.registry.getHandlerMapping()).isNull();
assertThat(this.registry.getHandlerMapping()).isNull();
}
@Test

View File

@ -97,7 +97,7 @@ public class ResourceUrlProviderTests {
request.setRequestURI("/contextpath-longer-than-request-path/style.css");
String url = "/resources/foo.css";
String resolvedUrl = this.urlProvider.getForRequestUrl(request, url);
assertThat((Object) resolvedUrl).isNull();
assertThat(resolvedUrl).isNull();
}
@Test

View File

@ -73,7 +73,7 @@ class VersionResourceResolverTests {
this.resolver.setStrategyMap(Collections.emptyMap());
Resource actual = this.resolver.resolveResourceInternal(null, file, this.locations, this.chain);
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.chain, times(1)).resolveResource(null, file, this.locations);
}
@ -85,7 +85,7 @@ class VersionResourceResolverTests {
this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy));
Resource actual = this.resolver.resolveResourceInternal(null, file, this.locations, this.chain);
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.chain, times(1)).resolveResource(null, file, this.locations);
verify(this.versionStrategy, times(1)).extractVersion(file);
}
@ -102,7 +102,7 @@ class VersionResourceResolverTests {
this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy));
Resource actual = this.resolver.resolveResourceInternal(null, versionFile, this.locations, this.chain);
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.versionStrategy, times(1)).removeVersion(versionFile, version);
}
@ -120,7 +120,7 @@ class VersionResourceResolverTests {
this.resolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy));
Resource actual = this.resolver.resolveResourceInternal(null, versionFile, this.locations, this.chain);
assertThat((Object) actual).isNull();
assertThat(actual).isNull();
verify(this.versionStrategy, times(1)).getResourceVersion(expected);
}

View File

@ -133,7 +133,7 @@ public class ResourceBundleViewResolverTests {
@Test
public void noSuchViewEnglish() throws Exception {
assertThat((Object) rb.resolveViewName("xxxxxxweorqiwuopeir", Locale.ENGLISH)).isNull();
assertThat(rb.resolveViewName("xxxxxxweorqiwuopeir", Locale.ENGLISH)).isNull();
}
@Test

View File

@ -126,7 +126,7 @@ public class MappingJackson2JsonViewTests {
view.render(model, request, response);
assertThat((Object) response.getHeader("Cache-Control")).isNull();
assertThat(response.getHeader("Cache-Control")).isNull();
}
@Test