Added transactional awareness to the tests to ensure they pass.

This commit is contained in:
Jon Brisbin
2012-07-30 14:23:00 -05:00
parent 2f6650c846
commit 7bc2b0cb97
4 changed files with 5 additions and 10 deletions

View File

@@ -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

View File

@@ -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() {

View File

@@ -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")

View File

@@ -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: