}
private void testDataSourceFactory() throws Exception {
ObjectFactory factory = new JdbcDataSourceFactory();
assertTrue(null == factory.getObjectInstance("test", null, null, null));
Reference ref = new Reference("java.lang.String");
assertTrue(null == factory.getObjectInstance(ref, null, null, null));
ref = new Reference(JdbcDataSource.class.getName());
ref.add(new StringRefAddr("url", "jdbc:h2:mem:"));
ref.add(new StringRefAddr("user", "u"));
ref.add(new StringRefAddr("password", "p"));
ref.add(new StringRefAddr("loginTimeout", "1"));
ref.add(new StringRefAddr("description", "test"));
JdbcDataSource ds = (JdbcDataSource) factory.getObjectInstance(ref, null, null, null);
assertEquals(1, ds.getLoginTimeout());
assertEquals("test", ds.getDescription());
assertEquals("jdbc:h2:mem:", ds.getURL());
assertEquals("u", ds.getUser());
assertEquals("p", ds.getPassword());
Reference ref2 = ds.getReference();
assertEquals(ref.size(), ref2.size());
assertEquals(ref.get("url").getContent().toString(), ref2.get("url").getContent().toString());
assertEquals(ref.get("user").getContent().toString(), ref2.get("user").getContent().toString());
assertEquals(ref.get("password").getContent().toString(), ref2.get("password").getContent().toString());
assertEquals(ref.get("loginTimeout").getContent().toString(), ref2.get("loginTimeout").getContent().toString());
assertEquals(ref.get("description").getContent().toString(), ref2.get("description").getContent().toString());
ds.setPasswordChars("abc".toCharArray());
assertEquals("abc", ds.getPassword());
}