Skip to content

Commit

Permalink
add unittest for filename normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorHarbo committed Jul 24, 2023
1 parent 3bf93ff commit 3fbace7
Showing 1 changed file with 34 additions and 0 deletions.
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());
}
}

0 comments on commit 3fbace7

Please sign in to comment.