Consistently include leading slash for classpath: resources in the TCF
This commit is contained in:
		
							parent
							
								
									920fbb34c8
								
							
						
					
					
						commit
						dcf160e427
					
				| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright 2002-2020 the original author or authors.
 | 
					 * Copyright 2002-2022 the original author or authors.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 * you may not use this file except in compliance with the License.
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
| 
						 | 
					@ -98,6 +98,8 @@ import org.springframework.util.StringUtils;
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListener {
 | 
					public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static final String SLASH = "/";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static final Log logger = LogFactory.getLog(SqlScriptsTestExecutionListener.class);
 | 
						private static final Log logger = LogFactory.getLog(SqlScriptsTestExecutionListener.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -343,7 +345,7 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		resourcePath += ".sql";
 | 
							resourcePath += ".sql";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
 | 
							String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + SLASH + resourcePath;
 | 
				
			||||||
		ClassPathResource classPathResource = new ClassPathResource(resourcePath);
 | 
							ClassPathResource classPathResource = new ClassPathResource(resourcePath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (classPathResource.exists()) {
 | 
							if (classPathResource.exists()) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,6 +67,8 @@ import org.springframework.util.ResourceUtils;
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public abstract class AbstractContextLoader implements SmartContextLoader {
 | 
					public abstract class AbstractContextLoader implements SmartContextLoader {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static final String SLASH = "/";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static final String[] EMPTY_STRING_ARRAY = new String[0];
 | 
						private static final String[] EMPTY_STRING_ARRAY = new String[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static final Log logger = LogFactory.getLog(AbstractContextLoader.class);
 | 
						private static final Log logger = LogFactory.getLog(AbstractContextLoader.class);
 | 
				
			||||||
| 
						 | 
					@ -252,7 +254,7 @@ public abstract class AbstractContextLoader implements SmartContextLoader {
 | 
				
			||||||
			String resourcePath = ClassUtils.convertClassNameToResourcePath(clazz.getName()) + suffix;
 | 
								String resourcePath = ClassUtils.convertClassNameToResourcePath(clazz.getName()) + suffix;
 | 
				
			||||||
			ClassPathResource classPathResource = new ClassPathResource(resourcePath);
 | 
								ClassPathResource classPathResource = new ClassPathResource(resourcePath);
 | 
				
			||||||
			if (classPathResource.exists()) {
 | 
								if (classPathResource.exists()) {
 | 
				
			||||||
				String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
 | 
									String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + SLASH + resourcePath;
 | 
				
			||||||
				if (logger.isInfoEnabled()) {
 | 
									if (logger.isInfoEnabled()) {
 | 
				
			||||||
					logger.info(String.format("Detected default resource location \"%s\" for test class [%s]",
 | 
										logger.info(String.format("Detected default resource location \"%s\" for test class [%s]",
 | 
				
			||||||
							prefixedResourcePath, clazz.getName()));
 | 
												prefixedResourcePath, clazz.getName()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright 2002-2020 the original author or authors.
 | 
					 * Copyright 2002-2022 the original author or authors.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 * you may not use this file except in compliance with the License.
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
| 
						 | 
					@ -50,6 +50,8 @@ import org.springframework.util.StringUtils;
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class TestPropertySourceAttributes {
 | 
					class TestPropertySourceAttributes {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static final String SLASH = "/";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static final Log logger = LogFactory.getLog(TestPropertySourceAttributes.class);
 | 
						private static final Log logger = LogFactory.getLog(TestPropertySourceAttributes.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -156,7 +158,7 @@ class TestPropertySourceAttributes {
 | 
				
			||||||
			logger.error(msg);
 | 
								logger.error(msg);
 | 
				
			||||||
			throw new IllegalStateException(msg);
 | 
								throw new IllegalStateException(msg);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + resourcePath;
 | 
							String prefixedResourcePath = ResourceUtils.CLASSPATH_URL_PREFIX + SLASH + resourcePath;
 | 
				
			||||||
		if (logger.isInfoEnabled()) {
 | 
							if (logger.isInfoEnabled()) {
 | 
				
			||||||
			logger.info(String.format("Detected default properties file \"%s\" for test class [%s]",
 | 
								logger.info(String.format("Detected default properties file \"%s\" for test class [%s]",
 | 
				
			||||||
					prefixedResourcePath, testClass.getName()));
 | 
										prefixedResourcePath, testClass.getName()));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,7 +73,7 @@ class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigurationUt
 | 
				
			||||||
		assertMergedConfig(
 | 
							assertMergedConfig(
 | 
				
			||||||
			mergedConfig,
 | 
								mergedConfig,
 | 
				
			||||||
			testClass,
 | 
								testClass,
 | 
				
			||||||
			array("classpath:org/springframework/test/context/support/AbstractContextConfigurationUtilsTests$BareAnnotations-context.xml"),
 | 
								array("classpath:/org/springframework/test/context/support/AbstractContextConfigurationUtilsTests$BareAnnotations-context.xml"),
 | 
				
			||||||
			EMPTY_CLASS_ARRAY, DelegatingSmartContextLoader.class);
 | 
								EMPTY_CLASS_ARRAY, DelegatingSmartContextLoader.class);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +78,7 @@ class GenericXmlContextLoaderResourceLocationsTests {
 | 
				
			||||||
			args(ClasspathNonExistentDefaultLocationsTestCase.class, array()),
 | 
								args(ClasspathNonExistentDefaultLocationsTestCase.class, array()),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			args(ClasspathExistentDefaultLocationsTestCase.class, array(
 | 
								args(ClasspathExistentDefaultLocationsTestCase.class, array(
 | 
				
			||||||
				"classpath:org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$ClasspathExistentDefaultLocationsTestCase-context.xml")),
 | 
									"classpath:/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests$ClasspathExistentDefaultLocationsTestCase-context.xml")),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			args(ImplicitClasspathLocationsTestCase.class,
 | 
								args(ImplicitClasspathLocationsTestCase.class,
 | 
				
			||||||
				array("classpath:/org/springframework/test/context/support/context1.xml",
 | 
									array("classpath:/org/springframework/test/context/support/context1.xml",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue