Skip to content

Commit

Permalink
issue-5: Initially finished
Browse files Browse the repository at this point in the history
  • Loading branch information
yersan committed Jun 6, 2015
1 parent 3c8013b commit 2cc5d49
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 132 deletions.
135 changes: 38 additions & 97 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<maven.compiler.testTarget>1.6</maven.compiler.testTarget>
<maven.compiler.debug>true</maven.compiler.debug>
<maven.compiler.debuglevel>lines,vars,source</maven.compiler.debuglevel>
<maven.test.skip>false</maven.test.skip>
<maven.test.skip>true</maven.test.skip>
</properties>


Expand Down Expand Up @@ -206,7 +206,7 @@
<directory>meta</directory>
<targetPath>META-INF</targetPath>
</resource>

</resources>
</build>

Expand Down Expand Up @@ -315,8 +315,9 @@
</build>
</profile>


<profile>
<id>glassfish-managed</id>
<id>wildfly-managed</id>
<properties>
<!--
Determines which browser instance is created for WebDriver testing. Following values are valid:
Expand All @@ -329,24 +330,26 @@
safari
-->
<project.integration.tests.browser>htmlUnit</project.integration.tests.browser>
<maven.test.skip>false</maven.test.skip>
<bootsfaces.arquillian.jboss.version>8.2.0.Final</bootsfaces.arquillian.jboss.version>

</properties>

<dependencies>

<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-managed-3.1</artifactId>
<version>1.0.0.CR4</version>
<scope>test</scope>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>8.2.0.Final</version>
<scope>test</scope>
</dependency>

<dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<version>7.0</version>
<scope>provided</scope>
</dependency>


<!-- required library to in using phantomjs -->
<dependency>
Expand All @@ -373,101 +376,38 @@

</dependencies>


<build>
<finalName>bootsfaces-test</finalName>
<plugins>
<!-- You need the maven dependency plugin to download locally a zip with the server, unless you provide your own, it will download under the /target directory -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${bootsfaces.arquillian.jboss.version}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<testResources>
<testResource>
<directory>src/test/resources/webapp</directory>
<includes>
<include>**/*</include>
</includes>
</testResource>
<testResource>
<directory>src/test/resources-arquillian</directory>
<filtering>true</filtering>
</testResource>
</testResources>
</build>

</profile>


<profile>
<id>wildfly-managed</id>
<properties>
<!--
Determines which browser instance is created for WebDriver testing. Following values are valid:
chrome
firefox
htmlUnit
internetExplorer
opera
phantomjs
safari
-->
<project.integration.tests.browser>htmlUnit</project.integration.tests.browser>
</properties>

<dependencies>

<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>8.2.0.Final</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>

<!-- required library to in using phantomjs -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
<scope>test</scope>
</dependency>

<!-- use last version of htmlunit browser -->
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.16</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<finalName>bootsfaces-test</finalName>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand All @@ -481,21 +421,21 @@
</execution>
</executions>
<configuration>

<!-- Fork every test because it will launch a separate AS instance -->
<forkMode>always</forkMode>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<!-- the maven dependency plugin will have already downloaded the server on /target -->
<jboss.home>/Users/ysantana/DEVELOPMENT/SERVERS/wildfly-8.2.0.Final</jboss.home>
<module.path>/Users/ysantana/DEVELOPMENT/SERVERS/wildfly-8.2.0.Final/modules</module.path>
<jboss.home>${project.build.directory}/wildfly-${bootsfaces.arquillian.jboss.version}</jboss.home>
<module.path>${project.build.directory}/wildfly-${bootsfaces.arquillian.jboss.version}/modules</module.path>
</systemPropertyVariables>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>

</plugin>
</plugins>


<testResources>
<testResource>
<directory>src/test/resources/webapp</directory>
Expand All @@ -504,7 +444,7 @@
</includes>
</testResource>
<testResource>
<directory>src/test/resources-glassfish-embedded</directory>
<directory>src/test/resources-arquillian</directory>
<filtering>true</filtering>
</testResource>
</testResources>
Expand All @@ -514,6 +454,7 @@
</profiles>



<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
*/
package net.boostfaces.component;

