use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class BackupToolTest method shouldResetTimeout.
@Test
public void shouldResetTimeout() throws Exception {
String newTimeout = "3";
/*seconds by default*/
long expectedTimeout = 3 * 1000;
String[] args = new String[] { "-host", "localhost", "-to", "my_backup", "-timeout", newTimeout };
BackupService service = mock(BackupService.class);
PrintStream systemOut = mock(PrintStream.class);
// when
new BackupTool(service, systemOut).run(args);
// then
verify(service).doIncrementalBackupOrFallbackToFull(eq("localhost"), eq(BackupServer.DEFAULT_PORT), eq(new File("my_backup")), eq(ConsistencyCheck.FULL), any(Config.class), eq(expectedTimeout), eq(false));
verify(systemOut).println("Performing backup from '" + new HostnamePort("localhost", BackupServer.DEFAULT_PORT) + "'");
verify(systemOut).println("Done");
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class BackupToolTest method shouldIgnoreFullFlag.
@Test
public void shouldIgnoreFullFlag() throws Exception {
String[] args = new String[] { "-full", "-host", "localhost", "-to", "my_backup" };
BackupService service = mock(BackupService.class);
when(service.directoryContainsDb(any(FileSystemAbstraction.class), eq(new File("my_backup")))).thenReturn(true);
PrintStream systemOut = mock(PrintStream.class);
// when
new BackupTool(service, systemOut).run(args);
// then
verify(service).doIncrementalBackupOrFallbackToFull(eq("localhost"), eq(BackupServer.DEFAULT_PORT), eq(new File("my_backup")), eq(ConsistencyCheck.FULL), any(Config.class), eq(BackupClient.BIG_READ_TIMEOUT), eq(false));
verify(systemOut).println("Performing backup from '" + new HostnamePort("localhost", BackupServer.DEFAULT_PORT) + "'");
verify(systemOut).println("Done");
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class BackupToolTest method shouldUseIncrementalOrFallbackToFull.
@Test
public void shouldUseIncrementalOrFallbackToFull() throws Exception {
String[] args = new String[] { "-host", "localhost", "-to", "my_backup" };
BackupService service = mock(BackupService.class);
PrintStream systemOut = mock(PrintStream.class);
// when
new BackupTool(service, systemOut).run(args);
// then
verify(service).doIncrementalBackupOrFallbackToFull(eq("localhost"), eq(BackupServer.DEFAULT_PORT), eq(new File("my_backup")), eq(ConsistencyCheck.FULL), any(Config.class), eq(BackupClient.BIG_READ_TIMEOUT), eq(false));
verify(systemOut).println("Performing backup from '" + new HostnamePort("localhost", BackupServer.DEFAULT_PORT) + "'");
verify(systemOut).println("Done");
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class BackupToolTest method shouldRespectVerifyFlagWithLegacyArguments.
@Test
public void shouldRespectVerifyFlagWithLegacyArguments() throws BackupTool.ToolFailureException {
// Given
String host = "localhost";
File targetDir = new File("/var/backup/neo4j/").getAbsoluteFile();
String[] args = { "-from", host, "-to", targetDir.getAbsolutePath(), "-verify", "false" };
BackupService service = mock(BackupService.class);
PrintStream systemOut = mock(PrintStream.class);
// When
new BackupTool(service, systemOut).run(args);
// Then
verify(service).doIncrementalBackupOrFallbackToFull(eq(host), eq(BackupServer.DEFAULT_PORT), eq(targetDir), eq(ConsistencyCheck.NONE), any(Config.class), eq(BackupClient.BIG_READ_TIMEOUT), eq(false));
verify(systemOut).println("Performing backup from '" + new HostnamePort(host, BackupServer.DEFAULT_PORT) + "'");
verify(systemOut).println("Done");
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class PingerTest method normalPingSequenceShouldBeOneThenTwoThenThreeEtc.
@Test
public void normalPingSequenceShouldBeOneThenTwoThenThreeEtc() throws Exception {
int[] expectedSequence = { 1, 2, 3, 4 };
final HostnamePort hostURL = new HostnamePort(hostname, server.getLocalPort());
final Map<String, String> udcFields = new HashMap<String, String>();
Pinger p = new Pinger(hostURL, new TestUdcCollector(udcFields));
for (int i = 0; i < expectedSequence.length; i++) {
p.ping();
int count = Integer.parseInt(handler.getQueryMap().get(UdcConstants.PING));
assertEquals(expectedSequence[i], count);
}
}
Aggregations