Search in sources :

Example 6 with HostnamePort

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");
}
Also used : PrintStream(java.io.PrintStream) Config(org.neo4j.kernel.configuration.Config) HostnamePort(org.neo4j.helpers.HostnamePort) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 7 with HostnamePort

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");
}
Also used : PrintStream(java.io.PrintStream) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) HostnamePort(org.neo4j.helpers.HostnamePort) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 8 with HostnamePort

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");
}
Also used : PrintStream(java.io.PrintStream) Config(org.neo4j.kernel.configuration.Config) HostnamePort(org.neo4j.helpers.HostnamePort) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 9 with HostnamePort

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");
}
Also used : PrintStream(java.io.PrintStream) Config(org.neo4j.kernel.configuration.Config) HostnamePort(org.neo4j.helpers.HostnamePort) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 10 with HostnamePort

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);
    }
}
Also used : HashMap(java.util.HashMap) HostnamePort(org.neo4j.helpers.HostnamePort) Test(org.junit.Test)

Aggregations

HostnamePort (org.neo4j.helpers.HostnamePort)41 Test (org.junit.Test)29 File (java.io.File)9 Config (org.neo4j.kernel.configuration.Config)9 URI (java.net.URI)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Cluster (org.neo4j.cluster.protocol.cluster.Cluster)6 PrintStream (java.io.PrintStream)5 InetSocketAddress (java.net.InetSocketAddress)5 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)5 Matchers.anyString (org.mockito.Matchers.anyString)5 DefaultSlaveFactory (org.neo4j.kernel.ha.com.master.DefaultSlaveFactory)5 HashMap (java.util.HashMap)4 SocketConnection (org.neo4j.bolt.v1.transport.socket.client.SocketConnection)4 SlaveFactory (org.neo4j.kernel.ha.com.master.SlaveFactory)4 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)4 InputStream (java.io.InputStream)3 Socket (java.net.Socket)3 Channel (org.jboss.netty.channel.Channel)3 ChannelException (org.jboss.netty.channel.ChannelException)3