|
78 | 78 | import org.springframework.data.redis.core.mapping.RedisMappingContext;
|
79 | 79 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
80 | 80 | import org.springframework.data.redis.test.util.RedisTestData;
|
| 81 | +import org.springframework.util.ClassUtils; |
81 | 82 | import org.springframework.util.StringUtils;
|
82 | 83 |
|
83 | 84 | import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
@@ -1994,16 +1995,22 @@ void readGenericEntity() {
|
1994 | 1995 | assertThat(generic.entity.name).isEqualTo("hello");
|
1995 | 1996 | }
|
1996 | 1997 |
|
1997 |
| - @Test // GH-2168 |
| 1998 | + @Test // GH-2168, GH-3179 |
1998 | 1999 | void writePlainList() {
|
1999 |
| - |
2000 | 2000 | List<Object> source = Arrays.asList("Hello", "stream", "message", 100L);
|
2001 | 2001 | RedisTestData target = write(source);
|
2002 |
| - |
2003 |
| - assertThat(target).containsEntry("[0]", "Hello") // |
2004 |
| - .containsEntry("[1]", "stream") // |
2005 |
| - .containsEntry("[2]", "message") // |
2006 |
| - .containsEntry("[3]", "100"); |
| 2002 | + Object classValue = target.getBucket().get("_class"); |
| 2003 | + |
| 2004 | + assertThat(classValue) |
| 2005 | + .as("_class metadata should be written") |
| 2006 | + .isNotNull() |
| 2007 | + .isInstanceOf(byte[].class); |
| 2008 | + assertThat(new String((byte[]) classValue, StandardCharsets.UTF_8)) |
| 2009 | + .isEqualTo(ClassUtils.getUserClass(source).getName()); |
| 2010 | + assertThat(target).containsEntry("[0]", "Hello") |
| 2011 | + .containsEntry("[1]", "stream") |
| 2012 | + .containsEntry("[2]", "message") |
| 2013 | + .containsEntry("[3]", "100"); |
2007 | 2014 | }
|
2008 | 2015 |
|
2009 | 2016 | @Test // DATAREDIS-1175
|
|
0 commit comments