@@ -121,7 +121,7 @@ public void visit(TarArchiveEntry entry, byte[] content) throws IOException {
121
121
}
122
122
123
123
@ Test
124
- public void testCreationUtf8 () throws Exception {
124
+ public void testCreationEncoding () throws Exception {
125
125
DataProducer [] data = prepareData ();
126
126
File deb = File .createTempFile ("jdeb" , ".deb" );
127
127
@@ -144,7 +144,7 @@ public void testCreationUtf8() throws Exception {
144
144
145
145
DebMaker maker = new DebMaker (new NullConsole (), Arrays .asList (data ), Arrays .<DataProducer >asList (conffile1 , conffile2 ));
146
146
147
- maker .setControl (new File (getClass ().getResource ("deb/controlutf8 " ).toURI ()));
147
+ maker .setControl (new File (getClass ().getResource ("deb/controlencoding " ).toURI ()));
148
148
maker .setDeb (deb );
149
149
150
150
// first step: invalid encoding
@@ -176,6 +176,28 @@ else if (entry.getName().equals("./postinst") || entry.getName().equals("./prerm
176
176
throw new IOException (e );
177
177
}
178
178
}
179
+ else if (entry .getName ().startsWith ("./shell_" )) {
180
+ try {
181
+ for (String line : org .apache .commons .io .IOUtils .readLines (new ByteArrayInputStream (content ), StandardCharsets .UTF_8 )) {
182
+ if (line .startsWith ("# Custom script" )) {
183
+ assertFalse ("the encoding is valid but should be wrong" , line .endsWith ("created by ジョン" ));
184
+ }
185
+ }
186
+ } catch (Exception e ) {
187
+ throw new IOException (e );
188
+ }
189
+ }
190
+ else if (entry .getName ().equals ("./text.txt" )) {
191
+ try {
192
+ for (String line : org .apache .commons .io .IOUtils .readLines (new ByteArrayInputStream (content ), StandardCharsets .UTF_8 )) {
193
+ if (line .startsWith ("Text file" )) {
194
+ assertFalse ("the encoding is valid but should be wrong" , line .endsWith ("created by ジョン" ));
195
+ }
196
+ }
197
+ } catch (Exception e ) {
198
+ throw new IOException (e );
199
+ }
200
+ }
179
201
}
180
202
});
181
203
@@ -208,6 +230,28 @@ else if (entry.getName().equals("./postinst") || entry.getName().equals("./prerm
208
230
throw new IOException (e );
209
231
}
210
232
}
233
+ else if (entry .getName ().startsWith ("./shell_" )) {
234
+ try {
235
+ for (String line : org .apache .commons .io .IOUtils .readLines (new ByteArrayInputStream (content ), StandardCharsets .UTF_8 )) {
236
+ if (line .startsWith ("# Custom script" )) {
237
+ assertTrue ("the encoding is valid but should be wrong" , line .endsWith ("created by ジョン" ));
238
+ }
239
+ }
240
+ } catch (Exception e ) {
241
+ throw new IOException (e );
242
+ }
243
+ }
244
+ else if (entry .getName ().equals ("./text.txt" )) {
245
+ try {
246
+ for (String line : org .apache .commons .io .IOUtils .readLines (new ByteArrayInputStream (content ), StandardCharsets .UTF_8 )) {
247
+ if (line .startsWith ("Text file" )) {
248
+ assertTrue ("the encoding is valid but should be wrong" , line .endsWith ("created by ジョン" ));
249
+ }
250
+ }
251
+ } catch (Exception e ) {
252
+ throw new IOException (e );
253
+ }
254
+ }
211
255
}
212
256
});
213
257
}
0 commit comments