Improved IntelliJ startup script.
[svjatoslav_commons.git] / src / test / java / eu / svjatoslav / commons / file / IOHelperTest.java
1 /*
2  * Svjatoslav Commons - shared library of common functionality.
3  * Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 3 of the GNU Lesser General Public License
7  * or later as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.commons.file;
11
12 import org.junit.Assert;
13 import org.junit.Test;
14
15 import java.io.File;
16 import java.io.IOException;
17
18 public class IOHelperTest {
19
20     public static final String UTF_8 = "UTF-8";
21
22     @Test
23     public void testOverwriteFileIfContentDiffers() throws IOException {
24         final File file = new File("overrideTest.txt");
25
26         Assert.assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
27                 "aoa".getBytes(UTF_8)));
28
29         Assert.assertFalse(IOHelper.overwriteFileIfContentDiffers(file,
30                 "aoa".getBytes(UTF_8)));
31
32         Assert.assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
33                 "1234".getBytes(UTF_8)));
34
35         file.delete();
36     }
37
38 }