diff --git a/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java b/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java index 14603c1ff3f35b58efe937c7c4f59aedfe06d120..d929997d3190e95aeac5acf0ac533c4073ac1cdb 100644 --- a/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java +++ b/src/main/java/org/springframework/samples/petclinic/model/BaseEntity.java @@ -15,19 +15,22 @@ */ package org.springframework.samples.petclinic.model; +import java.io.Serializable; + import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.MappedSuperclass; /** - * Simple JavaBean domain object with an id property. Used as a base class for objects needing this property. + * Simple JavaBean domain object with an id property. Used as a base class for objects + * needing this property. * * @author Ken Krebs * @author Juergen Hoeller */ @MappedSuperclass -public class BaseEntity { +public class BaseEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) protected Integer id; diff --git a/src/main/java/org/springframework/samples/petclinic/vet/Vet.java b/src/main/java/org/springframework/samples/petclinic/vet/Vet.java index 3cde3d1bffcf87fd12fabcbb2abb32140c1c363d..43aecc41e20ddbc18c65a5bd65b47b638d55d876 100644 --- a/src/main/java/org/springframework/samples/petclinic/vet/Vet.java +++ b/src/main/java/org/springframework/samples/petclinic/vet/Vet.java @@ -15,7 +15,6 @@ */ package org.springframework.samples.petclinic.vet; -import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -44,7 +43,7 @@ import org.springframework.samples.petclinic.model.Person; */ @Entity @Table(name = "vets") -public class Vet extends Person implements Serializable { +public class Vet extends Person { @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"), inverseJoinColumns = @JoinColumn(name = "specialty_id")) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ddb57e3e39e884442eb3090d419a8ae9893e6eca..fb3e513c36aabfc2307ae08310c4ffb59d74535a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -14,6 +14,7 @@ spring.messages.basename=messages/messages # Actuator / Management management.contextPath=/manage +# Spring Boot 1.5 makes actuator secure by default management.security.enabled=false # Logging diff --git a/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java b/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java new file mode 100644 index 0000000000000000000000000000000000000000..de3a7b9bba61ee18bf7870a582fb96618a95ee00 --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/vet/VetTests.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016-2017 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.samples.petclinic.vet; + +import org.junit.Test; + +import org.springframework.util.SerializationUtils; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Dave Syer + * + */ +public class VetTests { + + @Test + public void testSerialization() { + Vet vet = new Vet(); + vet.setFirstName("Zaphod"); + vet.setLastName("Beeblebrox"); + vet.setId(123); + Vet other = (Vet) SerializationUtils + .deserialize(SerializationUtils.serialize(vet)); + assertThat(other.getFirstName()).isEqualTo(vet.getFirstName()); + assertThat(other.getLastName()).isEqualTo(vet.getLastName()); + assertThat(other.getId()).isEqualTo(vet.getId()); + } + +}