/** * Convert string representation of transaction support to appropriate value. * * @param transactionSupport String representation of transaction support. * @return Appropriate TransactionSupport instance. */ public static TransactionSupport valueOf(String transactionSupport) { if (TransactionSupport.XA_TRANSACTION.toString().equals(transactionSupport)) { return TransactionSupport.XA_TRANSACTION; } else if (TransactionSupport.LOCAL_TRANSACTION.toString().equals(transactionSupport)) { return TransactionSupport.LOCAL_TRANSACTION; } else { return TransactionSupport.NO_TRANSACTION; } }
@Override protected void addConfigurationScriptProperties(Map<String, String> propertiesMap) { propertiesMap.put("cargo.datasource.id", ds.getId()); propertiesMap.put("cargo.datasource.driver", ds.getDriverClass()); propertiesMap.put("cargo.datasource.url", ds.getUrl()); propertiesMap.put("cargo.datasource.username", ds.getUsername()); propertiesMap.put("cargo.datasource.password", ds.getPassword()); propertiesMap.put("cargo.datasource.jndi", ds.getJndiLocation()); propertiesMap.put("cargo.datasource.type", ds.getConnectionType()); propertiesMap.put("cargo.datasource.transactionsupport", ds.getTransactionSupport(). toString()); } }
@Override protected void addConfigurationScriptProperties(Map<String, String> propertiesMap) { propertiesMap.put("cargo.datasource.id", ds.getId()); propertiesMap.put("cargo.datasource.driver", ds.getDriverClass()); propertiesMap.put("cargo.datasource.url", ds.getUrl()); propertiesMap.put("cargo.datasource.username", ds.getUsername()); propertiesMap.put("cargo.datasource.password", ds.getPassword()); propertiesMap.put("cargo.datasource.jndi", ds.getJndiLocation()); propertiesMap.put("cargo.datasource.type", ds.getConnectionType()); propertiesMap.put("cargo.datasource.transactionsupport", ds.getTransactionSupport(). toString()); } }
/** * 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 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 the {@link Properties} constructor. */ public void testPropertiesConstructor() { Properties props = new Properties(); props.setProperty(DatasourcePropertySet.ID, "rudolf"); props.setProperty(DatasourcePropertySet.TRANSACTION_SUPPORT, TransactionSupport.NO_TRANSACTION.toString()); props.setProperty(DatasourcePropertySet.JNDI_LOCATION, "jdbc/JiraDS"); props .setProperty(DatasourcePropertySet.CONNECTION_TYPE, ConfigurationEntryType.JDBC_DRIVER); props.setProperty(DatasourcePropertySet.DRIVER_CLASS, "org.hsqldb.jdbcDriver"); props.setProperty(DatasourcePropertySet.URL, "postresql:localhost:jirads"); props.setProperty(DatasourcePropertySet.USERNAME, "sa"); props.setProperty(DatasourcePropertySet.PASSWORD, ""); DataSource ds = dataSourceConverter.fromProperties(props); assertEquals(0, ds.getConnectionProperties().size()); assertEquals("", ds.getPassword()); assertEquals(props, dataSourceConverter.toProperties(ds)); }