我是 JUnit 新手,正在尝试测试使用 JPA DAO 的 Spring Web 服务。我需要测试类似于下面的服务方法。
服务方法使用注释@Transactional(propagation=Propagation.REQUIRED),ServiceObjectRepository.update()方法调用本机 sql 查询来更新数据库。
@Transactional(propagation=Propagation.REQUIRED)
public void serviceMethod(){
//Read DB for ServiceObject to update
//Call ServiceObjectRepository.update() method to update DB
}
Run Code Online (Sandbox Code Playgroud)
服务对象存储库
public interface ServiceObjectRepository extends JpaRepository<ServiceObject, Integer> {
@Query(value ="UPDATE serviceobjcet AS c SET c.objectstatus= :os WHERE c.objid = :oi", nativeQuery = true)
public Integer update(@Param("os")short objStatus,@Param("oi")int objId);
}
Run Code Online (Sandbox Code Playgroud)
测试类
@TransactionConfiguration(defaultRollback=true)
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
locations = "classpath:service-test.xml")
@Transactional
public class ServiceHandlerTest {
@Test
public void testServiceMethod() {
//Create …Run Code Online (Sandbox Code Playgroud) 我想在JTabbedPane的标题栏上添加一个按钮(类似于Firefox中的'打开新标签'('+')按钮)我试图添加到JTabbedPane容器的玻璃窗格中.但由于我的tabbedpane包含在JPanel中似乎它对我不起作用.任何建议对我都有很大的帮助.谢谢.