From e19247579de9bd3b829dc602f11ceba90a5b2c46 Mon Sep 17 00:00:00 2001 From: Mathieu Bague Date: Fri, 27 Jan 2017 21:06:17 +0100 Subject: [PATCH] Fix unit tests --- .../eu/itesla_project/wca/CoverageTest.java | 19 ------------------- .../eu/itesla_project/wca/WCAUtilsTest.java | 16 ++++++---------- 2 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 wca-integration/src/test/java/eu/itesla_project/wca/CoverageTest.java diff --git a/wca-integration/src/test/java/eu/itesla_project/wca/CoverageTest.java b/wca-integration/src/test/java/eu/itesla_project/wca/CoverageTest.java deleted file mode 100644 index 6338656c..00000000 --- a/wca-integration/src/test/java/eu/itesla_project/wca/CoverageTest.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2017, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.wca; - -import org.junit.Test; - -/** - * @author Mathieu Bague - */ -public class CoverageTest { - - @Test - public void testNothing() { - } -} diff --git a/wca-integration/src/test/java/eu/itesla_project/wca/WCAUtilsTest.java b/wca-integration/src/test/java/eu/itesla_project/wca/WCAUtilsTest.java index 0de5c6f3..10b51fdd 100644 --- a/wca-integration/src/test/java/eu/itesla_project/wca/WCAUtilsTest.java +++ b/wca-integration/src/test/java/eu/itesla_project/wca/WCAUtilsTest.java @@ -6,26 +6,22 @@ */ package eu.itesla_project.wca; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; import java.util.zip.GZIPInputStream; +import org.apache.commons.io.IOUtils; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.junit.After; import org.junit.Before; import org.junit.Test; -import com.google.common.io.CharStreams; import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; @@ -54,13 +50,13 @@ public void tearDown() throws Exception { public void testExportState() throws IOException, URISyntaxException { Path folder = Files.createDirectory(fileSystem.getPath("/export-folder")); Network network = NetworkTest1Factory.create(); - network.setCaseDate(new DateTime(1483228800000l).withZone(DateTimeZone.UTC)); + network.setCaseDate(new DateTime(1483228800000L).withZone(DateTimeZone.UTC)); WCAUtils.exportState(network, folder, 0, 0); Path exportedState = folder.resolve(network.getId() + "_0_0.xiidm.gz"); assertTrue(Files.exists(exportedState)); - File expectedState = new File(getClass().getResource("/network1.xiidm").toURI()); - assertEquals(CharStreams.toString(new InputStreamReader(new FileInputStream(expectedState))), - CharStreams.toString(new InputStreamReader(new GZIPInputStream(Files.newInputStream(exportedState))))); - } + try (GZIPInputStream stream = new GZIPInputStream(Files.newInputStream(exportedState))) { + assertTrue(IOUtils.contentEquals(getClass().getResourceAsStream("/network1.xiidm"), stream)); + } + } }