Java 类org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration 实例源码

项目: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();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:IntegrationAutoConfigurationTests.java   
@Test
public void parentContext() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JmxAutoConfiguration.class,
            IntegrationAutoConfiguration.class);
    this.context.refresh();
    AnnotationConfigApplicationContext parent = this.context;
    this.context = new AnnotationConfigApplicationContext();
    this.context.setParent(parent);
    this.context.register(JmxAutoConfiguration.class,
            IntegrationAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(HeaderChannelRegistry.class)).isNotNull();
    ((ConfigurableApplicationContext) this.context.getParent()).close();
    this.context.close();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
@Test
public void registerWithSimpleWebApp() throws Exception {
    this.context = new SpringApplicationBuilder()
            .sources(EmbeddedServletContainerAutoConfiguration.class,
                    ServerPropertiesAutoConfiguration.class,
                    DispatcherServletAutoConfiguration.class,
                    JmxAutoConfiguration.class,
                    SpringApplicationAdminJmxAutoConfiguration.class)
            .run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
    assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
    assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
            "EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
    int expected = ((EmbeddedWebApplicationContext) this.context)
            .getEmbeddedServletContainer().getPort();
    String actual = getProperty(createDefaultObjectName(), "local.server.port");
    assertThat(actual).isEqualTo(String.valueOf(expected));
}
项目: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();
}
项目:spring-boot-concourse    文件:IntegrationAutoConfigurationTests.java   
@Test
public void parentContext() {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JmxAutoConfiguration.class,
            IntegrationAutoConfiguration.class);
    this.context.refresh();
    AnnotationConfigApplicationContext parent = this.context;
    this.context = new AnnotationConfigApplicationContext();
    this.context.setParent(parent);
    this.context.register(JmxAutoConfiguration.class,
            IntegrationAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(HeaderChannelRegistry.class)).isNotNull();
    ((ConfigurableApplicationContext) this.context.getParent()).close();
    this.context.close();
}
项目:spring-boot-concourse    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
@Test
public void registerWithSimpleWebApp() throws Exception {
    this.context = new SpringApplicationBuilder()
            .sources(EmbeddedServletContainerAutoConfiguration.class,
                    ServerPropertiesAutoConfiguration.class,
                    DispatcherServletAutoConfiguration.class,
                    JmxAutoConfiguration.class,
                    SpringApplicationAdminJmxAutoConfiguration.class)
            .run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
    assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
    assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
            "EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
    int expected = ((EmbeddedWebApplicationContext) this.context)
            .getEmbeddedServletContainer().getPort();
    String actual = getProperty(createDefaultObjectName(), "local.server.port");
    assertThat(actual).isEqualTo(String.valueOf(expected));
}
项目: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")));
}
项目:contestparser    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
        InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);

    AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
    parent.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.setParent(parent);

    parent.refresh();
    this.context.refresh();

    parent.close();
}
项目:contestparser    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
@Test
public void registerWithSimpleWebApp() throws Exception {
    this.context = new SpringApplicationBuilder()
            .sources(EmbeddedServletContainerAutoConfiguration.class,
                    ServerPropertiesAutoConfiguration.class,
                    DispatcherServletAutoConfiguration.class,
                    JmxAutoConfiguration.class,
                    SpringApplicationAdminJmxAutoConfiguration.class)
            .run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
    assertTrue(this.context instanceof EmbeddedWebApplicationContext);
    assertEquals(true, this.mBeanServer.getAttribute(createDefaultObjectName(),
            "EmbeddedWebApplication"));
    int expected = ((EmbeddedWebApplicationContext) this.context)
            .getEmbeddedServletContainer().getPort();
    String actual = getProperty(createDefaultObjectName(), "local.server.port");
    assertEquals(String.valueOf(expected), actual);
}
项目: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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
        InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
    parent.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.setParent(parent);
    parent.refresh();
    this.context.refresh();
    parent.close();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:IntegrationAutoConfigurationTests.java   
private void load(Class<?> config, String... environment) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    if (config != null) {
        ctx.register(config);
    }
    TestPropertySourceUtils.addInlinedPropertiesToEnvironment(ctx, environment);
    ctx.register(JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
    ctx.refresh();
    this.context = ctx;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
private void load(String... environment) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(applicationContext, environment);
    applicationContext.register(JmxAutoConfiguration.class,
            SpringApplicationAdminJmxAutoConfiguration.class);
    applicationContext.refresh();
    this.context = applicationContext;
}
项目: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);
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfigurationTests.java   
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
        InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
    parent.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
            EndpointMBeanExportAutoConfiguration.class);
    this.context.setParent(parent);
    parent.refresh();
    this.context.refresh();
    parent.close();
}
项目:spring-boot-concourse    文件:IntegrationAutoConfigurationTests.java   
private void load(String... environment) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    TestPropertySourceUtils.addInlinedPropertiesToEnvironment(ctx, environment);
    ctx.register(JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
    ctx.refresh();
    this.context = ctx;
}
项目:spring-boot-concourse    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
private void load(String... environment) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(applicationContext, environment);
    applicationContext.register(JmxAutoConfiguration.class,
            SpringApplicationAdminJmxAutoConfiguration.class);
    applicationContext.refresh();
    this.context = applicationContext;
}
项目: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();
}
项目:contestparser    文件:IntegrationAutoConfigurationTests.java   
@Test
public void addJmxAuto() {
    this.context.register(JmxAutoConfiguration.class,
            IntegrationAutoConfiguration.class);
    this.context.refresh();
    assertNotNull(this.context.getBean(HeaderChannelRegistry.class));
    this.context.close();
}
项目:contestparser    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
private void load(String... environment) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
    EnvironmentTestUtils.addEnvironment(applicationContext, environment);
    applicationContext.register(JmxAutoConfiguration.class,
            SpringApplicationAdminJmxAutoConfiguration.class);
    applicationContext.refresh();
    this.context = applicationContext;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointMBeanExportAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(MBeanServer.class)
public MBeanServer mbeanServer() {
    return new JmxAutoConfiguration().mbeanServer();
}
项目:spring-boot-concourse    文件:EndpointMBeanExportAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(MBeanServer.class)
public MBeanServer mbeanServer() {
    return new JmxAutoConfiguration().mbeanServer();
}
项目:contestparser    文件:EndpointMBeanExportAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(MBeanServer.class)
public MBeanServer mbeanServer() {
    return new JmxAutoConfiguration().mbeanServer();
}
项目:contestparser    文件:IntegrationAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean(MBeanServer.class)
public MBeanServer mbeanServer() {
    return new JmxAutoConfiguration().mbeanServer();
}