use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class PingerTest method crashPingSequenceShouldBeMinusOneThenTwoThenThreeEtc.
@Test
public void crashPingSequenceShouldBeMinusOneThenTwoThenThreeEtc() 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).withCrash());
for (int i = 0; i < expectedSequence.length; i++) {
p.ping();
int count = Integer.parseInt(handler.getQueryMap().get(UdcConstants.PING));
assertEquals(expectedSequence[i], count);
}
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class BackupToolIT method oldIncompatibleBackupsThrows.
@Test
public void oldIncompatibleBackupsThrows() throws Exception {
// Prepare an "old" backup
prepareNeoStoreFile(StandardV2_3.STORE_VERSION);
// Start database to backup
dbRule.getGraphDatabaseAPI();
expected.expect(BackupTool.ToolFailureException.class);
expected.expectMessage("Failed to perform backup because existing backup is from a different version.");
// Perform backup
backupTool.executeBackup(new HostnamePort("localhost", 6362), backupDir.toFile(), ConsistencyCheck.NONE, Config.defaults(), 20L * 60L * 1000L, false);
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class BackupToolTest method shouldIgnoreIncrementalFlag.
@Test
public void shouldIgnoreIncrementalFlag() throws Exception {
String[] args = new String[] { "-incremental", "-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 PortRangeSocketBinderTest method shouldReturnChannelAndSocketIfAnyPortsAreFree.
@Test
public void shouldReturnChannelAndSocketIfAnyPortsAreFree() {
// given
HostnamePort localhost = new HostnamePort("localhost", 9000, 9001);
ServerBootstrap bootstrap = mock(ServerBootstrap.class);
Channel channel = mock(Channel.class);
when(bootstrap.bind(new InetSocketAddress("localhost", 9000))).thenThrow(new ChannelException());
when(bootstrap.bind(new InetSocketAddress("localhost", 9001))).thenReturn(channel);
// when
Connection connection = new PortRangeSocketBinder(bootstrap).bindToFirstAvailablePortInRange(localhost);
//then
assertEquals(channel, connection.getChannel());
assertEquals(new InetSocketAddress(localhost.getHost(), 9001), connection.getSocketAddress());
}
use of org.neo4j.helpers.HostnamePort in project neo4j by neo4j.
the class PortRangeSocketBinderTest method shouldReThrowExceptionIfCannotBindToAnyOfThePortsInTheRange.
@Test
public void shouldReThrowExceptionIfCannotBindToAnyOfThePortsInTheRange() {
// given
HostnamePort localhost = new HostnamePort("localhost", 9000, 9002);
ServerBootstrap bootstrap = mock(ServerBootstrap.class);
when(bootstrap.bind(new InetSocketAddress("localhost", 9000))).thenThrow(new ChannelException("Failed to bind to: 9000"));
when(bootstrap.bind(new InetSocketAddress("localhost", 9001))).thenThrow(new ChannelException("Failed to bind to: 9001"));
when(bootstrap.bind(new InetSocketAddress("localhost", 9002))).thenThrow(new ChannelException("Failed to bind to: 9002"));
try {
// when
new PortRangeSocketBinder(bootstrap).bindToFirstAvailablePortInRange(localhost);
fail("should have thrown ChannelException");
} catch (ChannelException ex) {
// expected
assertEquals(2, suppressedExceptions(ex));
}
}
Aggregations