60a5e7809b99a2d337791f6c24dd51dcbdd66d7c
[svjatoslav_commons.git] / IOHelperTest.java
1 /*
2  * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko.
3  * This project is released under Creative Commons Zero (CC0) license.
4  */
5 package eu.svjatoslav.commons.file;
6
7 import org.junit.Assert;
8 import org.junit.Test;
9
10 import java.io.File;
11 import java.io.IOException;
12
13 public class IOHelperTest {
14
15     public static final String UTF_8 = "UTF-8";
16
17     @Test
18     public void testOverwriteFileIfContentDiffers() throws IOException {
19         final File file = new File("overrideTest.txt");
20
21         Assert.assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
22                 "aoa".getBytes(UTF_8)));
23
24         Assert.assertFalse(IOHelper.overwriteFileIfContentDiffers(file,
25                 "aoa".getBytes(UTF_8)));
26
27         Assert.assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
28                 "1234".getBytes(UTF_8)));
29
30         file.delete();
31     }
32
33 }