This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix failing Jenkins tests: http://bugs.sun.com/bugdatabase/view_bug.d…

  • Loading branch information...
chocolateboy committed Jul 26, 2012
1 parent e6b228a commit 73ded3d4aa3bc83904d969dda045f783fcc262a6
Showing with 36 additions and 34 deletions.
  1. +36 −34 src/test/java/net/pms/util/FileUtilTest.java
@@ -28,137 +28,139 @@
import static org.fest.assertions.Assertions.assertThat;
public class FileUtilTest {
+ private final Class<?> CLASS = FileUtilTest.class;
+
@Test
public void testGetFileCharset_WINDOWS_1251() throws Exception {
- File file = new File(this.getClass().getResource("russian-cp1251.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-cp1251.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_WINDOWS_1251);
}
@Test
public void testGetFileCharset_IBM866() throws Exception {
- File file = new File(this.getClass().getResource("russian-ibm866.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-ibm866.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_IBM866);
}
@Test
public void testGetFileCharset_KOI8_R() throws Exception {
- File file = new File(this.getClass().getResource("russian-koi8-r.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-koi8-r.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_KOI8_R);
}
@Test
public void testGetFileCharset_UTF8_without_BOM() throws Exception {
- File file = new File(this.getClass().getResource("russian-utf8-without-bom.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-utf8-without-bom.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_UTF_8);
}
@Test
public void testGetFileCharset_UTF8_with_BOM() throws Exception {
- File file = new File(this.getClass().getResource("russian-utf8-with-bom.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-utf8-with-bom.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_UTF_8);
}
@Test
public void testGetFileCharset_UTF16_LE() throws Exception {
- File file = new File(this.getClass().getResource("russian-utf16-le.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-utf16-le.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_UTF_16LE);
}
@Test
public void testGetFileCharset_UTF16_BE() throws Exception {
- File file = new File(this.getClass().getResource("russian-utf16-be.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-utf16-be.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_UTF_16BE);
}
@Test
public void testGetFileCharset_UTF32_LE() throws Exception {
- File file = new File(this.getClass().getResource("russian-utf32-le.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-utf32-le.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_UTF_32LE);
}
@Test
public void testGetFileCharset_UTF32_BE() throws Exception {
- File file = new File(this.getClass().getResource("russian-utf32-be.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("russian-utf32-be.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_UTF_32BE);
}
@Test
public void testGetFileCharset_BIG5() throws Exception {
- File file = new File(this.getClass().getResource("chinese-gb18030.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("chinese-gb18030.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_GB18030);
}
@Test
public void testGetFileCharset_GB2312() throws Exception {
- File file = new File(this.getClass().getResource("chinese-big5.srt").getFile());
+ File file = FileUtils.toFile(CLASS.getResource("chinese-big5.srt"));
assertThat(FileUtil.getFileCharset(file)).isEqualTo(Constants.CHARSET_BIG5);
}
@Test
public void testIsFileUTF8() throws Exception {
- File file_utf8 = new File(this.getClass().getResource("russian-utf8-without-bom.srt").getFile());
+ File file_utf8 = FileUtils.toFile(CLASS.getResource("russian-utf8-without-bom.srt"));
assertThat(FileUtil.isFileUTF8(file_utf8)).isTrue();
- File file_utf8_2 = new File(this.getClass().getResource("russian-utf8-with-bom.srt").getFile());
+ File file_utf8_2 = FileUtils.toFile(CLASS.getResource("russian-utf8-with-bom.srt"));
assertThat(FileUtil.isFileUTF8(file_utf8_2)).isTrue();
- File file_utf8_3 = new File(this.getClass().getResource("english-utf8-with-bom.srt").getFile());
+ File file_utf8_3 = FileUtils.toFile(CLASS.getResource("english-utf8-with-bom.srt"));
assertThat(FileUtil.isFileUTF8(file_utf8_3)).isTrue();
- File file_utf_16 = new File(this.getClass().getResource("russian-utf16-le.srt").getFile());
+ File file_utf_16 = FileUtils.toFile(CLASS.getResource("russian-utf16-le.srt"));
assertThat(FileUtil.isFileUTF8(file_utf_16)).isFalse();
- File file_utf_16_2 = new File(this.getClass().getResource("russian-utf16-be.srt").getFile());
+ File file_utf_16_2 = FileUtils.toFile(CLASS.getResource("russian-utf16-be.srt"));
assertThat(FileUtil.isFileUTF8(file_utf_16_2)).isFalse();
- File file_cp1251 = new File(this.getClass().getResource("russian-cp1251.srt").getFile());
+ File file_cp1251 = FileUtils.toFile(CLASS.getResource("russian-cp1251.srt"));
assertThat(FileUtil.isFileUTF8(file_cp1251)).isFalse();
- File file_ch = new File(this.getClass().getResource("chinese-gb18030.srt").getFile());
+ File file_ch = FileUtils.toFile(CLASS.getResource("chinese-gb18030.srt"));
assertThat(FileUtil.isFileUTF8(file_ch)).isFalse();
- File file_ch_2 = new File(this.getClass().getResource("chinese-big5.srt").getFile());
+ File file_ch_2 = FileUtils.toFile(CLASS.getResource("chinese-big5.srt"));
assertThat(FileUtil.isFileUTF8(file_ch_2)).isFalse();
}
@Test
public void testIsFileUTF16() throws Exception {
- File file_utf8 = new File(this.getClass().getResource("russian-utf8-without-bom.srt").getFile());
+ File file_utf8 = FileUtils.toFile(CLASS.getResource("russian-utf8-without-bom.srt"));
assertThat(FileUtil.isFileUTF16(file_utf8)).isFalse();
- File file_utf8_2 = new File(this.getClass().getResource("russian-utf8-with-bom.srt").getFile());
+ File file_utf8_2 = FileUtils.toFile(CLASS.getResource("russian-utf8-with-bom.srt"));
assertThat(FileUtil.isFileUTF16(file_utf8_2)).isFalse();
- File file_utf8_3 = new File(this.getClass().getResource("english-utf8-with-bom.srt").getFile());
+ File file_utf8_3 = FileUtils.toFile(CLASS.getResource("english-utf8-with-bom.srt"));
assertThat(FileUtil.isFileUTF16(file_utf8_3)).isFalse();
- File file_utf_16 = new File(this.getClass().getResource("russian-utf16-le.srt").getFile());
+ File file_utf_16 = FileUtils.toFile(CLASS.getResource("russian-utf16-le.srt"));
assertThat(FileUtil.isFileUTF16(file_utf_16)).isTrue();
- File file_utf_16_2 = new File(this.getClass().getResource("russian-utf16-be.srt").getFile());
+ File file_utf_16_2 = FileUtils.toFile(CLASS.getResource("russian-utf16-be.srt"));
assertThat(FileUtil.isFileUTF16(file_utf_16_2)).isTrue();
- File file_cp1251 = new File(this.getClass().getResource("russian-cp1251.srt").getFile());
+ File file_cp1251 = FileUtils.toFile(CLASS.getResource("russian-cp1251.srt"));
assertThat(FileUtil.isFileUTF16(file_cp1251)).isFalse();
- File file_ch = new File(this.getClass().getResource("chinese-gb18030.srt").getFile());
+ File file_ch = FileUtils.toFile(CLASS.getResource("chinese-gb18030.srt"));
assertThat(FileUtil.isFileUTF16(file_ch)).isFalse();
- File file_ch_2 = new File(this.getClass().getResource("chinese-big5.srt").getFile());
+ File file_ch_2 = FileUtils.toFile(CLASS.getResource("chinese-big5.srt"));
assertThat(FileUtil.isFileUTF16(file_ch_2)).isFalse();
}
@Test
public void testConvertFileFromUtf16ToUtf8_inputFileIsUTF16LE() throws Exception {
- File file_utf8le = new File(this.getClass().getResource("russian-utf16-le.srt").getFile());
- File outputFile = new File(file_utf8le.getParentFile(),"output-utf8-from-utf16-le.srt");
+ File file_utf8le = FileUtils.toFile(CLASS.getResource("russian-utf16-le.srt"));
+ File outputFile = new File(file_utf8le.getParentFile(), "output-utf8-from-utf16-le.srt");
outputFile.delete();
FileUtil.convertFileFromUtf16ToUtf8(file_utf8le, outputFile);
- File file_utf8 = new File(this.getClass().getResource("russian-utf8-without-bom.srt").getFile());
+ File file_utf8 = FileUtils.toFile(CLASS.getResource("russian-utf8-without-bom.srt"));
assertThat(FileUtils.contentEquals(outputFile, file_utf8)).isTrue();
outputFile.delete();
}
@Test
public void testConvertFileFromUtf16ToUtf8_inputFileIsUTF16BE() throws Exception {
- File file_utf8be = new File(this.getClass().getResource("russian-utf16-be.srt").getFile());
- File outputFile = new File(file_utf8be.getParentFile(),"output-utf8-from-utf16-be.srt");
+ File file_utf8be = FileUtils.toFile(CLASS.getResource("russian-utf16-be.srt"));
+ File outputFile = new File(file_utf8be.getParentFile(), "output-utf8-from-utf16-be.srt");
outputFile.delete();
FileUtil.convertFileFromUtf16ToUtf8(file_utf8be, outputFile);
- File file_utf8 = new File(this.getClass().getResource("russian-utf8-with-bom.srt").getFile());
+ File file_utf8 = FileUtils.toFile(CLASS.getResource("russian-utf8-with-bom.srt"));
assertThat(FileUtils.contentEquals(outputFile, file_utf8)).isTrue();
outputFile.delete();
}
@Test(expected = IllegalArgumentException.class)
public void testConvertFileFromUtf16ToUtf8_notUtf16InputFile() throws Exception {
- File file_cp1251 = new File(this.getClass().getResource("russian-cp1251.srt").getFile());
+ File file_cp1251 = FileUtils.toFile(CLASS.getResource("russian-cp1251.srt"));
FileUtil.convertFileFromUtf16ToUtf8(file_cp1251, new File("output.srt"));
}

0 comments on commit 73ded3d

Please sign in to comment.