@@ -61,6 +61,53 @@ void testLoad() throws IOException, URISyntaxException {
61
61
new AbstractMap .SimpleEntry <>("key.4" , "\\ u1234\u1234 " ));
62
62
}
63
63
64
+ void testLoadCrLf () throws IOException , URISyntaxException {
65
+ Properties p = Properties .loadProperties (getResource ("/testcrlf.properties" ));
66
+ assertThat (p ).size ().isEqualTo (7 );
67
+ assertThat (p .keySet ())
68
+ .containsExactly (
69
+ "one" , "two" , "three" , " with spaces" , "altsep" , "multiline" , "key.4" );
70
+ assertThat (p .rawKeySet ())
71
+ .containsExactly (
72
+ "one" , "two" , "three" , "\\ with\\ spaces" , "altsep" , "multiline" , "key.4" );
73
+ assertThat (p .values ())
74
+ .containsExactly (
75
+ "simple" ,
76
+ "value containing spaces" ,
77
+ "and escapes\n \t \r \f " ,
78
+ "everywhere " ,
79
+ "value" ,
80
+ "one two three" ,
81
+ "\u1234 \u1234 " );
82
+ assertThat (p .rawValues ())
83
+ .containsExactly (
84
+ "simple" ,
85
+ "value containing spaces" ,
86
+ "and escapes\\ n\\ t\\ r\\ f" ,
87
+ "everywhere " ,
88
+ "value" ,
89
+ "one \\ \n two \\ \n \t three" ,
90
+ "\\ u1234\u1234 " );
91
+ assertThat (p .entrySet ())
92
+ .containsExactly (
93
+ new AbstractMap .SimpleEntry <>("one" , "simple" ),
94
+ new AbstractMap .SimpleEntry <>("two" , "value containing spaces" ),
95
+ new AbstractMap .SimpleEntry <>("three" , "and escapes\n \t \r \f " ),
96
+ new AbstractMap .SimpleEntry <>(" with spaces" , "everywhere " ),
97
+ new AbstractMap .SimpleEntry <>("altsep" , "value" ),
98
+ new AbstractMap .SimpleEntry <>("multiline" , "one two three" ),
99
+ new AbstractMap .SimpleEntry <>("key.4" , "\u1234 \u1234 " ));
100
+ assertThat (p .rawEntrySet ())
101
+ .containsExactly (
102
+ new AbstractMap .SimpleEntry <>("one" , "simple" ),
103
+ new AbstractMap .SimpleEntry <>("two" , "value containing spaces" ),
104
+ new AbstractMap .SimpleEntry <>("three" , "and escapes\\ n\\ t\\ r\\ f" ),
105
+ new AbstractMap .SimpleEntry <>("\\ with\\ spaces" , "everywhere " ),
106
+ new AbstractMap .SimpleEntry <>("altsep" , "value" ),
107
+ new AbstractMap .SimpleEntry <>("multiline" , "one \\ \n two \\ \n \t three" ),
108
+ new AbstractMap .SimpleEntry <>("key.4" , "\\ u1234\u1234 " ));
109
+ }
110
+
64
111
@ Test
65
112
void testStore () throws IOException , URISyntaxException {
66
113
Path f = getResource ("/test.properties" );
@@ -70,6 +117,15 @@ void testStore() throws IOException, URISyntaxException {
70
117
assertThat (sw .toString ()).isEqualTo (readAll (f ));
71
118
}
72
119
120
+ @ Test
121
+ void testStoreCrLf () throws IOException , URISyntaxException {
122
+ Path f = getResource ("/testcrlf.properties" );
123
+ Properties p = Properties .loadProperties (f );
124
+ StringWriter sw = new StringWriter ();
125
+ p .store (sw );
126
+ assertThat (sw .toString ()).isEqualTo (readAll (f ));
127
+ }
128
+
73
129
@ Test
74
130
void testStoreHeader () throws IOException , URISyntaxException {
75
131
Path f = getResource ("/test.properties" );
0 commit comments