From 7bc2b0cb97c601faaa2b1e42e0c61489f8f26ac6 Mon Sep 17 00:00:00 2001 From: Jon Brisbin Date: Mon, 30 Jul 2012 14:23:00 -0500 Subject: [PATCH] Added transactional awareness to the tests to ensure they pass. --- build.gradle | 2 +- .../data/rest/webmvc/RepositoryRestHandlerAdapter.java | 9 --------- .../data/rest/webmvc/spec/BaseSpec.groovy | 2 ++ .../data/rest/webmvc/spec/RelationshipsSpec.groovy | 2 ++ 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 408494e9e..325c55941 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ configure(subprojects) { subproject -> compile.extendsFrom providedCompile } - [compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:serial", "-Xlint:unchecked", "-Xlint:rawtypes"] + [compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:serial", "-Xlint:unchecked"] project.sourceCompatibility = 1.6 project.targetCompatibility = 1.6 diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java index 109a18cfa..77089bf66 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java @@ -3,8 +3,6 @@ package org.springframework.data.rest.webmvc; import java.util.Arrays; import org.springframework.core.Ordered; -import org.springframework.http.MediaType; -import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; @@ -18,13 +16,6 @@ public class RepositoryRestHandlerAdapter extends RequestMappingHandlerAdapter { new ServerHttpRequestMethodArgumentResolver(), new PagingAndSortingMethodArgumentResolver(config) )); - - // Add JSON converter for special Spring Data media type - MappingJacksonHttpMessageConverter json = new MappingJacksonHttpMessageConverter(); - json.setSupportedMediaTypes( - Arrays.asList(MediaType.APPLICATION_JSON, MediaType.valueOf("application/x-spring-data+json")) - ); - getMessageConverters().add(json); } @Override public int getOrder() { diff --git a/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/BaseSpec.groovy b/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/BaseSpec.groovy index 0d7c3ec30..2d9212618 100644 --- a/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/BaseSpec.groovy +++ b/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/BaseSpec.groovy @@ -16,6 +16,7 @@ import org.springframework.http.server.ServletServerHttpRequest import org.springframework.mock.web.MockHttpServletRequest import org.springframework.orm.jpa.EntityManagerHolder import org.springframework.test.context.ContextConfiguration +import org.springframework.transaction.annotation.Transactional import org.springframework.web.util.UriComponentsBuilder import spock.lang.Specification @@ -38,6 +39,7 @@ abstract class BaseSpec extends Specification { UriComponentsBuilder baseUri ObjectMapper mapper = new ObjectMapper() + @Transactional def setup() { baseUri = UriComponentsBuilder.fromUriString("http://localhost:8080/data") diff --git a/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/RelationshipsSpec.groovy b/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/RelationshipsSpec.groovy index 4dcc898d2..c41244038 100644 --- a/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/RelationshipsSpec.groovy +++ b/spring-data-rest-webmvc/src/test/groovy/org/springframework/data/rest/webmvc/spec/RelationshipsSpec.groovy @@ -1,12 +1,14 @@ package org.springframework.data.rest.webmvc.spec import org.springframework.http.HttpStatus +import org.springframework.transaction.annotation.Transactional /** * @author Jon Brisbin */ class RelationshipsSpec extends BaseSpec { + @Transactional def "saves entity relationship"() { given: