org.springframework.boot.actuate.endpoint.EndpointId Java Examples
The following examples show how to use
org.springframework.boot.actuate.endpoint.EndpointId.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractEndpointTests.java From quickfixj-spring-boot-starter with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") void assertReadProperties(Class<?> testConfigClass) { load(testConfigClass, (discoverer) -> { Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints()); assertThat(endpoints).containsKey(endpointId); ExposableWebEndpoint endpoint = endpoints.get(endpointId); assertThat(endpoint.getOperations()).hasSize(1); WebOperation operation = endpoint.getOperations().iterator().next(); Object invoker = ReflectionTestUtils.getField(operation, "invoker"); assertThat(invoker).isInstanceOf(ReflectiveOperationInvoker.class); Map<String, Properties> properties = (Map<String, Properties>) ((ReflectiveOperationInvoker) invoker).invoke( new InvocationContext(mock(SecurityContext.class), Collections.emptyMap())); assertThat(properties).hasSize(1); }); }
Example #2
Source File: AbstractEndpointTests.java From quickfixj-spring-boot-starter with Apache License 2.0 | 6 votes |
private void load(Function<EndpointId, Long> timeToLive, PathMapper endpointPathMapper, Class<?> configuration, Consumer<WebEndpointDiscoverer> consumer) { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configuration)) { ConversionServiceParameterValueMapper parameterMapper = new ConversionServiceParameterValueMapper(DefaultConversionService.getSharedInstance()); EndpointMediaTypes mediaTypes = new EndpointMediaTypes( Collections.singletonList("application/json"), Collections.singletonList("application/json")); WebEndpointDiscoverer discoverer = new WebEndpointDiscoverer(context, parameterMapper, mediaTypes, Collections.singletonList(endpointPathMapper), Collections.singleton(new CachingOperationInvokerAdvisor(timeToLive)), Collections.emptyList()); consumer.accept(discoverer); } }
Example #3
Source File: SkipPatternConfigTest.java From java-spring-web with Apache License 2.0 | 6 votes |
private ExposableWebEndpoint createEndpoint(final String name) { return new ExposableWebEndpoint() { @Override public String getRootPath() { return name; } @Override public EndpointId getEndpointId() { return EndpointId.of(name); } @Override public boolean isEnableByDefault() { return false; } @Override public Collection<WebOperation> getOperations() { return null; } }; }
Example #4
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_preferIpAddress_serveraddress_missing() { instanceProperties.setPreferIp(true); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/application/alive"); publishApplicationReadyEvent(factory, 8080, null); Application app = factory.createApplication(); assertThat(app.getServiceUrl()).matches("http://\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}:8080/"); }
Example #5
Source File: ServletApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_servicePath() { servletContext.setContextPath("app"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); publishApplicationReadyEvent(factory, 80, null); instance.setServicePath("/servicePath/"); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":80/servicePath/app/actuator"); assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":80/servicePath/app/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":80/servicePath/app"); }
Example #6
Source File: ServletApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_servletPath() { when(dispatcherServletPath.getPrefix()).thenReturn("app"); servletContext.setContextPath("srv"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); publishApplicationReadyEvent(factory, 80, null); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":80/srv/app/actuator"); assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":80/srv/app/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":80/srv"); }
Example #7
Source File: ServletApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_contextPath() { servletContext.setContextPath("app"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); publishApplicationReadyEvent(factory, 80, null); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":80/app/actuator"); assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":80/app/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":80/app"); }
Example #8
Source File: ServletApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_contextPath_mgmtPortPath() { servletContext.setContextPath("app"); webEndpoint.setBasePath("/admin"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health"); publishApplicationReadyEvent(factory, 8080, 8081); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":8081/admin"); assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":8081/admin/health"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/app"); }
Example #9
Source File: ServletApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_contextPath_mgmtPath() { servletContext.setContextPath("app"); webEndpoint.setBasePath("/admin"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health"); publishApplicationReadyEvent(factory, 8080, null); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":8080/app/admin"); assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":8080/app/admin/health"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/app"); }
Example #10
Source File: CloudFoundryApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void should_use_service_base_uri() { when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); this.cfApplicationProperties.setUris(singletonList("application/Uppercase")); this.instanceProperties.setServiceBaseUrl("https://serviceBaseUrl"); Application app = this.factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("https://serviceBaseUrl/actuator"); assertThat(app.getHealthUrl()).isEqualTo("https://serviceBaseUrl/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("https://serviceBaseUrl/"); }
Example #11
Source File: CloudFoundryApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void should_use_application_uri() { when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); this.cfApplicationProperties.setUris(singletonList("application/Uppercase")); Application app = this.factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://application/Uppercase/actuator"); assertThat(app.getHealthUrl()).isEqualTo("http://application/Uppercase/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("http://application/Uppercase/"); }
Example #12
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_service_path() { instanceProperties.setServiceBaseUrl("http://service:80"); instanceProperties.setServicePath("app"); webEndpoint.setBasePath("/admin"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health"); Application app = factory.createApplication(); assertThat(app.getServiceUrl()).isEqualTo("http://service:80/app"); assertThat(app.getManagementUrl()).isEqualTo("http://service:80/app/admin"); assertThat(app.getHealthUrl()).isEqualTo("http://service:80/app/admin/health"); }
Example #13
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_service_baseUrl() { instanceProperties.setServiceBaseUrl("http://service:80"); webEndpoint.setBasePath("/admin"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health"); Application app = factory.createApplication(); assertThat(app.getServiceUrl()).isEqualTo("http://service:80/"); assertThat(app.getManagementUrl()).isEqualTo("http://service:80/admin"); assertThat(app.getHealthUrl()).isEqualTo("http://service:80/admin/health"); }
Example #14
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_all_baseUrls() { instanceProperties.setManagementBaseUrl("http://management:8090"); instanceProperties.setServiceBaseUrl("http://service:80"); webEndpoint.setBasePath("/admin"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health"); Application app = factory.createApplication(); assertThat(app.getServiceUrl()).isEqualTo("http://service:80/"); assertThat(app.getManagementUrl()).isEqualTo("http://management:8090/admin"); assertThat(app.getHealthUrl()).isEqualTo("http://management:8090/admin/health"); }
Example #15
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_preferIpAddress() throws UnknownHostException { instanceProperties.setPreferIp(true); server.setAddress(InetAddress.getByName("127.0.0.1")); management.setAddress(InetAddress.getByName("127.0.0.2")); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); publishApplicationReadyEvent(factory, 8080, 8081); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://127.0.0.2:8081/actuator"); assertThat(app.getHealthUrl()).isEqualTo("http://127.0.0.2:8081/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("http://127.0.0.1:8080/"); }
Example #16
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_preferIpAddress_managementaddress_missing() { instanceProperties.setPreferIp(true); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/application/alive"); publishApplicationReadyEvent(factory, 8080, 8081); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).matches("http://\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}:8081/actuator"); }
Example #17
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_ssl_management() { management.setSsl(new Ssl()); management.getSsl().setEnabled(true); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/alive"); publishApplicationReadyEvent(factory, 8080, 9090); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("https://" + getHostname() + ":9090/actuator"); assertThat(app.getHealthUrl()).isEqualTo("https://" + getHostname() + ":9090/actuator/alive"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/"); }
Example #18
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_ssl() { server.setSsl(new Ssl()); server.getSsl().setEnabled(true); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); publishApplicationReadyEvent(factory, 8080, null); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("https://" + getHostname() + ":8080/actuator"); assertThat(app.getHealthUrl()).isEqualTo("https://" + getHostname() + ":8080/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("https://" + getHostname() + ":8080/"); }
Example #19
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_default() { instanceProperties.setMetadata(singletonMap("instance", "test")); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health"); publishApplicationReadyEvent(factory, 8080, null); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":8080/actuator"); assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":8080/actuator/health"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/"); assertThat(app.getMetadata()).containsExactly(entry("contributor", "test"), entry("instance", "test")); }
Example #20
Source File: DefaultApplicationFactoryTest.java From spring-boot-admin with Apache License 2.0 | 5 votes |
@Test public void test_mgmtPortPath() { webEndpoint.setBasePath("/admin"); when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/alive"); publishApplicationReadyEvent(factory, 8080, 8081); Application app = factory.createApplication(); assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":8081/admin"); assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":8081/admin/alive"); assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/"); }
Example #21
Source File: DefaultApplicationFactory.java From spring-boot-admin with Apache License 2.0 | 5 votes |
protected String getHealthEndpointPath() { String health = pathMappedEndpoints.getPath(EndpointId.of("health")); if (StringUtils.hasText(health)) { return health; } String status = pathMappedEndpoints.getPath(EndpointId.of("status")); if (StringUtils.hasText(status)) { return status; } throw new IllegalStateException("Either health or status endpoint must be enabled!"); }
Example #22
Source File: AbstractEndpointTests.java From quickfixj-spring-boot-starter with Apache License 2.0 | 4 votes |
private Map<EndpointId, ExposableWebEndpoint> mapEndpoints(Collection<ExposableWebEndpoint> endpoints) { Map<EndpointId, ExposableWebEndpoint> endpointById = new HashMap<>(); endpoints.forEach((endpoint) -> endpointById.put(endpoint.getEndpointId(), endpoint)); return endpointById; }
Example #23
Source File: AbstractEndpointTests.java From quickfixj-spring-boot-starter with Apache License 2.0 | 4 votes |
private void load(Class<?> configuration, Consumer<WebEndpointDiscoverer> consumer) { this.load((id) -> null, EndpointId::toString, configuration, consumer); }
Example #24
Source File: AbstractEndpointTests.java From quickfixj-spring-boot-starter with Apache License 2.0 | 4 votes |
void assertActuatorEndpointNotLoaded(Class<?> testConfigClass) { load(testConfigClass, (discoverer) -> { Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints()); assertThat(endpoints).doesNotContainKey(endpointId); }); }
Example #25
Source File: AbstractEndpointTests.java From quickfixj-spring-boot-starter with Apache License 2.0 | 4 votes |
void assertActuatorEndpointLoaded(Class<?> testConfigClass) { load(testConfigClass, (discoverer) -> { Map<EndpointId, ExposableWebEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints()); assertThat(endpoints).containsOnlyKeys(endpointId); }); }
Example #26
Source File: AbstractEndpointTests.java From quickfixj-spring-boot-starter with Apache License 2.0 | 4 votes |
AbstractEndpointTests(EndpointId endpointId) { this.endpointId = endpointId; }