/** * Gets the string value of this logging level for use as a value of the * {@link GeneralPropertySet#LOGGING} property. * * @return The string value of this logging level. */ public String getLevel() { return toString(); }
/** * Test user parsing. */ public void testParseUser() { User expectedUser = new User(); expectedUser.setName("name"); expectedUser.setPassword("pwd"); expectedUser.addRole("role"); User user = User.parseUser("name:pwd:role"); assertEquals(expectedUser, user); }
/** * Test roles parsing. */ public void testParseRoles() { List<String> roles = User.parseRoles("role1,role2,role3"); assertEquals(3, roles.size()); assertEquals("role1", roles.get(0)); assertEquals("role2", roles.get(1)); assertEquals("role3", roles.get(2)); }
/** * 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 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 user parsing with no roles. */ public void testParseUserWithNoRoles() { User expectedUser = new User(); expectedUser.setName("name"); expectedUser.setPassword("pwd"); User user = User.parseUser("name:pwd"); assertEquals(expectedUser, user); }
/** * 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 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 user parsing. */ public void testParseUserWithWhitespace() { User expectedUser = new User(); expectedUser.setName("name"); expectedUser.setPassword("pwd"); expectedUser.addRole("role"); User user = User.parseUser("\n\t name:pwd:role"); assertEquals(expectedUser, user); }
/** * 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 dot. */ public void testIdWithADot() { String jndiName = "jdbc.DataSource"; String propertyString = DatasourcePropertySet.JNDI_LOCATION + "=" + jndiName; DataSource ds = dataSourceConverter.fromPropertyString(propertyString); assertEquals("DataSource", ds.getId()); }
/** * Test user parsing with empty password. */ public void testParseUserWithEmptyPassword() { User expectedUser = new User(); expectedUser.setName("name"); expectedUser.setPassword(""); expectedUser.addRole("role"); User user = User.parseUser("name::role"); assertEquals(expectedUser, user); }
/** * 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 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 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()); }
/** * 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 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()); }