Java 类org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException 实例源码

项目:mot-automated-testsuite    文件:DataControllerTest.java   
/**
 * Tests the GET /dataset/uncached endpoint, for an other error.
 * @throws Exception    Test failed
 */
@Test
public void getUncachedDataset_OtherError() throws Exception {

    given(dataProvider.getUncachedDataset("ERROR_DATASET", 2))
            .willThrow(new DataSourceLookupFailureException("Fatal error!")); // example Spring runtime exception

    // should return 500 response with JSON respponse
    mvc.perform(get("/dataset/uncached/ERROR_DATASET/2").accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(status().isInternalServerError())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(content().string("{\"message\":\"Fatal error!\"}"));
}
项目:mot-automated-testsuite    文件:DataControllerTest.java   
/**
 * Tests the GET /entry/uncached endpoint, for an other error.
 * @throws Exception    Test failed
 */
@Test
public void getUncachedDatasetEntry_OtherError() throws Exception {

    given(dataProvider.getUncachedDatasetEntry("ERROR_DATASET"))
            .willThrow(new DataSourceLookupFailureException("Fatal error!")); // example Spring runtime exception

    // should return 500 response with JSON respponse
    mvc.perform(get("/entry/uncached/ERROR_DATASET").accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(status().isInternalServerError())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(content().string("{\"message\":\"Fatal error!\"}"));
}
项目:mot-automated-testsuite    文件:DataControllerTest.java   
/**
 * Tests the GET /entry/cached endpoint, for an other error.
 * @throws Exception    Test failed
 */
@Test
public void getCachedDatasetEntry_OtherError() throws Exception {

    given(dataProvider.getCachedDatasetEntry("ERROR_DATASET"))
            .willThrow(new DataSourceLookupFailureException("Fatal error!")); // example Spring runtime exception

    // should return 500 response with JSON respponse
    mvc.perform(get("/entry/cached/ERROR_DATASET").accept(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(status().isInternalServerError())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(content().string("{\"message\":\"Fatal error!\"}"));
}
项目:keti    文件:AcsDbHealthIndicatorTest.java   
@DataProvider
public Object[][] statuses() {
    TitanMigrationManager happyMigrationManager = new TitanMigrationManager();
    TitanMigrationManager sadMigrationManager = new TitanMigrationManager();
    Whitebox.setInternalState(happyMigrationManager, IS_MIGRATION_COMPLETE_FIELD_NAME, true);
    Whitebox.setInternalState(sadMigrationManager, IS_MIGRATION_COMPLETE_FIELD_NAME, false);

    return new Object[][] { new Object[] { mockDbWithUp(), Status.UP, AcsMonitoringUtilities.HealthCode.AVAILABLE,
            happyMigrationManager },

            { mockDbWithException(new TransientDataAccessResourceException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.UNAVAILABLE, happyMigrationManager },

            { mockDbWithException(new QueryTimeoutException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.UNAVAILABLE, happyMigrationManager },

            { mockDbWithException(new DataSourceLookupFailureException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.UNREACHABLE, happyMigrationManager },

            { mockDbWithException(new PermissionDeniedDataAccessException("", null)), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.MISCONFIGURATION, happyMigrationManager },

            { mockDbWithException(new ConcurrencyFailureException("")), Status.DOWN,
                    AcsMonitoringUtilities.HealthCode.ERROR, happyMigrationManager },

            { mockDbWithUp(), Status.DOWN, AcsMonitoringUtilities.HealthCode.MIGRATION_INCOMPLETE,
                    sadMigrationManager }, };
}
项目:security-stateless-samples    文件:QueryObjectGenericServImpl.java   
/**
 * Get Session
 *
 * @return session
 */
private Session obtainSession() {
    if (sessionFactory == null) {
        throw new DataSourceLookupFailureException("sessionFactory must not be empty or null");
    }
    return sessionFactory.getCurrentSession();

}
项目:gnext    文件:BaseDao.java   
/**
 * Sets the hibernate sessionFactory.
 * 
 * @param sessionFactory
 *            hibernate sessionFactory.
 */
@Resource
public void setSessionFactory(SessionFactory sessionFactory) {
    if(sessionFactory==null){
        throw new DataSourceLookupFailureException("sessionFactory must not be empty or null");
    }
    this.sessionFactory = sessionFactory;
}
项目:opennmszh    文件:DefaultTroubleTicketProxy.java   
private void send(Event e) {
    try {
        m_eventProxy.send(e);
    } catch (EventProxyException e1) {
        throw new DataSourceLookupFailureException("Unable to send event to eventd", e1);
    }
}
项目:opennmszh    文件:DefaultAdminCategoryService.java   
private void send(final Event e) {
    try {
        m_eventProxy.send(e);
    } catch (final EventProxyException e1) {
        throw new DataSourceLookupFailureException("Unable to send event to eventd", e1);
    }
}
项目:OpenNMS    文件:DefaultTroubleTicketProxy.java   
private void send(Event e) {
    try {
        m_eventProxy.send(e);
    } catch (EventProxyException e1) {
        throw new DataSourceLookupFailureException("Unable to send event to eventd", e1);
    }
}
项目:OpenNMS    文件:DefaultAdminCategoryService.java   
private void send(final Event e) {
    try {
        m_eventProxy.send(e);
    } catch (final EventProxyException e1) {
        throw new DataSourceLookupFailureException("Unable to send event to eventd", e1);
    }
}
项目:OrcidHub    文件:DatabaseConfiguration.java   
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingClass(name = "it.cineca.pst.huborcid.config.HerokuDatabaseConfiguration")
@Profile("!" + Constants.SPRING_PROFILE_CLOUD)
public DataSource dataSource() {
    log.debug("Configuring Datasource");
    if (dataSourcePropertyResolver.getProperty("url") == null && dataSourcePropertyResolver.getProperty("databaseName") == null) {
        log.error("Your database connection pool configuration is incorrect! The application" +
                " cannot start. Please check your Spring profile, current profiles are: {}",
                Arrays.toString(env.getActiveProfiles()));

        throw new ApplicationContextException("Database connection pool is not configured correctly");
    }
    HikariConfig config = new HikariConfig();
    if(StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("jndi"))){
     config.setDataSourceClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName"));
     if(StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("url"))) {
         config.addDataSourceProperty("databaseName", dataSourcePropertyResolver.getProperty("databaseName"));
         config.addDataSourceProperty("serverName", dataSourcePropertyResolver.getProperty("serverName"));
     } else {
         config.addDataSourceProperty("url", dataSourcePropertyResolver.getProperty("url"));
     }
     config.addDataSourceProperty("user", dataSourcePropertyResolver.getProperty("username"));
     config.addDataSourceProperty("password", dataSourcePropertyResolver.getProperty("password"));
     config.setConnectionTimeout(10000);
     config.setMaximumPoolSize(25);
    }else{
        final JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
        dataSourceLookup.setResourceRef(true);
        DataSource dataSourceTemp = null;
        try {
            dataSourceTemp = dataSourceLookup.getDataSource(dataSourcePropertyResolver.getProperty("jndi"));
        } catch (DataSourceLookupFailureException e) {
            log.error("DataSource not found.");
        }
        config.setDataSource(dataSourceTemp);
    }

    if (metricRegistry != null) {
        config.setMetricRegistry(metricRegistry);
    }
    return new HikariDataSource(config);
}