Arquillian Spring 框架扩展 1.0.0.Beta1 发布了,这也是该扩展首次发布的版本,支持客户端应用上下文注册以及 Spring 事务处理。
Arquillian 可让你在远程或者嵌入式的容器里测试业务逻辑,同时可作为一个压缩包发布到容器中,并通过客户端来进行交互测试。
Arquillian 是一个可以方便的在现有类基础性扩展测试用例,基于 JUnit 。
客户端测试:
@RunWith(Arquillian.class) @SpringClientConfiguration("applicationContext-rest.xml") public class ClientRestServiceTestCase {@Deployment(testable = false) @OverProtocol("Servlet 3.0") public static Archive createTestArchive() { return Deployments.createWebApplication() .addAsWebInfResource("mvc/web.xml", "web.xml") .addAsWebInfResource("service-servlet.xml"); }@ArquillianResource private URL contextPath;@Autowired private RestTemplate restTemplate;@Test public void testGetEmployees() {Employee result = restTemplate.getForObject(contextPath + "/Employees/1", Employee.class);assertEquals("The returned employee has invalid name.", "John Smith", result.getName()); } }
Spring 事务测试
@RunWith(Arquillian.class) @Transactional(manager = "txManager") @SpringConfiguration("applicationContext.xml") public class JpaEmployeeRepositoryTestCase {@Autowired private EmployeeRepository employeeRepository;@PersistenceContext private EntityManager entityManager;@Test public void testSave() {Employee employee = new Employee(); employee.setName("Test employee");employeeRepository.save(employee);List result = entityManager.createQuery("from Employee").getResultList();assertEquals("Two employees were expected.", 1, result.size()); } }
发布详情
| Component | Arquillian Spring Framework Extension |
|---|---|
| Version | 1.0.0.Beta1 view tag |
| Release date | 2012-08-17 |
| Released by | Aslak Knutsen |
| Compiled against |
|
Arquillian 的详细介绍:请点这里
Arquillian 的下载地址:请点这里
