use of org.batfish.common.BatfishLogger in project batfish by batfish.
the class BatfishTestUtils method initBatfish.
private static Batfish initBatfish(SortedMap<String, Configuration> configurations, @Nonnull TemporaryFolder tempFolder) throws IOException {
Settings settings = new Settings(new String[] {});
settings.setLogger(new BatfishLogger("debug", false));
final Cache<Snapshot, SortedMap<String, Configuration>> testrigs = makeTestrigCache();
final Cache<Snapshot, SortedMap<String, Configuration>> compressedTestrigs = makeTestrigCache();
Path containerDir = tempFolder.newFolder().toPath();
settings.setContainerDir(containerDir);
if (!configurations.isEmpty()) {
settings.setTestrig("tempTestrig");
settings.setEnvironmentName("tempEnvironment");
Batfish.initTestrigSettings(settings);
settings.getBaseTestrigSettings().getEnvironmentSettings().getEnvPath().toFile().mkdirs();
testrigs.put(new Snapshot("tempTestrig", "tempEnvironment"), configurations);
settings.setActiveTestrigSettings(settings.getBaseTestrigSettings());
}
Batfish batfish = new Batfish(settings, compressedTestrigs, testrigs, makeDataPlaneCache(), makeDataPlaneCache(), makeEnvBgpCache(), makeEnvRouteCache(), makeForwardingAnalysisCache());
if (!configurations.isEmpty()) {
Batfish.serializeAsJson(settings.getBaseTestrigSettings().getEnvironmentSettings().getSerializedTopologyPath(), batfish.computeEnvironmentTopology(configurations), "environment topology");
}
return batfish;
}
use of org.batfish.common.BatfishLogger in project batfish by batfish.
the class ClientTest method checkProcessCommandErrorMessage.
private void checkProcessCommandErrorMessage(Command command, String[] parameters, String expected) throws Exception {
Client client = new Client(new String[] { "-runmode", "gendatamodel" });
File tempFile = _folder.newFile("writer");
FileWriter writer = new FileWriter(tempFile);
client._logger = new BatfishLogger("output", false);
String[] args = ArrayUtils.addAll(new String[] { command.commandName() }, parameters);
assertFalse(client.processCommand(args, writer));
assertThat(client.getLogger().getHistory().toString(500), equalTo(expected));
writer.close();
}
Aggregations