|
| 1 | +package edu.unc.lib.boxc.common.http; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Test; |
| 4 | + |
| 5 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 6 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 7 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 8 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 9 | + |
| 10 | +/** |
| 11 | + * @author bbpennel |
| 12 | + */ |
| 13 | +public class MimetypeHelpersTest { |
| 14 | + @Test |
| 15 | + public void isValidMimetypeNullTest() { |
| 16 | + String mimetype = null; |
| 17 | + assertFalse(MimetypeHelpers.isValidMimetype(mimetype)); |
| 18 | + } |
| 19 | + |
| 20 | + @Test |
| 21 | + public void isValidMimetypeBlankTest() { |
| 22 | + String mimetype = ""; |
| 23 | + assertFalse(MimetypeHelpers.isValidMimetype(mimetype)); |
| 24 | + } |
| 25 | + |
| 26 | + @Test |
| 27 | + public void isValidMimetypeSymlinkTest() { |
| 28 | + String mimetype = "inode/symlink"; |
| 29 | + assertFalse(MimetypeHelpers.isValidMimetype(mimetype)); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void isValidMimetypeInvalidFormatTest() { |
| 34 | + String mimetype = "invalid format"; |
| 35 | + assertFalse(MimetypeHelpers.isValidMimetype(mimetype)); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void isValidMimetypeNefTest() { |
| 40 | + String mimetype = "image/x-nikon-nef"; |
| 41 | + assertTrue(MimetypeHelpers.isValidMimetype(mimetype)); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void formatMimetypeNullTest() { |
| 46 | + String mimetype = null; |
| 47 | + assertNull(MimetypeHelpers.formatMimetype(mimetype)); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void formatMimetypeWithParamsTest() { |
| 52 | + String mimetype = "text/plain; charset=UTF-8"; |
| 53 | + assertEquals("text/plain", MimetypeHelpers.formatMimetype(mimetype)); |
| 54 | + } |
| 55 | + |
| 56 | + @Test |
| 57 | + public void formatMimetypeRegularTest() { |
| 58 | + String mimetype = "text/plain"; |
| 59 | + assertEquals("text/plain", MimetypeHelpers.formatMimetype(mimetype)); |
| 60 | + } |
| 61 | +} |
0 commit comments