diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..46ad2096 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +language: java +jdk: + - oraclejdk8 +env: + matrix: + - PROFILE=non-existant + - PROFILE=spring40 +# - PROFILE=spring40-next + - PROFILE=spring41 + - PROFILE=spring41-next + - PROFILE=spring42-next +cache: + directories: + - $HOME/.m2 +sudo: false +install: true +script: "mvn clean dependency:list test -P${PROFILE} -Dsort" \ No newline at end of file diff --git a/pom.xml b/pom.xml index c49cf2c1..25697fc0 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ hyper-text driven REST web services. - 2012-2014 + 2012-2015 Pivotal, Inc. @@ -24,7 +24,7 @@ ogierke Oliver Gierke - ogierke(at)gopivotal.com + ogierke(at)pivotal.io Pivotal, Inc. Project lead @@ -70,6 +70,62 @@ true + + + + spring40 + + 4.0.9.RELEASE + + + + + spring40-next + + 4.0.10.BUILD-SNAPSHOT + + + + spring-libs-snapshot + http://repo.spring.io/libs-snapshot + + + + + + spring41 + + 4.1.5.RELEASE + + + + + spring41-next + + 4.1.6.BUILD-SNAPSHOT + + + + spring-libs-snapshot + http://repo.spring.io/libs-snapshot + + + + + + spring42-next + + 4.2.0.BUILD-SNAPSHOT + + + + spring-libs-snapshot + http://repo.spring.io/libs-snapshot + + + + + diff --git a/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java b/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java index 5c31efc4..a51983b9 100644 --- a/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java +++ b/src/test/java/org/springframework/hateoas/config/EnableHypermediaSupportIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2015 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. @@ -18,6 +18,7 @@ package org.springframework.hateoas.config; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -45,8 +46,10 @@ import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessage import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.util.ReflectionUtils; import org.springframework.web.client.RestTemplate; import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite; import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter; import org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; @@ -101,7 +104,7 @@ public class EnableHypermediaSupportIntegrationTest { boolean found = false; - for (HandlerMethodArgumentResolver resolver : adapter.getArgumentResolvers().getResolvers()) { + for (HandlerMethodArgumentResolver resolver : getResolvers(adapter)) { if (resolver instanceof AbstractMessageConverterMethodArgumentResolver) { @@ -161,6 +164,29 @@ public class EnableHypermediaSupportIntegrationTest { Matchers.> hasItems(instanceOf(MappingJackson2HttpMessageConverter.class))); } + /** + * Method to mitigate API changes between Spring 3.2 and 4.0. + * + * @param adapter + * @return + */ + @SuppressWarnings("unchecked") + private static List getResolvers(RequestMappingHandlerAdapter adapter) { + + Method method = ReflectionUtils.findMethod(RequestMappingHandlerAdapter.class, "getArgumentResolvers"); + Object result = ReflectionUtils.invokeMethod(method, adapter); + + if (result instanceof List) { + return (List) result; + } + + if (result instanceof HandlerMethodArgumentResolverComposite) { + return ((HandlerMethodArgumentResolverComposite) result).getResolvers(); + } + + throw new IllegalStateException("Unexpected result when looking up argument resolvers!"); + } + @Configuration @Import(DelegateConfig.class) static class HalConfig { diff --git a/src/test/java/org/springframework/hateoas/core/ControllerEntityLinksFactoryBeanUnitTest.java b/src/test/java/org/springframework/hateoas/core/ControllerEntityLinksFactoryBeanUnitTest.java index 3e243570..9af24f70 100644 --- a/src/test/java/org/springframework/hateoas/core/ControllerEntityLinksFactoryBeanUnitTest.java +++ b/src/test/java/org/springframework/hateoas/core/ControllerEntityLinksFactoryBeanUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2015 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. @@ -23,7 +23,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.context.ApplicationContext; +import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.hateoas.core.ControllerEntityLinksUnitTest.Person; import org.springframework.hateoas.core.ControllerEntityLinksUnitTest.SampleController; @@ -37,8 +37,7 @@ import org.springframework.stereotype.Controller; */ public class ControllerEntityLinksFactoryBeanUnitTest { - @Rule - public ExpectedException exception = ExpectedException.none(); + @Rule public ExpectedException exception = ExpectedException.none(); @Test public void rejectsFactoryBeanIfAnnotationNotSet() throws Exception { @@ -56,7 +55,8 @@ public class ControllerEntityLinksFactoryBeanUnitTest { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerBeanDefinition("controller", new RootBeanDefinition(SampleController.class)); - ApplicationContext context = new GenericApplicationContext(factory); + ConfigurableApplicationContext context = new GenericApplicationContext(factory); + context.refresh(); ControllerEntityLinksFactoryBean builder = new ControllerEntityLinksFactoryBean(); builder.setAnnotation(Controller.class);