f9faa76997962c6ad99ed51414e3cb8594fba365
[svjatoslav_commons.git] / src / test / java / eu / svjatoslav / commons / file / IOHelperTest.java
1 /*
2  * Svjatoslav Commons - shared library of common functionality.
3  * Copyright ©2012-2014, 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 java.io.File;
13 import java.io.IOException;
14
15 import junit.framework.TestCase;
16
17 import org.junit.Test;
18
19 public class IOHelperTest extends TestCase {
20
21         @Test
22         public void testOverwriteFileIfContentDiffers() throws IOException {
23                 final File file = new File("overrideTest.txt");
24
25                 assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
26                                 "aoa".getBytes()));
27
28                 assertFalse(IOHelper.overwriteFileIfContentDiffers(file,
29                                 "aoa".getBytes()));
30
31                 assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
32                                 "1234".getBytes()));
33
34                 file.delete();
35         }
36
37 }