首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Arquillian Warp验证支持Bean值

使用Arquillian Warp验证支持Bean值
EN

Stack Overflow用户
提问于 2017-08-09 15:33:51
回答 1查看 279关注 0票数 1

我的目标是使用Arquillian Warp进行测试

  1. 已在以前的测试

上导航到JSF页面。

在另一个测试中,

  1. 将文本字段设置为一个值,使用warp我需要注入ViewScope Bean,并验证支持bean

中的值

示例代码

代码语言:javascript
复制
@RunWith(Arquillian.class)
@WarpTest
@RunAsClient
public class TestIT {

    private static final String WEBAPP_SRC = "src/main/webapp";
    private static final String WEB_INF_SRC = "src/main/webapp/WEB-INF";
    private static final String WEB_RESOURCES = "src/main/webapp/resources";

    @Deployment(testable = true)
    public static WebArchive createDeployment() {
        File[] files = Maven.resolver().loadPomFromFile("pom.xml")
                .importRuntimeDependencies().resolve().withTransitivity().asFile();

        WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
                .addPackages(true, "com.mobitill")
                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsWebInfResource(new File(WEB_INF_SRC, "template.xhtml"))
                .addAsWebInfResource(new File(WEB_INF_SRC, "jboss-web.xml"))
                .addAsWebInfResource(new File(WEB_INF_SRC, "web.xml"))
                .addAsWebResource(new File(WEBAPP_SRC, "index.xhtml"))
                .addAsWebResource(new File("src/main/webapp/demo", "home.xhtml"), "demo/home.xhtml")
                .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                        .importDirectory(WEB_RESOURCES).as(GenericArchive.class), "resources")
                .addAsLibraries(files);
        System.out.println(war.toString(true));
        return war;
    }
    @Drone
    private WebDriver browser;
    @ArquillianResource
    private URL deploymentUrl;

    @Test
    @InSequence(1)
    public final void browserTest() throws Exception {
        browser.get(deploymentUrl.toExternalForm() + "index");
        guardHttp(loginImage).click();
        Assert.assertEquals("navigate to home page ", "https://127.0.0.1:8080/citi/demo/home", browser.getCurrentUrl());
    }
    @Test
    @InSequence(2)
    public final void homeManagedBean() throws Exception {
        Warp
                .initiate(new Activity() {
                    @Override
                    public void perform() {
                        WebElement txtMerchantEmailAddress = browser.findElement(By.id("txtMerchantEmailAddress"));
                        txtMerchantEmailAddress.sendKeys("demouser@yahoo.com");
                        guardAjax(btnMerchantSave).click();
                    }
                })
                .observe(request().header().containsHeader("faces-request"))
                .inspect(new Inspection() {
                    private static final long serialVersionUID = 1L;

                    @Inject
                    HomeManagedBean hmb;

                    @ArquillianResource
                    FacesContext facesContext;

                    @BeforePhase(UPDATE_MODEL_VALUES)
                    public void initial_state_havent_changed_yet() {
                        Assert.assertEquals("email value ", "demouser@yahoo.com", hmb.getMerchantEmail());
                    }

                    @AfterPhase(UPDATE_MODEL_VALUES)
                    public void changed_input_value_has_been_applied() {
                        Assert.assertEquals(" email value ", "demouser@yahoo.com", hmb.getMerchantEmail());
                    }
                });
    }
}

我不断得到的错误是

代码语言:javascript
复制
org.jboss.arquillian.warp.impl.client.execution.WarpSynchronizationException: The Warp failed to observe requests or match them with response.

There were no requests matched by observer [containsHeader('faces-request')]

If Warp enriched a wrong request, use observe(...) method to select appropriate request which should be enriched instead.
Otherwise check the server-side log and enable Arquillian debugging mode on both, test and server VM by passing -Darquillian.debug=true.

    at org.jboss.arquillian.warp.impl.client.execution.SynchronizationPoint.awaitResponses(SynchronizationPoint.java:155)
    at org.jboss.arquillian.warp.impl.client.execution.DefaultExecutionSynchronizer.waitForResponse(DefaultExecutionSynchronizer.java:60)
    at org.jboss.arquillian.warp.impl.client.execution.WarpExecutionObserver.awaitResponse(WarpExecutionObserver.java:64)

欢迎任何帮助,或者在集成测试期间验证jsf viewscope bean的另一种方法。

EN

回答 1

Stack Overflow用户

发布于 2017-09-22 17:45:39

我能够整理出它不工作,并能够创建一个示例项目,以供将来任何人遇到同样的问题时参考

Testing using arquillian warp example

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45584304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档