2017-08-09 10 views
0

Mon but est de tester à l'aide Arquillian chaîneVerify Sauvegarde valeurs de Bean en utilisant Arquillian chaîne

1. Déjà navigué à une page JSF lors d'un test précédent

2. Sur un autre test définir un champ de texte à une la valeur, en utilisant la chaîne i besoin d'injecter le Bean ViewScope, et vérifier la valeur de la fève de support

Exemple de code

@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("[email protected]"); 
         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 ", "[email protected]", hmb.getMerchantEmail()); 
        } 

        @AfterPhase(UPDATE_MODEL_VALUES) 
        public void changed_input_value_has_been_applied() { 
         Assert.assertEquals(" email value ", "[email protected]", hmb.getMerchantEmail()); 
        } 
       }); 
    } 
} 

l'erreur continue i gettting est

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) 

toute aide sera la bienvenue ou une autre façon de valider un haricot JSF viewscope lors de tests d'intégration

+0

Essayez d'utiliser '@ RunAsClient' uniquement sur' browserTest'. –

+0

Avez-vous essayé de lancer avec Postman ou avec Chrome Dev Tools pour vérifier si cet ensemble d'en-têtes est défini? – lordofthejars

+0

@lordofthejars pouvez-vous clarifier quels en-têtes – Francis

Répondre