Use tabs rather than spaces in tests

Update tests to ensure that tabs are used instead of spaces. Also
consistently apply a new line at the end of each file.

Issue: SPR-16968
This commit is contained in:
Phillip Webb
2018-06-25 09:24:30 -07:00
committed by Juergen Hoeller
parent 1c25cec44f
commit a89e716cc7
209 changed files with 528 additions and 529 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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.
@@ -32,4 +32,4 @@ public class MockRunnable implements Runnable {
return this.executed;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -42,4 +42,4 @@ public class MediaTypeFactoryTests {
assertTrue(MediaTypeFactory.getMediaTypes(null).isEmpty());
}
}
}

View File

@@ -113,4 +113,4 @@ public class MultipartBodyBuilderTests {
assertEquals(PublisherEntity.class, entity.getClass());
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -161,4 +161,4 @@ public class EncoderHttpMessageWriterTests {
return new EncoderHttpMessageWriter<>(this.encoder);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -59,7 +59,7 @@ public class ServerSentEventHttpMessageReaderTests extends AbstractDataBufferAll
public void readServerSentEvents() {
MockServerHttpRequest request = MockServerHttpRequest.post("/").body(
"id:c42\nevent:foo\nretry:123\n:bla\n:bla bla\n:bla bla bla\ndata:bar\n\n" +
"id:c43\nevent:bar\nretry:456\ndata:baz\n\n");
"id:c43\nevent:bar\nretry:456\ndata:baz\n\n");
Flux<ServerSentEvent> events = this.messageReader
.read(ResolvableType.forClassWithGenerics(ServerSentEvent.class, String.class),

View File

@@ -66,7 +66,7 @@ public class Jackson2SmileDecoderTests extends AbstractDataBufferAllocatingTestC
ObjectMapper mapper = Jackson2ObjectMapperBuilder.smile().build();
Pojo pojo = new Pojo("foo", "bar");
byte[] serializedPojo = mapper.writer().writeValueAsBytes(pojo);
Flux<DataBuffer> source = Flux.just(this.bufferFactory.wrap(serializedPojo));
ResolvableType elementType = forClass(Pojo.class);
Flux<Object> flux = decoder.decode(source, elementType, null, emptyMap());

View File

@@ -42,14 +42,14 @@ import static org.springframework.http.MediaType.APPLICATION_XML;
/**
* Unit tests for {@link Jackson2SmileEncoder}.
*
*
* @author Sebastien Deleuze
*/
public class Jackson2SmileEncoderTests extends AbstractDataBufferAllocatingTestCase {
private final static MimeType SMILE_MIME_TYPE = new MimeType("application", "x-jackson-smile");
private final static MimeType STREAM_SMILE_MIME_TYPE = new MimeType("application", "stream+x-jackson-smile");
private final Jackson2SmileEncoder encoder = new Jackson2SmileEncoder();
@@ -106,7 +106,7 @@ public class Jackson2SmileEncoderTests extends AbstractDataBufferAllocatingTestC
.consumeNextWith(dataBuffer -> readPojo(mapper, Pojo.class, dataBuffer))
.verifyComplete();
}
public <T> T readPojo(ObjectMapper mapper, Class<T> valueType, DataBuffer dataBuffer) {
try {
T value = mapper.reader().forType(valueType).readValue(DataBufferTestUtils.dumpBytes(dataBuffer));

View File

@@ -228,4 +228,4 @@ public class Jackson2TokenizerTests extends AbstractDataBufferAllocatingTestCase
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -98,4 +98,4 @@ public class XmlEventDecoderTests extends AbstractDataBufferAllocatingTestCase {
assertEquals(expectedData, event.asCharacters().getData());
}
}
}

View File

@@ -165,4 +165,4 @@ public class ResourceRegionHttpMessageConverterTests {
assertThat(outputMessage.getBodyAsString(StandardCharsets.UTF_8), is("Spring"));
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -59,7 +59,7 @@ public class ProtobufHttpMessageConverterTests {
@Test
public void extensionRegistryInitialized() {
verify(this.registryInitializer, times(1)).initializeExtensionRegistry(any());
verify(this.registryInitializer, times(1)).initializeExtensionRegistry(any());
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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 ProtobufJsonFormatHttpMessageConverterTests {
@Test
public void extensionRegistryInitialized() {
verify(this.registryInitializer, times(1)).initializeExtensionRegistry(any());
verify(this.registryInitializer, times(1)).initializeExtensionRegistry(any());
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -271,4 +271,4 @@ public class Jaxb2CollectionHttpMessageConverterTests {
}
}
}
}

View File

@@ -95,14 +95,14 @@ public class ServletServerHttpRequestTests {
@Test // SPR-13876
public void getUriWithEncoding() throws URISyntaxException {
URI uri = new URI("https://example.com/%E4%B8%AD%E6%96%87" +
URI uri = new URI("https://example.com/%E4%B8%AD%E6%96%87" +
"?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework");
mockRequest.setScheme(uri.getScheme());
mockRequest.setServerName(uri.getHost());
mockRequest.setServerPort(uri.getPort());
mockRequest.setRequestURI(uri.getRawPath());
mockRequest.setQueryString(uri.getRawQuery());
assertEquals(uri, request.getURI());
mockRequest.setScheme(uri.getScheme());
mockRequest.setServerName(uri.getHost());
mockRequest.setServerPort(uri.getPort());
mockRequest.setRequestURI(uri.getRawPath());
mockRequest.setQueryString(uri.getRawQuery());
assertEquals(uri, request.getURI());
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
/**
* Unit tests for {@link AbstractListenerReadPublisher}
*
*
* @author Violeta Georgieva
* @since 5.0
*/

View File

@@ -85,4 +85,4 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -567,4 +567,4 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest {
}
}
}
}

View File

@@ -94,7 +94,7 @@ public class MockAsyncContext implements AsyncContext {
@Override
public void dispatch() {
dispatch(this.request.getRequestURI());
}
}
@Override
public void dispatch(String path) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
@Before
public void setupClient() {
this.template = new RestTemplate(this.clientHttpRequestFactory);
this.template = new RestTemplate(this.clientHttpRequestFactory);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -170,5 +170,5 @@ public class CharacterEncodingFilterTests {
private String filteredName(String prefix) {
return prefix + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX;
}
}

View File

@@ -325,9 +325,9 @@ public class ForwardedHeaderFilterTests {
HttpServletRequest actual = filterAndGetWrappedRequest();
assertEquals("http://localhost/prefix/mvc-showcase", actual.getRequestURL().toString());
}
@Test
public void requestURLNewStringBuffer() throws Exception {
public void requestURLNewStringBuffer() throws Exception {
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix/");
this.request.setRequestURI("/mvc-showcase");

View File

@@ -32,7 +32,7 @@ import static org.junit.Assert.*;
/**
* Tests for {@link HiddenHttpMethodFilter}.
*
*
* @author Arjen Poutsma
* @author Brian Clozel
*/
@@ -79,4 +79,4 @@ public class HiddenHttpMethodFilterTests {
this.filter.doFilter(request, response, filterChain);
}
}
}

View File

@@ -135,4 +135,4 @@ public class ForwardedHeaderFilterTests {
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
@@ -140,4 +140,4 @@ public class MockFacesContext extends FacesContext {
public void responseComplete() {
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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.
@@ -48,4 +48,4 @@ public class MockLifecycle extends Lifecycle {
public void render(FacesContext facesContext) throws FacesException {
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 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.
@@ -103,8 +103,8 @@ public class CookieValueMethodArgumentResolverTests {
public void params(@CookieValue("name") Cookie param1,
@CookieValue(name = "name", defaultValue = "bar") String param2,
String param3) {
@CookieValue(name = "name", defaultValue = "bar") String param2,
String param3) {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 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.
@@ -98,8 +98,7 @@ public class ExpressionValueMethodArgumentResolverTests {
}
public void params(@Value("#{systemProperties.systemProperty}") int param1,
@Value("#{request.contextPath}") String param2,
String notSupported) {
@Value("#{request.contextPath}") String param2, String notSupported) {
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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.
@@ -91,4 +91,4 @@ public class MapMethodProcessorTests {
return null;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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,4 +92,4 @@ public class ModelMethodProcessorTests {
return null;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -135,9 +135,8 @@ public class RequestHeaderMapMethodArgumentResolverTests {
public void params(@RequestHeader Map<?, ?> param1,
@RequestHeader MultiValueMap<?, ?> param2,
@RequestHeader HttpHeaders param3,
Map<?,?> unsupported) {
@RequestHeader MultiValueMap<?, ?> param2, @RequestHeader HttpHeaders param3,
Map<?, ?> unsupported) {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -116,4 +116,4 @@ public class SessionAttributesHandlerTests {
private static class SessionAttributeHandler {
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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.
@@ -87,4 +87,4 @@ public class HandlerMethodArgumentResolverCompositeTests {
private void handle(Integer arg1, String arg2) {
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -128,4 +128,4 @@ public class HandlerMethodReturnValueHandlerCompositeTests {
private static class Promise<T> {}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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,4 +57,4 @@ public class StubArgumentResolver implements HandlerMethodArgumentResolver {
this.resolvedParameters.add(parameter);
return this.stubValue;
}
}
}

View File

@@ -68,4 +68,4 @@ public class DefaultServerWebExchangeTests {
new AcceptHeaderLocaleContextResolver());
}
}
}

View File

@@ -63,7 +63,7 @@ public class DefaultWebSessionManagerTests {
@Mock
private WebSession updateSession;
@Before
public void setUp() throws Exception {

View File

@@ -131,4 +131,4 @@ public class InMemoryWebSessionStoreTests {
assertNotNull(this.store.retrieveSession(session5.getId()).block());
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2018 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.
@@ -26,25 +26,24 @@ import static org.junit.Assert.*;
*/
public class ServletContextPropertyUtilsTests {
@Test
public void resolveAsServletContextInitParameter() {
MockServletContext servletContext = new MockServletContext();
servletContext.setInitParameter("test.prop", "bar");
String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext);
assertEquals("bar", resolved);
}
@Test
public void resolveAsServletContextInitParameter() {
MockServletContext servletContext = new MockServletContext();
servletContext.setInitParameter("test.prop", "bar");
String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext);
assertEquals("bar", resolved);
}
@Test
public void fallbackToSystemProperties() {
MockServletContext servletContext = new MockServletContext();
System.setProperty("test.prop", "bar");
try {
String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext);
assertEquals("bar", resolved);
}
@Test
public void fallbackToSystemProperties() {
MockServletContext servletContext = new MockServletContext();
System.setProperty("test.prop", "bar");
try {
String resolved = ServletContextPropertyUtils.resolvePlaceholders("${test.prop:foo}", servletContext);
assertEquals("bar", resolved);
}
finally {
System.clearProperty("test.prop");
}
}
System.clearProperty("test.prop");
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 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.
@@ -443,4 +443,4 @@ public class UrlPathHelperTests {
assertNull(this.helper.getOriginatingQueryString(request));
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -475,7 +475,7 @@ public class PathPatternParserTests {
}
private PathPattern.PathMatchInfo matchAndExtract(PathPattern pp, String path) {
return pp.matchAndExtract(PathPatternTests.toPathContainer(path));
return pp.matchAndExtract(PathPatternTests.toPathContainer(path));
}
private PathContainer toPSC(String path) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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 @@ public class PathPatternTests {
private void assertNoMatch(PathPattern pp, String path) {
assertFalse(pp.matches(toPathContainer(path)));
}
@Test
public void optionalTrailingSeparators() {
PathPattern pp;
@@ -134,7 +134,7 @@ public class PathPatternTests {
assertMatches(pp,"/resource/");
assertEquals("resource",pp.matchAndExtract(toPathContainer("/resource/")).getUriVariables().get("var"));
assertNoMatch(pp,"/resource//");
// CaptureTheRestPathElement
pp = parse("/{*var}");
assertMatches(pp,"/resource");
@@ -145,14 +145,14 @@ public class PathPatternTests {
assertEquals("/resource//",pp.matchAndExtract(toPathContainer("/resource//")).getUriVariables().get("var"));
assertMatches(pp,"//resource//");
assertEquals("//resource//",pp.matchAndExtract(toPathContainer("//resource//")).getUriVariables().get("var"));
// WildcardTheRestPathElement
pp = parse("/**");
assertMatches(pp,"/resource");
assertMatches(pp,"/resource/");
assertMatches(pp,"/resource//");
assertMatches(pp,"//resource//");
// WildcardPathElement
pp = parse("/*");
assertMatches(pp,"/resource");
@@ -218,7 +218,7 @@ public class PathPatternTests {
assertMatches(pp,"/resource/");
assertEquals("resource",pp.matchAndExtract(toPathContainer("/resource/")).getUriVariables().get("var"));
assertNoMatch(pp,"/resource//");
// CaptureTheRestPathElement
pp = parser.parse("/{*var}");
assertMatches(pp,"/resource");
@@ -229,14 +229,14 @@ public class PathPatternTests {
assertEquals("/resource//",pp.matchAndExtract(toPathContainer("/resource//")).getUriVariables().get("var"));
assertMatches(pp,"//resource//");
assertEquals("//resource//",pp.matchAndExtract(toPathContainer("//resource//")).getUriVariables().get("var"));
// WildcardTheRestPathElement
pp = parser.parse("/**");
assertMatches(pp,"/resource");
assertMatches(pp,"/resource/");
assertMatches(pp,"/resource//");
assertMatches(pp,"//resource//");
// WildcardPathElement
pp = parser.parse("/*");
assertMatches(pp,"/resource");
@@ -296,9 +296,9 @@ public class PathPatternTests {
checkCapture("{var:foo}","foo","var","foo");
checkCapture("{var:f o}","f%20o","var","f o"); // constraint is expressed in non encoded form
checkCapture("{var:f.o}","f%20o","var","f o");
checkCapture("{var:f\\|o}","f%7co","var","f|o");
checkCapture("{var:f\\|o}","f%7co","var","f|o");
}
@Test
public void encodingAndBoundVariablesCaptureTheRestPathElement() {
checkCapture("/{*var}","/f%20o","var","/f o");
@@ -317,7 +317,7 @@ public class PathPatternTests {
checkCapture("/{var1}_ _{var2:f\\|o}","/f%20o_%20_f%7co","var1","f o","var2","f|o");
checkCapture("/{var1:f o}_ _{var2:f\\|o}","/f%20o_%20_f%7co","var1","f o","var2","f|o");
}
@Test
public void pathRemainingCornerCases_spr15336() {
// No match when the literal path element is a longer form of the segment in the pattern
@@ -347,7 +347,7 @@ public class PathPatternTests {
assertNotNull(pri);
assertEquals("i",pri.getPathRemaining().value());
assertEquals("b",pri.getUriVariables().get("bbb"));
pri = parse("/{aaa}_{bbb}/e*f/{x}/g").matchStartOfPath(toPathContainer("/aa_bb/ef/x/g/i"));
assertNotNull(pri);
assertEquals("/i",pri.getPathRemaining().value());
@@ -435,7 +435,7 @@ public class PathPatternTests {
checkMatches("/one/////two/three", "/one/////two/three");
checkCapture("///{foo}///bar", "///one///bar", "foo", "one");
}
@Test
public void wildcards() {
checkMatches("/*/bar", "/foo/bar");
@@ -558,7 +558,7 @@ public class PathPatternTests {
assertEquals("foo",pri.getUriVariables().get("this"));
assertEquals("bar",pri.getUriVariables().get("one"));
assertEquals("goo",pri.getUriVariables().get("here"));
pp = parse("/aaa/{foo}");
pri = getPathRemaining(pp, "/aaa/bbb");
assertEquals("",pri.getPathRemaining().value());
@@ -568,7 +568,7 @@ public class PathPatternTests {
pri = getPathRemaining(pp, "/aaa/bbb");
assertEquals("",pri.getPathRemaining().value());
assertEquals(0,pri.getUriVariables().size());
pp = parse("/*/{foo}/b*");
pri = getPathRemaining(pp, "/foo");
assertNull(pri);
@@ -580,7 +580,7 @@ public class PathPatternTests {
assertEquals("/jkl",pri.getPathRemaining().value());
assertEquals("def",pri.getUriVariables().get("foo"));
}
@Test
public void caseSensitivity() {
PathPatternParser pp = new PathPatternParser();
@@ -663,13 +663,13 @@ public class PathPatternTests {
}
@Test
public void extractPathWithinPattern_spr15259() {
public void extractPathWithinPattern_spr15259() {
checkExtractPathWithinPattern("/**","//","");
checkExtractPathWithinPattern("/**","/","");
checkExtractPathWithinPattern("/**","","");
checkExtractPathWithinPattern("/**","/foobar","foobar");
}
@Test
public void extractPathWithinPattern() throws Exception {
checkExtractPathWithinPattern("/welcome*/", "/welcome/", "welcome");
@@ -715,14 +715,14 @@ public class PathPatternTests {
assertNoMatch(pp,"/");
assertNoMatch(pp,"//");
checkCapture("/{foo}", "/abc", "foo", "abc");
pp = new PathPatternParser().parse("/{foo}/{bar}");
assertMatches(pp,"/abc/def");
assertNoMatch(pp,"/def");
assertNoMatch(pp,"/");
assertNoMatch(pp,"//def");
assertNoMatch(pp,"//");
pp = parse("/{foo}/boo");
assertMatches(pp,"/abc/boo");
assertMatches(pp,"/a/boo");
@@ -738,14 +738,14 @@ public class PathPatternTests {
assertNoMatch(pp,"/1");
assertMatches(pp,"/a");
assertNoMatch(pp,"/");
// Two captures mean we use a RegexPathElement
pp = new PathPatternParser().parse("/{foo}{bar}");
assertMatches(pp,"/abcdef");
assertNoMatch(pp,"/");
assertNoMatch(pp,"//");
checkCapture("/{foo:[a-z][a-z]}{bar:[a-z]}", "/abc", "foo", "ab", "bar", "c");
// Only patterns not capturing variables cannot match against just /
PathPatternParser ppp = new PathPatternParser();
ppp.setMatchOptionalTrailingSeparator(true);
@@ -766,7 +766,7 @@ public class PathPatternTests {
assertEquals("a",vars.get("foo"));
assertEquals("",vars.get("bar"));
}
@Test
public void extractUriTemplateVariables() throws Exception {
assertMatches(parse("{hotel}"),"1");
@@ -959,7 +959,7 @@ public class PathPatternTests {
assertEquals(-1, comparator.compare(parse("*"), parse("*/**")));
assertEquals(1, comparator.compare(parse("*/**"), parse("*")));
}
@Test
public void compare_spr15597() {
PathPatternParser parser = new PathPatternParser();
@@ -967,7 +967,7 @@ public class PathPatternTests {
PathPattern p2 = parser.parse("/{foo}.*");
PathPattern.PathMatchInfo r1 = matchAndExtract(p1, "/file.txt");
PathPattern.PathMatchInfo r2 = matchAndExtract(p2, "/file.txt");
// works fine
assertEquals("file.txt", r1.getUriVariables().get("foo"));
assertEquals("file", r2.getUriVariables().get("foo"));
@@ -1126,7 +1126,7 @@ public class PathPatternTests {
result = matchAndExtract("/abc/{var}","/abc/one");
assertEquals("one",result.getUriVariables().get("var"));
assertNull(result.getMatrixVariables().get("var"));
result = matchAndExtract("","");
assertNotNull(result);
result = matchAndExtract("","/");
@@ -1134,22 +1134,22 @@ public class PathPatternTests {
}
private PathPattern.PathMatchInfo matchAndExtract(String pattern, String path) {
return parse(pattern).matchAndExtract(PathPatternTests.toPathContainer(path));
return parse(pattern).matchAndExtract(PathPatternTests.toPathContainer(path));
}
private PathPattern parse(String path) {
PathPatternParser pp = new PathPatternParser();
pp.setMatchOptionalTrailingSeparator(true);
return pp.parse(path);
}
public static PathContainer toPathContainer(String path) {
if (path == null) {
return null;
}
return PathContainer.parsePath(path);
}
private void checkMatches(String uriTemplate, String path) {
PathPatternParser parser = new PathPatternParser();
parser.setMatchOptionalTrailingSeparator(true);
@@ -1197,11 +1197,11 @@ public class PathPatternTests {
private PathRemainingMatchInfo getPathRemaining(String pattern, String path) {
return parse(pattern).matchStartOfPath(toPathContainer(path));
}
private PathRemainingMatchInfo getPathRemaining(PathPattern pattern, String path) {
return pattern.matchStartOfPath(toPathContainer(path));
}
private PathPattern.PathMatchInfo matchAndExtract(PathPattern p, String path) {
return p.matchAndExtract(toPathContainer(path));
}