From db62390de90c93a78743c97cc2cc9ccd964994a5 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 9 Sep 2016 23:25:31 +0200 Subject: [PATCH] DATACMNS-864 - Tweaks in tests after activation for Spring 5 builds. After the Spring 5 build profile has been activated properly in Spring Data build [0], the test cases for RepositoryPopulators failed as there was only an explicit detection of Spring 4 to point the test to the right resource file. Removed the guard now as all supported versions can now use the same file. Adapt to the stricter contract in Spring 5's MethodParameter in unit test for QuerydsPredicateArgumentResolver. [0] https://github.com/spring-projects/spring-data-build/commit/31df5de90707206e60a385fc95a5d35519969430 --- ...oryPopulatorBeanDefinitionParserIntegrationTests.java | 9 ++------- .../QuerydslPredicateArgumentResolverUnitTests.java | 2 +- .../config/{populators-spring-4.0.xml => populators.xml} | 0 3 files changed, 3 insertions(+), 8 deletions(-) rename src/test/resources/org/springframework/data/repository/config/{populators-spring-4.0.xml => populators.xml} (100%) diff --git a/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java b/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java index dfe2a849f..8323bb831 100644 --- a/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java +++ b/src/test/java/org/springframework/data/repository/config/ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 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. @@ -24,7 +24,6 @@ import org.junit.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.core.SpringVersion; import org.springframework.core.io.ClassPathResource; import org.springframework.data.repository.init.Jackson2ResourceReader; import org.springframework.data.repository.init.ResourceReaderRepositoryPopulator; @@ -98,11 +97,7 @@ public class ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTes } private static ClassPathResource getPopulatorResource() { - - String springVersion = SpringVersion.getVersion(); - String populatorsResourceName = springVersion.startsWith("4") ? "populators-spring-4.0.xml" : "populators.xml"; - - return new ClassPathResource(populatorsResourceName, + return new ClassPathResource("populators.xml", ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTests.class); } } diff --git a/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java b/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java index 6deefbcd2..552541565 100644 --- a/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java +++ b/src/test/java/org/springframework/data/web/querydsl/QuerydslPredicateArgumentResolverUnitTests.java @@ -254,7 +254,7 @@ public class QuerydslPredicateArgumentResolverUnitTests { private static MethodParameter getMethodParameterFor(String methodName, Class... args) throws RuntimeException { try { - return new MethodParameter(Sample.class.getMethod(methodName, args), 0); + return new MethodParameter(Sample.class.getMethod(methodName, args), args.length == 0 ? -1 : 0); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } diff --git a/src/test/resources/org/springframework/data/repository/config/populators-spring-4.0.xml b/src/test/resources/org/springframework/data/repository/config/populators.xml similarity index 100% rename from src/test/resources/org/springframework/data/repository/config/populators-spring-4.0.xml rename to src/test/resources/org/springframework/data/repository/config/populators.xml