From 449377908fe20d6f0cae5822e6db204b2abf8e00 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 26 Oct 2020 14:53:09 +0100 Subject: [PATCH] Fix JUnit 4 to AssertJ migration bugs The migration from JUnit 4 assertions to AssertJ assertions resulted in several unnecessary casts from int to long that actually cause assertions to pass when they should otherwise fail. This commit fixes all such bugs for the pattern `.isNotEqualTo((long)`. --- ...DefinitionMetadataEqualsHashCodeTests.java | 4 +-- .../core/MethodParameterTests.java | 4 +-- .../SynthesizingMethodParameterTests.java | 4 +-- .../spel/support/ReflectionHelperTests.java | 6 ++-- .../MergedContextConfigurationTests.java | 32 +++++++++---------- .../ServerHttpRequestIntegrationTests.java | 4 +-- .../ServerHttpsRequestIntegrationTests.java | 4 +-- .../util/pattern/PathPatternParserTests.java | 3 +- .../condition/RequestMappingInfoTests.java | 14 ++++---- .../mvc/method/RequestMappingInfoTests.java | 16 +++++----- .../OriginHandshakeInterceptorTests.java | 12 +++---- .../handler/DefaultSockJsServiceTests.java | 10 +++--- 12 files changed, 56 insertions(+), 57 deletions(-) diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java index 1c469274c29..36c0c4be39c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -126,7 +126,7 @@ public class DefinitionMetadataEqualsHashCodeTests { assertThat(equal.hashCode()).as("Hash code for equal instances should match").isEqualTo(master.hashCode()); assertThat(notEqual).as("Should not be equal").isNotEqualTo(master); - assertThat(notEqual.hashCode()).as("Hash code for non-equal instances should not match").isNotEqualTo((long) master.hashCode()); + assertThat(notEqual.hashCode()).as("Hash code for non-equal instances should not match").isNotEqualTo(master.hashCode()); assertThat(subclass).as("Subclass should be equal").isEqualTo(master); assertThat(subclass.hashCode()).as("Hash code for subclass should match").isEqualTo(master.hashCode()); diff --git a/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java b/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java index 160aa064fba..6f5220f2771 100644 --- a/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java +++ b/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -89,7 +89,7 @@ class MethodParameterTests { Method method = getClass().getMethod("method", String.class, Long.TYPE); MethodParameter methodParameter = new MethodParameter(method, 0); assertThat(methodParameter.hashCode()).isEqualTo(stringParameter.hashCode()); - assertThat(methodParameter.hashCode()).isNotEqualTo((long) longParameter.hashCode()); + assertThat(methodParameter.hashCode()).isNotEqualTo(longParameter.hashCode()); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java b/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java index 52b1c77f3d5..a1eea091314 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -86,7 +86,7 @@ class SynthesizingMethodParameterTests { Method method = getClass().getMethod("method", String.class, Long.TYPE); SynthesizingMethodParameter methodParameter = new SynthesizingMethodParameter(method, 0); assertThat(methodParameter.hashCode()).isEqualTo(stringParameter.hashCode()); - assertThat(methodParameter.hashCode()).isNotEqualTo((long) longParameter.hashCode()); + assertThat(methodParameter.hashCode()).isNotEqualTo(longParameter.hashCode()); } @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java index faa58780037..c651d41d47b 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -89,8 +89,8 @@ public class ReflectionHelperTests extends AbstractExpressionTests { assertThat(tv1).isNotEqualTo(tv3); assertThat(tv2).isNotEqualTo(tv3); assertThat(tv2.hashCode()).isEqualTo(tv1.hashCode()); - assertThat(tv3.hashCode()).isNotEqualTo((long) tv1.hashCode()); - assertThat(tv3.hashCode()).isNotEqualTo((long) tv2.hashCode()); + assertThat(tv3.hashCode()).isNotEqualTo(tv1.hashCode()); + assertThat(tv3.hashCode()).isNotEqualTo(tv2.hashCode()); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java index 3311f14443a..26bac7594c4 100644 --- a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java @@ -55,14 +55,14 @@ class MergedContextConfigurationTests { void hashCodeWithNulls() { MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(null, null, null, null, null); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(null, null, null, null, null); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test void hashCodeWithNullArrays() { MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), null, null, null, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), null, null, null, loader); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -71,7 +71,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -80,7 +80,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, new AnnotationConfigContextLoader()); - assertThat(mergedConfig2.hashCode()).isNotEqualTo((long) mergedConfig1.hashCode()); + assertThat(mergedConfig2.hashCode()).isNotEqualTo(mergedConfig1.hashCode()); } @Test @@ -90,7 +90,7 @@ class MergedContextConfigurationTests { EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), locations, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -101,7 +101,7 @@ class MergedContextConfigurationTests { EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), locations2, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); - assertThat(mergedConfig2.hashCode()).isNotEqualTo((long) mergedConfig1.hashCode()); + assertThat(mergedConfig2.hashCode()).isNotEqualTo(mergedConfig1.hashCode()); } @Test @@ -111,7 +111,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, classes, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, classes, EMPTY_STRING_ARRAY, loader); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -122,7 +122,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, classes1, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, classes2, EMPTY_STRING_ARRAY, loader); - assertThat(mergedConfig2.hashCode()).isNotEqualTo((long) mergedConfig1.hashCode()); + assertThat(mergedConfig2.hashCode()).isNotEqualTo(mergedConfig1.hashCode()); } @Test @@ -132,7 +132,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles, loader); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -143,7 +143,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); - assertThat(mergedConfig2.hashCode()).isNotEqualTo((long) mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -154,7 +154,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -165,7 +165,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); - assertThat(mergedConfig2.hashCode()).isNotEqualTo((long) mergedConfig1.hashCode()); + assertThat(mergedConfig2.hashCode()).isNotEqualTo(mergedConfig1.hashCode()); } @Test @@ -184,7 +184,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } @Test @@ -201,7 +201,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses1, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, initializerClasses2, EMPTY_STRING_ARRAY, loader); - assertThat(mergedConfig2.hashCode()).isNotEqualTo((long) mergedConfig1.hashCode()); + assertThat(mergedConfig2.hashCode()).isNotEqualTo(mergedConfig1.hashCode()); } /** @@ -216,7 +216,7 @@ class MergedContextConfigurationTests { EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent); - assertThat(mergedConfig2.hashCode()).isEqualTo(mergedConfig1.hashCode()); + assertThat(mergedConfig2).hasSameHashCodeAs(mergedConfig1); } /** @@ -233,7 +233,7 @@ class MergedContextConfigurationTests { EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent1); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, loader, null, parent2); - assertThat(mergedConfig2.hashCode()).isNotEqualTo((long) mergedConfig1.hashCode()); + assertThat(mergedConfig2.hashCode()).isNotEqualTo(mergedConfig1.hashCode()); } @Test diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java index 901180f5e18..8e0ca6179c0 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -58,7 +58,7 @@ class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTe URI uri = request.getURI(); assertThat(uri.getScheme()).isEqualTo("http"); assertThat(uri.getHost()).isNotNull(); - assertThat(uri.getPort()).isNotEqualTo((long) -1); + assertThat(uri.getPort()).isNotEqualTo(-1); assertThat(request.getRemoteAddress()).isNotNull(); assertThat(uri.getPath()).isEqualTo("/foo"); assertThat(uri.getQuery()).isEqualTo("param=bar"); diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java index 0599911088e..b8deed7afa4 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -95,7 +95,7 @@ class ServerHttpsRequestIntegrationTests { URI uri = request.getURI(); assertThat(uri.getScheme()).isEqualTo("https"); assertThat(uri.getHost()).isNotNull(); - assertThat(uri.getPort()).isNotEqualTo((long) -1); + assertThat(uri.getPort()).isNotEqualTo(-1); assertThat(request.getRemoteAddress()).isNotNull(); assertThat(uri.getPath()).isEqualTo("/foo"); assertThat(uri.getQuery()).isEqualTo("param=bar"); diff --git a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java index 8b6c204c4f7..99253bbd520 100644 --- a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java @@ -108,12 +108,11 @@ public class PathPatternParserTests { assertThat(pp2).isEqualTo(pp1); assertThat(pp2.hashCode()).isEqualTo(pp1.hashCode()); assertThat(pp3).isNotEqualTo(pp1); - assertThat(pp1.equals("abc")).isFalse(); pp1 = caseInsensitiveParser.parse("/abc"); pp2 = caseSensitiveParser.parse("/abc"); assertThat(pp1.equals(pp2)).isFalse(); - assertThat(pp2.hashCode()).isNotEqualTo((long) pp1.hashCode()); + assertThat(pp2.hashCode()).isNotEqualTo(pp1.hashCode()); } @Test diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java index cb5020949b3..badbb700244 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java @@ -233,7 +233,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(RequestMethod.GET, RequestMethod.POST) .params("foo=bar").headers("foo=bar") @@ -242,7 +242,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(RequestMethod.GET) .params("/NOOOOOO").headers("foo=bar") @@ -251,7 +251,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(RequestMethod.GET) .params("foo=bar").headers("/NOOOOOO") @@ -260,7 +260,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(RequestMethod.GET) .params("foo=bar").headers("foo=bar") @@ -269,7 +269,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(RequestMethod.GET) .params("foo=bar").headers("foo=bar") @@ -278,7 +278,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(RequestMethod.GET) .params("foo=bar").headers("foo=bar") @@ -287,7 +287,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java index 2f837231249..283fb98028c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -230,7 +230,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(GET, RequestMethod.POST) .params("foo=bar", "customFoo=customBar").headers("foo=bar") @@ -238,7 +238,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(GET) .params("/NOOOOOO", "customFoo=customBar").headers("foo=bar") @@ -246,7 +246,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(GET) .params("foo=bar", "customFoo=customBar").headers("/NOOOOOO") @@ -254,7 +254,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(GET) .params("foo=bar", "customFoo=customBar").headers("foo=bar") @@ -262,7 +262,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(GET) .params("foo=bar", "customFoo=customBar").headers("foo=bar") @@ -270,7 +270,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); info2 = paths("/foo").methods(GET) .params("foo=bar", "customFoo=NOOOOOO").headers("foo=bar") @@ -278,7 +278,7 @@ public class RequestMappingInfoTests { .build(); assertThat(info1.equals(info2)).isFalse(); - assertThat(info2.hashCode()).isNotEqualTo((long) info1.hashCode()); + assertThat(info2.hashCode()).isNotEqualTo(info1.hashCode()); } @Test diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java index e724ce85948..a53ef5c1180 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -57,7 +57,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { List allowed = Collections.singletonList("https://mydomain1.example"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(allowed); assertThat(interceptor.beforeHandshake(request, response, wsHandler, attributes)).isTrue(); - assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo((long) servletResponse.getStatus()); + assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo(servletResponse.getStatus()); } @Test @@ -75,7 +75,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { List allowed = Arrays.asList("https://mydomain1.example", "https://mydomain2.example", "http://mydomain3.example"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(allowed); assertThat(interceptor.beforeHandshake(request, response, wsHandler, attributes)).isTrue(); - assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo((long) servletResponse.getStatus()); + assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo(servletResponse.getStatus()); } @Test @@ -104,7 +104,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(); interceptor.setAllowedOrigins(Collections.singletonList("*")); assertThat(interceptor.beforeHandshake(request, response, wsHandler, attributes)).isTrue(); - assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo((long) servletResponse.getStatus()); + assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo(servletResponse.getStatus()); } @Test @@ -113,7 +113,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { this.servletRequest.setServerName("mydomain2.example"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(Collections.emptyList()); assertThat(interceptor.beforeHandshake(request, response, wsHandler, attributes)).isTrue(); - assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo((long) servletResponse.getStatus()); + assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo(servletResponse.getStatus()); } @Test @@ -122,7 +122,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { this.servletRequest.setServerName("mydomain2.example"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(Arrays.asList("http://mydomain1.example")); assertThat(interceptor.beforeHandshake(request, response, wsHandler, attributes)).isTrue(); - assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo((long) servletResponse.getStatus()); + assertThat(HttpStatus.FORBIDDEN.value()).isNotEqualTo(servletResponse.getStatus()); } @Test diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java index 083e105c017..3a651c015b4 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -286,7 +286,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests { String sockJsPath = "/websocket"; setRequest("GET", sockJsPrefix + sockJsPath); wsService.handleRequest(this.request, this.response, sockJsPath, this.wsHandler); - assertThat(this.servletResponse.getStatus()).isNotEqualTo((long) 403); + assertThat(this.servletResponse.getStatus()).isNotEqualTo(403); resetRequestAndResponse(); List allowed = Collections.singletonList("https://mydomain1.example"); @@ -295,7 +295,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests { setRequest("GET", sockJsPrefix + sockJsPath); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain1.example"); wsService.handleRequest(this.request, this.response, sockJsPath, this.wsHandler); - assertThat(this.servletResponse.getStatus()).isNotEqualTo((long) 403); + assertThat(this.servletResponse.getStatus()).isNotEqualTo(403); resetRequestAndResponse(); setRequest("GET", sockJsPrefix + sockJsPath); @@ -309,7 +309,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests { String sockJsPath = "/iframe.html"; setRequest("GET", sockJsPrefix + sockJsPath); this.service.handleRequest(this.request, this.response, sockJsPath, this.wsHandler); - assertThat(this.servletResponse.getStatus()).isNotEqualTo((long) 404); + assertThat(this.servletResponse.getStatus()).isNotEqualTo(404); assertThat(this.servletResponse.getHeader("X-Frame-Options")).isEqualTo("SAMEORIGIN"); resetRequestAndResponse(); @@ -323,7 +323,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests { setRequest("GET", sockJsPrefix + sockJsPath); this.service.setAllowedOrigins(Collections.singletonList("*")); this.service.handleRequest(this.request, this.response, sockJsPath, this.wsHandler); - assertThat(this.servletResponse.getStatus()).isNotEqualTo((long) 404); + assertThat(this.servletResponse.getStatus()).isNotEqualTo(404); assertThat(this.servletResponse.getHeader("X-Frame-Options")).isNull(); }