Skip to content

Instantly share code, notes, and snippets.

@emag
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save emag/964c8ce9062ceec71a2e to your computer and use it in GitHub Desktop.

Select an option

Save emag/964c8ce9062ceec71a2e to your computer and use it in GitHub Desktop.
Arquillian Warp
package viewscope;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.arquillian.warp.Activity;
import org.jboss.arquillian.warp.Inspection;
import org.jboss.arquillian.warp.Warp;
import org.jboss.arquillian.warp.WarpTest;
import org.jboss.arquillian.warp.jsf.AfterPhase;
import org.jboss.arquillian.warp.jsf.Phase;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import javax.inject.Inject;
import java.io.File;
import java.net.URL;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
@RunWith(Arquillian.class)
@WarpTest
@RunAsClient
public class ViewScopedControllerTest {
@Deployment
public static WebArchive deployment() {
return ShrinkWrap.create(WebArchive.class, "view-scoped.war")
.addClass(ViewScopedController.class)
.addAsWebResource(new File("src/main/webapp/index.xhtml"), "index.xhtml")
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"))
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
;
}
@Drone
WebDriver browser;
@ArquillianResource
URL contextPath;
@Test
public void test() {
Warp
.initiate(new Activity() {
public void perform() {
browser.navigate().to(contextPath + "index.xhtml");
}
})
.inspect(new Inspection() {
private static final long serialVersionUID = 1L;
@Inject
ViewScopedController controller;
@AfterPhase(Phase.RENDER_RESPONSE)
public void test() {
assertThat(controller, is(notNullValue()));
assertThat(controller.getNumber(), is(10));
controller.setNumber(100);
assertThat(controller.getNumber(), is(100));
}
});
}
}
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running viewscope.ViewScopedControllerTest
1 05, 2015 8:51:39 午後 org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusedSessionPermanentFileStorage readStore
情報: Reused session store is not available at /home/emag/.drone-webdriver-session-store, a new one will be created.
1 05, 2015 8:51:41 午後 org.jboss.arquillian.drone.webdriver.factory.AbstractWebDriverFactory createConfiguration
情報: Property "browser" was not specified, using default value of htmlUnit
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.431 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.078 s
[INFO] Finished at: 2015-01-05T20:51:46+09:00
[INFO] Final Memory: 33M/407M
[INFO] ------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment