Java 类org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
        InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("endpoints.jmx.domain", "test-domain");
    environment.setProperty("endpoints.jmx.unique_names", "true");
    environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
    this.context = new AnnotationConfigApplicationContext();
    this.context.setEnvironment(environment);
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.refresh();
    this.context.getBean(EndpointMBeanExporter.class);

    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
            getObjectName("test-domain", "healthEndpoint", this.context).toString()
                    + ",key1=value1,key2=value2"))).isNotNull();
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
        InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("endpoints.jmx.domain", "test-domain");
    environment.setProperty("endpoints.jmx.unique_names", "true");
    environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
    this.context = new AnnotationConfigApplicationContext();
    this.context.setEnvironment(environment);
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.refresh();
    this.context.getBean(EndpointMBeanExporter.class);

    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
            getObjectName("test-domain", "healthEndpoint", this.context).toString()
                    + ",key1=value1,key2=value2"))).isNotNull();
}
项目:contestparser    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
        InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("endpoints.jmx.domain", "test-domain");
    environment.setProperty("endpoints.jmx.unique_names", "true");
    environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
    this.context = new AnnotationConfigApplicationContext();
    this.context.setEnvironment(environment);
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.refresh();
    this.context.getBean(EndpointMBeanExporter.class);

    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);

    assertNotNull(mbeanExporter.getServer()
            .getMBeanInfo(ObjectNameManager.getInstance(
                    getObjectName("test-domain", "healthEndpoint", this.context)
                            .toString() + ",key1=value1,key2=value2")));
}
项目:eiffel-remrem-publish    文件:SpringLoggingInitializer.java   
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    Class[] loggers = {SpringApplication.class, /*App.class,*/ ConfigFileApplicationListener.class, EndpointMBeanExporter.class,
            AutoConfigurationReportLoggingInitializer.class};
    Logger log = (Logger) LoggerFactory.getLogger("ROOT");
    log.setLevel(Level.ERROR);
    for (Class logger : loggers) {
        log = (Logger) LoggerFactory.getLogger(logger);
        log.setLevel(Level.ERROR);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfiguration.java   
@Bean
public EndpointMBeanExporter endpointMBeanExporter(MBeanServer server) {
    EndpointMBeanExporter mbeanExporter = new EndpointMBeanExporter(
            this.objectMapper);
    String domain = this.properties.getDomain();
    if (StringUtils.hasText(domain)) {
        mbeanExporter.setDomain(domain);
    }
    mbeanExporter.setServer(server);
    mbeanExporter.setEnsureUniqueRuntimeObjectNames(this.properties.isUniqueNames());
    mbeanExporter.setObjectNameStaticProperties(this.properties.getStaticNames());
    return mbeanExporter;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null)).isNotEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsNotInstalledIfManagedResource()
        throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            ManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource()
        throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test(expected = NoSuchBeanDefinitionException.class)
public void testEndpointMBeanExporterIsNotInstalled() {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("endpoints.jmx.enabled", "false");
    this.context = new AnnotationConfigApplicationContext();
    this.context.setEnvironment(environment);
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.refresh();
    this.context.getBean(EndpointMBeanExporter.class);
}
项目:eiffel-remrem-generate    文件:SpringLoggingInitializer.java   
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    Class[] loggers = { SpringApplication.class, App.class, ConfigFileApplicationListener.class,
            EndpointMBeanExporter.class, AutoConfigurationReportLoggingInitializer.class };
    Logger log = (Logger) LoggerFactory.getLogger("ROOT");
    log.setLevel(Level.ERROR);
    for (Class logger : loggers) {
        log = (Logger) LoggerFactory.getLogger(logger);
        log.setLevel(Level.ERROR);
    }
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfiguration.java   
@Bean
public EndpointMBeanExporter endpointMBeanExporter(MBeanServer server) {
    EndpointMBeanExporter mbeanExporter = new EndpointMBeanExporter(
            this.objectMapper);
    String domain = this.properties.getDomain();
    if (StringUtils.hasText(domain)) {
        mbeanExporter.setDomain(domain);
    }
    mbeanExporter.setServer(server);
    mbeanExporter.setEnsureUniqueRuntimeObjectNames(this.properties.isUniqueNames());
    mbeanExporter.setObjectNameStaticProperties(this.properties.getStaticNames());
    return mbeanExporter;
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null)).isNotEmpty();
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsNotInstalledIfManagedResource()
        throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            ManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource()
        throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(EndpointMBeanExporter.class)).isNotNull();
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
    assertThat(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null)).isEmpty();
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test(expected = NoSuchBeanDefinitionException.class)
public void testEndpointMBeanExporterIsNotInstalled() {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("endpoints.jmx.enabled", "false");
    this.context = new AnnotationConfigApplicationContext();
    this.context.setEnvironment(environment);
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.refresh();
    this.context.getBean(EndpointMBeanExporter.class);
}
项目:contestparser    文件:EndpointMBeanExportAutoConfiguration.java   
@Bean
public EndpointMBeanExporter endpointMBeanExporter(MBeanServer server) {
    EndpointMBeanExporter mbeanExporter = new EndpointMBeanExporter(
            this.objectMapper);
    String domain = this.properties.getDomain();
    if (StringUtils.hasText(domain)) {
        mbeanExporter.setDomain(domain);
    }
    mbeanExporter.setServer(server);
    mbeanExporter.setEnsureUniqueRuntimeObjectNames(this.properties.isUniqueNames());
    mbeanExporter.setObjectNameStaticProperties(this.properties.getStaticNames());
    return mbeanExporter;
}
项目:contestparser    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsInstalled() throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertNotNull(this.context.getBean(EndpointMBeanExporter.class));
    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);

    assertFalse(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null).isEmpty());
}
项目:contestparser    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsNotInstalledIfManagedResource()
        throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            ManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertNotNull(this.context.getBean(EndpointMBeanExporter.class));

    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);

    assertTrue(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null).isEmpty());
}
项目:contestparser    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterIsNotInstalledIfNestedInManagedResource()
        throws Exception {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(TestConfiguration.class, JmxAutoConfiguration.class,
            NestedInManagedEndpoint.class, EndpointMBeanExportAutoConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    assertNotNull(this.context.getBean(EndpointMBeanExporter.class));

    MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);

    assertTrue(mbeanExporter.getServer()
            .queryNames(getObjectName("*", "*,*", this.context), null).isEmpty());
}
项目:contestparser    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test(expected = NoSuchBeanDefinitionException.class)
public void testEndpointMBeanExporterIsNotInstalled() {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("endpoints.jmx.enabled", "false");
    this.context = new AnnotationConfigApplicationContext();
    this.context.setEnvironment(environment);
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.refresh();
    this.context.getBean(EndpointMBeanExporter.class);
    fail();
}