-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unittest for filename normalization
- Loading branch information
1 parent
3bf93ff
commit 3fbace7
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/test/java/dk/kb/netarchivesuite/solrwayback/normalize/FilenameNormalizeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package dk.kb.netarchivesuite.solrwayback.normalize; | ||
|
||
import org.junit.Test; | ||
|
||
import static dk.kb.netarchivesuite.solrwayback.export.StreamingRawZipExport.normalizeFilename; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class FilenameNormalizeTest { | ||
|
||
@Test | ||
public void testUnderscores(){ | ||
String test = "test__filename_with___cuncurrent_underscores_.ext"; | ||
|
||
String result = normalizeFilename(test); | ||
|
||
assertEquals("test_filename_with_cuncurrent_underscores.ext", result); | ||
} | ||
|
||
@Test | ||
public void testBadCharacters(){ | ||
String test = "test%file&name.with.extra.punctuation&what.ext"; | ||
String result = normalizeFilename(test); | ||
assertEquals("testfilenamewithextrapunctuationwhat.ext", result); | ||
} | ||
|
||
|
||
@Test | ||
public void testLongName(){ | ||
String test = "1234567890_thisfilenameiswaytolongforaproperfilename_howdoesthemethodhandleme_iwonderificandestroysomesystemsbybeingsoboringlyuglylong" + | ||
"omgthisisonlyhalfthelengthofwhatineedtobetodestroysomesystemshowonearthdoibecomeaslongasneededmaybeitwillhelpifijustrambleonandonandonforsomewords.ext"; | ||
String result = normalizeFilename(test); | ||
assertEquals(255, result.length()); | ||
} | ||
} |