Commit f5c55dc2 authored by Administrator's avatar Administrator

Adds the JSF and EAR projects

This commit adds the JSF project with a web application that allows the
management of owners (by the administrators) and pets (by the owners).
The JSF project includes the functional tests for the owners management
page.

The EAR project only contains a POM that creates an EAR distribution of
the system.
parent 7d038626
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>ear</artifactId>
<packaging>ear</packaging>
<name>EAR</name>
<description>XCS Sample - EAR</description>
<dependencies>
<dependency>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>domain</artifactId>
</dependency>
<dependency>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>service</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>rest</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>jsf</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultLibBundleDir>lib/</defaultLibBundleDir>
<skinnyWars>true</skinnyWars>
</configuration>
</plugin>
</plugins>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>jsf</artifactId>
<packaging>war</packaging>
<name>JSF</name>
<description>XCS Sample - JSF</description>
<dependencies>
<!-- General -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>service</artifactId>
<scope>provided</scope>
</dependency>
<!-- Testing -->
<dependency>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>tests</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-dbunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.graphene</groupId>
<artifactId>graphene-webdriver</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
# Connect to Wildfly instance
connect
# Create Oracle JDBC Driver Module
# If the module already exists, Wildfly will output a message saying that the module already exists and the script exits.
module add \
--name=org.postgre \
--resources=${settings.localRepository}/org/postgresql/postgresql/9.3-1102-jdbc41/postgresql-9.3-1102-jdbc41.jar \
--dependencies=javax.api,javax.transaction.api
# Add Driver Properties
/subsystem=datasources/jdbc-driver=postgre: \
add( \
driver-name="postgre", \
driver-module-name="org.postgre")
\ No newline at end of file
package es.uvigo.esei.xcs.jsf;
import java.security.Principal;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ManagedBean(name = "login")
@RequestScoped
public class LoginManagedBean {
@Inject
private Principal currentUserPrincipal;
@Inject
private HttpServletRequest request;
private String login;
private String password;
private boolean error = false;
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isError() {
return error;
}
public String doLogin() {
try {
request.login(this.getLogin(), this.getPassword());
this.error = false;
if (this.isAdmin()) {
return redirectTo(this.getAdminViewId());
} else if (this.isOwner()) {
return redirectTo(this.getOwnerViewId());
} else {
return redirectTo(this.getViewId());
}
} catch (ServletException e) {
this.error = true;
return this.getViewId();
}
}
public String doLogout() throws ServletException {
request.logout();
return redirectTo("/index.xhtml");
}
public Principal getCurrentUser() {
return this.currentUserPrincipal;
}
private String redirectTo(String url) {
return url + "?faces-redirect=true";
}
private String getViewId() {
return FacesContext.getCurrentInstance().getViewRoot().getViewId();
}
private String getOwnerViewId() {
return "/owner/pets.xhtml";
}
private String getAdminViewId() {
return "/admin/owners.xhtml";
}
private boolean isAdmin() {
return this.isUserInRole("ADMIN");
}
private boolean isOwner() {
return this.isUserInRole("OWNER");
}
private boolean isUserInRole(String role) {
return FacesContext.getCurrentInstance().getExternalContext()
.isUserInRole(role);
}
}
\ No newline at end of file
package es.uvigo.esei.xcs.jsf;
import static java.util.stream.Collectors.joining;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import es.uvigo.esei.xcs.domain.entities.Owner;
import es.uvigo.esei.xcs.domain.entities.Pet;
import es.uvigo.esei.xcs.service.OwnerService;
@ManagedBean(name = "owner")
@SessionScoped
public class OwnerManagerdBean {
@Inject
private OwnerService service;
private String login;
private String password;
private Owner currentOwner;
private String errorMessage;
public String getLogin() {
return login;
}
public void setLogin(String name) {
this.login = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getErrorMessage() {
return errorMessage;
}
public boolean isError() {
return this.errorMessage != null;
}
public boolean isEditing() {
return this.currentOwner != null;
}
public List<Owner> getOwners() {
return this.service.list();
}
public String getPetNames(String login) {
return this.service.getPets(login).stream()
.map(Pet::getName)
.collect(joining(", "));
}
public String edit(Owner owner) {
this.currentOwner = owner;
this.login = this.currentOwner.getLogin();
return this.getViewId();
}
public String cancelEditing() {
this.clear();
return this.getViewId();
}
public String remove(String login) {
this.service.remove(login);
return redirectTo(this.getViewId());
}
public String store() {
try {
if (this.isEditing()) {
this.currentOwner.changePassword(this.password);
this.service.update(this.currentOwner);
} else {
this.service.create(new Owner(login, password));
}
this.clear();
return redirectTo(this.getViewId());
} catch (Throwable t) {
this.errorMessage = t.getMessage();
return this.getViewId();
}
}
private void clear() {
this.login = null;
this.password = null;
this.errorMessage = null;
this.currentOwner = null;
}
private String redirectTo(String url) {
return url + "?faces-redirect=true";
}
private String getViewId() {
return FacesContext.getCurrentInstance().getViewRoot().getViewId();
}
}
package es.uvigo.esei.xcs.jsf;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import es.uvigo.esei.xcs.domain.entities.AnimalType;
import es.uvigo.esei.xcs.domain.entities.Pet;
import es.uvigo.esei.xcs.service.PetService;
@ManagedBean(name = "pet")
@SessionScoped
public class PetManagedBean {
@Inject
private PetService service;
private String name;
private Date birth;
private AnimalType animal;
private Pet currentPet;
private String errorMessage;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
public String getAnimal() {
return Optional.ofNullable(this.animal)
.map(AnimalType::name)
.orElse(null);
}
public void setAnimal(String animal) {
this.animal = AnimalType.valueOf(animal);
}
public String getErrorMessage() {
return errorMessage;
}
public boolean isError() {
return this.errorMessage != null;
}
public boolean isEditing() {
return this.currentPet != null;
}
public List<Pet> getPets() {
return this.service.list();
}
public String edit(Pet pet) {
this.currentPet = pet;
this.name = this.currentPet.getName();
this.birth = this.currentPet.getBirth();
this.animal = this.currentPet.getAnimal();
return this.getViewId();
}
public String cancelEditing() {
this.clear();
return this.getViewId();
}
public String remove(int id) {
this.service.remove(id);
return redirectTo(this.getViewId());
}
public String store() {
try {
if (this.isEditing()) {
this.currentPet.setName(this.name);
this.currentPet.setBirth(this.birth);
this.currentPet.setAnimal(this.animal);
this.service.update(this.currentPet);
} else {
this.service.create(new Pet(name, animal, birth));
}
this.clear();
return redirectTo(this.getViewId());
} catch (Throwable t) {
this.errorMessage = t.getMessage();
return this.getViewId();
}
}
private void clear() {
this.currentPet = null;
this.name = null;
this.birth = null;
this.animal = null;
this.errorMessage = null;
}
private String redirectTo(String url) {
return url + "?faces-redirect=true";
}
private String getViewId() {
return FacesContext.getCurrentInstance().getViewRoot().getViewId();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="runtime">
<jta-data-source>java:jboss/datasources/xcs</jta-data-source>
<class>es.uvigo.esei.xcs.domain.entities.Owner</class>
<class>es.uvigo.esei.xcs.domain.entities.Pet</class>
<class>es.uvigo.esei.xcs.domain.entities.Administrator</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>xcs-sample-security-domain</security-domain>
</jboss-web>
\ No newline at end of file
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
<h:head>
<title>Pet Store</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
</h:head>
<h:body>
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">Pet Store</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<h:form rendered="#{login.currentUser.name != 'anonymous'}" class="navbar-form navbar-right">
<span>Current User: #{login.currentUser}</span>
<h:commandButton id="submit" class="btn btn-success" value="Logout" action="#{login.doLogout}" />
</h:form>
<h:form id="login-form" class="navbar-form navbar-right" rendered="#{login.currentUser == 'anonymous'}">
<div class="form-group">
<h:inputText id="login-field" class="#{login.currentUser == 'anonymous' and !login.error ? 'form-control' : 'form-control alert-danger'}"
value="#{login.login}" a:placeholder="login"></h:inputText>
<h:inputSecret id="password-field" class="#{login.currentUser == 'anonymous' and !login.error ? 'form-control' : 'form-control alert-danger'}"
value="#{login.password}" a:placeholder="password"></h:inputSecret>
</div>
<h:commandButton id="submit" class="btn btn-success" value="Login" action="#{login.doLogin}" />
</h:form>
</div>
</div>
</nav>
<div class="jumbotron">
<ui:insert name="jumbotron"/>
</div>
<div class="row marketing">
<ui:insert name="content"/>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</h:body>
</html>
\ No newline at end of file
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Pet Store JSF</display-name>
<welcome-file-list>
<welcome-file>/faces/index.xhtml</welcome-file>
</welcome-file-list>
<!--Defining security constraint for type of roles available -->
<security-constraint>
<web-resource-collection>
<web-resource-name>admin</web-resource-name>
<url-pattern>/faces/admin/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>owner</web-resource-name>
<url-pattern>/faces/owner/*</url-pattern>
<http-method>POST</http-method>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>OWNER</role-name>
</auth-constraint>
</security-constraint>
<!--Defining security constraint for type of roles available -->
<!--Denining security role -->
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<security-role>
<role-name>OWNER</role-name>
</security-role>
<!--Denining security role -->
</web-app>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
<head>
<title>Pet Store - Owners</title>
</head>
<body>
<ui:composition template="../WEB-INF/template.xhtml">
<ui:define name="jumbotron">
<h2>Owner</h2>
<h:panelGroup class="row">
<h:form id="owner-form">
<h:outputLabel for="name-field">Name</h:outputLabel>
<h:inputText id="name-field" class="form-control" a:placeholder="Owner name" value="#{owner.login}" readonly="#{owner.editing}"></h:inputText>
<h:outputLabel for="password-field">Password</h:outputLabel>
<h:inputSecret id="password-field" class="form-control" a:placeholder="Owner password" value="#{owner.password}"></h:inputSecret>
<h:commandButton id="submit-button" class="btn btn-default" value="Store" action="#{owner.store}" />
<h:commandButton id="cancel-button" class="btn btn-default" value="Cancel" action="#{owner.cancelEditing()}" rendered="#{owner.editing}"/>
</h:form>
</h:panelGroup>
<div class="row">
<h:panelGroup id="store-error" class="alert alert-danger" role="alert" rendered="#{owner.error}">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
Error: #{owner.errorMessage}
</h:panelGroup>
</div>
</ui:define>
<ui:define name="content">
<h:dataTable id="owners-table"
value="#{owner.owners}" var="c"
styleClass="table table-striped table-bordered"
columnClasses="owners-table-login,owners-table-password,owners-table-pets,owners-table-options"
>
<h:column>
<f:facet name="header">Login</f:facet>
#{c.login}
</h:column>
<h:column>
<f:facet name="header">Password</f:facet>
#{c.password}
</h:column>
<h:column>
<f:facet name="header">Pets</f:facet>
#{owner.getPetNames(c.login)}
</h:column>
<h:column>
<h:form>
<h:commandButton class="owners-table-remove" value="Remove" action="#{owner.remove(c.login)}"/>
<h:commandButton class="owners-table-edit" value="Edit" action="#{owner.edit(c)}"/>
</h:form>
</h:column>
</h:dataTable>
</ui:define>
</ui:composition>
</body>
</html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
<head>
<title>Pet Store - Index</title>
</head>
<body>
<ui:composition template="./WEB-INF/template.xhtml">
<ui:define name="jumbotron">
<h2>Welcome!</h2>
<div>This is the Pet Store web page, where you can manage your pets. Please, login to continue.</div>
</ui:define>
</ui:composition>
</body>
</html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
<head>
<title>Pet Store - Pets</title>
</head>
<body>
<ui:composition template="../WEB-INF/template.xhtml">
<ui:define name="jumbotron">
<h2>New Pet</h2>
<h:panelGroup class="row">
<h:form>
<h:inputText class="form-control" a:placeholder="Pet name" value="#{pet.name}"></h:inputText>
<h:inputText value="#{pet.birth}" size="20" required="true" label="Receipt Date" class="form-control">
<f:convertDateTime pattern="yyyy-M-d hh:mm:ss" />
</h:inputText>
<h:selectOneMenu value="#{pet.animal}" class="form-control" a:placeholder="Birth (YYYY-MM-DD hh:mm:ss)">
<f:selectItem itemValue="BIRD" itemLabel="Bird" />
<f:selectItem itemValue="CAT" itemLabel="Cat" />
<f:selectItem itemValue="DOG" itemLabel="Dog" />
</h:selectOneMenu>
<h:commandButton id="submit" class="btn btn-default" value="Store" action="#{pet.store()}" />
<h:commandButton id="cancel" class="btn btn-default" value="Cancel" action="#{pet.cancelEditing()}" rendered="#{pet.editing}"/>
</h:form>
</h:panelGroup>
<div class="row">
<h:panelGroup class="alert alert-danger" role="alert" rendered="#{pet.error}">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
Error: #{pet.errorMessage}
</h:panelGroup>
</div>
</ui:define>
<ui:define name="content">
<h:dataTable value="#{pet.pets}" var="p" styleClass="table table-striped table-bordered">
<h:column>
<f:facet name="header">Name</f:facet>
#{p.name}
</h:column>
<h:column>
<f:facet name="header">Birth</f:facet>
<h:outputText value="#{p.birth}">
<f:convertDateTime pattern="yyyy-M-d hh:mm:ss" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">Type</f:facet>
#{p.animal}
</h:column>
<h:column>
<h:form>
<h:commandButton value="Remove" type="submit" action="#{pet.remove(p.id)}"/>
<h:commandButton value="Edit" action="#{pet.edit(p)}"/>
</h:form>
</h:column>
</h:dataTable>
</ui:define>
</ui:composition>
</body>
</html>
\ No newline at end of file
package es.uvigo.esei.xcs.jsf;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.existentLogin;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.existentOwner;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.newOwnerLogin;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.newOwnerPassword;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.newOwnerWithoutPets;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.ownerWithPets;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.ownerWithoutPets;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.owners;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.ownersAnd;
import static es.uvigo.esei.xcs.domain.entities.OwnersDataset.ownersWithout;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.nio.file.Path;
import java.nio.file.Paths;
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.graphene.page.InitialPage;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.persistence.Cleanup;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
import org.jboss.arquillian.persistence.TestExecutionPhase;
import org.jboss.arquillian.persistence.UsingDataSet;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import es.uvigo.esei.xcs.domain.entities.Owner;
import es.uvigo.esei.xcs.jsf.pages.LoginPage;
import es.uvigo.esei.xcs.jsf.pages.OwnersPage;
import es.uvigo.esei.xcs.service.OwnerService;
@RunWith(Arquillian.class)
public class OwnerJsfTest {
private static final Path WEBAPP = Paths.get("src/main/webapp");
@Drone
private WebDriver browser;
@Page
private OwnersPage ownersPage;
@Deployment
public static Archive<?> createDeployment() {
return ShrinkWrap.create(WebArchive.class, "test.war")
.addPackage(LoginManagedBean.class.getPackage())
.addPackage(OwnerService.class.getPackage())
.addPackage(Owner.class.getPackage())
.addPackage(WebDriver.class.getPackage())
.addPackage(LoginPage.class.getPackage())
.addAsWebResource(WEBAPP.resolve("index.xhtml").toFile())
.addAsWebResource(WEBAPP.resolve("admin/owners.xhtml").toFile(), "admin/owners.xhtml")
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(WEBAPP.resolve("WEB-INF/template.xhtml").toFile())
.addAsWebInfResource("jboss-web.xml")
.addAsWebInfResource("web.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Before
public void setUp() {
if (this.browser != null)
this.browser.manage().deleteAllCookies();
}
@Test @InSequence(1)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeLoginFail() {}
@Test @InSequence(2)
@RunAsClient
public void testLoginFail(@InitialPage LoginPage loginPage) {
loginPage.login("bad", "userpass");
loginPage.assertOnLoginPage();
loginAsAdmin(loginPage);
}
@Test @InSequence(3)
@ShouldMatchDataSet("owners.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterLoginFail() {}
@Test @InSequence(10)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeList() {}
@Test @InSequence(11)
@RunAsClient
public void testList(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
assertThat(ownersPage.areOwnersInTable(owners()), is(true));
}
@Test @InSequence(12)
@ShouldMatchDataSet("owners.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterGet() {}
@Test @InSequence(21)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeCreate() {}
@Test @InSequence(22)
@RunAsClient
public void testCreate(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
ownersPage.createOwner(newOwnerLogin(), newOwnerPassword());
ownersPage.assertOnOwnersPage();
final Owner[] expectedOwners = ownersAnd(newOwnerWithoutPets());
assertThat(ownersPage.areOwnersInTable(expectedOwners), is(true));
}
@Test @InSequence(23)
@ShouldMatchDataSet({ "owners.xml", "owners-create-without-pets.xml" })
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterCreate() {}
@Test @InSequence(24)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeCreateExistingOwner() {}
@Test @InSequence(25)
@RunAsClient
public void testCreateExistingOwner(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
assertThat(ownersPage.isErrorMessageVisible(), is(false));
final String existentLogin = existentLogin();
ownersPage.createOwner(existentLogin, "anypassword");
ownersPage.assertOnOwnersPage();
assertThat(ownersPage.isErrorMessageVisible(), is(true));
}
@Test @InSequence(26)
@ShouldMatchDataSet("owners.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterCreateExistingOwner() {}
@Test @InSequence(27)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeCreateShortPassword() {}
@Test @InSequence(28)
@RunAsClient
public void testCreateShortPassword(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
assertThat(ownersPage.isErrorMessageVisible(), is(false));
ownersPage.createOwner(newOwnerLogin(), "short");
ownersPage.assertOnOwnersPage();
assertThat(ownersPage.isErrorMessageVisible(), is(true));
}
@Test @InSequence(29)
@ShouldMatchDataSet("owners.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterCreateShortPassword() {}
@Test @InSequence(31)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeDeleteOwnerWithoutPets() {}
@Test @InSequence(32)
@RunAsClient
public void testDeleteOwnerWithoutPets(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
assertDeleteOwner(ownerWithoutPets());
}
@Test @InSequence(33)
@ShouldMatchDataSet("owners-remove-without-pets.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterDeleteOwnerWithoutPets() {}
@Test @InSequence(34)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeDeleteOwnerWithPets() {}
@Test @InSequence(35)
@RunAsClient
public void testDeleteOwnerWithPets(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
assertDeleteOwner(ownerWithPets());
}
@Test @InSequence(36)
@ShouldMatchDataSet("owners-remove-with-pets.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterDeleteOwnerWithPets() {}
private void assertDeleteOwner(Owner ownerToDelete) {
ownersPage.removeOwner(ownerToDelete);
ownersPage.assertOnOwnersPage();
final Owner[] expectedOwners = ownersWithout(ownerToDelete);
assertThat(ownersPage.areOwnersInTable(expectedOwners), is(true));
}
@Test @InSequence(41)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeEdit() {}
@Test @InSequence(42)
@RunAsClient
public void testEdit(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
final Owner owner = existentOwner();
ownersPage.editOwner(owner);
assertThat(ownersPage.isEditing(), is(true));
ownersPage.changePassword("newpassword");
ownersPage.assertOnOwnersPage();
assertThat(ownersPage.isEditing(), is(false));
}
@Test @InSequence(43)
@ShouldMatchDataSet("owners-update-password.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterEdit() {}
@Test @InSequence(44)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeEditShortPassword() {}
@Test @InSequence(45)
@RunAsClient
public void testEditShortPassword(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
assertThat(ownersPage.isErrorMessageVisible(), is(false));
final Owner owner = existentOwner();
ownersPage.editOwner(owner);
assertThat(ownersPage.isEditing(), is(true));
ownersPage.changePassword("short");
ownersPage.assertOnOwnersPage();
assertThat(ownersPage.isErrorMessageVisible(), is(true));
assertThat(ownersPage.isEditing(), is(true));
}
@Test @InSequence(46)
@UsingDataSet("owners.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterEditShortPassword() {}
@Test @InSequence(47)
@UsingDataSet("owners.xml")
@Cleanup(phase = TestExecutionPhase.NONE)
public void beforeCancelEdit() {}
@Test @InSequence(48)
@RunAsClient
public void testCancelEdit(@InitialPage LoginPage loginPage) {
loginAsAdmin(loginPage);
final Owner owner = existentOwner();
ownersPage.editOwner(owner);
assertThat(ownersPage.isEditing(), is(true));
ownersPage.cancelEdit();
assertThat(ownersPage.isEditing(), is(false));
}
@Test @InSequence(49)
@UsingDataSet("owners.xml")
@CleanupUsingScript({ "cleanup.sql", "cleanup-autoincrement.sql" })
public void afterCancelEdit() {}
private void loginAsAdmin(LoginPage loginPage) {
loginPage.login("jose", "josepass");
ownersPage.assertOnOwnersPage();
}
}
package es.uvigo.esei.xcs.jsf.pages;
import static org.jboss.arquillian.graphene.Graphene.guardHttp;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class LoginForm {
@FindBy(id = "login-form:login-field")
private WebElement inputLogin;
@FindBy(id = "login-form:password-field")
private WebElement inputPassword;
@FindBy(id = "login-form:submit")
private WebElement buttonSubmit;
public void login(String login, String password) {
inputLogin.clear();
inputPassword.clear();
inputLogin.sendKeys(login);
inputPassword.sendKeys(password);
guardHttp(buttonSubmit).click();
}
}
package es.uvigo.esei.xcs.jsf.pages;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Location;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;
@Location("faces/index.xhtml")
public class LoginPage {
@Drone
private WebDriver browser;
@FindBy(id = "login-form")
private LoginForm loginForm;
public void login(String login, String password) {
this.loginForm.login(login, password);
}
public void assertOnLoginPage() {
assertThat(browser.getCurrentUrl(), containsString("/faces/index.xhtml"));
}
}
package es.uvigo.esei.xcs.jsf.pages;
import static org.jboss.arquillian.graphene.Graphene.guardHttp;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class OwnerForm {
@FindBy(id = "owner-form:name-field")
private WebElement fieldName;
@FindBy(id = "owner-form:password-field")
private WebElement fieldPassword;
@FindBy(id = "owner-form:submit-button")
private WebElement buttonSubmit;
@FindBy(id = "owner-form:cancel-button")
private WebElement buttonCancel;
public void setName(String name) {
this.fieldName.sendKeys(name);
}
public void setPassword(String password) {
this.fieldPassword.sendKeys(password);
}
public String getName() {
return this.fieldName.getText();
}
public String getPassword() {
return this.fieldPassword.getText();
}
public void submit() {
guardHttp(this.buttonSubmit).click();
}
public void cancel() {
guardHttp(this.buttonCancel).click();
}
public boolean isEditing() {
return this.fieldName.getAttribute("readonly") != null;
}
}
package es.uvigo.esei.xcs.jsf.pages;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.Assert.assertThat;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.GrapheneElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.FindBy;
import es.uvigo.esei.xcs.domain.entities.Owner;
public class OwnersPage {
@Drone
private WebDriver browser;
@FindBy(id = "owner-form")
private OwnerForm formOwner;
@FindBy(id = "owners-table")
private OwnersTable tableOwners;
// GrapheneElement adds "isPresent()" to WebElement.
@FindBy(id = "store-error")
private GrapheneElement storeError;
public void assertOnOwnersPage() {
assertThat(browser.getCurrentUrl(), containsString("/faces/admin/owners.xhtml"));
}
public boolean areOwnersInTable(Owner ... owners) {
for (Owner owner : owners) {
if (!this.isOwnerInTable(owner))
return false;
}
return true;
}
public boolean isOwnerInTable(Owner owner) {
return this.tableOwners.hasOwner(owner);
}
public void createOwner(String login, String password) {
this.formOwner.setName(login);
this.formOwner.setPassword(password);
this.formOwner.submit();
}
public void removeOwner(Owner owner) {
this.tableOwners.remove(owner);
}
public void editOwner(Owner owner) {
this.tableOwners.edit(owner);
}
public void changePassword(String password) {
this.formOwner.setPassword(password);
this.formOwner.submit();
}
public boolean isErrorMessageVisible() {
return storeError.isPresent();
}
public boolean isEditing() {
return this.formOwner.isEditing();
}
public void cancelEdit() {
this.formOwner.cancel();
}
}
package es.uvigo.esei.xcs.jsf.pages;
import static org.jboss.arquillian.graphene.Graphene.guardHttp;
import java.util.Collection;
import java.util.List;
import org.jboss.arquillian.graphene.findby.FindByJQuery;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import es.uvigo.esei.xcs.domain.entities.Owner;
import es.uvigo.esei.xcs.domain.entities.Pet;
public class OwnersTable {
@FindByJQuery("tbody tr")
private List<OwnerRow> trOwner;
public boolean hasOwner(Owner owner) {
for (OwnerRow row : trOwner) {
if (row.hasOwner(owner))
return true;
}
return false;
}
public OwnerRow getOwnerRow(Owner owner) {
for (OwnerRow row : trOwner) {
if (row.hasOwner(owner))
return row;
}
throw new IllegalArgumentException("No row for owner: " + owner.getLogin());
}
public void remove(Owner owner) {
guardHttp(this.getOwnerRow(owner).getButtonRemove()).click();
}
public void edit(Owner owner) {
guardHttp(this.getOwnerRow(owner).getButtonEdit()).click();
}
public static class OwnerRow {
@FindBy(className = "owners-table-login")
private WebElement tdLogin;
@FindBy(className = "owners-table-password")
private WebElement tdPassword;
@FindBy(className = "owners-table-pets")
private WebElement tdPets;
@FindBy(className = "owners-table-remove")
private WebElement buttonRemove;
@FindBy(className = "owners-table-edit")
private WebElement buttonEdit;
public boolean hasOwner(Owner owner) {
return this.getLoginText().equals(owner.getLogin())
&& this.getPasswordText().equals(owner.getPassword())
&& arePetNamesInTest(owner.getPets(), this.getPetsText());
}
private String getLoginText() {
return this.tdLogin.getText().trim();
}
private String getPasswordText() {
return this.tdPassword.getText().trim();
}
private String getPetsText() {
return this.tdPets.getText().trim();
}
public WebElement getButtonRemove() {
return this.buttonRemove;
}
public WebElement getButtonEdit() {
return this.buttonEdit;
}
private static boolean arePetNamesInTest(Collection<Pet> pets, String text) {
return pets.stream()
.map(Pet::getName)
.allMatch(text::contains);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
<alternatives>
<class>es.uvigo.esei.xcs.service.util.security.TestPrincipal</class>
</alternatives>
</beans>
ALTER TABLE Pet ALTER COLUMN id RESTART WITH 1;
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>xcs-sample-security-domain</security-domain>
</jboss-web>
\ No newline at end of file
<?xml version="1.0" ?>
<server xmlns="urn:jboss:domain:2.2">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.deployment-scanner"/>
<extension module="org.jboss.as.ee"/>
<extension module="org.jboss.as.ejb3"/>
<extension module="org.jboss.as.jaxrs"/>
<extension module="org.jboss.as.jdr"/>
<extension module="org.jboss.as.jmx"/>
<extension module="org.jboss.as.jpa"/>
<extension module="org.jboss.as.jsf"/>
<extension module="org.jboss.as.logging"/>
<extension module="org.jboss.as.mail"/>
<extension module="org.jboss.as.naming"/>
<extension module="org.jboss.as.pojo"/>
<extension module="org.jboss.as.remoting"/>
<extension module="org.jboss.as.sar"/>
<extension module="org.jboss.as.security"/>
<extension module="org.jboss.as.transactions"/>
<extension module="org.jboss.as.webservices"/>
<extension module="org.jboss.as.weld"/>
<extension module="org.wildfly.extension.batch"/>
<extension module="org.wildfly.extension.io"/>
<extension module="org.wildfly.extension.undertow"/>
</extensions>
<management>
<security-realms>
<security-realm name="ManagementRealm">
<authentication>
<local default-user="$local" skip-group-loading="true"/>
<properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization map-groups-to-roles="false">
<properties path="mgmt-groups.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
<security-realm name="ApplicationRealm">
<authentication>
<local default-user="$local" allowed-users="*" skip-group-loading="true"/>
<properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization>
<properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
<!-- Custom realm -->
<security-realm name="RemotingRealm">
<authentication>
<jaas name="AppRealmLoopThrough" />
</authentication>
</security-realm>
</security-realms>
<audit-log>
<formatters>
<json-formatter name="json-formatter"/>
</formatters>
<handlers>
<file-handler name="file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.server.data.dir"/>
</handlers>
<logger log-boot="true" log-read-only="false" enabled="false">
<handlers>
<handler name="file"/>
</handlers>
</logger>
</audit-log>
<management-interfaces>
<http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
<socket-binding http="management-http"/>
</http-interface>
</management-interfaces>
<access-control provider="simple">
<role-mapping>
<role name="SuperUser">
<include>
<user name="$local"/>
</include>
</role>
</role-mapping>
</access-control>
</management>
<profile>
<subsystem xmlns="urn:jboss:domain:logging:2.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<logger category="jacorb">
<level name="WARN"/>
</logger>
<logger category="jacorb.config">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</subsystem>
<subsystem xmlns="urn:jboss:domain:batch:1.0">
<job-repository>
<in-memory/>
</job-repository>
<thread-pool>
<max-threads count="10"/>
<keepalive-time time="30" unit="seconds"/>
</thread-pool>
</subsystem>
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ee:2.0">
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
<concurrent>
<context-services>
<context-service name="default" jndi-name="java:jboss/ee/concurrency/context/default" use-transaction-setup-provider="true"/>
</context-services>
<managed-thread-factories>
<managed-thread-factory name="default" jndi-name="java:jboss/ee/concurrency/factory/default" context-service="default"/>
</managed-thread-factories>
<managed-executor-services>
<managed-executor-service name="default" jndi-name="java:jboss/ee/concurrency/executor/default" context-service="default" hung-task-threshold="60000" core-threads="5" max-threads="25" keepalive-time="5000"/>
</managed-executor-services>
<managed-scheduled-executor-services>
<managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-threshold="60000" core-threads="2" keepalive-time="3000"/>
</managed-scheduled-executor-services>
</concurrent>
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ejb3:2.0">
<session-bean>
<stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
<singleton default-access-timeout="5000"/>
</session-bean>
<pools>
<bean-instance-pools>
<strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
<strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
</bean-instance-pools>
</pools>
<caches>
<cache name="simple"/>
<cache name="distributable" passivation-store-ref="infinispan" aliases="passivating clustered"/>
</caches>
<passivation-stores>
<passivation-store name="infinispan" cache-container="ejb" max-size="10000"/>
</passivation-stores>
<async thread-pool-name="default"/>
<timer-service thread-pool-name="default" default-data-store="default-file-store">
<data-stores>
<file-data-store name="default-file-store" path="timer-service-data" relative-to="jboss.server.data.dir"/>
</data-stores>
</timer-service>
<remote connector-ref="http-remoting-connector" thread-pool-name="default"/>
<thread-pools>
<thread-pool name="default">
<max-threads count="10"/>
<keepalive-time time="100" unit="milliseconds"/>
</thread-pool>
</thread-pools>
<default-security-domain value="other"/>
<default-missing-method-permissions-deny-access value="true"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:io:1.1">
<worker name="default"/>
<buffer-pool name="default"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:infinispan:2.0">
<cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
<local-cache name="passivation" batching="true">
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="persistent" batching="true">
<file-store passivation="false" purge="false"/>
</local-cache>
</cache-container>
<cache-container name="ejb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan" aliases="sfsb">
<local-cache name="passivation" batching="true">
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="persistent" batching="true">
<file-store passivation="false" purge="false"/>
</local-cache>
</cache-container>
<cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
<local-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="local-query">
<transaction mode="NONE"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="timestamps">
<transaction mode="NONE"/>
<eviction strategy="NONE"/>
</local-cache>
</cache-container>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
<subsystem xmlns="urn:jboss:domain:jca:2.0">
<archive-validation enabled="true" fail-on-error="true" fail-on-warn="false"/>
<bean-validation enabled="true"/>
<default-workmanager>
<short-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</short-running-threads>
<long-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</long-running-threads>
</default-workmanager>
<cached-connection-manager/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jdr:1.0"/>
<subsystem xmlns="urn:jboss:domain:jmx:1.3">
<expose-resolved-model/>
<expose-expression-model/>
<remoting-connector/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jpa:1.1">
<jpa default-datasource="" default-extended-persistence-inheritance="DEEP"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jsf:1.0"/>
<subsystem xmlns="urn:jboss:domain:mail:2.0">
<mail-session name="default" jndi-name="java:jboss/mail/Default">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
</subsystem>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<remote-naming/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:pojo:1.0"/>
<subsystem xmlns="urn:jboss:domain:remoting:2.0">
<endpoint worker="default"/>
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="RemotingRealm"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:resource-adapters:2.0"/>
<subsystem xmlns="urn:jboss:domain:sar:1.0"/>
<subsystem xmlns="urn:jboss:domain:security:1.2">
<security-domains>
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="RealmDirect" flag="required">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
<security-domain name="jboss-web-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jboss-ejb-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<!-- Custom domain -->
<security-domain name="AppRealmLoopThrough" cache-type="default">
<authentication>
<login-module code="Client" flag="required">
<module-option name="multi-threaded" value="true" />
</login-module>
</authentication>
</security-domain>
<security-domain name="xcs-sample-security-domain">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/ExampleDS" />
<module-option name="principalsQuery"
value="SELECT password FROM User WHERE login=?" />
<module-option name="rolesQuery"
value="SELECT role, 'Roles' FROM User WHERE login=?" />
<module-option name="hashAlgorithm" value="MD5"/>
<module-option name="hashEncoding" value="hex"/>
<module-option name="ignorePasswordCase" value="true"/>
</login-module>
</authentication>
</security-domain>
</security-domains>
</subsystem>
<subsystem xmlns="urn:jboss:domain:transactions:2.0">
<core-environment>
<process-id>
<uuid/>
</process-id>
</core-environment>
<recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
<subsystem xmlns="urn:jboss:domain:webservices:1.2">
<wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
<endpoint-config name="Standard-Endpoint-Config"/>
<endpoint-config name="Recording-Endpoint-Config">
<pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
<handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
</pre-handler-chain>
</endpoint-config>
<client-config name="Standard-Client-Config"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:weld:2.0"/>
</profile>
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0">
<socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/>
<socket-binding name="http" port="8080"/>
<socket-binding name="https" port="8443"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
</server>
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="test">
<jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
\ No newline at end of file
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Pet Store JSF</display-name>
<welcome-file-list>
<welcome-file>/faces/index.xhtml</welcome-file>
</welcome-file-list>
<!--Defining security constraint for type of roles available -->
<security-constraint>
<web-resource-collection>
<web-resource-name>admin</web-resource-name>
<url-pattern>/api/owner/*</url-pattern>
<http-method-omission>OPTIONS</http-method-omission>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>owner</web-resource-name>
<url-pattern>/api/pet/*</url-pattern>
<http-method-omission>OPTIONS</http-method-omission>
</web-resource-collection>
<auth-constraint>
<role-name>OWNER</role-name>
</auth-constraint>
</security-constraint>
<!--Defining security constraint for type of roles available -->
<!--Denining security role -->
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<security-role>
<role-name>OWNER</role-name>
</security-role>
<!--Denining security role -->
</web-app>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
<alternatives>
<class>es.uvigo.esei.xcs.service.util.security.TestPrincipal</class>
</alternatives>
</beans>
ALTER TABLE Pet AUTO_INCREMENT = 1;
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>xcs-sample-security-domain</security-domain>
</jboss-web>
\ No newline at end of file
<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.ironjacamar.org/doc/schema"
xsi:schemaLocation="http://www.ironjacamar.org/doc/schema http://www.ironjacamar.org/doc/schema/datasources_1_1.xsd">
<datasource jndi-name="java:jboss/datasources/xcs" pool-name="MySQLPool">
<connection-url>jdbc:mysql://localhost:3306/xcs</connection-url>
<driver>mysql-connector-java-${mysql.version}.jar</driver>
<pool>
<max-pool-size>30</max-pool-size>
</pool>
<security>
<user-name>xcs</user-name>
<password>xcs</password>
</security>
</datasource>
</datasources>
\ No newline at end of file
<?xml version="1.0" ?>
<server xmlns="urn:jboss:domain:2.2">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
<extension module="org.jboss.as.connector"/>
<extension module="org.jboss.as.deployment-scanner"/>
<extension module="org.jboss.as.ee"/>
<extension module="org.jboss.as.ejb3"/>
<extension module="org.jboss.as.jaxrs"/>
<extension module="org.jboss.as.jdr"/>
<extension module="org.jboss.as.jmx"/>
<extension module="org.jboss.as.jpa"/>
<extension module="org.jboss.as.jsf"/>
<extension module="org.jboss.as.logging"/>
<extension module="org.jboss.as.mail"/>
<extension module="org.jboss.as.naming"/>
<extension module="org.jboss.as.pojo"/>
<extension module="org.jboss.as.remoting"/>
<extension module="org.jboss.as.sar"/>
<extension module="org.jboss.as.security"/>
<extension module="org.jboss.as.transactions"/>
<extension module="org.jboss.as.webservices"/>
<extension module="org.jboss.as.weld"/>
<extension module="org.wildfly.extension.batch"/>
<extension module="org.wildfly.extension.io"/>
<extension module="org.wildfly.extension.undertow"/>
</extensions>
<management>
<security-realms>
<security-realm name="ManagementRealm">
<authentication>
<local default-user="$local" skip-group-loading="true"/>
<properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization map-groups-to-roles="false">
<properties path="mgmt-groups.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
<security-realm name="ApplicationRealm">
<authentication>
<local default-user="$local" allowed-users="*" skip-group-loading="true"/>
<properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization>
<properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
<!-- Custom realm -->
<security-realm name="RemotingRealm">
<authentication>
<jaas name="AppRealmLoopThrough" />
</authentication>
</security-realm>
</security-realms>
<audit-log>
<formatters>
<json-formatter name="json-formatter"/>
</formatters>
<handlers>
<file-handler name="file" formatter="json-formatter" path="audit-log.log" relative-to="jboss.server.data.dir"/>
</handlers>
<logger log-boot="true" log-read-only="false" enabled="false">
<handlers>
<handler name="file"/>
</handlers>
</logger>
</audit-log>
<management-interfaces>
<http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
<socket-binding http="management-http"/>
</http-interface>
</management-interfaces>
<access-control provider="simple">
<role-mapping>
<role name="SuperUser">
<include>
<user name="$local"/>
</include>
</role>
</role-mapping>
</access-control>
</management>
<profile>
<subsystem xmlns="urn:jboss:domain:logging:2.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<logger category="jacorb">
<level name="WARN"/>
</logger>
<logger category="jacorb.config">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</subsystem>
<subsystem xmlns="urn:jboss:domain:batch:1.0">
<job-repository>
<in-memory/>
</job-repository>
<thread-pool>
<max-threads count="10"/>
<keepalive-time time="30" unit="seconds"/>
</thread-pool>
</subsystem>
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ee:2.0">
<spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>
<concurrent>
<context-services>
<context-service name="default" jndi-name="java:jboss/ee/concurrency/context/default" use-transaction-setup-provider="true"/>
</context-services>
<managed-thread-factories>
<managed-thread-factory name="default" jndi-name="java:jboss/ee/concurrency/factory/default" context-service="default"/>
</managed-thread-factories>
<managed-executor-services>
<managed-executor-service name="default" jndi-name="java:jboss/ee/concurrency/executor/default" context-service="default" hung-task-threshold="60000" core-threads="5" max-threads="25" keepalive-time="5000"/>
</managed-executor-services>
<managed-scheduled-executor-services>
<managed-scheduled-executor-service name="default" jndi-name="java:jboss/ee/concurrency/scheduler/default" context-service="default" hung-task-threshold="60000" core-threads="2" keepalive-time="3000"/>
</managed-scheduled-executor-services>
</concurrent>
<default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" jms-connection-factory="java:jboss/DefaultJMSConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ejb3:2.0">
<session-bean>
<stateful default-access-timeout="5000" cache-ref="simple" passivation-disabled-cache-ref="simple"/>
<singleton default-access-timeout="5000"/>
</session-bean>
<pools>
<bean-instance-pools>
<strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
<strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
</bean-instance-pools>
</pools>
<caches>
<cache name="simple"/>
<cache name="distributable" passivation-store-ref="infinispan" aliases="passivating clustered"/>
</caches>
<passivation-stores>
<passivation-store name="infinispan" cache-container="ejb" max-size="10000"/>
</passivation-stores>
<async thread-pool-name="default"/>
<timer-service thread-pool-name="default" default-data-store="default-file-store">
<data-stores>
<file-data-store name="default-file-store" path="timer-service-data" relative-to="jboss.server.data.dir"/>
</data-stores>
</timer-service>
<remote connector-ref="http-remoting-connector" thread-pool-name="default"/>
<thread-pools>
<thread-pool name="default">
<max-threads count="10"/>
<keepalive-time time="100" unit="milliseconds"/>
</thread-pool>
</thread-pools>
<default-security-domain value="other"/>
<default-missing-method-permissions-deny-access value="true"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:io:1.1">
<worker name="default"/>
<buffer-pool name="default"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:infinispan:2.0">
<cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan">
<local-cache name="passivation" batching="true">
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="persistent" batching="true">
<file-store passivation="false" purge="false"/>
</local-cache>
</cache-container>
<cache-container name="ejb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan" aliases="sfsb">
<local-cache name="passivation" batching="true">
<file-store passivation="true" purge="false"/>
</local-cache>
<local-cache name="persistent" batching="true">
<file-store passivation="false" purge="false"/>
</local-cache>
</cache-container>
<cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
<local-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="local-query">
<transaction mode="NONE"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="timestamps">
<transaction mode="NONE"/>
<eviction strategy="NONE"/>
</local-cache>
</cache-container>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
<subsystem xmlns="urn:jboss:domain:jca:2.0">
<archive-validation enabled="true" fail-on-error="true" fail-on-warn="false"/>
<bean-validation enabled="true"/>
<default-workmanager>
<short-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</short-running-threads>
<long-running-threads>
<core-threads count="50"/>
<queue-length count="50"/>
<max-threads count="50"/>
<keepalive-time time="10" unit="seconds"/>
</long-running-threads>
</default-workmanager>
<cached-connection-manager/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jdr:1.0"/>
<subsystem xmlns="urn:jboss:domain:jmx:1.3">
<expose-resolved-model/>
<expose-expression-model/>
<remoting-connector/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jpa:1.1">
<jpa default-datasource="" default-extended-persistence-inheritance="DEEP"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jsf:1.0"/>
<subsystem xmlns="urn:jboss:domain:mail:2.0">
<mail-session name="default" jndi-name="java:jboss/mail/Default">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
</subsystem>
<subsystem xmlns="urn:jboss:domain:naming:2.0">
<remote-naming/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:pojo:1.0"/>
<subsystem xmlns="urn:jboss:domain:remoting:2.0">
<endpoint worker="default"/>
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="RemotingRealm"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:resource-adapters:2.0"/>
<subsystem xmlns="urn:jboss:domain:sar:1.0"/>
<subsystem xmlns="urn:jboss:domain:security:1.2">
<security-domains>
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="RealmDirect" flag="required">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
<security-domain name="jboss-web-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jboss-ejb-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<!-- Custom domain -->
<security-domain name="AppRealmLoopThrough" cache-type="default">
<authentication>
<login-module code="Client" flag="required">
<module-option name="multi-threaded" value="true" />
</login-module>
</authentication>
</security-domain>
<security-domain name="xcs-sample-security-domain">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/xcs" />
<module-option name="principalsQuery"
value="SELECT password FROM User WHERE login=?" />
<module-option name="rolesQuery"
value="SELECT role, 'Roles' FROM User WHERE login=?" />
<module-option name="hashAlgorithm" value="MD5"/>
<module-option name="hashEncoding" value="hex"/>
<module-option name="ignorePasswordCase" value="true"/>
</login-module>
</authentication>
</security-domain>
</security-domains>
</subsystem>
<subsystem xmlns="urn:jboss:domain:transactions:2.0">
<core-environment>
<process-id>
<uuid/>
</process-id>
</core-environment>
<recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
<subsystem xmlns="urn:jboss:domain:webservices:1.2">
<wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
<endpoint-config name="Standard-Endpoint-Config"/>
<endpoint-config name="Recording-Endpoint-Config">
<pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
<handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
</pre-handler-chain>
</endpoint-config>
<client-config name="Standard-Client-Config"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:weld:2.0"/>
</profile>
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="0">
<socket-binding name="management-http" interface="management" port="9990"/>
<socket-binding name="management-https" interface="management" port="9993"/>
<socket-binding name="ajp" port="8009"/>
<socket-binding name="http" port="8080"/>
<socket-binding name="https" port="8443"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
</server>
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="test">
<jta-data-source>java:jboss/datasources/xcs</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
\ No newline at end of file
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Pet Store JSF</display-name>
<welcome-file-list>
<welcome-file>/faces/index.xhtml</welcome-file>
</welcome-file-list>
<!--Defining security constraint for type of roles available -->
<security-constraint>
<web-resource-collection>
<web-resource-name>admin</web-resource-name>
<url-pattern>/api/owner/*</url-pattern>
<http-method-omission>OPTIONS</http-method-omission>
</web-resource-collection>
<auth-constraint>
<role-name>ADMIN</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>owner</web-resource-name>
<url-pattern>/api/pet/*</url-pattern>
<http-method-omission>OPTIONS</http-method-omission>
</web-resource-collection>
<auth-constraint>
<role-name>OWNER</role-name>
</auth-constraint>
</security-constraint>
<!--Defining security constraint for type of roles available -->
<!--Denining security role -->
<security-role>
<role-name>ADMIN</role-name>
</security-role>
<security-role>
<role-name>OWNER</role-name>
</security-role>
<!--Denining security role -->
</web-app>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<extension qualifier="persistence">
<property name="defaultDataSeedStrategy">CLEAN_INSERT</property>
</extension>
<container qualifier="wildfly-embedded-h2" default="true">
<configuration>
<property name="jbossHome">target/wildfly-${wildfly.version}</property>
<property name="modulePath">target/wildfly-${wildfly.version}/modules</property>
</configuration>
</container>
<container qualifier="wildfly-embedded-mysql">
<configuration>
<property name="jbossHome">target/wildfly-${wildfly.version}</property>
<property name="modulePath">target/wildfly-${wildfly.version}/modules</property>
</configuration>
</container>
</arquillian>
\ No newline at end of file
......@@ -13,6 +13,8 @@
<module>tests</module>
<module>service</module>
<module>rest</module>
<module>jsf</module>
<module>ear</module>
</modules>
<properties>
......@@ -22,17 +24,17 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- BOM versions -->
<javaee.api.version>7.0</javaee.api.version>
<arquillian.version>1.1.9.Final</arquillian.version>
<arquillian.rest.version>1.0.0.Alpha3</arquillian.rest.version>
<arquillian.selenium.version>2.47.1</arquillian.selenium.version>
<arquillian.selenium.version>2.48.2</arquillian.selenium.version>
<!-- Dependencies versions -->
<wildfly.version>8.2.1.Final</wildfly.version>
<commons.lang3.version>3.4</commons.lang3.version>
<!-- Testing dependecies versions -->
<junit.version>4.12</junit.version>
<hamcrest.version>2.0.0.0</hamcrest.version>
......@@ -41,13 +43,14 @@
<slf4j.version>1.5.10</slf4j.version>
<easymock.version>3.4</easymock.version>
<resteasy.version>3.0.13.Final</resteasy.version>
<graphene.webdrive.version>2.1.0.Alpha2</graphene.webdrive.version>
<graphene.webdrive.version>2.1.0.Alpha3</graphene.webdrive.version>
<!-- Plugins versions -->
<wildfly.maven.plugin.version>1.1.0.Alpha1</wildfly.maven.plugin.version>
<wildfly.maven.plugin.version>1.1.0.Alpha4</wildfly.maven.plugin.version>
<maven.dependency.plugin.version>2.10</maven.dependency.plugin.version>
<maven.surefire.plugin.version>2.18.1</maven.surefire.plugin.version>
<maven.resources.plugin.version>2.7</maven.resources.plugin.version>
<maven.ear.plugin>2.10.1</maven.ear.plugin>
</properties>
<dependencyManagement>
......@@ -72,7 +75,7 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Modules -->
<dependency>
<groupId>${project.groupId}</groupId>
......@@ -89,20 +92,25 @@
<artifactId>rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jsf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<!-- General -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version>
</dependency>
<!-- Testing -->
<dependency>
<groupId>junit</groupId>
......@@ -197,7 +205,13 @@
<artifactId>wildfly-maven-plugin</artifactId>
<version>${wildfly.maven.plugin.version}</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${maven.ear.plugin}</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
......@@ -335,7 +349,7 @@
</plugins>
</build>
</profile>
<profile>
<id>wildfly-embedded-mysql</id>
<dependencies>
......
......@@ -22,6 +22,7 @@
<dependency>
<groupId>es.uvigo.esei.xcs</groupId>
<artifactId>service</artifactId>
<scope>provided</scope>
</dependency>
<!-- Testing -->
......
package es.uvigo.esei.xcs.domain.entities;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
......@@ -47,6 +49,33 @@ public class OwnersDataset {
};
}
public static Owner[] ownersAnd(Owner ... additionalOwners) {
final Owner[] owners = owners();
final Owner[] ownersWithNewOwner = new Owner[owners.length + additionalOwners.length];
System.arraycopy(owners, 0, ownersWithNewOwner, 0, owners.length);
System.arraycopy(additionalOwners, 0, ownersWithNewOwner, owners.length, additionalOwners.length);
return ownersWithNewOwner;
}
public static Owner[] ownersWithout(Owner ... removeOwners) {
final List<Owner> owners = new ArrayList<>(asList(owners()));
for (Owner owner : removeOwners) {
final Iterator<Owner> itOwner = owners.iterator();
while (itOwner.hasNext()) {
if (itOwner.next().getLogin().equals(owner.getLogin())) {
itOwner.remove();
break;
}
}
}
return owners.toArray(new Owner[owners.size()]);
}
public static String petNameWithMultipleOwners() {
return "Max";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment