Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Bague committed Jan 27, 2017
1 parent 8b47fc6 commit e192475
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.

This file was deleted.

Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}
}
}

0 comments on commit e192475

Please sign in to comment.