diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java index 471647f89c..d1c4db25c2 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -219,10 +219,12 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, @Override @Nullable public String[] getParameterNames() { - if (this.parameterNames == null) { - this.parameterNames = parameterNameDiscoverer.getParameterNames(getMethod()); + String[] parameterNames = this.parameterNames; + if (parameterNames == null) { + parameterNames = parameterNameDiscoverer.getParameterNames(getMethod()); + this.parameterNames = parameterNames; } - return this.parameterNames; + return parameterNames; } @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java index 4435d7746a..a98c6eb41b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 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. @@ -92,8 +92,7 @@ public class DirectFieldAccessor extends AbstractNestablePropertyAccessor { @Override protected NotWritablePropertyException createNotWritablePropertyException(String propertyName) { PropertyMatches matches = PropertyMatches.forField(propertyName, getRootClass()); - throw new NotWritablePropertyException( - getRootClass(), getNestedPath() + propertyName, + throw new NotWritablePropertyException(getRootClass(), getNestedPath() + propertyName, matches.buildErrorMessage(), matches.getPossibleMatches()); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index b2453bf593..02616c27c5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.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. @@ -613,7 +613,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean private final boolean required; - private volatile boolean cached = false; + private volatile boolean cached; @Nullable private volatile Object cachedFieldValue; @@ -644,21 +644,20 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean } synchronized (this) { if (!this.cached) { + Object cachedFieldValue = null; if (value != null || this.required) { - this.cachedFieldValue = desc; + cachedFieldValue = desc; registerDependentBeans(beanName, autowiredBeanNames); if (autowiredBeanNames.size() == 1) { String autowiredBeanName = autowiredBeanNames.iterator().next(); if (beanFactory.containsBean(autowiredBeanName) && beanFactory.isTypeMatch(autowiredBeanName, field.getType())) { - this.cachedFieldValue = new ShortcutDependencyDescriptor( + cachedFieldValue = new ShortcutDependencyDescriptor( desc, autowiredBeanName, field.getType()); } } } - else { - this.cachedFieldValue = null; - } + this.cachedFieldValue = cachedFieldValue; this.cached = true; } } @@ -678,7 +677,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean private final boolean required; - private volatile boolean cached = false; + private volatile boolean cached; @Nullable private volatile Object[] cachedMethodArguments; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index 23b397b30f..b114826270 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -76,7 +76,6 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; */ public class SpelReproTests extends AbstractExpressionTests { - @Test public void NPE_SPR5661() { evaluate("joinThreeStrings('a',null,'c')", "anullc", String.class); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java index 418ff975ed..17939f7a0f 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.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. @@ -16,9 +16,10 @@ package org.springframework.expression.spel.testresources; -///CLOVER:OFF public class Person { + private String privateName; + Company company; public Person(String name) { @@ -41,4 +42,5 @@ public class Person { public Company getCompany() { return company; } + } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.java index 3bc88ff9f4..7beb41441a 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.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. @@ -19,19 +19,25 @@ package org.springframework.expression.spel.testresources; import java.util.List; public class TestAddress{ - private String street; - private List crossStreets; - public String getStreet() { - return street; - } - public void setStreet(String street) { - this.street = street; - } - public List getCrossStreets() { - return crossStreets; - } - public void setCrossStreets(List crossStreets) { - this.crossStreets = crossStreets; - } + private String street; + + private List crossStreets; + + public String getStreet() { + return street; } + + public void setStreet(String street) { + this.street = street; + } + + public List getCrossStreets() { + return crossStreets; + } + + public void setCrossStreets(List crossStreets) { + this.crossStreets = crossStreets; + } + +} diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.java index ad1f58480e..e9470f26c8 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.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. @@ -17,19 +17,25 @@ package org.springframework.expression.spel.testresources; public class TestPerson { - private String name; - private TestAddress address; - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public TestAddress getAddress() { - return address; - } - public void setAddress(TestAddress address) { - this.address = address; - } + private String name; + + private TestAddress address; + + public String getName() { + return name; } + + public void setName(String name) { + this.name = name; + } + + public TestAddress getAddress() { + return address; + } + + public void setAddress(TestAddress address) { + this.address = address; + } + +} diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java index c8295860ac..27776fad7f 100755 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java @@ -637,21 +637,23 @@ public class CallMetaDataContext { schemaNameToUse = this.metaDataProvider.schemaNameToUse(getSchemaName()); } - String procedureNameToUse = this.metaDataProvider.procedureNameToUse(getProcedureName()); if (isFunction() || isReturnValueRequired()) { - callString = new StringBuilder().append("{? = call "). - append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : ""). - append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : ""). - append(procedureNameToUse).append("("); + callString = new StringBuilder("{? = call "); parameterCount = -1; } else { - callString = new StringBuilder().append("{call "). - append(StringUtils.hasLength(catalogNameToUse) ? catalogNameToUse + "." : ""). - append(StringUtils.hasLength(schemaNameToUse) ? schemaNameToUse + "." : ""). - append(procedureNameToUse).append("("); + callString = new StringBuilder("{call "); } + if (StringUtils.hasLength(catalogNameToUse)) { + callString.append(catalogNameToUse).append("."); + } + if (StringUtils.hasLength(schemaNameToUse)) { + callString.append(schemaNameToUse).append("."); + } + callString.append(this.metaDataProvider.procedureNameToUse(getProcedureName())); + callString.append("("); + for (SqlParameter parameter : this.callParameters) { if (!parameter.isResultsParameter()) { if (parameterCount > 0) { diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index 20d9e70ff2..fbb9f293d2 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -53,8 +53,8 @@ class UriComponentsBuilderTests { void plain() throws URISyntaxException { UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); UriComponents result = builder.scheme("https").host("example.com") - .path("foo").queryParam("bar").fragment("baz") - .build(); + .path("foo").queryParam("bar").fragment("baz").build(); + assertThat(result.getScheme()).isEqualTo("https"); assertThat(result.getHost()).isEqualTo("example.com"); assertThat(result.getPath()).isEqualTo("foo"); @@ -91,10 +91,10 @@ class UriComponentsBuilderTests { @Test void fromPath() throws URISyntaxException { UriComponents result = UriComponentsBuilder.fromPath("foo").queryParam("bar").fragment("baz").build(); + assertThat(result.getPath()).isEqualTo("foo"); assertThat(result.getQuery()).isEqualTo("bar"); assertThat(result.getFragment()).isEqualTo("baz"); - assertThat(result.toUriString()).as("Invalid result URI String").isEqualTo("foo?bar#baz"); URI expected = new URI("foo?bar#baz"); @@ -111,12 +111,12 @@ class UriComponentsBuilderTests { void fromHierarchicalUri() throws URISyntaxException { URI uri = new URI("https://example.com/foo?bar#baz"); UriComponents result = UriComponentsBuilder.fromUri(uri).build(); + assertThat(result.getScheme()).isEqualTo("https"); assertThat(result.getHost()).isEqualTo("example.com"); assertThat(result.getPath()).isEqualTo("/foo"); assertThat(result.getQuery()).isEqualTo("bar"); assertThat(result.getFragment()).isEqualTo("baz"); - assertThat(result.toUri()).as("Invalid result URI").isEqualTo(uri); } @@ -124,10 +124,10 @@ class UriComponentsBuilderTests { void fromOpaqueUri() throws URISyntaxException { URI uri = new URI("mailto:foo@bar.com#baz"); UriComponents result = UriComponentsBuilder.fromUri(uri).build(); + assertThat(result.getScheme()).isEqualTo("mailto"); assertThat(result.getSchemeSpecificPart()).isEqualTo("foo@bar.com"); assertThat(result.getFragment()).isEqualTo("baz"); - assertThat(result.toUri()).as("Invalid result URI").isEqualTo(uri); } @@ -606,7 +606,7 @@ class UriComponentsBuilderTests { assertThat(after.getPath()).isEqualTo("/foo/"); } - @Test // gh-19890 + @Test // gh-19890 void fromHttpRequestWithEmptyScheme() { HttpRequest request = new HttpRequest() { @Override @@ -854,7 +854,7 @@ class UriComponentsBuilderTests { assertThat(uriComponents.getQueryParams().get("bar").get(0)).isNull(); } - @Test // gh-24444 + @Test // gh-24444 void opaqueUriDoesNotResetOnNullInput() throws URISyntaxException { URI uri = new URI("urn:ietf:wg:oauth:2.0:oob"); UriComponents result = UriComponentsBuilder.fromUri(uri) @@ -1114,7 +1114,7 @@ class UriComponentsBuilderTests { assertThat(result.toUriString()).isEqualTo("https://example.com/rest/mobile/users/1"); } - @Test // gh-25737 + @Test // gh-25737 void fromHttpRequestForwardedHeaderComma() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Forwarded", "for=192.0.2.0,for=192.0.2.1;proto=https;host=192.0.2.3:9090"); @@ -1153,7 +1153,7 @@ class UriComponentsBuilderTests { assertThat(uri).isEqualTo("http://localhost:8081/{path}?sort={sort}&sort=another_value"); } - @Test // SPR-17630 + @Test // SPR-17630 void toUriStringWithCurlyBraces() { assertThat(UriComponentsBuilder.fromUriString("/path?q={asa}asa").toUriString()).isEqualTo("/path?q=%7Basa%7Dasa"); } diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java index a0578029ba..f093609427 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.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. @@ -43,7 +43,6 @@ public class UriComponentsTests { @Test public void expandAndEncode() { - UriComponents uri = UriComponentsBuilder .fromPath("/hotel list/{city} specials").queryParam("q", "{value}").build() .expand("Z\u00fcrich", "a+b").encode(); @@ -53,7 +52,6 @@ public class UriComponentsTests { @Test public void encodeAndExpand() { - UriComponents uri = UriComponentsBuilder .fromPath("/hotel list/{city} specials").queryParam("q", "{value}").encode().build() .expand("Z\u00fcrich", "a+b"); @@ -63,16 +61,14 @@ public class UriComponentsTests { @Test public void encodeAndExpandPartially() { - UriComponents uri = UriComponentsBuilder .fromPath("/hotel list/{city} specials").queryParam("q", "{value}").encode() - .uriVariables(Collections.singletonMap("city", "Z\u00fcrich")) - .build(); + .uriVariables(Collections.singletonMap("city", "Z\u00fcrich")).build(); assertThat(uri.expand("a+b").toString()).isEqualTo("/hotel%20list/Z%C3%BCrich%20specials?q=a%2Bb"); } - @Test // SPR-17168 + @Test // SPR-17168 public void encodeAndExpandWithDollarSign() { UriComponents uri = UriComponentsBuilder.fromPath("/path").queryParam("q", "{value}").encode().build(); assertThat(uri.expand("JavaClass$1.class").toString()).isEqualTo("/path?q=JavaClass%241.class"); @@ -80,71 +76,71 @@ public class UriComponentsTests { @Test public void toUriEncoded() throws URISyntaxException { - UriComponents uriComponents = UriComponentsBuilder.fromUriString( - "https://example.com/hotel list/Z\u00fcrich").build(); - assertThat(uriComponents.encode().toUri()).isEqualTo(new URI("https://example.com/hotel%20list/Z%C3%BCrich")); + UriComponents uri = UriComponentsBuilder.fromUriString("https://example.com/hotel list/Z\u00fcrich").build(); + assertThat(uri.encode().toUri()).isEqualTo(new URI("https://example.com/hotel%20list/Z%C3%BCrich")); } @Test public void toUriNotEncoded() throws URISyntaxException { - UriComponents uriComponents = UriComponentsBuilder.fromUriString( - "https://example.com/hotel list/Z\u00fcrich").build(); - assertThat(uriComponents.toUri()).isEqualTo(new URI("https://example.com/hotel%20list/Z\u00fcrich")); + UriComponents uri = UriComponentsBuilder.fromUriString("https://example.com/hotel list/Z\u00fcrich").build(); + assertThat(uri.toUri()).isEqualTo(new URI("https://example.com/hotel%20list/Z\u00fcrich")); } @Test public void toUriAlreadyEncoded() throws URISyntaxException { - UriComponents uriComponents = UriComponentsBuilder.fromUriString( - "https://example.com/hotel%20list/Z%C3%BCrich").build(true); - UriComponents encoded = uriComponents.encode(); - assertThat(encoded.toUri()).isEqualTo(new URI("https://example.com/hotel%20list/Z%C3%BCrich")); + UriComponents uri = UriComponentsBuilder.fromUriString("https://example.com/hotel%20list/Z%C3%BCrich").build(true); + assertThat(uri.encode().toUri()).isEqualTo(new URI("https://example.com/hotel%20list/Z%C3%BCrich")); } @Test public void toUriWithIpv6HostAlreadyEncoded() throws URISyntaxException { - UriComponents uriComponents = UriComponentsBuilder.fromUriString( + UriComponents uri = UriComponentsBuilder.fromUriString( "http://[1abc:2abc:3abc::5ABC:6abc]:8080/hotel%20list/Z%C3%BCrich").build(true); - UriComponents encoded = uriComponents.encode(); - assertThat(encoded.toUri()).isEqualTo(new URI("http://[1abc:2abc:3abc::5ABC:6abc]:8080/hotel%20list/Z%C3%BCrich")); + + assertThat(uri.encode().toUri()).isEqualTo( + new URI("http://[1abc:2abc:3abc::5ABC:6abc]:8080/hotel%20list/Z%C3%BCrich")); } @Test public void expand() { - UriComponents uriComponents = UriComponentsBuilder.fromUriString( - "https://example.com").path("/{foo} {bar}").build(); - uriComponents = uriComponents.expand("1 2", "3 4"); - assertThat(uriComponents.getPath()).isEqualTo("/1 2 3 4"); - assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/1 2 3 4"); + UriComponents uri = UriComponentsBuilder.fromUriString("https://example.com").path("/{foo} {bar}").build(); + uri = uri.expand("1 2", "3 4"); + + assertThat(uri.getPath()).isEqualTo("/1 2 3 4"); + assertThat(uri.toUriString()).isEqualTo("https://example.com/1 2 3 4"); } - @Test // SPR-13311 + @Test // SPR-13311 public void expandWithRegexVar() { String template = "/myurl/{name:[a-z]{1,5}}/show"; - UriComponents uriComponents = UriComponentsBuilder.fromUriString(template).build(); - uriComponents = uriComponents.expand(Collections.singletonMap("name", "test")); - assertThat(uriComponents.getPath()).isEqualTo("/myurl/test/show"); + UriComponents uri = UriComponentsBuilder.fromUriString(template).build(); + uri = uri.expand(Collections.singletonMap("name", "test")); + + assertThat(uri.getPath()).isEqualTo("/myurl/test/show"); } - @Test // SPR-17630 + @Test // SPR-17630 public void uirTemplateExpandWithMismatchedCurlyBraces() { - assertThat(UriComponentsBuilder.fromUriString("/myurl/?q={{{{").encode().build().toUriString()).isEqualTo("/myurl/?q=%7B%7B%7B%7B"); + UriComponents uri = UriComponentsBuilder.fromUriString("/myurl/?q={{{{").encode().build(); + assertThat(uri.toUriString()).isEqualTo("/myurl/?q=%7B%7B%7B%7B"); } - @Test // gh-22447 + @Test // gh-22447 public void expandWithFragmentOrder() { - UriComponents uriComponents = UriComponentsBuilder + UriComponents uri = UriComponentsBuilder .fromUriString("https://{host}/{path}#{fragment}").build() .expand("example.com", "foo", "bar"); - assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/foo#bar"); + assertThat(uri.toUriString()).isEqualTo("https://example.com/foo#bar"); } - @Test // SPR-12123 + @Test // SPR-12123 public void port() { UriComponents uri1 = fromUriString("https://example.com:8080/bar").build(); UriComponents uri2 = fromUriString("https://example.com/bar").port(8080).build(); UriComponents uri3 = fromUriString("https://example.com/bar").port("{port}").build().expand(8080); UriComponents uri4 = fromUriString("https://example.com/bar").port("808{digit}").build().expand(0); + assertThat(uri1.getPort()).isEqualTo(8080); assertThat(uri1.toUriString()).isEqualTo("https://example.com:8080/bar"); assertThat(uri2.getPort()).isEqualTo(8080); @@ -175,20 +171,22 @@ public class UriComponentsTests { @Test public void normalize() { - UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo/../bar").build(); - assertThat(uriComponents.normalize().toString()).isEqualTo("https://example.com/bar"); + UriComponents uri = UriComponentsBuilder.fromUriString("https://example.com/foo/../bar").build(); + assertThat(uri.normalize().toString()).isEqualTo("https://example.com/bar"); } @Test public void serializable() throws Exception { - UriComponents uriComponents = UriComponentsBuilder.fromUriString( + UriComponents uri = UriComponentsBuilder.fromUriString( "https://example.com").path("/{foo}").query("bar={baz}").build(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); - oos.writeObject(uriComponents); + oos.writeObject(uri); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); UriComponents readObject = (UriComponents) ois.readObject(); - assertThat(uriComponents.toString()).isEqualTo(readObject.toString()); + + assertThat(uri.toString()).isEqualTo(readObject.toString()); } @Test @@ -197,6 +195,7 @@ public class UriComponentsTests { UriComponentsBuilder targetBuilder = UriComponentsBuilder.newInstance(); source.copyToUriComponentsBuilder(targetBuilder); UriComponents result = targetBuilder.build().encode(); + assertThat(result.getPath()).isEqualTo("/foo/bar/ba%2Fz"); assertThat(result.getPathSegments()).isEqualTo(Arrays.asList("foo", "bar", "ba%2Fz")); } @@ -207,6 +206,7 @@ public class UriComponentsTests { UriComponents uric1 = UriComponentsBuilder.fromUriString(url).path("/{foo}").query("bar={baz}").build(); UriComponents uric2 = UriComponentsBuilder.fromUriString(url).path("/{foo}").query("bar={baz}").build(); UriComponents uric3 = UriComponentsBuilder.fromUriString(url).path("/{foo}").query("bin={baz}").build(); + assertThat(uric1).isInstanceOf(HierarchicalUriComponents.class); assertThat(uric1).isEqualTo(uric1); assertThat(uric1).isEqualTo(uric2); @@ -219,6 +219,7 @@ public class UriComponentsTests { UriComponents uric1 = UriComponentsBuilder.fromUriString(baseUrl + "/foo/bar").build(); UriComponents uric2 = UriComponentsBuilder.fromUriString(baseUrl + "/foo/bar").build(); UriComponents uric3 = UriComponentsBuilder.fromUriString(baseUrl + "/foo/bin").build(); + assertThat(uric1).isInstanceOf(OpaqueUriComponents.class); assertThat(uric1).isEqualTo(uric1); assertThat(uric1).isEqualTo(uric2); diff --git a/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java b/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java index d1fd6a19e9..6405e5cabf 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.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. @@ -49,9 +49,7 @@ public class UriTemplateTests { assertThat(result).as("Invalid expanded template").isEqualTo(new URI("/hotels/1/bookings/42")); } - // SPR-9712 - - @Test + @Test // SPR-9712 public void expandVarArgsWithArrayValue() throws Exception { UriTemplate template = new UriTemplate("/sum?numbers={numbers}"); URI result = template.expand(new int[] {1, 2, 3}); @@ -61,8 +59,7 @@ public class UriTemplateTests { @Test public void expandVarArgsNotEnoughVariables() throws Exception { UriTemplate template = new UriTemplate("/hotels/{hotel}/bookings/{booking}"); - assertThatIllegalArgumentException().isThrownBy(() -> - template.expand("1")); + assertThatIllegalArgumentException().isThrownBy(() -> template.expand("1")); } @Test @@ -156,7 +153,7 @@ public class UriTemplateTests { assertThat(result).as("Invalid match").isEqualTo(expected); } - @Test // SPR-13627 + @Test // SPR-13627 public void matchCustomRegexWithNestedCurlyBraces() throws Exception { UriTemplate template = new UriTemplate("/site.{domain:co.[a-z]{2}}"); Map result = template.match("/site.co.eu"); @@ -181,8 +178,8 @@ public class UriTemplateTests { assertThat(result).as("Invalid match").isEqualTo(expected); } - @Test // SPR-16169 - public void matchWithMultipleSegmentsAtTheEnd() { + @Test // SPR-16169 + public void matchWithMultipleSegmentsAtTheEnd() throws Exception { UriTemplate template = new UriTemplate("/account/{accountId}"); assertThat(template.matches("/account/15/alias/5")).isFalse(); } @@ -202,21 +199,20 @@ public class UriTemplateTests { assertThat(template.matches("/search?query=foo#bar")).isTrue(); } - @Test // SPR-13705 - public void matchesWithSlashAtTheEnd() { - UriTemplate uriTemplate = new UriTemplate("/test/"); - assertThat(uriTemplate.matches("/test/")).isTrue(); + @Test // SPR-13705 + public void matchesWithSlashAtTheEnd() throws Exception { + assertThat(new UriTemplate("/test/").matches("/test/")).isTrue(); } @Test - public void expandWithDollar() { + public void expandWithDollar() throws Exception { UriTemplate template = new UriTemplate("/{a}"); URI uri = template.expand("$replacement"); assertThat(uri.toString()).isEqualTo("/$replacement"); } @Test - public void expandWithAtSign() { + public void expandWithAtSign() throws Exception { UriTemplate template = new UriTemplate("http://localhost/query={query}"); URI uri = template.expand("foo@bar"); assertThat(uri.toString()).isEqualTo("http://localhost/query=foo@bar"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java index b2e6366a10..0213b52847 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.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. @@ -84,7 +84,7 @@ public class DispatcherServletTests { @BeforeEach - public void setUp() throws ServletException { + public void setup() throws ServletException { MockServletConfig complexConfig = new MockServletConfig(getServletContext(), "complex"); complexConfig.addInitParameter("publishContext", "false"); complexConfig.addInitParameter("class", "notWritable"); @@ -105,6 +105,7 @@ public class DispatcherServletTests { return servletConfig.getServletContext(); } + @Test public void configuredDispatcherServlets() { assertThat(("simple" + FrameworkServlet.DEFAULT_NAMESPACE_SUFFIX).equals(simpleDispatcherServlet.getNamespace())).as("Correct namespace").isTrue();