当前位置: 首页>>代码示例>>Java>>正文


Java Builder.build方法代码示例

本文整理汇总了Java中org.springframework.boot.actuate.health.Health.Builder.build方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.build方法的具体用法?Java Builder.build怎么用?Java Builder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.boot.actuate.health.Health.Builder的用法示例。


在下文中一共展示了Builder.build方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDoHealthCheckSingleQueueCheckMetricException

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Test
public void testDoHealthCheckSingleQueueCheckMetricException() throws Exception
{
    Queue queue = generateQueue("test");
    healthIndicator.addQueueCheck(queue, 10000, 2);

    propertiesManager.request(queue);
    PowerMock.expectLastCall().andThrow(new RuntimeException());

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.DOWN, health.getStatus());
    Assert.assertNull(health.getDetails().get("test"));
}
 
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:19,代码来源:RabbitQueueCheckHealthIndicatorTest.java

示例2: health

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
public Health health() {

	try {

		VaultHealth vaultHealthResponse = vaultOperations.opsForSys().health();

		Builder healthBuilder = getHealthBuilder(vaultHealthResponse);

		if (StringUtils.hasText(vaultHealthResponse.getVersion())) {
			healthBuilder = healthBuilder.withDetail("version",
					vaultHealthResponse.getVersion());
		}

		return healthBuilder.build();
	}
	catch (Exception e) {
		return Health.down(e).build();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-vault,代码行数:21,代码来源:VaultHealthIndicator.java

示例3: testDoHealthCheckSingleQueueCheckUp

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "boxing" })
@Test
public void testDoHealthCheckSingleQueueCheckUp() throws Exception
{
    Queue queue = generateQueue("test");
    healthIndicator.addQueueCheck(queue, 10000, 2);

    RabbitQueueProperties properties = new RabbitQueueProperties();
    properties.setConsumerCount(4);
    properties.setMessageCount(5883);
    propertiesManager.request(queue);
    PowerMock.expectLastCall().andReturn(properties);

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.UP, health.getStatus());
    Assert.assertNotNull(health.getDetails().get("test"));
    Map<String, Object> details = (Map<String, Object>) health.getDetails().get("test");
    Assert.assertEquals(Status.UP.getCode(), details.get("status"));
    Assert.assertEquals(5883, details.get("currentMessageCount"));
    Assert.assertEquals(10000, details.get("maxMessageCount"));
    Assert.assertEquals(4, details.get("currentConsumerCount"));
    Assert.assertEquals(2, details.get("minConsumerCount"));
}
 
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:29,代码来源:RabbitQueueCheckHealthIndicatorTest.java

示例4: testDoHealthCheckSingleQueueCheckQueueSizeDown

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "boxing" })
@Test
public void testDoHealthCheckSingleQueueCheckQueueSizeDown() throws Exception
{
    Queue queue = generateQueue("test");
    healthIndicator.addQueueCheck(queue, 10000, 2);

    RabbitQueueProperties properties = new RabbitQueueProperties();
    properties.setConsumerCount(4);
    properties.setMessageCount(15883);
    propertiesManager.request(queue);
    PowerMock.expectLastCall().andReturn(properties);

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.DOWN, health.getStatus());
    Assert.assertNotNull(health.getDetails().get("test"));
    Map<String, Object> details = (Map<String, Object>) health.getDetails().get("test");
    Assert.assertEquals(Status.DOWN.getCode(), details.get("status"));
    Assert.assertEquals(15883, details.get("currentMessageCount"));
    Assert.assertEquals(10000, details.get("maxMessageCount"));
    Assert.assertEquals(4, details.get("currentConsumerCount"));
    Assert.assertEquals(2, details.get("minConsumerCount"));
}
 
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:29,代码来源:RabbitQueueCheckHealthIndicatorTest.java

示例5: testDoHealthCheckSingleQueueCheckConsumerDown

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "boxing" })
@Test
public void testDoHealthCheckSingleQueueCheckConsumerDown() throws Exception
{
    Queue queue = generateQueue("test");
    healthIndicator.addQueueCheck(queue, 10000, 2);

    RabbitQueueProperties properties = new RabbitQueueProperties();
    properties.setConsumerCount(1);
    properties.setMessageCount(5883);
    propertiesManager.request(queue);
    PowerMock.expectLastCall().andReturn(properties);

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.DOWN, health.getStatus());
    Assert.assertNotNull(health.getDetails().get("test"));
    Map<String, Object> details = (Map<String, Object>) health.getDetails().get("test");
    Assert.assertEquals(Status.DOWN.getCode(), details.get("status"));
    Assert.assertEquals(5883, details.get("currentMessageCount"));
    Assert.assertEquals(10000, details.get("maxMessageCount"));
    Assert.assertEquals(1, details.get("currentConsumerCount"));
    Assert.assertEquals(2, details.get("minConsumerCount"));
}
 
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:29,代码来源:RabbitQueueCheckHealthIndicatorTest.java

示例6: testDoHealthCheckMultipleQueueChecksOneUpOneDown

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "boxing" })
@Test
public void testDoHealthCheckMultipleQueueChecksOneUpOneDown() throws Exception
{
    Queue queue1 = generateQueue("test1");
    healthIndicator.addQueueCheck(queue1, 10000, 2);
    Queue queue2 = generateQueue("test2");
    healthIndicator.addQueueCheck(queue2, 40000, 5);

    RabbitQueueProperties properties1 = new RabbitQueueProperties();
    properties1.setConsumerCount(1);
    properties1.setMessageCount(15883);
    propertiesManager.request(queue1);
    PowerMock.expectLastCall().andReturn(properties1);

    RabbitQueueProperties properties2 = new RabbitQueueProperties();
    properties2.setConsumerCount(10);
    properties2.setMessageCount(5883);
    propertiesManager.request(queue2);
    PowerMock.expectLastCall().andReturn(properties2);

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.DOWN, health.getStatus());
    Assert.assertEquals(2, health.getDetails().size());

    Assert.assertNotNull(health.getDetails().get("test1"));
    Map<String, Object> details1 = (Map<String, Object>) health.getDetails().get("test1");
    Assert.assertEquals(Status.DOWN.getCode(), details1.get("status"));
    Assert.assertEquals(15883, details1.get("currentMessageCount"));
    Assert.assertEquals(10000, details1.get("maxMessageCount"));
    Assert.assertEquals(1, details1.get("currentConsumerCount"));
    Assert.assertEquals(2, details1.get("minConsumerCount"));

    Assert.assertNotNull(health.getDetails().get("test2"));
    Map<String, Object> details2 = (Map<String, Object>) health.getDetails().get("test2");
    Assert.assertEquals(Status.UP.getCode(), details2.get("status"));
    Assert.assertEquals(5883, details2.get("currentMessageCount"));
    Assert.assertEquals(40000, details2.get("maxMessageCount"));
    Assert.assertEquals(10, details2.get("currentConsumerCount"));
    Assert.assertEquals(5, details2.get("minConsumerCount"));
}
 
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:47,代码来源:RabbitQueueCheckHealthIndicatorTest.java


注:本文中的org.springframework.boot.actuate.health.Health.Builder.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。