import net.bootsfaces.layout.*;
import java.io.IOException;
import javax.inject.Inject;
import javax.persistence.SequenceGenerator;
import net.bootsfaces.IntegrationTestsBase;
import org.jboss.arquillian.container.test.api.Deployment;
import static org.jboss.arquillian.graphene.Graphene.guardAjax;
import org.jboss.arquillian.graphene.GrapheneElement;
import org.jboss.arquillian.graphene.findby.FindByJQuery;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Filters;
import org.jboss.shrinkwrap.api.GenericArchive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.importer.ExplodedImporter;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.support.FindBy;

/**
* Simple test which validates the rendered information for b:selectbooleancheckbox tag.
Expand Down Expand Up @@ -51,14 +51,87 @@ public void setup() throws IOException {
browser.get(context + "/faces/SelectBooleanCheckBox.xhtml");
}

@Inject
SelectBooleanCheckBoxSessionBean selectBooleanCheckBoxSessionBean;
@FindBy(id = "chk_1")
private GrapheneElement chk_1;

@FindBy(id = "chk_2")
private GrapheneElement chk_2;

@FindBy(id = "chk_3")
private GrapheneElement chk_3;

@FindBy(id = "cmd")
private GrapheneElement cmd;

@FindBy(id = "msg")
private GrapheneElement msg;

@FindByJQuery("#msg li")
private GrapheneElement facesMessage;

@FindBy(id = "chk_1_label")
private GrapheneElement chk_1_label;




@Test
public void renderSelectBooleanCheckBox() {
@InSequence(1)
public void testSelectBooleanCheckBoxRender() {
String pageTitle = browser.getTitle();

//assert page title
assertEquals("SelectBooleanCheckBox IT", pageTitle);

assertTrue("chk_1 rendered failed", chk_1.getAttribute("onchange").equals("var dummy=0;"));
assertTrue("chk_1 rendered failed", chk_1.getAttribute("onselect").equals("var dummy=0;"));
}

@Test
@InSequence(10)
public void testSelectBooleanCheckBoxValidator() {

//assert that there is no message
assertFalse(facesMessage.isPresent());

//unselect the checkBox
chk_2.click();

//submit
guardAjax(cmd).click();

//assert that there is no message
assertTrue(facesMessage.getText().contains("chk_2 CheckBox value required"));

}

@Test
@InSequence(20)
public void testSelectBooleanCheckBoxBinding() {

//binding value was set in backed bean, must be checked
assertTrue("chk_3 binding failed", chk_3.getAttribute("checked").equals("true"));
}


@Test
@InSequence(30)
public void testSelectBooleanCheckBoxValuechangeListener() {
//change listener count is 0 ?
assertTrue(chk_1_label.getText().contains("0"));

chk_1.click();

//submit
guardAjax(cmd).click();

//binding value was set in backed bean, must be checked
//change listener count is 0 ?
assertTrue(chk_1_label.getText().contains("1"));
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.event.ValueChangeEvent;
import javax.inject.Named;
import net.bootsfaces.component.SelectBooleanCheckbox;
Expand All @@ -25,9 +24,8 @@ public class SelectBooleanCheckBoxSessionBean implements Serializable {
private int valueChangeCount;
private SelectBooleanCheckbox booleanCheckbox;


public void ajaxAction(){
boolValue1 = !boolValue1;
}

public void valueChangeMethod(ValueChangeEvent e){
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/bootsfaces/IntegrationTestsBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static WebArchive createBaseDeployment() {
BeansDescriptor beans = Descriptors.importAs(BeansDescriptor.class)
.fromFile(WEBAPP_SRC+"/WEB-INF/beans.xml");

WebAppDescriptor webDescriptor = Descriptors.importAs(WebAppDescriptor.class)
WebAppDescriptor webDescriptor = Descriptors.importAs(WebAppDescriptor.class)
.fromFile(WEBAPP_SRC+"/WEB-INF/web.xml");


Expand Down
6 changes: 2 additions & 4 deletions src/test/resources-arquillian/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
</engine>


<container qualifier="arquillian-glassfish-managed" default="true">
<container qualifier="wildfly-managed" default="true">
<configuration>
<property name="glassFishHome">/Users/ysantana/DEVELOPMENT/SERVERS/glassfish4</property>
<property name="adminHost">localhost</property>
<property name="adminPort">4848</property>

</configuration>
</container>

Expand Down
Loading

0 comments on commit 2cc5d49

Please sign in to comment.