@Override protected Object getOptionalValue(Environment source, String name) { Object result = source.getProperty(name); if (result != null) { result = ((EnvironmentEndpoint) getDelegate()).sanitize(name, result); } return result; }
@Override protected Object getValue(Environment source, String name) { String result = source.getProperty(name); if (result == null) { throw new NoSuchPropertyException("No such property: " + name); } return ((EnvironmentEndpoint) getDelegate()).sanitize(name, result); }
@Test public void endpoints() throws Exception { load(EndpointAutoConfiguration.class); assertThat(this.context.getBean(BeansEndpoint.class)).isNotNull(); assertThat(this.context.getBean(DumpEndpoint.class)).isNotNull(); assertThat(this.context.getBean(EnvironmentEndpoint.class)).isNotNull(); assertThat(this.context.getBean(HealthEndpoint.class)).isNotNull(); assertThat(this.context.getBean(InfoEndpoint.class)).isNotNull(); assertThat(this.context.getBean(MetricsEndpoint.class)).isNotNull(); assertThat(this.context.getBean(ShutdownEndpoint.class)).isNotNull(); assertThat(this.context.getBean(TraceEndpoint.class)).isNotNull(); assertThat(this.context.getBean(RequestMappingEndpoint.class)).isNotNull(); }
@Before public void setUp() { this.context.getBean(EnvironmentEndpoint.class).setEnabled(true); this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build(); EnvironmentTestUtils.addEnvironment((ConfigurableApplicationContext) this.context, "foo:bar", "fool:baz"); }
@Test public void endpoints() throws Exception { load(EndpointAutoConfiguration.class); assertNotNull(this.context.getBean(BeansEndpoint.class)); assertNotNull(this.context.getBean(DumpEndpoint.class)); assertNotNull(this.context.getBean(EnvironmentEndpoint.class)); assertNotNull(this.context.getBean(HealthEndpoint.class)); assertNotNull(this.context.getBean(InfoEndpoint.class)); assertNotNull(this.context.getBean(MetricsEndpoint.class)); assertNotNull(this.context.getBean(ShutdownEndpoint.class)); assertNotNull(this.context.getBean(TraceEndpoint.class)); assertNotNull(this.context.getBean(RequestMappingEndpoint.class)); }
public EnvironmentService(EnvironmentEndpoint endpoint) { this.endpoint = endpoint; }
@Bean @ConditionalOnBean(EnvironmentEndpoint.class) @ConditionalOnEnabledEndpoint("env") public EnvironmentMvcEndpoint environmentMvcEndpoint(EnvironmentEndpoint delegate) { return new EnvironmentMvcEndpoint(delegate); }
@Bean @ConditionalOnMissingBean public EnvironmentEndpoint environmentEndpoint() { return new EnvironmentEndpoint(); }
public EnvironmentMvcEndpoint(EnvironmentEndpoint delegate) { super(delegate); }
@Test public void subWhenDisabled() throws Exception { this.context.getBean(EnvironmentEndpoint.class).setEnabled(false); this.mvc.perform(get("/env/foo")).andExpect(status().isNotFound()); }
@Bean public EnvironmentEndpoint endpoint() { return new EnvironmentEndpoint(); }
@Bean public EnvironmentEndpoint environmentEndpoint() { return new LimitedEnvironmentEndpoint(); }