#297 - Upgraded to Boot 2.0 and Spring Data Kay.

Bumped version number to 2.0. Upgraded to Spring Boot 2.0.

Stuff disabled in the meantime:

- Cassandra: needs API adaptions in configuration
- JPA > Security: test fails with weird Hibernate error
- Redis > Reactive: API updates needed
- Solr: configration updates necessary

adjust versions

Updated elastic search to the new version.

Fixed the reactor version to Bismuth-BUILD-SNAPSHOT. This probably should be undone when boot references the proper bom.
This commit is contained in:
Oliver Gierke
2017-05-04 19:28:40 +02:00
parent 90546357c7
commit 4164bc4607
98 changed files with 319 additions and 368 deletions

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<name>Spring Data REST - Examples</name>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<properties>

View File

@@ -38,9 +38,9 @@ public interface ItemRepository extends CrudRepository<Item, Long> {
/*
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#delete(java.io.Serializable)
* @see org.springframework.data.repository.CrudRepository#deleteById(java.lang.Object)
*/
@Override
@PreAuthorize("hasRole('ROLE_ADMIN')")
void delete(Long aLong);
void deleteById(Long aLong);
}

View File

@@ -62,7 +62,7 @@ public class MethodLevelSecurityTests {
}
try {
itemRepository.delete(1L);
itemRepository.deleteById(1L);
fail("Expected a security error");
} catch (AuthenticationCredentialsNotFoundException e) {
// expected
@@ -83,7 +83,7 @@ public class MethodLevelSecurityTests {
// expected
}
try {
itemRepository.delete(1L);
itemRepository.deleteById(1L);
fail("Expected a security error");
} catch (AccessDeniedException e) {
// expected
@@ -96,7 +96,9 @@ public class MethodLevelSecurityTests {
SecurityUtils.runAs("system", "system", "ROLE_USER", "ROLE_ADMIN");
itemRepository.findAll();
itemRepository.save(new Item("MacBook Pro"));
itemRepository.delete(1L);
Item item = itemRepository.save(new Item("MacBook Pro"));
itemRepository.deleteById(item.getId());
}
}

View File

@@ -18,7 +18,6 @@ package example.springdata.rest.security;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
@@ -70,8 +69,7 @@ public class UrlLevelSecurityTests {
mvc.perform(get("/").//
accept(MediaTypes.HAL_JSON)).//
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
andExpect(status().isOk()).//
andDo(print());
andExpect(status().isOk());
}
@Test
@@ -80,8 +78,7 @@ public class UrlLevelSecurityTests {
mvc.perform(post("/employees").//
content(PAYLOAD).//
accept(MediaTypes.HAL_JSON)).//
andExpect(status().isUnauthorized()).//
andDo(print());
andExpect(status().isUnauthorized());
}
@Test
@@ -94,13 +91,11 @@ public class UrlLevelSecurityTests {
mvc.perform(get("/employees").//
headers(headers)).//
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
andExpect(status().isOk()).//
andDo(print());
andExpect(status().isOk());
mvc.perform(post("/employees").//
headers(headers)).//
andExpect(status().isForbidden()).//
andDo(print());
andExpect(status().isForbidden());
}
@Test
@@ -113,8 +108,7 @@ public class UrlLevelSecurityTests {
mvc.perform(get("/employees").//
headers(headers)).//
andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON)).//
andExpect(status().isOk()).//
andDo(print());
andExpect(status().isOk());
headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
@@ -124,7 +118,6 @@ public class UrlLevelSecurityTests {
headers(headers))
.//
andExpect(status().isCreated()).//
andDo(print()).//
andReturn().getResponse().getHeader(HttpHeaders.LOCATION);
ObjectMapper mapper = new ObjectMapper();

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<dependencies>
@@ -28,7 +28,6 @@
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-mongodb</artifactId>
<version>${querydsl.version}</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
@@ -120,7 +119,7 @@
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/annotations</outputDirectory>
<outputDirectory>target/generated-sources/queries</outputDirectory>
<processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
<logOnlyOnError>true</logOnlyOnError>
</configuration>

View File

@@ -51,7 +51,7 @@ public class StoreInitializer {
List<Store> stores = readStores();
log.info("Importing {} stores into MongoDB…", stores.size());
repository.save(stores);
repository.saveAll(stores);
log.info("Successfully imported {} stores.", repository.count());
}

View File

@@ -21,7 +21,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RestResource;
@@ -34,7 +34,7 @@ import com.querydsl.core.types.dsl.StringPath;
*
* @author Oliver Gierke
*/
public interface StoreRepository extends PagingAndSortingRepository<Store, UUID>, QueryDslPredicateExecutor<Store> {
public interface StoreRepository extends PagingAndSortingRepository<Store, UUID>, QuerydslPredicateExecutor<Store> {
@RestResource(rel = "by-location")
Page<Store> findByAddressLocationNear(Point location, Distance distance, Pageable pageable);

View File

@@ -28,9 +28,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
<dependencies>

View File

@@ -18,9 +18,8 @@ package example.springdata.rest.uris;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import java.io.Serializable;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.core.support.EntityLookup;
import org.springframework.data.rest.core.support.EntityLookupSupport;
@@ -33,7 +32,7 @@ import org.springframework.data.rest.core.support.EntityLookupSupport;
* @author Oliver Gierke
* @see SpringDataRestCustomization#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration)
*/
@RequiredArgsConstructor(onConstructor = @__(@Autowired) )
@RequiredArgsConstructor
public class UserEntityLookup extends EntityLookupSupport<User> {
private final @NonNull UserRepository repository;
@@ -43,16 +42,16 @@ public class UserEntityLookup extends EntityLookupSupport<User> {
* @see org.springframework.data.rest.core.support.EntityLookup#getId(java.lang.Object)
*/
@Override
public Serializable getResourceIdentifier(User entity) {
public Object getResourceIdentifier(User entity) {
return entity.getUsername();
}
/*
* (non-Javadoc)
* @see org.springframework.data.rest.core.support.EntityLookup#lookupEntity(java.io.Serializable)
* @see org.springframework.data.rest.core.support.EntityLookup#lookupEntity(java.lang.Object)
*/
@Override
public Object lookupEntity(Serializable id) {
public Optional<User> lookupEntity(Object id) {
return repository.findByUsername(id.toString());
}
}