/** * Test the driver properties when the username and the password is set on datasource. */ public void testDatabaseDriverPropertiesUserAndPasswordPropertySetsDataSourceUserAndPassword() { String driverPropertyString = "user=APP;password=egg;CreateDatabase=create"; String propertyString = DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("APP", ds.getUsername()); assertEquals("egg", ds.getPassword()); }
/** * Test that the {@link DatasourcePropertySet#CONNECTION_TYPE} property can define an XA * datasource. */ public void testXADataSourceIsXADataSource() { Properties props = new Properties(); props.setProperty(DatasourcePropertySet.CONNECTION_TYPE, ConfigurationEntryType.XA_DATASOURCE); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals("javax.sql.XADataSource", ds.getConnectionType()); assertEquals(TransactionSupport.XA_TRANSACTION, ds.getTransactionSupport()); }
/** * Test the setting of multiple properties delimited by a semicolon. */ public void testMultipleDriverPropertiesDelimitedBySemiColon() { Properties driverProperties = new Properties(); driverProperties.setProperty("user", "APP"); driverProperties.setProperty("CreateDatabase", "create"); String driverPropertyString = "user=APP;CreateDatabase=create"; String propertyString = DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals(driverProperties, ds.getConnectionProperties()); }
/** * Test that the {@link ConfigurationEntryType#JDBC_DRIVER} property is the driver. */ public void testDriverIsDriver() { Properties props = new Properties(); props .setProperty(DatasourcePropertySet.CONNECTION_TYPE, ConfigurationEntryType.JDBC_DRIVER); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals("java.sql.Driver", ds.getConnectionType()); }
/** * Test that the default value is driver. */ public void testDefaultIsDriver() { Properties props = new Properties(); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals("java.sql.Driver", ds.getConnectionType()); }
/** * Test the empty driver properties getter. */ public void testGetEmptyDriverProperties() { String propertyString = ""; String driverPropertyString = DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + propertyString; DataSource ds = dataSourceConverter.fromPropertyString(driverPropertyString); assertEquals(0, ds.getConnectionProperties().size()); }
/** * Test that the default mode is {@link TransactionSupport#NO_TRANSACTION}. */ public void testDefaultIsNoTransaction() { Properties props = new Properties(); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals(TransactionSupport.NO_TRANSACTION, ds.getTransactionSupport()); }
/** * Test an id with a Java column. */ public void testIdWithJavaColon() { String jndiName = "java:DataSource"; String propertyString = DatasourcePropertySet.JNDI_LOCATION + "=" + jndiName; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("DataSource", ds.getId()); } }
/** * Test the driver properties when the username is set on datasource. */ public void testDatabaseDriverPropertiesUsernamePropertySetsUserOnDataSource() { String driverPropertyString = "user=APP;CreateDatabase=create"; String propertyString = DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("APP", ds.getUsername()); }
/** * Test the driver properties when the password is set on datasource. */ public void testDatabaseDriverPropertiesPasswordPropertySetsPasswordOnDataSource() { String driverPropertyString = "password=egg;CreateDatabase=create"; String propertyString = DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("egg", ds.getPassword()); }
/** * Test an id with a dot. */ public void testIdWithADot() { String jndiName = "jdbc.DataSource"; String propertyString = DatasourcePropertySet.JNDI_LOCATION + "=" + jndiName; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("DataSource", ds.getId()); }
/** * Test an id without dots nor slashes. */ public void testIdWithoutDotsOrSlashes() { String jndiName = "DataSource"; String propertyString = DatasourcePropertySet.JNDI_LOCATION + "=" + jndiName; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals(jndiName, ds.getId()); }
/** * Test that the {@link TransactionSupport#LOCAL_TRANSACTION} mode is * {@link TransactionSupport#LOCAL_TRANSACTION}. */ public void testLocalTransactionIsLocalTransaction() { Properties props = new Properties(); props.setProperty(DatasourcePropertySet.TRANSACTION_SUPPORT, TransactionSupport.LOCAL_TRANSACTION.toString()); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals(TransactionSupport.LOCAL_TRANSACTION, ds.getTransactionSupport()); }
/** * Test that the {@link TransactionSupport#XA_TRANSACTION} mode is * {@link TransactionSupport#XA_TRANSACTION}. */ public void testXATransactionIsXATransaction() { Properties props = new Properties(); props.setProperty(DatasourcePropertySet.TRANSACTION_SUPPORT, TransactionSupport.XA_TRANSACTION.toString()); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals(TransactionSupport.XA_TRANSACTION, ds.getTransactionSupport()); }
/** * Test that an empty property string generates a <code>null</code>. */ public void testIdIsNullWhenPropertyStringIsBlank() { String propertyString = ""; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals(null, ds.getId()); }
/** * Test the driver properties when an empty password is set on datasource. */ public void testDatabaseDriverPropertiesEmptyPasswordPropertySetsPasswordOnDataSource() { String driverPropertyString = "password=;CreateDatabase=create"; String propertyString = DatasourcePropertySet.CONNECTION_PROPERTIES + "=" + driverPropertyString; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("", ds.getPassword()); }
/** * Test an id with a dot and a slash. */ public void testIdWithADotAndASlash() { String jndiName = "jdbc.app1/DataSource"; String propertyString = DatasourcePropertySet.JNDI_LOCATION + "=" + jndiName; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("DataSource", ds.getId()); }
/** * Test that the {@link TransactionSupport#NO_TRANSACTION} mode is * {@link TransactionSupport#NO_TRANSACTION}. */ public void testNoTransactionIsNoTransaction() { Properties props = new Properties(); props.setProperty(DatasourcePropertySet.TRANSACTION_SUPPORT, TransactionSupport.NO_TRANSACTION.toString()); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals(TransactionSupport.NO_TRANSACTION, ds.getTransactionSupport()); }
/** * Test an id with a slash. */ public void testIdWithSlash() { String jndiName = "jdbc/DataSource"; String propertyString = DatasourcePropertySet.JNDI_LOCATION + "=" + jndiName; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("DataSource", ds.getId()); }
/** * Test an id with two slashes. */ public void testIdWithTwoSlashes() { String jndiName = "jdbc/app1/DataSource"; String propertyString = DatasourcePropertySet.JNDI_LOCATION + "=" + jndiName; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("DataSource", ds.getId()); }