Changed license to CC0
[svjatoslav_commons.git] / src / test / java / eu / svjatoslav / commons / file / 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 }