From 8b75f3da06e5f88427864e1a0254c1c5f843e350 Mon Sep 17 00:00:00 2001 From: sameira Date: Fri, 25 Dec 2015 23:37:49 +0530 Subject: [PATCH 1/9] Adding Spring Data Redis Examples --- spring-data-radis/pom.xml | 78 ++++++++++++++++++ .../spring/data/radis/model/Student.java | 64 ++++++++++++++ .../data/radis/repo/StudentRepository.java | 17 ++++ .../radis/repo/StudentRepositoryImpl.java | 37 +++++++++ .../src/main/resources/logback.xml | 20 +++++ .../src/main/resources/spring-config.xml | 19 +++++ spring-data-radis/src/main/resources/test.png | Bin 0 -> 855 bytes .../radis/repo/StudentRepositoryTest.java | 58 +++++++++++++ 8 files changed, 293 insertions(+) create mode 100644 spring-data-radis/pom.xml create mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java create mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java create mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java create mode 100644 spring-data-radis/src/main/resources/logback.xml create mode 100644 spring-data-radis/src/main/resources/spring-config.xml create mode 100644 spring-data-radis/src/main/resources/test.png create mode 100644 spring-data-radis/src/test/java/org/baeldung/spring/data/radis/repo/StudentRepositoryTest.java diff --git a/spring-data-radis/pom.xml b/spring-data-radis/pom.xml new file mode 100644 index 0000000000..4d3b467d7b --- /dev/null +++ b/spring-data-radis/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + org.baeldung + sprint-data-radis + 0.0.1-SNAPSHOT + jar + + sprint-data-radis + + + UTF-8 + 4.2.2.RELEASE + 1.6.2.RELEASE + 0.8.0 + + + + + org.springframework.data + spring-data-redis + ${spring-data-redis} + + + + cglib + cglib-nodep + 2.2 + + + + log4j + log4j + 1.2.16 + + + + redis.clients + jedis + 2.5.1 + jar + + + + org.springframework + spring-core + ${spring.version} + + + + org.springframework + spring-context + ${spring.version} + + + + junit + junit + 4.12 + test + + + + org.springframework + spring-test + ${spring.version} + test + + + + com.lordofthejars + nosqlunit-redis + ${nosqlunit.version} + + + + diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java new file mode 100644 index 0000000000..4b8a90943c --- /dev/null +++ b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java @@ -0,0 +1,64 @@ +package org.baeldung.spring.data.radis.model; + + +import java.io.Serializable; + +public class Student implements Serializable { + + private static final long serialVersionUID = -1907106213598514113L; + + public enum Gender{Male, Female} + private String id; + private String name; + private Gender gender; + private int grade; + + public Student(String id, String name, Gender gender, int grade) { + this.id = id; + this.name = name; + this.gender = gender; + this.grade = grade; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Gender getGender() { + return gender; + } + + public void setGender(Gender gender) { + this.gender = gender; + } + + public int getGrade() { + return grade; + } + + public void setGrade(int grade) { + this.grade = grade; + } + + @Override + public String toString() { + return "Student{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", gender=" + gender + + ", grade=" + grade + + '}'; + } +} \ No newline at end of file diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java new file mode 100644 index 0000000000..bc1201478c --- /dev/null +++ b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.data.radis.repo; + +import org.baeldung.spring.data.radis.model.Student; + +import java.util.Map; + +public interface StudentRepository { + void saveStudent(Student person); + + void updateStudent(Student student); + + Student findStudent(String id); + + Map findAllStudents(); + + void deleteStudent(String id); +} diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java new file mode 100644 index 0000000000..3033020c24 --- /dev/null +++ b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java @@ -0,0 +1,37 @@ +package org.baeldung.spring.data.radis.repo; + +import org.baeldung.spring.data.radis.model.Student; +import org.springframework.data.redis.core.RedisTemplate; + +import java.util.Map; + +public class StudentRepositoryImpl implements StudentRepository { + + private static final String KEY = "Student"; + + private RedisTemplate redisTemplate; + + public void setRedisTemplate(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + public void saveStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public void updateStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public Student findStudent(final String id) { + return (Student)this.redisTemplate.opsForHash().get(KEY, id); + } + + public Map findAllStudents() { + return this.redisTemplate.opsForHash().entries(KEY); + } + + public void deleteStudent(final String id) { + this.redisTemplate.opsForHash().delete(KEY,id); + } +} diff --git a/spring-data-radis/src/main/resources/logback.xml b/spring-data-radis/src/main/resources/logback.xml new file mode 100644 index 0000000000..215eeede64 --- /dev/null +++ b/spring-data-radis/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/spring-config.xml b/spring-data-radis/src/main/resources/spring-config.xml new file mode 100644 index 0000000000..950cd9a6fd --- /dev/null +++ b/spring-data-radis/src/main/resources/spring-config.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/test.png b/spring-data-radis/src/main/resources/test.png new file mode 100644 index 0000000000000000000000000000000000000000..c3b5e8027635ff4f0a0b10c0a9a6aa7a014e6086 GIT binary patch literal 855 zcmex=6kE^cmKJ|O{KK0!WiZUHd? zL17V5QBfX#aS1UI2_X?t5k_Vf7B*H^PBu0!em)*P5fKr7L0%pn0bT(feo-D?UVdI4 zpg0dNAHM*Q$HT+J$HNcg@q#%Zh5rvQ2y!sUFvu`73NkPWGBOJ?{y)MX0rV0OKpYGv zIoQ})S%5M+0t`%y%uFn-%&bsZMkb)c1=$oC*g1rh3>^~-jRG5mMVuBM1ge%|WME=O zF^8Fjk%^U!0Vt;gv=3+$3p2tNMkYaKCBqLwfr*X6ijMzpG4L=04G?4&WUyx___R78 z`bEZ3n*%y$c1p?=OzsY{vOIcDRID^@mH5k5n_VmCLN*tlQtc~BqmaI3acZm^A1dHBrChNRU-KfIG`3a9F1Z+JCT zaBkFRt*1+W!zihZ}s%F&cxn?h~EIRD%9;ni-#KyOjOZ3l7 z_6Ks(XSKVYPbdvPm!tpIJj%Ot(S2`WC0AaXj1Ds{Yc~e@JYj`ND^=I^G)#%-Q1qX7 z;Q8}@p=SNS>z3K2PrXivv`$ retrievedStudent = studentRepository.findAllStudents(); + assertEquals(retrievedStudent.size(), 2); + } + + @Test + public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { + final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); + studentRepository.saveStudent(student); + studentRepository.deleteStudent(student.getId()); + final Student retrievedStudent = studentRepository.findStudent(student.getId()); + assertNull(retrievedStudent); + } +} \ No newline at end of file From 31b5d9ff16dc3322a7f6a9f11ef7206d014fe2e1 Mon Sep 17 00:00:00 2001 From: sameira Date: Fri, 25 Dec 2015 23:54:54 +0530 Subject: [PATCH 2/9] Adding Spring Data Redis Examples --- spring-data-redis/pom.xml | 78 ++++++++++++++++++ .../spring/data/redis/model/Student.java | 64 ++++++++++++++ .../data/redis/repo/StudentRepository.java | 17 ++++ .../redis/repo/StudentRepositoryImpl.java | 37 +++++++++ .../src/main/resources/logback.xml | 20 +++++ .../src/main/resources/spring-config.xml | 19 +++++ spring-data-redis/src/main/resources/test.png | Bin 0 -> 855 bytes .../redis/repo/StudentRepositoryTest.java | 58 +++++++++++++ 8 files changed, 293 insertions(+) create mode 100644 spring-data-redis/pom.xml create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java create mode 100644 spring-data-redis/src/main/resources/logback.xml create mode 100644 spring-data-redis/src/main/resources/spring-config.xml create mode 100644 spring-data-redis/src/main/resources/test.png create mode 100644 spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java diff --git a/spring-data-redis/pom.xml b/spring-data-redis/pom.xml new file mode 100644 index 0000000000..57bc76d5ff --- /dev/null +++ b/spring-data-redis/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + org.baeldung + sprint-data-redis + 0.0.1-SNAPSHOT + jar + + sprint-data-redis + + + UTF-8 + 4.2.2.RELEASE + 1.6.2.RELEASE + 0.8.0 + + + + + org.springframework.data + spring-data-redis + ${spring-data-redis} + + + + cglib + cglib-nodep + 2.2 + + + + log4j + log4j + 1.2.16 + + + + redis.clients + jedis + 2.5.1 + jar + + + + org.springframework + spring-core + ${spring.version} + + + + org.springframework + spring-context + ${spring.version} + + + + junit + junit + 4.12 + test + + + + org.springframework + spring-test + ${spring.version} + test + + + + com.lordofthejars + nosqlunit-redis + ${nosqlunit.version} + + + + diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java new file mode 100644 index 0000000000..4302edfab2 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java @@ -0,0 +1,64 @@ +package org.baeldung.spring.data.redis.model; + + +import java.io.Serializable; + +public class Student implements Serializable { + + private static final long serialVersionUID = -1907106213598514113L; + + public enum Gender{Male, Female} + private String id; + private String name; + private Gender gender; + private int grade; + + public Student(String id, String name, Gender gender, int grade) { + this.id = id; + this.name = name; + this.gender = gender; + this.grade = grade; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Gender getGender() { + return gender; + } + + public void setGender(Gender gender) { + this.gender = gender; + } + + public int getGrade() { + return grade; + } + + public void setGrade(int grade) { + this.grade = grade; + } + + @Override + public String toString() { + return "Student{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", gender=" + gender + + ", grade=" + grade + + '}'; + } +} \ No newline at end of file diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java new file mode 100644 index 0000000000..ae7e63c888 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java @@ -0,0 +1,17 @@ +package org.baeldung.spring.data.redis.repo; + +import org.baeldung.spring.data.redis.model.Student; + +import java.util.Map; + +public interface StudentRepository { + void saveStudent(Student person); + + void updateStudent(Student student); + + Student findStudent(String id); + + Map findAllStudents(); + + void deleteStudent(String id); +} diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java new file mode 100644 index 0000000000..6be8d7fd20 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java @@ -0,0 +1,37 @@ +package org.baeldung.spring.data.redis.repo; + +import org.baeldung.spring.data.redis.model.Student; +import org.springframework.data.redis.core.RedisTemplate; + +import java.util.Map; + +public class StudentRepositoryImpl implements StudentRepository { + + private static final String KEY = "Student"; + + private RedisTemplate redisTemplate; + + public void setRedisTemplate(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + public void saveStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public void updateStudent(final Student student) { + this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + } + + public Student findStudent(final String id) { + return (Student)this.redisTemplate.opsForHash().get(KEY, id); + } + + public Map findAllStudents() { + return this.redisTemplate.opsForHash().entries(KEY); + } + + public void deleteStudent(final String id) { + this.redisTemplate.opsForHash().delete(KEY,id); + } +} diff --git a/spring-data-redis/src/main/resources/logback.xml b/spring-data-redis/src/main/resources/logback.xml new file mode 100644 index 0000000000..215eeede64 --- /dev/null +++ b/spring-data-redis/src/main/resources/logback.xml @@ -0,0 +1,20 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-redis/src/main/resources/spring-config.xml b/spring-data-redis/src/main/resources/spring-config.xml new file mode 100644 index 0000000000..4ca240d3f1 --- /dev/null +++ b/spring-data-redis/src/main/resources/spring-config.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-data-redis/src/main/resources/test.png b/spring-data-redis/src/main/resources/test.png new file mode 100644 index 0000000000000000000000000000000000000000..c3b5e8027635ff4f0a0b10c0a9a6aa7a014e6086 GIT binary patch literal 855 zcmex=6kE^cmKJ|O{KK0!WiZUHd? zL17V5QBfX#aS1UI2_X?t5k_Vf7B*H^PBu0!em)*P5fKr7L0%pn0bT(feo-D?UVdI4 zpg0dNAHM*Q$HT+J$HNcg@q#%Zh5rvQ2y!sUFvu`73NkPWGBOJ?{y)MX0rV0OKpYGv zIoQ})S%5M+0t`%y%uFn-%&bsZMkb)c1=$oC*g1rh3>^~-jRG5mMVuBM1ge%|WME=O zF^8Fjk%^U!0Vt;gv=3+$3p2tNMkYaKCBqLwfr*X6ijMzpG4L=04G?4&WUyx___R78 z`bEZ3n*%y$c1p?=OzsY{vOIcDRID^@mH5k5n_VmCLN*tlQtc~BqmaI3acZm^A1dHBrChNRU-KfIG`3a9F1Z+JCT zaBkFRt*1+W!zihZ}s%F&cxn?h~EIRD%9;ni-#KyOjOZ3l7 z_6Ks(XSKVYPbdvPm!tpIJj%Ot(S2`WC0AaXj1Ds{Yc~e@JYj`ND^=I^G)#%-Q1qX7 z;Q8}@p=SNS>z3K2PrXivv`$ retrievedStudent = studentRepository.findAllStudents(); + assertEquals(retrievedStudent.size(), 2); + } + + @Test + public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { + final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); + studentRepository.saveStudent(student); + studentRepository.deleteStudent(student.getId()); + final Student retrievedStudent = studentRepository.findStudent(student.getId()); + assertNull(retrievedStudent); + } +} \ No newline at end of file From fa8427aa9d3ad82c3d2a00b7d73ec47315599ad7 Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:01:31 +0530 Subject: [PATCH 3/9] Adding ReadMe File --- spring-data-redis/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 spring-data-redis/README.md diff --git a/spring-data-redis/README.md b/spring-data-redis/README.md new file mode 100644 index 0000000000..716d52a563 --- /dev/null +++ b/spring-data-redis/README.md @@ -0,0 +1,15 @@ +## Spring Data Cassandra + +### Relevant Articles: +- [Introduction to Spring Data Redis] + +### Build the Project with Tests Running +``` +mvn clean install +``` + +### Run Tests Directly +``` +mvn test +``` + From be8feed4917b6d6bb7a4a97df116861e8dfc3a39 Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:02:28 +0530 Subject: [PATCH 4/9] Updated README file --- spring-data-redis/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-data-redis/README.md b/spring-data-redis/README.md index 716d52a563..b9b2e5d93d 100644 --- a/spring-data-redis/README.md +++ b/spring-data-redis/README.md @@ -1,4 +1,4 @@ -## Spring Data Cassandra +## Spring Data Redis ### Relevant Articles: - [Introduction to Spring Data Redis] From 948a7279fcc2fe29c278def0c3fc4e0a5bc7d322 Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:38:18 +0530 Subject: [PATCH 5/9] Adding eclipse formatting --- spring-data-redis/pom.xml | 2 -- .../baeldung/spring/data/redis/model/Student.java | 13 +++++-------- .../spring/data/redis/repo/StudentRepository.java | 3 ++- .../data/redis/repo/StudentRepositoryImpl.java | 4 ++-- .../data/redis/repo/StudentRepositoryTest.java | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/spring-data-redis/pom.xml b/spring-data-redis/pom.xml index 57bc76d5ff..98da69934c 100644 --- a/spring-data-redis/pom.xml +++ b/spring-data-redis/pom.xml @@ -7,8 +7,6 @@ 0.0.1-SNAPSHOT jar - sprint-data-redis - UTF-8 4.2.2.RELEASE diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java index 4302edfab2..a37ecb8dd9 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java @@ -1,13 +1,15 @@ package org.baeldung.spring.data.redis.model; - import java.io.Serializable; public class Student implements Serializable { private static final long serialVersionUID = -1907106213598514113L; - public enum Gender{Male, Female} + public enum Gender { + Male, Female + } + private String id; private String name; private Gender gender; @@ -54,11 +56,6 @@ public class Student implements Serializable { @Override public String toString() { - return "Student{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", gender=" + gender + - ", grade=" + grade + - '}'; + return "Student{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", gender=" + gender + ", grade=" + grade + '}'; } } \ No newline at end of file diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java index ae7e63c888..59b3a4c5e8 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java @@ -5,8 +5,9 @@ import org.baeldung.spring.data.redis.model.Student; import java.util.Map; public interface StudentRepository { + void saveStudent(Student person); - + void updateStudent(Student student); Student findStudent(String id); diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java index 6be8d7fd20..d964b830d2 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java @@ -24,7 +24,7 @@ public class StudentRepositoryImpl implements StudentRepository { } public Student findStudent(final String id) { - return (Student)this.redisTemplate.opsForHash().get(KEY, id); + return (Student) this.redisTemplate.opsForHash().get(KEY, id); } public Map findAllStudents() { @@ -32,6 +32,6 @@ public class StudentRepositoryImpl implements StudentRepository { } public void deleteStudent(final String id) { - this.redisTemplate.opsForHash().delete(KEY,id); + this.redisTemplate.opsForHash().delete(KEY, id); } } diff --git a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java index 19e59f69d1..a68d93c173 100644 --- a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java +++ b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:/spring-config.xml"}) +@ContextConfiguration(locations = { "classpath:/spring-config.xml" }) public class StudentRepositoryTest { @Autowired From 97ca1980acc48dbe9051b95a338b089d019b124e Mon Sep 17 00:00:00 2001 From: sameira Date: Sat, 26 Dec 2015 00:47:00 +0530 Subject: [PATCH 6/9] Removing invalid folder --- spring-data-radis/pom.xml | 78 ------------------ .../spring/data/radis/model/Student.java | 64 -------------- .../data/radis/repo/StudentRepository.java | 17 ---- .../radis/repo/StudentRepositoryImpl.java | 37 --------- .../src/main/resources/logback.xml | 20 ----- .../src/main/resources/spring-config.xml | 19 ----- spring-data-radis/src/main/resources/test.png | Bin 855 -> 0 bytes .../radis/repo/StudentRepositoryTest.java | 58 ------------- 8 files changed, 293 deletions(-) delete mode 100644 spring-data-radis/pom.xml delete mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java delete mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java delete mode 100644 spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java delete mode 100644 spring-data-radis/src/main/resources/logback.xml delete mode 100644 spring-data-radis/src/main/resources/spring-config.xml delete mode 100644 spring-data-radis/src/main/resources/test.png delete mode 100644 spring-data-radis/src/test/java/org/baeldung/spring/data/radis/repo/StudentRepositoryTest.java diff --git a/spring-data-radis/pom.xml b/spring-data-radis/pom.xml deleted file mode 100644 index 4d3b467d7b..0000000000 --- a/spring-data-radis/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - 4.0.0 - - org.baeldung - sprint-data-radis - 0.0.1-SNAPSHOT - jar - - sprint-data-radis - - - UTF-8 - 4.2.2.RELEASE - 1.6.2.RELEASE - 0.8.0 - - - - - org.springframework.data - spring-data-redis - ${spring-data-redis} - - - - cglib - cglib-nodep - 2.2 - - - - log4j - log4j - 1.2.16 - - - - redis.clients - jedis - 2.5.1 - jar - - - - org.springframework - spring-core - ${spring.version} - - - - org.springframework - spring-context - ${spring.version} - - - - junit - junit - 4.12 - test - - - - org.springframework - spring-test - ${spring.version} - test - - - - com.lordofthejars - nosqlunit-redis - ${nosqlunit.version} - - - - diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java deleted file mode 100644 index 4b8a90943c..0000000000 --- a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/model/Student.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.baeldung.spring.data.radis.model; - - -import java.io.Serializable; - -public class Student implements Serializable { - - private static final long serialVersionUID = -1907106213598514113L; - - public enum Gender{Male, Female} - private String id; - private String name; - private Gender gender; - private int grade; - - public Student(String id, String name, Gender gender, int grade) { - this.id = id; - this.name = name; - this.gender = gender; - this.grade = grade; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Gender getGender() { - return gender; - } - - public void setGender(Gender gender) { - this.gender = gender; - } - - public int getGrade() { - return grade; - } - - public void setGrade(int grade) { - this.grade = grade; - } - - @Override - public String toString() { - return "Student{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - ", gender=" + gender + - ", grade=" + grade + - '}'; - } -} \ No newline at end of file diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java deleted file mode 100644 index bc1201478c..0000000000 --- a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.spring.data.radis.repo; - -import org.baeldung.spring.data.radis.model.Student; - -import java.util.Map; - -public interface StudentRepository { - void saveStudent(Student person); - - void updateStudent(Student student); - - Student findStudent(String id); - - Map findAllStudents(); - - void deleteStudent(String id); -} diff --git a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java b/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java deleted file mode 100644 index 3033020c24..0000000000 --- a/spring-data-radis/src/main/java/org/baeldung/spring/data/radis/repo/StudentRepositoryImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.baeldung.spring.data.radis.repo; - -import org.baeldung.spring.data.radis.model.Student; -import org.springframework.data.redis.core.RedisTemplate; - -import java.util.Map; - -public class StudentRepositoryImpl implements StudentRepository { - - private static final String KEY = "Student"; - - private RedisTemplate redisTemplate; - - public void setRedisTemplate(RedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - } - - public void saveStudent(final Student student) { - this.redisTemplate.opsForHash().put(KEY, student.getId(), student); - } - - public void updateStudent(final Student student) { - this.redisTemplate.opsForHash().put(KEY, student.getId(), student); - } - - public Student findStudent(final String id) { - return (Student)this.redisTemplate.opsForHash().get(KEY, id); - } - - public Map findAllStudents() { - return this.redisTemplate.opsForHash().entries(KEY); - } - - public void deleteStudent(final String id) { - this.redisTemplate.opsForHash().delete(KEY,id); - } -} diff --git a/spring-data-radis/src/main/resources/logback.xml b/spring-data-radis/src/main/resources/logback.xml deleted file mode 100644 index 215eeede64..0000000000 --- a/spring-data-radis/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/spring-config.xml b/spring-data-radis/src/main/resources/spring-config.xml deleted file mode 100644 index 950cd9a6fd..0000000000 --- a/spring-data-radis/src/main/resources/spring-config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-data-radis/src/main/resources/test.png b/spring-data-radis/src/main/resources/test.png deleted file mode 100644 index c3b5e8027635ff4f0a0b10c0a9a6aa7a014e6086..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 855 zcmex=6kE^cmKJ|O{KK0!WiZUHd? zL17V5QBfX#aS1UI2_X?t5k_Vf7B*H^PBu0!em)*P5fKr7L0%pn0bT(feo-D?UVdI4 zpg0dNAHM*Q$HT+J$HNcg@q#%Zh5rvQ2y!sUFvu`73NkPWGBOJ?{y)MX0rV0OKpYGv zIoQ})S%5M+0t`%y%uFn-%&bsZMkb)c1=$oC*g1rh3>^~-jRG5mMVuBM1ge%|WME=O zF^8Fjk%^U!0Vt;gv=3+$3p2tNMkYaKCBqLwfr*X6ijMzpG4L=04G?4&WUyx___R78 z`bEZ3n*%y$c1p?=OzsY{vOIcDRID^@mH5k5n_VmCLN*tlQtc~BqmaI3acZm^A1dHBrChNRU-KfIG`3a9F1Z+JCT zaBkFRt*1+W!zihZ}s%F&cxn?h~EIRD%9;ni-#KyOjOZ3l7 z_6Ks(XSKVYPbdvPm!tpIJj%Ot(S2`WC0AaXj1Ds{Yc~e@JYj`ND^=I^G)#%-Q1qX7 z;Q8}@p=SNS>z3K2PrXivv`$ retrievedStudent = studentRepository.findAllStudents(); - assertEquals(retrievedStudent.size(), 2); - } - - @Test - public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { - final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); - studentRepository.saveStudent(student); - studentRepository.deleteStudent(student.getId()); - final Student retrievedStudent = studentRepository.findStudent(student.getId()); - assertNull(retrievedStudent); - } -} \ No newline at end of file From bc7240ead1a907e1218ceed9b8be343abe18ddb3 Mon Sep 17 00:00:00 2001 From: sameira Date: Fri, 22 Jan 2016 08:44:58 +0530 Subject: [PATCH 7/9] Adding Java config --- .../spring/data/redis/config/RedisConfig.java | 21 ++++++++ .../spring/data/redis/model/Student.java | 2 +- .../redis/repo/StudentRepositoryImpl.java | 6 ++- .../redis/repo/StudentRepositoryTest.java | 48 +++++++++++-------- 4 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java new file mode 100644 index 0000000000..83244a4d94 --- /dev/null +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java @@ -0,0 +1,21 @@ +package org.baeldung.spring.data.redis.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; + +@Configuration +public class RedisConfig { + @Bean + JedisConnectionFactory jedisConnectionFactory() { + return new JedisConnectionFactory(); + } + + @Bean + public RedisTemplate< String, Object> redisTemplate() { + final RedisTemplate< String, Object> template = new RedisTemplate(); + template.setConnectionFactory(jedisConnectionFactory()); + return template; + } +} diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java index a37ecb8dd9..825248f183 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java @@ -7,7 +7,7 @@ public class Student implements Serializable { private static final long serialVersionUID = -1907106213598514113L; public enum Gender { - Male, Female + MALE, FEMALE } private String id; diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java index d964b830d2..020a96f1e4 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java @@ -2,16 +2,18 @@ package org.baeldung.spring.data.redis.repo; import org.baeldung.spring.data.redis.model.Student; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Repository; import java.util.Map; +@Repository public class StudentRepositoryImpl implements StudentRepository { private static final String KEY = "Student"; - private RedisTemplate redisTemplate; + private RedisTemplate redisTemplate; - public void setRedisTemplate(RedisTemplate redisTemplate) { + public void setRedisTemplate(RedisTemplate redisTemplate) { this.redisTemplate = redisTemplate; } diff --git a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java index a68d93c173..09bc74e5cf 100644 --- a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java +++ b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java @@ -1,9 +1,10 @@ package org.baeldung.spring.data.redis.repo; +import org.baeldung.spring.data.redis.config.RedisConfig; import org.baeldung.spring.data.redis.model.Student; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -13,46 +14,53 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:/spring-config.xml" }) +//@ContextConfiguration(locations = { "classpath:/spring-config.xml" }) +@ContextConfiguration(classes = RedisConfig.class) public class StudentRepositoryTest { - @Autowired - private StudentRepository studentRepository; + private StudentRepositoryImpl studentRepositoryImpl; + + @Before + public void setUp(){ + studentRepositoryImpl = new StudentRepositoryImpl(); + RedisConfig redisConfig = new RedisConfig(); + studentRepositoryImpl.setRedisTemplate(redisConfig.redisTemplate()); + } @Test public void whenSavingStudent_thenAvailableOnRetrieval() throws Exception { - final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); - studentRepository.saveStudent(student); - final Student retrievedStudent = studentRepository.findStudent(student.getId()); + final Student student = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); + studentRepositoryImpl.saveStudent(student); + final Student retrievedStudent = studentRepositoryImpl.findStudent(student.getId()); assertEquals(student.getId(), retrievedStudent.getId()); } @Test public void whenUpdatingStudent_thenAvailableOnRetrieval() throws Exception { - final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); - studentRepository.saveStudent(student); + final Student student = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); + studentRepositoryImpl.saveStudent(student); student.setName("Richard Watson"); - studentRepository.saveStudent(student); - final Student retrievedStudent = studentRepository.findStudent(student.getId()); + studentRepositoryImpl.saveStudent(student); + final Student retrievedStudent = studentRepositoryImpl.findStudent(student.getId()); assertEquals(student.getName(), retrievedStudent.getName()); } @Test public void whenSavingStudents_thenAllShouldAvailableOnRetrieval() throws Exception { - final Student engStudent = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); - final Student medStudent = new Student("Med2015001", "Gareth Houston", Student.Gender.Male, 2); - studentRepository.saveStudent(engStudent); - studentRepository.saveStudent(medStudent); - final Map retrievedStudent = studentRepository.findAllStudents(); + final Student engStudent = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); + final Student medStudent = new Student("Med2015001", "Gareth Houston", Student.Gender.MALE, 2); + studentRepositoryImpl.saveStudent(engStudent); + studentRepositoryImpl.saveStudent(medStudent); + final Map retrievedStudent = studentRepositoryImpl.findAllStudents(); assertEquals(retrievedStudent.size(), 2); } @Test public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { - final Student student = new Student("Eng2015001", "John Doe", Student.Gender.Male, 1); - studentRepository.saveStudent(student); - studentRepository.deleteStudent(student.getId()); - final Student retrievedStudent = studentRepository.findStudent(student.getId()); + final Student student = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); + studentRepositoryImpl.saveStudent(student); + studentRepositoryImpl.deleteStudent(student.getId()); + final Student retrievedStudent = studentRepositoryImpl.findStudent(student.getId()); assertNull(retrievedStudent); } } \ No newline at end of file From ecf5baea13bc5c2451d2bc48aec386799ae3f833 Mon Sep 17 00:00:00 2001 From: David Morley Date: Mon, 25 Jan 2016 07:25:48 -0600 Subject: [PATCH 8/9] Fix Spring configuration for Spring Data Redis example --- .../spring/data/redis/config/RedisConfig.java | 5 ++- .../data/redis/repo/StudentRepository.java | 1 + .../redis/repo/StudentRepositoryImpl.java | 14 ++++---- .../src/main/resources/spring-config.xml | 19 ----------- .../redis/repo/StudentRepositoryTest.java | 34 ++++++++----------- 5 files changed, 25 insertions(+), 48 deletions(-) delete mode 100644 spring-data-redis/src/main/resources/spring-config.xml diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java index 83244a4d94..a7e75a438a 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/config/RedisConfig.java @@ -1,19 +1,22 @@ package org.baeldung.spring.data.redis.config; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; @Configuration +@ComponentScan("org.baeldung.spring.data.redis") public class RedisConfig { + @Bean JedisConnectionFactory jedisConnectionFactory() { return new JedisConnectionFactory(); } @Bean - public RedisTemplate< String, Object> redisTemplate() { + public RedisTemplate redisTemplate() { final RedisTemplate< String, Object> template = new RedisTemplate(); template.setConnectionFactory(jedisConnectionFactory()); return template; diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java index 59b3a4c5e8..6a909ed137 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepository.java @@ -1,6 +1,7 @@ package org.baeldung.spring.data.redis.repo; import org.baeldung.spring.data.redis.model.Student; +import org.springframework.stereotype.Component; import java.util.Map; diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java index 020a96f1e4..55e6ad5edc 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/repo/StudentRepositoryImpl.java @@ -1,6 +1,7 @@ package org.baeldung.spring.data.redis.repo; import org.baeldung.spring.data.redis.model.Student; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; @@ -11,26 +12,23 @@ public class StudentRepositoryImpl implements StudentRepository { private static final String KEY = "Student"; + @Autowired private RedisTemplate redisTemplate; - public void setRedisTemplate(RedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - } - public void saveStudent(final Student student) { - this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + redisTemplate.opsForHash().put(KEY, student.getId(), student); } public void updateStudent(final Student student) { - this.redisTemplate.opsForHash().put(KEY, student.getId(), student); + redisTemplate.opsForHash().put(KEY, student.getId(), student); } public Student findStudent(final String id) { - return (Student) this.redisTemplate.opsForHash().get(KEY, id); + return (Student) redisTemplate.opsForHash().get(KEY, id); } public Map findAllStudents() { - return this.redisTemplate.opsForHash().entries(KEY); + return redisTemplate.opsForHash().entries(KEY); } public void deleteStudent(final String id) { diff --git a/spring-data-redis/src/main/resources/spring-config.xml b/spring-data-redis/src/main/resources/spring-config.xml deleted file mode 100644 index 4ca240d3f1..0000000000 --- a/spring-data-redis/src/main/resources/spring-config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java index 09bc74e5cf..08540abd36 100644 --- a/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java +++ b/spring-data-redis/src/test/java/org/baeldung/spring/data/redis/repo/StudentRepositoryTest.java @@ -5,6 +5,7 @@ import org.baeldung.spring.data.redis.model.Student; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -14,34 +15,27 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @RunWith(SpringJUnit4ClassRunner.class) -//@ContextConfiguration(locations = { "classpath:/spring-config.xml" }) @ContextConfiguration(classes = RedisConfig.class) public class StudentRepositoryTest { - private StudentRepositoryImpl studentRepositoryImpl; - - @Before - public void setUp(){ - studentRepositoryImpl = new StudentRepositoryImpl(); - RedisConfig redisConfig = new RedisConfig(); - studentRepositoryImpl.setRedisTemplate(redisConfig.redisTemplate()); - } + @Autowired + private StudentRepository studentRepository; @Test public void whenSavingStudent_thenAvailableOnRetrieval() throws Exception { final Student student = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); - studentRepositoryImpl.saveStudent(student); - final Student retrievedStudent = studentRepositoryImpl.findStudent(student.getId()); + studentRepository.saveStudent(student); + final Student retrievedStudent = studentRepository.findStudent(student.getId()); assertEquals(student.getId(), retrievedStudent.getId()); } @Test public void whenUpdatingStudent_thenAvailableOnRetrieval() throws Exception { final Student student = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); - studentRepositoryImpl.saveStudent(student); + studentRepository.saveStudent(student); student.setName("Richard Watson"); - studentRepositoryImpl.saveStudent(student); - final Student retrievedStudent = studentRepositoryImpl.findStudent(student.getId()); + studentRepository.saveStudent(student); + final Student retrievedStudent = studentRepository.findStudent(student.getId()); assertEquals(student.getName(), retrievedStudent.getName()); } @@ -49,18 +43,18 @@ public class StudentRepositoryTest { public void whenSavingStudents_thenAllShouldAvailableOnRetrieval() throws Exception { final Student engStudent = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); final Student medStudent = new Student("Med2015001", "Gareth Houston", Student.Gender.MALE, 2); - studentRepositoryImpl.saveStudent(engStudent); - studentRepositoryImpl.saveStudent(medStudent); - final Map retrievedStudent = studentRepositoryImpl.findAllStudents(); + studentRepository.saveStudent(engStudent); + studentRepository.saveStudent(medStudent); + final Map retrievedStudent = studentRepository.findAllStudents(); assertEquals(retrievedStudent.size(), 2); } @Test public void whenDeletingStudent_thenNotAvailableOnRetrieval() throws Exception { final Student student = new Student("Eng2015001", "John Doe", Student.Gender.MALE, 1); - studentRepositoryImpl.saveStudent(student); - studentRepositoryImpl.deleteStudent(student.getId()); - final Student retrievedStudent = studentRepositoryImpl.findStudent(student.getId()); + studentRepository.saveStudent(student); + studentRepository.deleteStudent(student.getId()); + final Student retrievedStudent = studentRepository.findStudent(student.getId()); assertNull(retrievedStudent); } } \ No newline at end of file From cc8d42c58bfa5dc671a9fb670cae5b196f9e2e53 Mon Sep 17 00:00:00 2001 From: David Morley Date: Sat, 30 Jan 2016 15:41:48 -0600 Subject: [PATCH 9/9] Clean up Spring Data Redis example --- .../main/java/org/baeldung/spring/data/redis/model/Student.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java index 825248f183..acc96899ce 100644 --- a/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java +++ b/spring-data-redis/src/main/java/org/baeldung/spring/data/redis/model/Student.java @@ -4,8 +4,6 @@ import java.io.Serializable; public class Student implements Serializable { - private static final long serialVersionUID = -1907106213598514113L; - public enum Gender { MALE, FEMALE }