@Test public void testAssignProperty() throws Exception { PropertyDescriptor pDesc; pDesc = ConnectionPoolFactory.assignProperty("foo", dataSource, "dataSourceName", "foo"); Assert.assertTrue(pDesc != null); Assert.assertTrue("dataSourceName".equals(pDesc.getName())); Assert.assertTrue("foo".equals(dataSource.getDataSourceName())); Throwable exceptionThrown = null; try { ConnectionPoolFactory.assignProperty("foo", dataSource, null, "foo"); } catch (Exception e) { exceptionThrown = e; } Assert.assertTrue(exceptionThrown != null); Assert.assertTrue(exceptionThrown.getMessage().contains("not valid")); pDesc = ConnectionPoolFactory.assignProperty("foo", dataSource, "crap", "foo"); Assert.assertTrue(pDesc == null); exceptionThrown = null; try { ConnectionPoolFactory.assignProperty("foo", dataSource, "jdbcConnectionProperties", "foo"); } catch (Exception e) { exceptionThrown = e; } Assert.assertTrue(exceptionThrown != null); String trace = ExceptionUtils.getStackTrace(exceptionThrown); Assert.assertTrue(trace.contains("java.util.Map")); }
protected static PropertyDescriptor assignProperty( String dataSourceName, Object poolRelatedBean, String propName, String propValue) { PropertyDescriptor pDesc = null; try { pDesc = PropertyUtils.getPropertyDescriptor(poolRelatedBean, propName); } catch (Exception e) { throw new MonetaException("Connection pool property not valid") .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } if (pDesc == null) { return null; } try { PropertyUtils.setProperty(poolRelatedBean, propName, ValueNormalizationUtil.convertString( pDesc.getPropertyType(), propValue)); } catch (Exception e) { throw new MonetaException("Error setting connection pool property", e) .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } return pDesc; }
ConnectionPoolFactory { protected static PropertyDescriptor assignProperty( String dataSourceName, Object poolRelatedBean, String propName, String propValue) { PropertyDescriptor pDesc = null; try { pDesc = PropertyUtils.getPropertyDescriptor(poolRelatedBean, propName); } catch (Exception e) { throw new MonetaException("Connection pool property not valid") .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } if (pDesc == null) { return null; } try { PropertyUtils.setProperty(poolRelatedBean, propName, ValueNormalizationUtil.convertString( pDesc.getPropertyType(), propValue)); } catch (Exception e) { throw new MonetaException("Error setting connection pool property", e) .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } return pDesc; } }
ConnectionPoolFactory { protected static PropertyDescriptor assignProperty( String dataSourceName, Object poolRelatedBean, String propName, String propValue) { PropertyDescriptor pDesc = null; try { pDesc = PropertyUtils.getPropertyDescriptor(poolRelatedBean, propName); } catch (Exception e) { throw new MonetaException("Connection pool property not valid") .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } if (pDesc == null) { return null; } try { PropertyUtils.setProperty(poolRelatedBean, propName, ValueNormalizationUtil.convertString( pDesc.getPropertyType(), propValue)); } catch (Exception e) { throw new MonetaException("Error setting connection pool property", e) .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } return pDesc; }  }
ConnectionPoolFactory { protected static PropertyDescriptor assignProperty( String dataSourceName, Object poolRelatedBean, String propName, String propValue) { PropertyDescriptor pDesc = null; try { pDesc = PropertyUtils.getPropertyDescriptor(poolRelatedBean, propName); } catch (Exception e) { throw new MonetaException("Connection pool property not valid") .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } if (pDesc == null) { return null; } try { PropertyUtils.setProperty(poolRelatedBean, propName, ValueNormalizationUtil.convertString( pDesc.getPropertyType(), propValue)); } catch (Exception e) { throw new MonetaException("Error setting connection pool property", e) .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } return pDesc; }  static ObjectPool<PoolableConnection> createConnectionPool(MonetaDataSource dataSourceType); }
ConnectionPoolFactory { protected static PropertyDescriptor assignProperty( String dataSourceName, Object poolRelatedBean, String propName, String propValue) { PropertyDescriptor pDesc = null; try { pDesc = PropertyUtils.getPropertyDescriptor(poolRelatedBean, propName); } catch (Exception e) { throw new MonetaException("Connection pool property not valid") .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } if (pDesc == null) { return null; } try { PropertyUtils.setProperty(poolRelatedBean, propName, ValueNormalizationUtil.convertString( pDesc.getPropertyType(), propValue)); } catch (Exception e) { throw new MonetaException("Error setting connection pool property", e) .addContextValue("Data source name", dataSourceName) .addContextValue("Property name", propName); } return pDesc; }  static ObjectPool<PoolableConnection> createConnectionPool(MonetaDataSource dataSourceType);  }