Package org.springframework.data.mongodb.core

Examples of org.springframework.data.mongodb.core.MongoTemplate.executeCommand()


    assertEquals("localhost", servers.get(1).getHost());
    assertEquals(10001, servers.get(0).getPort());
    assertEquals(10002, servers.get(1).getPort());

    MongoTemplate template = new MongoTemplate(mongo, "admin");
    CommandResult result = template.executeCommand("{replSetGetStatus : 1}");
    assertEquals("blort", result.getString("set"));
  }
}
View Full Code Here


  @Test
  public void mongoIsUp() throws Exception {
    CommandResult commandResult = mock(CommandResult.class);
    given(commandResult.getString("version")).willReturn("2.6.4");
    MongoTemplate mongoTemplate = mock(MongoTemplate.class);
    given(mongoTemplate.executeCommand("{ buildInfo: 1 }")).willReturn(commandResult);
    MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate);

    Health health = healthIndicator.health();
    assertEquals(Status.UP, health.getStatus());
    assertEquals("2.6.4", health.getDetails().get("version"));
View Full Code Here

  }

  @Test
  public void mongoIsDown() throws Exception {
    MongoTemplate mongoTemplate = mock(MongoTemplate.class);
    given(mongoTemplate.executeCommand("{ buildInfo: 1 }")).willThrow(
        new MongoException("Connection failed"));
    MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate);

    Health health = healthIndicator.health();
    assertEquals(Status.DOWN, health.getStatus());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.