2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
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.
10 package eu.svjatoslav.commons.file;
12 import org.junit.Assert;
13 import org.junit.Test;
16 import java.io.IOException;
18 public class IOHelperTest {
20 public static final String UTF_8 = "UTF-8";
23 public void testOverwriteFileIfContentDiffers() throws IOException {
24 final File file = new File("overrideTest.txt");
26 Assert.assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
27 "aoa".getBytes(UTF_8)));
29 Assert.assertFalse(IOHelper.overwriteFileIfContentDiffers(file,
30 "aoa".getBytes(UTF_8)));
32 Assert.assertTrue(IOHelper.overwriteFileIfContentDiffers(file,
33 "1234".getBytes(UTF_8)));