【发布时间】:2011-05-25 01:39:09
【问题描述】:
我通过 jndi 查找数据源信息,成功地在 weblogic 服务器之外测试了一些 DAO。我已经搜索了一个与 websphere 类似的选项,并且还必须遇到一个不涉及在应用程序中的某个位置或类似位置硬编码用户名和密码的解决方案。现在我的 jndi 设置在 spring 中是这样的:
我已经测试了 jndi 连接,当应用程序加载到 websphere 时它正在工作。例如,我希望能够在加载应用程序之前测试 eclipse 中的 daos。任何帮助将不胜感激。
这是测试用例的详细信息。
-------BaseTestCase.java--------
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations= {"file:data-access-config.xml"})
public class BaseTestCase {
}
-----PersonDaoTest.java----------------
import static org.junit.Assert.assertNotNull;
import java.util.List;<br>
import org.junit.Test;<br>
import org.springframework.beans.factory.annotation.Autowired;
import ....dao.PersonDao;<br>
import ....domain.Person;<br>
public class PersonDaoTest extends BaseTestCase {
@Autowired
private PersonDao personDao;
@Test
public void findByName() {
List<Person> people = personDao.listByName("j%", false, "userId");
assertNotNull(people);
}
}
【问题讨论】:
标签: spring junit websphere jndi