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

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSources() {
    load(MultipleDataSourcesConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.tomcat.active", "datasource.tomcat.usage",
            "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");

    // Hikari won't work unless a first connection has been retrieved
    JdbcTemplate jdbcTemplate = new JdbcTemplate(
            this.context.getBean("hikariDS", DataSource.class));
    jdbcTemplate.execute(new ConnectionCallback<Void>() {
        @Override
        public Void doInConnection(Connection connection)
                throws SQLException, DataAccessException {
            return null;
        }
    });

    Collection<Metric<?>> anotherMetrics = bean.metrics();
    assertMetrics(anotherMetrics, "datasource.tomcat.active",
            "datasource.tomcat.usage", "datasource.hikariDS.active",
            "datasource.hikariDS.usage", "datasource.commonsDbcp.active",
            "datasource.commonsDbcp.usage");
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSources() {
    load(MultipleDataSourcesConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.tomcat.active", "datasource.tomcat.usage",
            "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");

    // Hikari won't work unless a first connection has been retrieved
    JdbcTemplate jdbcTemplate = new JdbcTemplate(
            this.context.getBean("hikariDS", DataSource.class));
    jdbcTemplate.execute(new ConnectionCallback<Void>() {
        @Override
        public Void doInConnection(Connection connection)
                throws SQLException, DataAccessException {
            return null;
        }
    });

    Collection<Metric<?>> anotherMetrics = bean.metrics();
    assertMetrics(anotherMetrics, "datasource.tomcat.active",
            "datasource.tomcat.usage", "datasource.hikariDS.active",
            "datasource.hikariDS.usage", "datasource.commonsDbcp.active",
            "datasource.commonsDbcp.usage");
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSources() {
    load(MultipleDataSourcesConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.tomcat.active", "datasource.tomcat.usage",
            "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");

    // Hikari won't work unless a first connection has been retrieved
    JdbcTemplate jdbcTemplate = new JdbcTemplate(
            this.context.getBean("hikariDS", DataSource.class));
    jdbcTemplate.execute(new ConnectionCallback<Void>() {
        @Override
        public Void doInConnection(Connection connection)
                throws SQLException, DataAccessException {
            return null;
        }
    });

    Collection<Metric<?>> anotherMetrics = bean.metrics();
    assertMetrics(anotherMetrics, "datasource.tomcat.active",
            "datasource.tomcat.usage", "datasource.hikariDS.active",
            "datasource.hikariDS.usage", "datasource.commonsDbcp.active",
            "datasource.commonsDbcp.usage");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void autoDataSource() {
    load(DataSourceAutoConfiguration.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSourcesWithPrimary() {
    load(MultipleDataSourcesWithPrimaryConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
            "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSourcesWithCustomPrimary() {
    load(MultipleDataSourcesWithCustomPrimaryConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
            "datasource.dataSource.active", "datasource.dataSource.usage");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void customPrefix() {
    load(MultipleDataSourcesWithPrimaryConfig.class,
            CustomDataSourcePublicMetrics.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "ds.first.active", "ds.first.usage", "ds.second.active",
            "ds.second.usage");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Bean
public DataSourcePublicMetrics myDataSourcePublicMetrics() {
    return new DataSourcePublicMetrics() {
        @Override
        protected String createPrefix(String dataSourceName,
                DataSource dataSource, boolean primary) {
            return (primary ? "ds.first." : "ds.second");
        }
    };
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void autoDataSource() {
    load(DataSourceAutoConfiguration.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage");
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSourcesWithPrimary() {
    load(MultipleDataSourcesWithPrimaryConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
            "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSourcesWithCustomPrimary() {
    load(MultipleDataSourcesWithCustomPrimaryConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
            "datasource.dataSource.active", "datasource.dataSource.usage");
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void customPrefix() {
    load(MultipleDataSourcesWithPrimaryConfig.class,
            CustomDataSourcePublicMetrics.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "ds.first.active", "ds.first.usage", "ds.second.active",
            "ds.second.usage");
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Bean
public DataSourcePublicMetrics myDataSourcePublicMetrics() {
    return new DataSourcePublicMetrics() {
        @Override
        protected String createPrefix(String dataSourceName,
                DataSource dataSource, boolean primary) {
            return (primary ? "ds.first." : "ds.second");
        }
    };
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void autoDataSource() {
    load(DataSourceAutoConfiguration.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage");
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSourcesWithPrimary() {
    load(MultipleDataSourcesWithPrimaryConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
            "datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void multipleDataSourcesWithCustomPrimary() {
    load(MultipleDataSourcesWithCustomPrimaryConfig.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
            "datasource.dataSource.active", "datasource.dataSource.usage");
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void customPrefix() {
    load(MultipleDataSourcesWithPrimaryConfig.class,
            CustomDataSourcePublicMetrics.class);
    PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
    Collection<Metric<?>> metrics = bean.metrics();
    assertMetrics(metrics, "ds.first.active", "ds.first.usage", "ds.second.active",
            "ds.second.usage");
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Bean
public DataSourcePublicMetrics myDataSourcePublicMetrics() {
    return new DataSourcePublicMetrics() {
        @Override
        protected String createPrefix(String dataSourceName,
                DataSource dataSource, boolean primary) {
            return (primary ? "ds.first." : "ds.second");
        }
    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(DataSourcePoolMetadataProvider.class)
public DataSourcePublicMetrics dataSourcePublicMetrics() {
    return new DataSourcePublicMetrics();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void noDataSource() {
    load();
    assertThat(this.context.getBeansOfType(DataSourcePublicMetrics.class)).isEmpty();
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(DataSourcePoolMetadataProvider.class)
public DataSourcePublicMetrics dataSourcePublicMetrics() {
    return new DataSourcePublicMetrics();
}
项目:spring-boot-concourse    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void noDataSource() {
    load();
    assertThat(this.context.getBeansOfType(DataSourcePublicMetrics.class)).isEmpty();
}
项目:contestparser    文件:PublicMetricsAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(DataSourcePoolMetadataProvider.class)
public DataSourcePublicMetrics dataSourcePublicMetrics() {
    return new DataSourcePublicMetrics();
}
项目:contestparser    文件:PublicMetricsAutoConfigurationTests.java   
@Test
public void noDataSource() {
    load();
    assertEquals(0,
            this.context.getBeansOfType(DataSourcePublicMetrics.class).size());
}