mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
Add VrpXMLWrite method that returns OutputStream
Add test to check that two outputs are the same
This commit is contained in:
parent
bf40087b22
commit
bab1f7d6a8
2 changed files with 54 additions and 18 deletions
|
|
@ -34,6 +34,10 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -621,6 +625,19 @@ public class VrpXMLWriterTest {
|
|||
assertEquals("2", Solutions.bestOf(solutionsToRead).getUnassignedJobs().iterator().next().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outputStreamAndFileContentsAreEqual() throws IOException {
|
||||
VehicleRoutingProblem.Builder builder = twoVehicleTypesAndImpls();
|
||||
VehicleRoutingProblem vrp = builder.build();
|
||||
|
||||
new VrpXMLWriter(vrp, null).write(infileName);
|
||||
String outputStringFromFile = new String(Files.readAllBytes(Paths.get(infileName)));
|
||||
String outputStringFromStream = new VrpXMLWriter(vrp, null).write().toString();
|
||||
|
||||
assertEquals(outputStringFromFile, outputStringFromStream);
|
||||
|
||||
}
|
||||
|
||||
private VehicleRoutingProblem writeAndRereadXml(VehicleRoutingProblem vrp) {
|
||||
new VrpXMLWriter(vrp, null).write(infileName);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue