小编Thu*_*lla的帖子

JUnit 测试事务方法

我是 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)

java junit spring transactional

5
推荐指数
1
解决办法
1万
查看次数

Firefox在JTabbedPane上打开"新标签"

我想在JTabbedPane的标题栏上添加一个按钮(类似于Firefox中的'打开新标签'('+')按钮)我试图添加到JTabbedPane容器的玻璃窗格中.但由于我的tabbedpane包含在JPanel中似乎它对我不起作用.任何建议对我都有很大的帮助.谢谢.

firefox swing jtabbedpane

2
推荐指数
1
解决办法
1272
查看次数

标签 统计

firefox ×1

java ×1

jtabbedpane ×1

junit ×1

spring ×1

swing ×1

transactional ×1