|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
35 | 35 | import java.util.TreeSet;
|
36 | 36 |
|
37 | 37 | import org.junit.Test;
|
| 38 | + |
38 | 39 | import org.springframework.util.LinkedMultiValueMap;
|
39 | 40 | import org.springframework.util.MultiValueMap;
|
40 | 41 |
|
41 |
| -import static org.hamcrest.CoreMatchers.*; |
42 |
| -import static org.hamcrest.Matchers.empty; |
| 42 | +import static org.hamcrest.Matchers.*; |
43 | 43 | import static org.junit.Assert.*;
|
44 | 44 | import static org.springframework.core.CollectionFactory.*;
|
45 | 45 |
|
@@ -104,7 +104,7 @@ public void createCollectionIsNotTypeSafeForEnumSet() {
|
104 | 104 | * {@link CollectionFactory#createApproximateMap(Object, int)}
|
105 | 105 | * is not type-safe.
|
106 | 106 | * <p>The reasoning is similar that described in
|
107 |
| - * {@link #createApproximateCollectionIsNotTypeSafe()}. |
| 107 | + * {@link #createApproximateCollectionIsNotTypeSafeForEnumSet}. |
108 | 108 | */
|
109 | 109 | @Test
|
110 | 110 | public void createApproximateMapIsNotTypeSafeForEnumMap() {
|
@@ -242,6 +242,12 @@ public void createsEnumSet() {
|
242 | 242 | assertThat(createCollection(EnumSet.class, Color.class, 0), is(instanceOf(EnumSet.class)));
|
243 | 243 | }
|
244 | 244 |
|
| 245 | + @Test // SPR-17619 |
| 246 | + public void createsEnumSetSubclass() { |
| 247 | + EnumSet<Color> enumSet = EnumSet.noneOf(Color.class); |
| 248 | + assertThat(createCollection(enumSet.getClass(), Color.class, 0), is(instanceOf(enumSet.getClass()))); |
| 249 | + } |
| 250 | + |
245 | 251 | @Test(expected = IllegalArgumentException.class)
|
246 | 252 | public void rejectsInvalidElementTypeForEnumSet() {
|
247 | 253 | createCollection(EnumSet.class, Object.class, 0);
|
@@ -297,7 +303,8 @@ public void rejectsNullMapType() {
|
297 | 303 | }
|
298 | 304 |
|
299 | 305 |
|
300 |
| - static enum Color { |
| 306 | + enum Color { |
301 | 307 | RED, BLUE;
|
302 | 308 | }
|
| 309 | + |
303 | 310 | }
|
0 commit comments