Search in sources :

Example 76 with HighlyAvailableGraphDatabase

use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.

the class MasterInfoServiceTest method slaveShouldRespond404AndUNKNOWNWhenUnknown.

@Test
public void slaveShouldRespond404AndUNKNOWNWhenUnknown() throws Exception {
    // given
    HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
    when(database.role()).thenReturn("unknown");
    MasterInfoService service = new MasterInfoService(null, database);
    // when
    Response response = service.isSlave();
    // then
    assertEquals(404, response.getStatus());
    assertEquals("UNKNOWN", String.valueOf(response.getEntity()));
}
Also used : Response(javax.ws.rs.core.Response) HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) Test(org.junit.Test)

Example 77 with HighlyAvailableGraphDatabase

use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.

the class MasterInfoServiceTest method masterShouldRespond404AndFalseWhenSlave.

@Test
public void masterShouldRespond404AndFalseWhenSlave() throws Exception {
    // given
    HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
    when(database.role()).thenReturn("slave");
    MasterInfoService service = new MasterInfoService(null, database);
    // when
    Response response = service.isMaster();
    // then
    assertEquals(404, response.getStatus());
    assertEquals("false", String.valueOf(response.getEntity()));
}
Also used : Response(javax.ws.rs.core.Response) HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) Test(org.junit.Test)

Example 78 with HighlyAvailableGraphDatabase

use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.

the class MasterInfoServiceTest method shouldReportNonMasterOrSlaveAsUnavailableForTransactionProcessing.

@Test
public void shouldReportNonMasterOrSlaveAsUnavailableForTransactionProcessing() throws Exception {
    // given
    HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
    when(database.role()).thenReturn("unknown");
    MasterInfoService service = new MasterInfoService(null, database);
    // when
    Response response = service.isAvailable();
    // then
    assertEquals(404, response.getStatus());
    assertEquals("UNKNOWN", String.valueOf(response.getEntity()));
}
Also used : Response(javax.ws.rs.core.Response) HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) Test(org.junit.Test)

Example 79 with HighlyAvailableGraphDatabase

use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.

the class MasterInfoServiceTest method slaveShouldRespond404AndFalseWhenMaster.

@Test
public void slaveShouldRespond404AndFalseWhenMaster() throws Exception {
    // given
    HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
    when(database.role()).thenReturn("master");
    MasterInfoService service = new MasterInfoService(null, database);
    // when
    Response response = service.isSlave();
    // then
    assertEquals(404, response.getStatus());
    assertEquals("false", String.valueOf(response.getEntity()));
}
Also used : Response(javax.ws.rs.core.Response) HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) Test(org.junit.Test)

Example 80 with HighlyAvailableGraphDatabase

use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.

the class MasterInfoServiceTest method slaveShouldRespond200AndTrueWhenSlave.

@Test
public void slaveShouldRespond200AndTrueWhenSlave() throws Exception {
    // given
    HighlyAvailableGraphDatabase database = mock(HighlyAvailableGraphDatabase.class);
    when(database.role()).thenReturn("slave");
    MasterInfoService service = new MasterInfoService(null, database);
    // when
    Response response = service.isSlave();
    // then
    assertEquals(200, response.getStatus());
    assertEquals("true", String.valueOf(response.getEntity()));
}
Also used : Response(javax.ws.rs.core.Response) HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) Test(org.junit.Test)

Aggregations

HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)80 Test (org.junit.Test)68 Transaction (org.neo4j.graphdb.Transaction)38 ClusterManager (org.neo4j.kernel.impl.ha.ClusterManager)24 Node (org.neo4j.graphdb.Node)22 ManagedCluster (org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster)16 File (java.io.File)12 InstanceId (org.neo4j.cluster.InstanceId)10 Response (javax.ws.rs.core.Response)9 CountDownLatch (java.util.concurrent.CountDownLatch)8 TransientTransactionFailureException (org.neo4j.graphdb.TransientTransactionFailureException)5 TestHighlyAvailableGraphDatabaseFactory (org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory)5 RepairKit (org.neo4j.kernel.impl.ha.ClusterManager.RepairKit)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 ClusterClient (org.neo4j.cluster.client.ClusterClient)4 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)4 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)4 IOException (java.io.IOException)3 URI (java.net.URI)3 ExecutionException (java.util.concurrent.ExecutionException)3