小编Raf*_*res的帖子

JSF2 - javax.el.PropertyNotFoundException.不使用方法

当我尝试渲染视图时,浏览器显示此错误

01:46:11,371 GRAVE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) Error Rendering View[/index.xhtml]: javax.el.PropertyNotFoundException: /index.xhtml @15,74 value="#{actividades.getAll}": The class 'org.pfc.controller.principal.ActividadesController' does not have the property 'getAll'.
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
Run Code Online (Sandbox Code Playgroud)

ActvidadController代码

@ManagedBean(name="actividades")
@ViewScoped public class ActividadesController implements Serializable {

    private static final long serialVersionUID = 1L;

    private final static Log logger=LogFactory.getLog(ActividadesController.class);

    @ManagedProperty(value="#{actividadBO}")
    private ActividadBO actividad;



    public void setActividad(ActividadBO actividad) {
        this.actividad = actividad;
    }

    public List<Actividad> getAll(){

        logger.trace("ActividadesController.getAll");

        return actividad.getAll();
    }
}
Run Code Online (Sandbox Code Playgroud)

查看代码

    <h:body>
        <ui:composition template="/WEB-INF/templates/main-template.xhtml">
            <ui:define name="content">
                <h:dataTable value="#{actividades.getAll}" var="actividad">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText>Título</h:outputText>
                        </f:facet> …
Run Code Online (Sandbox Code Playgroud)

jsf icefaces jsf-2

4
推荐指数
1
解决办法
9430
查看次数

@Mock jpaRepository 在另一方面调用真正的保存方法 @MockBean 调用模拟方法

我以为我理解了两者之间的区别@Mock@MockBean甚至我认为任何被模拟的对象都不会调用真正的方法,尽管当我在测试下运行时,我可以看到篮子已插入到 hsqldb 日志中。所以现在我对为什么@Mock使用时插入篮子而使用时不插入篮子感到有些困惑@MockBean

INSERT INTO BASKET VALUES(5,'ABCDEFGHIJ','ACTIVE',1,'2019-01-18 12:00:36.066000','2019-01-18 12:00:36.066000')
Run Code Online (Sandbox Code Playgroud)

另一方面,如果我这样做,那么 hsqldb 是干净的。在这两种情况下测试都是成功的。

@MockBean
private BasketRepository basketRepo;
Run Code Online (Sandbox Code Playgroud)

测试班

@RunWith( SpringRunner.class )
@SpringBootTest( )
@ActiveProfiles( "test" )
public class BasketServiceTests
{

@SpyBean
private BasketService basketService;

@Mock
private BasketRepository basketRepo;

@Autowired
private UserAccountRepository userAccountRepo;

@Test
public void createBasketWithSameOrderRef() throws Exception
{
    UserAccount customer = userAccountRepo.findById( 1 )
            .orElseThrow( () -> new NotFoundException( "Customer not found" ) );

    Basket basket = new Basket();
    basket.setAudit( new Audit() …
Run Code Online (Sandbox Code Playgroud)

java unit-testing junit4 mockito spring-boot

0
推荐指数
1
解决办法
3601
查看次数

标签 统计

icefaces ×1

java ×1

jsf ×1

jsf-2 ×1

junit4 ×1

mockito ×1

spring-boot ×1

unit-testing ×1