1+ package io .microsphere .spring .config .env ;
2+
3+ import org .junit .Test ;
4+
5+ import java .util .HashMap ;
6+ import java .util .IdentityHashMap ;
7+ import java .util .LinkedHashMap ;
8+ import java .util .Map ;
9+ import java .util .TreeMap ;
10+
11+ import static java .util .Collections .emptyMap ;
12+ import static java .util .Collections .unmodifiableMap ;
13+ import static org .junit .Assert .assertEquals ;
14+
15+ /**
16+ * {@link ImmutableMapPropertySource} Test
17+ *
18+ * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
19+ * @see ImmutableMapPropertySource
20+ * @since 1.0.0
21+ */
22+ public class ImmutableMapPropertySourceTest {
23+
24+ private static final String NAME = "test" ;
25+
26+ private static final Class <? extends Map > SOURCE_CLASS = unmodifiableMap (emptyMap ()).getClass ();
27+
28+ @ Test
29+ public void testNewFromSortedMap () {
30+ ImmutableMapPropertySource propertySource = createPropertySource (new TreeMap <>());
31+ assertPropertySource (propertySource );
32+ }
33+
34+ @ Test
35+ public void testNewFromLinkedHashMap () {
36+ ImmutableMapPropertySource propertySource = createPropertySource (new LinkedHashMap <>());
37+ assertPropertySource (propertySource );
38+ }
39+
40+ @ Test
41+ public void testNewFromIdentityHashMap () {
42+ ImmutableMapPropertySource propertySource = createPropertySource (new IdentityHashMap <>());
43+ assertPropertySource (propertySource );
44+ }
45+
46+ @ Test
47+ public void testNewFromHashMap () {
48+ ImmutableMapPropertySource propertySource = createPropertySource (new HashMap <>());
49+ assertPropertySource (propertySource );
50+ }
51+
52+ void assertPropertySource (ImmutableMapPropertySource propertySource ) {
53+ assertEquals (NAME , propertySource .getName ());
54+ assertEquals (SOURCE_CLASS , propertySource .getSource ().getClass ());
55+ }
56+
57+ private ImmutableMapPropertySource createPropertySource (Map source ) {
58+ return new ImmutableMapPropertySource (NAME , source );
59+ }
60+ }
0 commit comments