use of cn.taketoday.jdbc.datasource.DriverManagerDataSource in project today-infrastructure by TAKETODAY.
the class PersistenceXmlParsingTests method testExample4.
@Test
public void testExample4() throws Exception {
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
DataSource ds = new DriverManagerDataSource();
builder.bind("java:comp/env/jdbc/MyDB", ds);
PersistenceUnitReader reader = new PersistenceUnitReader(new PathMatchingPatternResourceLoader(), new JndiDataSourceLookup());
String resource = "/cn/taketoday/orm/jpa/persistence-example4.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertThat(info).isNotNull();
assertThat(info.length).isEqualTo(1);
assertThat(info[0].getPersistenceUnitName()).isEqualTo("OrderManagement4");
assertThat(info[0].getMappingFileNames().size()).isEqualTo(1);
assertThat(info[0].getMappingFileNames().get(0)).isEqualTo("order-mappings.xml");
assertThat(info[0].getManagedClassNames().size()).isEqualTo(3);
assertThat(info[0].getManagedClassNames().get(0)).isEqualTo("com.acme.Order");
assertThat(info[0].getManagedClassNames().get(1)).isEqualTo("com.acme.Customer");
assertThat(info[0].getManagedClassNames().get(2)).isEqualTo("com.acme.Item");
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should be true when no value.").isTrue();
assertThat(info[0].getTransactionType()).isSameAs(PersistenceUnitTransactionType.RESOURCE_LOCAL);
assertThat(info[0].getProperties().keySet().size()).isEqualTo(0);
builder.clear();
}
use of cn.taketoday.jdbc.datasource.DriverManagerDataSource in project today-infrastructure by TAKETODAY.
the class RdbmsOperationTests method parametersSetWithList.
@Test
public void parametersSetWithList() {
DataSource ds = new DriverManagerDataSource();
operation.setDataSource(ds);
operation.setSql("select * from mytable where one = ? and two = ?");
operation.setParameters(new SqlParameter[] { new SqlParameter("one", Types.NUMERIC), new SqlParameter("two", Types.NUMERIC) });
operation.afterPropertiesSet();
operation.validateParameters(new Object[] { 1, "2" });
assertThat(operation.getDeclaredParameters().size()).isEqualTo(2);
}
use of cn.taketoday.jdbc.datasource.DriverManagerDataSource in project today-infrastructure by TAKETODAY.
the class RdbmsOperationTests method validateInOutParameter.
@Test
public void validateInOutParameter() {
operation.setDataSource(new DriverManagerDataSource());
operation.setSql("DUMMY_PROC");
operation.declareParameter(new SqlOutParameter("DUMMY_OUT_PARAM", Types.VARCHAR));
operation.declareParameter(new SqlInOutParameter("DUMMY_IN_OUT_PARAM", Types.VARCHAR));
operation.validateParameters(new Object[] { "DUMMY_VALUE1", "DUMMY_VALUE2" });
}
use of cn.taketoday.jdbc.datasource.DriverManagerDataSource in project today-infrastructure by TAKETODAY.
the class RdbmsOperationTests method compileTwice.
@Test
public void compileTwice() {
operation.setDataSource(new DriverManagerDataSource());
operation.setSql("select * from mytable");
operation.setTypes(null);
operation.compile();
operation.compile();
}
use of cn.taketoday.jdbc.datasource.DriverManagerDataSource in project today-framework by TAKETODAY.
the class PersistenceXmlParsingTests method testExample4.
@Test
public void testExample4() throws Exception {
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
DataSource ds = new DriverManagerDataSource();
builder.bind("java:comp/env/jdbc/MyDB", ds);
PersistenceUnitReader reader = new PersistenceUnitReader(new PathMatchingPatternResourceLoader(), new JndiDataSourceLookup());
String resource = "/cn/taketoday/orm/jpa/persistence-example4.xml";
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertThat(info).isNotNull();
assertThat(info.length).isEqualTo(1);
assertThat(info[0].getPersistenceUnitName()).isEqualTo("OrderManagement4");
assertThat(info[0].getMappingFileNames().size()).isEqualTo(1);
assertThat(info[0].getMappingFileNames().get(0)).isEqualTo("order-mappings.xml");
assertThat(info[0].getManagedClassNames().size()).isEqualTo(3);
assertThat(info[0].getManagedClassNames().get(0)).isEqualTo("com.acme.Order");
assertThat(info[0].getManagedClassNames().get(1)).isEqualTo("com.acme.Customer");
assertThat(info[0].getManagedClassNames().get(2)).isEqualTo("com.acme.Item");
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should be true when no value.").isTrue();
assertThat(info[0].getTransactionType()).isSameAs(PersistenceUnitTransactionType.RESOURCE_LOCAL);
assertThat(info[0].getProperties().keySet().size()).isEqualTo(0);
builder.clear();
}
Aggregations