Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

code review, still need to move unit test to groovy

  • Loading branch information...
commit dc7de7e725d8836726d5215c55f55ed67e11db3b 1 parent b8adfa6
@ccordenier authored
Showing with 80 additions and 1,230 deletions.
  1. +1 −1  src/main/java/com/tap5/hotelbooking/annotations/AnonymousAccess.java
  2. +4 −2 src/main/java/com/tap5/hotelbooking/components/AjaxLoader.java
  3. +4 −4 src/main/java/com/tap5/hotelbooking/components/HotelClass.java
  4. +2 −9 src/main/java/com/tap5/hotelbooking/components/Layout.java
  5. +1 −2  src/main/java/com/tap5/hotelbooking/components/Workspace.java
  6. +4 −4 src/main/java/com/tap5/hotelbooking/components/YourBookings.java
  7. +0 −1  src/main/java/com/tap5/hotelbooking/data/BedType.java
  8. +0 −17 src/main/java/com/tap5/hotelbooking/data/HotelBookingConstants.java
  9. +3 −4 src/main/java/com/tap5/hotelbooking/data/UserWorkspace.java
  10. +0 −3  src/main/java/com/tap5/hotelbooking/data/Years.java
  11. +0 −96 src/main/java/com/tap5/hotelbooking/domain/CrudServiceDAO.java
  12. +0 −97 src/main/java/com/tap5/hotelbooking/domain/HibernateCrudServiceDAO.java
  13. +0 −44 src/main/java/com/tap5/hotelbooking/domain/HibernateModule.java
  14. +0 −37 src/main/java/com/tap5/hotelbooking/domain/QueryParameters.java
  15. +0 −311 src/main/java/com/tap5/hotelbooking/domain/entities/Booking.java
  16. +0 −6 src/main/java/com/tap5/hotelbooking/domain/entities/CreditCardType.java
  17. +0 −201 src/main/java/com/tap5/hotelbooking/domain/entities/Hotel.java
  18. +0 −154 src/main/java/com/tap5/hotelbooking/domain/entities/User.java
  19. +3 −3 src/main/java/com/tap5/hotelbooking/pages/Book.java
  20. +1 −8 src/main/java/com/tap5/hotelbooking/pages/Index.java
  21. +1 −2  src/main/java/com/tap5/hotelbooking/pages/Search.java
  22. +2 −2 src/main/java/com/tap5/hotelbooking/pages/Settings.java
  23. +3 −3 src/main/java/com/tap5/hotelbooking/pages/Signup.java
  24. +3 −3 src/main/java/com/tap5/hotelbooking/pages/View.java
  25. +0 −4 src/main/java/com/tap5/hotelbooking/security/AuthenticationException.java
  26. +6 −12 src/main/java/com/tap5/hotelbooking/security/AuthenticationFilter.java
  27. +1 −1  src/main/java/com/tap5/hotelbooking/services/Authenticator.java
  28. +3 −3 src/main/java/com/tap5/hotelbooking/services/BasicAuthenticator.java
  29. +0 −131 src/main/java/com/tap5/hotelbooking/services/DemoDataModule.java
  30. +11 −10 src/main/java/com/tap5/hotelbooking/services/HotelBookingModule.java
  31. +0 −2  src/test/java/com/tap5/hotelbooking/test/integration/BaseIntegrationTestSuite.java
  32. +11 −10 src/test/java/com/tap5/hotelbooking/test/integration/BookHotelTest.java
  33. +15 −13 src/test/java/com/tap5/hotelbooking/test/integration/SearchPageTest.java
  34. +0 −26 src/test/java/com/tap5/hotelbooking/test/services/TestModule.java
  35. +1 −4 src/test/java/com/tap5/hotelbooking/test/unit/BaseUnitTestSuite.java
View
2  src/main/java/com/tap5/hotelbooking/annotations/AnonymousAccess.java
@@ -8,7 +8,7 @@
/**
* Security annotation for Tapestry Pages. Enables anonymous access to pages, so the user does not
- * have to be logged in
+ * have to be logged in.
*
* @author karesti
* @version 1.0
View
6 src/main/java/com/tap5/hotelbooking/components/AjaxLoader.java
@@ -3,6 +3,7 @@
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.BeginRender;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
@@ -55,7 +56,7 @@ String defaultElement()
}
@BeginRender
- void initMoreLink(MarkupWriter writer)
+ void initAjaxLoader(MarkupWriter writer)
{
loader = javascriptSupport.allocateClientId("loader");
@@ -66,7 +67,8 @@ void initMoreLink(MarkupWriter writer)
javascriptSupport.addInitializerCall(InitializationPriority.LATE, "initAjaxLoader", data);
}
- void afterRender(MarkupWriter writer)
+ @AfterRender
+ void writeAjaxLoader(MarkupWriter writer)
{
writer.element(element, "id", loader, "class", this.loaderClass, "style", "display:none;");
writer.end();
View
8 src/main/java/com/tap5/hotelbooking/components/HotelClass.java
@@ -7,16 +7,16 @@
import org.apache.tapestry5.services.AssetSource;
/**
- * Use this component with beandisplay to display an images for hotel's class.
- * It will display the image that corresponds to the number of stars of the hotel.
- *
+ * Use this component with beandisplay to display an images for hotel's class. It will display the
+ * image that corresponds to the number of stars of the hotel.
+ *
* @author ccordenier
*/
public class HotelClass
{
@Parameter(required = true)
@Property
- private Long stars;
+ private long stars;
@Inject
private AssetSource assetSource;
View
11 src/main/java/com/tap5/hotelbooking/components/Layout.java
@@ -9,7 +9,7 @@
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.entities.User;
import com.tap5.hotelbooking.pages.Index;
import com.tap5.hotelbooking.services.Authenticator;
@@ -47,14 +47,7 @@ public String getClassForPageName()
public User getUser()
{
- User user = null;
-
- if (authenticator.isLoggedIn())
- {
- user = authenticator.getLoggedUser();
- }
-
- return user;
+ return authenticator.isLoggedIn() ? authenticator.getLoggedUser() : null;
}
@Log
View
3  src/main/java/com/tap5/hotelbooking/components/Workspace.java
@@ -11,7 +11,7 @@
import org.apache.tapestry5.services.PageRenderLinkSource;
import com.tap5.hotelbooking.data.UserWorkspace;
-import com.tap5.hotelbooking.domain.entities.Booking;
+import com.tap5.hotelbooking.entities.Booking;
/**
* Display the list of current booking that has not been confirmed yet. You can click on displayed
@@ -22,7 +22,6 @@
*/
public class Workspace
{
-
@SessionState
@Property
private UserWorkspace userWorkspace;
View
8 src/main/java/com/tap5/hotelbooking/components/YourBookings.java
@@ -7,9 +7,9 @@
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.QueryParameters;
-import com.tap5.hotelbooking.domain.entities.Booking;
+import com.tap5.hotelbooking.dal.CrudServiceDAO;
+import com.tap5.hotelbooking.dal.QueryParameters;
+import com.tap5.hotelbooking.entities.Booking;
import com.tap5.hotelbooking.services.Authenticator;
/**
@@ -34,7 +34,7 @@
/**
* Prepare the list of booking to display, extract all the booking associated to the current
- * user.
+ * logged user.
*
* @return
*/
View
1  src/main/java/com/tap5/hotelbooking/data/BedType.java
@@ -28,7 +28,6 @@ public BedType()
public List<OptionGroupModel> getOptionGroups()
{
- // TODO Auto-generated method stub
return null;
}
View
17 src/main/java/com/tap5/hotelbooking/data/HotelBookingConstants.java
@@ -1,17 +0,0 @@
-package com.tap5.hotelbooking.data;
-
-/**
- * Define the Hotel booking symbols constants.
- *
- * @author ccordenier
- */
-public class HotelBookingConstants
-{
-
- public static final String DEFAULT_PAGE = "hotelbooking.default-page";
-
- public static final String SIGNIN_PAGE = "hotelbooking.signin-page";
-
- public static final String SIGNUP_PAGE = "hotelbooking.signup-page";
-
-}
View
7 src/main/java/com/tap5/hotelbooking/data/UserWorkspace.java
@@ -3,9 +3,9 @@
import java.util.ArrayList;
import java.util.List;
-import com.tap5.hotelbooking.domain.entities.Booking;
-import com.tap5.hotelbooking.domain.entities.Hotel;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.entities.Booking;
+import com.tap5.hotelbooking.entities.Hotel;
+import com.tap5.hotelbooking.entities.User;
/**
* Use this object to store user's booking
@@ -72,7 +72,6 @@ public Booking restoreBooking(Long bookId)
public void cancelCurrentBooking(Booking booking)
{
removeCurrentBooking(booking);
-
}
public void confirmCurrentBooking(Booking booking)
View
3  src/main/java/com/tap5/hotelbooking/data/Years.java
@@ -16,18 +16,15 @@
public Years()
{
-
int year = Calendar.getInstance().get(Calendar.YEAR);
for (int i = 0; i < 6; i++)
{
options.add(new OptionModelImpl(year + i + ""));
}
-
}
public List<OptionGroupModel> getOptionGroups()
{
- // TODO Auto-generated method stub
return null;
}
View
96 src/main/java/com/tap5/hotelbooking/domain/CrudServiceDAO.java
@@ -1,96 +0,0 @@
-package com.tap5.hotelbooking.domain;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tapestry5.hibernate.annotations.CommitAfter;
-
-/**
- * CrudServiceDAO interface.
- *
- * @author karesti
- */
-public interface CrudServiceDAO
-{
- /**
- * Creates a new object for the given type
- *
- * @param <T>
- * @param t
- * @return persisted Object
- */
- @CommitAfter
- <T> T create(T t);
-
- /**
- * Updates the given object
- *
- * @param <T>
- * @param t
- * @return persisted object
- */
- @CommitAfter
- <T> T update(T t);
-
- /**
- * Deletes the given object by id
- *
- * @param <T>
- * @param <PK>
- * @param type
- * , entity class type
- * @param id
- */
- @CommitAfter
- <T, PK extends Serializable> void delete(Class<T> type, PK id);
-
- /**
- * Finds an object by id
- *
- * @param <T>
- * @param <PK>
- * @param type
- * @param id
- * @return the object
- */
- <T, PK extends Serializable> T find(Class<T> type, PK id);
-
- /**
- * Finds a list of objects for the given query name
- *
- * @param <T>
- * @param queryName
- * @return returns a list of objects
- */
- <T> List<T> findWithNamedQuery(String queryName);
-
- /**
- * Find a query with parameters
- *
- * @param <T>
- * @param queryName
- * @param params
- * @return resulting list
- */
- <T> List<T> findWithNamedQuery(String queryName, Map<String, Object> params);
-
- /**
- * Returns one result, query without parameters
- *
- * @param <T>
- * @param queryName
- * @return T object
- */
- <T> T findUniqueWithNamedQuery(String queryName);
-
- /**
- * Returns just one result with a named query and parameters
- *
- * @param <T>
- * @param queryName
- * @param params
- * @return T object
- */
- <T> T findUniqueWithNamedQuery(String queryName, Map<String, Object> params);
-}
View
97 src/main/java/com/tap5/hotelbooking/domain/HibernateCrudServiceDAO.java
@@ -1,97 +0,0 @@
-package com.tap5.hotelbooking.domain;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.hibernate.Query;
-import org.hibernate.Session;
-
-/**
- * Hibernate CrudService
- *
- * @author karesti
- * @param <T>, type entity
- * @param <PK>, primarykey, the primary key
- */
-public class HibernateCrudServiceDAO implements CrudServiceDAO
-{
-
- @Inject
- private Session session;
-
- public <T> HibernateCrudServiceDAO(Class<T> type)
- {
-
- }
-
- public <T> T create(T t)
- {
- session.persist(t);
- session.flush();
- session.refresh(t);
- return t;
- }
-
- @SuppressWarnings("unchecked")
- public <T, PK extends Serializable> T find(Class<T> type, PK id)
- {
- return (T) session.get(type, id);
- }
-
- public <T> T update(T type)
- {
- session.merge(type);
- return type;
- }
-
- public <T, PK extends Serializable> void delete(Class<T> type, PK id)
- {
- @SuppressWarnings("unchecked")
- T ref = (T) session.get(type, id);
- session.delete(ref);
- }
-
- @SuppressWarnings("unchecked")
- public <T> List<T> findWithNamedQuery(String queryName)
- {
- return session.getNamedQuery(queryName).list();
- }
-
- @SuppressWarnings("unchecked")
- public <T> List<T> findWithNamedQuery(String queryName, Map<String, Object> params)
- {
- Set<Entry<String, Object>> rawParameters = params.entrySet();
- Query query = session.getNamedQuery(queryName);
-
- for (Entry<String, Object> entry : rawParameters)
- {
- query.setParameter(entry.getKey(), entry.getValue());
-
- }
- return query.list();
- }
-
- @SuppressWarnings("unchecked")
- public <T> T findUniqueWithNamedQuery(String queryName)
- {
- return (T) session.getNamedQuery(queryName).uniqueResult();
- }
-
- @SuppressWarnings("unchecked")
- public <T> T findUniqueWithNamedQuery(String queryName, Map<String, Object> params)
- {
- Set<Entry<String, Object>> rawParameters = params.entrySet();
- Query query = session.getNamedQuery(queryName);
-
- for (Entry<String, Object> entry : rawParameters)
- {
- query.setParameter(entry.getKey(), entry.getValue());
-
- }
- return (T) query.uniqueResult();
- }
-}
View
44 src/main/java/com/tap5/hotelbooking/domain/HibernateModule.java
@@ -1,44 +0,0 @@
-package com.tap5.hotelbooking.domain;
-
-import org.apache.tapestry5.beanvalidator.BeanValidatorConfigurer;
-import org.apache.tapestry5.hibernate.HibernateTransactionAdvisor;
-import org.apache.tapestry5.ioc.Configuration;
-import org.apache.tapestry5.ioc.MethodAdviceReceiver;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
-import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.annotations.Match;
-
-/**
- * This class should contain contribution to data stuff (hibernate configuration, beanvalidators...)
- */
-public class HibernateModule
-{
- public static void bind(ServiceBinder binder)
- {
- binder.bind(CrudServiceDAO.class, HibernateCrudServiceDAO.class);
- }
-
- public static void contributeHibernateEntityPackageManager(Configuration<String> configuration)
- {
- configuration.add("com.tap5.hotelbooking.domain.entities");
- }
-
- public static void contributeBeanValidatorSource(
- OrderedConfiguration<BeanValidatorConfigurer> configuration)
- {
- configuration.add("HotelBookingConfigurer", new BeanValidatorConfigurer()
- {
- public void configure(javax.validation.Configuration<?> configuration)
- {
- configuration.ignoreXmlConfiguration();
- }
- });
- }
-
- @Match("*DAO")
- public static void adviseTransactions(HibernateTransactionAdvisor advisor,
- MethodAdviceReceiver receiver)
- {
- advisor.addTransactionCommitAdvice(receiver);
- }
-}
View
37 src/main/java/com/tap5/hotelbooking/domain/QueryParameters.java
@@ -1,37 +0,0 @@
-package com.tap5.hotelbooking.domain;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * NamedQuery parameter helper to create the querys
- *
- * @author karesti
- */
-public class QueryParameters
-{
-
- private Map<String, Object> parameters = null;
-
- private QueryParameters(String name, Object value)
- {
- this.parameters = new HashMap<String, Object>();
- this.parameters.put(name, value);
- }
-
- public static QueryParameters with(String name, Object value)
- {
- return new QueryParameters(name, value);
- }
-
- public QueryParameters and(String name, Object value)
- {
- this.parameters.put(name, value);
- return this;
- }
-
- public Map<String, Object> parameters()
- {
- return this.parameters;
- }
-}
View
311 src/main/java/com/tap5/hotelbooking/domain/entities/Booking.java
@@ -1,311 +0,0 @@
-package com.tap5.hotelbooking.domain.entities;
-
-import static javax.persistence.TemporalType.DATE;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
-import javax.validation.constraints.Size;
-
-/**
- * <p>
- * <strong>Booking</strong> is the model/entity class that represents a hotel booking.
- * </p>
- *
- * @author Gavin King
- * @author Dan Allen
- */
-@Entity
-@NamedQueries(
-{ @NamedQuery(name = Booking.BY_USERNAME, query = "Select b from Booking b where b.user.username = :username") })
-@Table(name = "bookings")
-public class Booking implements Serializable
-{
- /**
- *
- */
- private static final long serialVersionUID = -6176295317720795275L;
-
- public static final String BY_USERNAME = "Booking.byUsername";
-
- private Long id;
-
- private User user;
-
- private Hotel hotel;
-
- private Date checkinDate;
-
- private Date checkoutDate;
-
- private String creditCardNumber;
-
- private CreditCardType creditCardType;
-
- private String creditCardName;
-
- private int creditCardExpiryMonth;
-
- private int creditCardExpiryYear;
-
- private boolean smoking;
-
- private int beds;
-
- private Date creationDate;
-
- @Transient
- private boolean status;
-
- public Booking()
- {
- }
-
- public Booking(Hotel hotel, User user, int daysFromNow, int nights)
- {
- this.hotel = hotel;
- this.user = user;
- this.creditCardName = user.getFullname();
- this.smoking = false;
- this.beds = 1;
- setReservationDates(daysFromNow, nights);
- creditCardExpiryMonth = Calendar.getInstance().get(Calendar.MONTH) + 1;
- this.creationDate = new Date();
- this.status = false;
- }
-
- @Id
- @GeneratedValue
- public Long getId()
- {
- return id;
- }
-
- public void setId(Long id)
- {
- this.id = id;
- }
-
- @NotNull
- @Temporal(DATE)
- public Date getCheckinDate()
- {
- return checkinDate;
- }
-
- public void setCheckinDate(Date datetime)
- {
- this.checkinDate = datetime;
- }
-
- @NotNull
- @ManyToOne
- public Hotel getHotel()
- {
- return hotel;
- }
-
- public void setHotel(Hotel hotel)
- {
- this.hotel = hotel;
- }
-
- @NotNull
- @ManyToOne
- public User getUser()
- {
- return user;
- }
-
- public void setUser(User user)
- {
- this.user = user;
- }
-
- @NotNull
- @Temporal(TemporalType.DATE)
- public Date getCheckoutDate()
- {
- return checkoutDate;
- }
-
- public void setCheckoutDate(Date checkoutDate)
- {
- this.checkoutDate = checkoutDate;
- }
-
- public boolean isSmoking()
- {
- return smoking;
- }
-
- public void setSmoking(boolean smoking)
- {
- this.smoking = smoking;
- }
-
- // @Size(min = 1, max = 3)
- public int getBeds()
- {
- return beds;
- }
-
- public void setBeds(int beds)
- {
- this.beds = beds;
- }
-
- @NotNull(message = "Credit card number is required")
- @Size(min = 16, max = 16, message = "Credit card number must 16 digits long")
- @Pattern(regexp = "^\\d*$", message = "Credit card number must be numeric")
- public String getCreditCardNumber()
- {
- return creditCardNumber;
- }
-
- public void setCreditCardNumber(String creditCardNumber)
- {
- this.creditCardNumber = creditCardNumber;
- }
-
- @NotNull(message = "Credit card type is required")
- @Enumerated(EnumType.STRING)
- public CreditCardType getCreditCardType()
- {
- return creditCardType;
- }
-
- public void setCreditCardType(CreditCardType creditCardType)
- {
- this.creditCardType = creditCardType;
- }
-
- @NotNull(message = "Credit card name is required")
- @Size(min = 3, max = 70, message = "Credit card name is required")
- public String getCreditCardName()
- {
- return creditCardName;
- }
-
- public void setCreditCardName(String creditCardName)
- {
- this.creditCardName = creditCardName;
- }
-
- /**
- * The credit card expiration month, represented using a 1-based numeric value (i.e., Jan = 1,
- * Feb = 2, ...).
- *
- * @return 1-based numeric month value
- */
- public int getCreditCardExpiryMonth()
- {
- return creditCardExpiryMonth;
- }
-
- public void setCreditCardExpiryMonth(int creditCardExpiryMonth)
- {
- this.creditCardExpiryMonth = creditCardExpiryMonth;
- }
-
- /**
- * The credit card expiration year.
- *
- * @return numberic year value
- */
- public int getCreditCardExpiryYear()
- {
- return creditCardExpiryYear;
- }
-
- public void setCreditCardExpiryYear(int creditCardExpiryYear)
- {
- this.creditCardExpiryYear = creditCardExpiryYear;
- }
-
- @Transient
- public String getDescription()
- {
- DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
- return hotel == null ? null : hotel.getName() + ", " + df.format(getCheckinDate()) + " to "
- + df.format(getCheckoutDate());
- }
-
- @Transient
- public BigDecimal getTotal()
- {
- return hotel.getPrice().multiply(new BigDecimal(getNights()));
- }
-
- @Transient
- public int getNights()
- {
- return (int) (checkoutDate.getTime() - checkinDate.getTime()) / 1000 / 60 / 60 / 24;
- }
-
- /**
- * Initialize the check-in and check-out dates.
- *
- * @param daysFromNow
- * Number of days the stay will begin from now
- * @param nights
- * Length of the stay in number of nights
- */
- public void setReservationDates(int daysFromNow, int nights)
- {
- Calendar refDate = Calendar.getInstance();
- refDate.set(
- refDate.get(Calendar.YEAR),
- refDate.get(Calendar.MONTH),
- refDate.get(Calendar.DAY_OF_MONTH) + daysFromNow,
- 0,
- 0,
- 0);
- setCheckinDate(refDate.getTime());
- refDate.add(Calendar.DAY_OF_MONTH, nights);
- setCheckoutDate(refDate.getTime());
- }
-
- public Date getCreationDate()
- {
- return creationDate;
- }
-
- public void setCreationDate(Date creationDate)
- {
- this.creationDate = creationDate;
- }
-
- public Boolean getStatus()
- {
- return status;
- }
-
- public void setStatus(Boolean status)
- {
- this.status = status;
- }
-
- @Override
- public String toString()
- {
- return "Booking(" + user + ", " + hotel + ")";
- }
-}
View
6 src/main/java/com/tap5/hotelbooking/domain/entities/CreditCardType.java
@@ -1,6 +0,0 @@
-package com.tap5.hotelbooking.domain.entities;
-
-public enum CreditCardType
-{
- VISA, MasterCard, AMEX, Discover
-}
View
201 src/main/java/com/tap5/hotelbooking/domain/entities/Hotel.java
@@ -1,201 +0,0 @@
-package com.tap5.hotelbooking.domain.entities;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-import org.hibernate.annotations.NaturalId;
-
-/**
- * <p>
- * <strong>Hotel</strong> is the model/entity class that represents a hotel.
- * </p>
- *
- * @author Gavin King
- * @author Dan Allen
- */
-@Entity
-@Table(name = "hotel")
-public class Hotel implements Serializable
-{
- /**
- *
- */
- private static final long serialVersionUID = -9200804524025548138L;
-
- private Long id;
-
- @NaturalId
- @Column(unique = true)
- private String name;
-
- private String address;
-
- private String city;
-
- private String state;
-
- private String zip;
-
- private String country;
-
- private Integer stars;
-
- private BigDecimal price;
-
- public Hotel()
- {
- }
-
- public Hotel(final String name, final String address, final String city, final String state,
- final String zip, final String country)
- {
- this.name = name;
- this.address = address;
- this.city = city;
- this.state = state;
- this.zip = zip;
- this.country = country;
- }
-
- public Hotel(final int price, final int stars, final String name, final String address,
- final String city, final String state, final String zip, final String country)
- {
- this.price = new BigDecimal(price);
- this.stars = stars;
- this.name = name;
- this.address = address;
- this.city = city;
- this.state = state;
- this.zip = zip;
- this.country = country;
- }
-
- @Id
- @GeneratedValue
- public Long getId()
- {
- return id;
- }
-
- public void setId(final Long id)
- {
- this.id = id;
- }
-
- @Size(max = 50)
- @NotNull
- public String getName()
- {
- return name;
- }
-
- public void setName(final String name)
- {
- this.name = name;
- }
-
- @Size(max = 100)
- @NotNull
- public String getAddress()
- {
- return address;
- }
-
- public void setAddress(final String address)
- {
- this.address = address;
- }
-
- @Size(max = 40)
- @NotNull
- public String getCity()
- {
- return city;
- }
-
- public void setCity(final String city)
- {
- this.city = city;
- }
-
- @Size(min = 3, max = 6)
- @NotNull
- public String getZip()
- {
- return zip;
- }
-
- public void setZip(final String zip)
- {
- this.zip = zip;
- }
-
- @Size(min = 2, max = 10)
- public String getState()
- {
- return state;
- }
-
- public void setState(final String state)
- {
- this.state = state;
- }
-
- @Size(min = 2, max = 40)
- @NotNull
- public String getCountry()
- {
- return country;
- }
-
- public void setCountry(final String country)
- {
- this.country = country;
- }
-
- @Min(1)
- @Max(5)
- public Integer getStars()
- {
- return stars;
- }
-
- public void setStars(final Integer stars)
- {
- this.stars = stars;
- }
-
- @Column(precision = 6, scale = 2)
- public BigDecimal getPrice()
- {
- return price;
- }
-
- public void setPrice(final BigDecimal price)
- {
- this.price = price;
- }
-
- @Transient
- public String getLocation()
- {
- return city + ", " + state + ", " + country;
- }
-
- @Override
- public String toString()
- {
- return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
- }
-}
View
154 src/main/java/com/tap5/hotelbooking/domain/entities/User.java
@@ -1,154 +0,0 @@
-package com.tap5.hotelbooking.domain.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-import org.hibernate.annotations.NaturalId;
-import org.hibernate.validator.constraints.Email;
-
-/**
- * Hotel Booking User
- *
- * @author karesti
- */
-@Entity
-@NamedQueries(
-{
- @NamedQuery(name = User.ALL, query = "Select u from User u"),
- @NamedQuery(name = User.BY_USERNAME_OR_EMAIL, query = "Select u from User u where u.username = :username or u.email = :email"),
- @NamedQuery(name = User.BY_CREDENTIALS, query = "Select u from User u where u.username = :username and u.password = :password") })
-@Table(name = "users")
-public class User
-{
-
- public static final String ALL = "User.all";
-
- public static final String BY_USERNAME_OR_EMAIL = "User.byUserNameOrEmail";
-
- public static final String BY_CREDENTIALS = "User.byCredentials";
-
- private static final long serialVersionUID = 4060967693790504175L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @NaturalId
- @Column(nullable = false, unique = true)
- @NotNull
- @Size(min = 3, max = 15)
- private String username;
-
- @Column(nullable = false)
- @NotNull
- @Size(min = 3, max = 50)
- private String fullname;
-
- @Column(nullable = false)
- @NotNull
- @Email
- private String email;
-
- @Column(nullable = false)
- @Size(min = 3, max = 12)
- @NotNull
- private String password;
-
- public User()
- {
- }
-
- public User(final String fullname, final String username, final String email)
- {
- this.fullname = fullname;
- this.username = username;
- this.email = email;
- }
-
- public User(final String fullname, final String username, final String email,
- final String password)
- {
- this(fullname, username, email);
- this.password = password;
- }
-
- public User(Long id, String username, String fullname, String email, String password)
- {
- super();
- this.id = id;
- this.username = username;
- this.fullname = fullname;
- this.email = email;
- this.password = password;
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("id ");
- builder.append(id);
- builder.append(",");
- builder.append("username ");
- builder.append(username);
- return builder.toString();
- }
-
- public Long getId()
- {
- return id;
- }
-
- public void setId(Long id)
- {
- this.id = id;
- }
-
- public String getEmail()
- {
- return email;
- }
-
- public void setEmail(String email)
- {
- this.email = email;
- }
-
- public String getUsername()
- {
- return username;
- }
-
- public void setUsername(String username)
- {
- this.username = username;
- }
-
- public void setFullname(String fullname)
- {
- this.fullname = fullname;
- }
-
- public String getFullname()
- {
- return fullname;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setPassword(String password)
- {
- this.password = password;
- }
-}
View
6 src/main/java/com/tap5/hotelbooking/pages/Book.java
@@ -17,13 +17,13 @@
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
+import com.tap5.hotelbooking.dal.CrudServiceDAO;
import com.tap5.hotelbooking.data.BedType;
import com.tap5.hotelbooking.data.Months;
import com.tap5.hotelbooking.data.UserWorkspace;
import com.tap5.hotelbooking.data.Years;
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.entities.Booking;
-import com.tap5.hotelbooking.domain.entities.Hotel;
+import com.tap5.hotelbooking.entities.Booking;
+import com.tap5.hotelbooking.entities.Hotel;
/**
* This page implements booking process for a give hotel.
View
9 src/main/java/com/tap5/hotelbooking/pages/Index.java
@@ -16,13 +16,6 @@
public Object onActivate()
{
- if (authenticator.isLoggedIn())
- {
- return Search.class;
- }
- else
- {
- return Signin.class;
- }
+ return authenticator.isLoggedIn() ? Search.class : Signin.class;
}
}
View
3  src/main/java/com/tap5/hotelbooking/pages/Search.java
@@ -14,7 +14,7 @@
import org.hibernate.criterion.Restrictions;
import com.tap5.hotelbooking.data.SearchCriteria;
-import com.tap5.hotelbooking.domain.entities.Hotel;
+import com.tap5.hotelbooking.entities.Hotel;
/**
* Lookup for Hotels.
@@ -23,7 +23,6 @@
*/
public class Search
{
-
@Inject
private Session session;
View
4 src/main/java/com/tap5/hotelbooking/pages/Settings.java
@@ -7,8 +7,8 @@
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.dal.CrudServiceDAO;
+import com.tap5.hotelbooking.entities.User;
import com.tap5.hotelbooking.services.Authenticator;
/**
View
6 src/main/java/com/tap5/hotelbooking/pages/Signup.java
@@ -11,9 +11,9 @@
import org.apache.tapestry5.ioc.annotations.Inject;
import com.tap5.hotelbooking.annotations.AnonymousAccess;
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.QueryParameters;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.dal.CrudServiceDAO;
+import com.tap5.hotelbooking.dal.QueryParameters;
+import com.tap5.hotelbooking.entities.User;
import com.tap5.hotelbooking.security.AuthenticationException;
import com.tap5.hotelbooking.services.Authenticator;
View
6 src/main/java/com/tap5/hotelbooking/pages/View.java
@@ -7,10 +7,10 @@
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;
+import com.tap5.hotelbooking.dal.CrudServiceDAO;
import com.tap5.hotelbooking.data.UserWorkspace;
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.entities.Hotel;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.entities.Hotel;
+import com.tap5.hotelbooking.entities.User;
import com.tap5.hotelbooking.services.Authenticator;
/**
View
4 src/main/java/com/tap5/hotelbooking/security/AuthenticationException.java
@@ -16,25 +16,21 @@
public AuthenticationException()
{
super();
-
}
public AuthenticationException(String message, Throwable cause)
{
super(message, cause);
-
}
public AuthenticationException(String message)
{
super(message);
-
}
public AuthenticationException(Throwable cause)
{
super(cause);
-
}
}
View
18 src/main/java/com/tap5/hotelbooking/security/AuthenticationFilter.java
@@ -3,8 +3,6 @@
import java.io.IOException;
import org.apache.tapestry5.Link;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.runtime.Component;
import org.apache.tapestry5.services.ComponentEventRequestParameters;
import org.apache.tapestry5.services.ComponentRequestFilter;
@@ -15,7 +13,9 @@
import org.apache.tapestry5.services.Response;
import com.tap5.hotelbooking.annotations.AnonymousAccess;
-import com.tap5.hotelbooking.data.HotelBookingConstants;
+import com.tap5.hotelbooking.pages.Search;
+import com.tap5.hotelbooking.pages.Signin;
+import com.tap5.hotelbooking.pages.Signup;
import com.tap5.hotelbooking.services.Authenticator;
/**
@@ -38,17 +38,11 @@
private final Authenticator authenticator;
- @Inject
- @Symbol(HotelBookingConstants.DEFAULT_PAGE)
- private String defaultPage;
+ private String defaultPage = Search.class.getSimpleName();
- @Inject
- @Symbol(HotelBookingConstants.SIGNIN_PAGE)
- private String signinPage;
+ private String signinPage = Signin.class.getSimpleName();
- @Inject
- @Symbol(HotelBookingConstants.SIGNUP_PAGE)
- private String signupPage;
+ private String signupPage = Signup.class.getSimpleName();
public AuthenticationFilter(PageRenderLinkSource renderLinkSource,
ComponentSource componentSource, Response response, Authenticator authenticator)
View
2  src/main/java/com/tap5/hotelbooking/services/Authenticator.java
@@ -1,6 +1,6 @@
package com.tap5.hotelbooking.services;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.entities.User;
import com.tap5.hotelbooking.security.AuthenticationException;
/**
View
6 src/main/java/com/tap5/hotelbooking/services/BasicAuthenticator.java
@@ -4,9 +4,9 @@
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.Session;
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.QueryParameters;
-import com.tap5.hotelbooking.domain.entities.User;
+import com.tap5.hotelbooking.dal.CrudServiceDAO;
+import com.tap5.hotelbooking.dal.QueryParameters;
+import com.tap5.hotelbooking.entities.User;
import com.tap5.hotelbooking.security.AuthenticationException;
/**
View
131 src/main/java/com/tap5/hotelbooking/services/DemoDataModule.java
@@ -1,131 +0,0 @@
-package com.tap5.hotelbooking.services;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tapestry5.ioc.annotations.Startup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.tap5.hotelbooking.domain.CrudServiceDAO;
-import com.tap5.hotelbooking.domain.entities.Hotel;
-import com.tap5.hotelbooking.domain.entities.User;
-
-/**
- * Demo Data Loader
- *
- * @author karesti
- * @version 1.0
- */
-public class DemoDataModule
-{
- private static final Logger LOGGER = LoggerFactory.getLogger(DemoDataModule.class);
-
- private final CrudServiceDAO dao;
-
- public DemoDataModule(CrudServiceDAO dao)
- {
- super();
- this.dao = dao;
- }
-
- @Startup
- public void initialize()
- {
- List<Hotel> hotels = new ArrayList<Hotel>();
- List<User> users = new ArrayList<User>();
-
- users.add(new User("Christophe Cordenier", "cordenier", "ccordenier@example.com",
- "cordenier"));
- users.add(new User("Katia Aresti", "karesti", "karesti@example.com", "karesti"));
-
- hotels.add(new Hotel(129, 3, "Marriott Courtyard", "Tower Place, Buckhead", "Atlanta",
- "GA", "30305", "USA"));
-
- hotels.add(new Hotel(84, 4, "Doubletree Atlanta-Buckhead", "3342 Peachtree Road NE",
- "Atlanta", "GA", "30326", "USA"));
-
- hotels.add(new Hotel(289, 4, "W New York - Union Square", "201 Park Avenue South",
- "New York", "NY", "10003", "USA"));
-
- hotels.add(new Hotel(219, 3, "W New York", "541 Lexington Avenue", "New York", "NY",
- "10022", "USA"));
-
- hotels.add(new Hotel(250, 3, "Hotel Rouge", "1315 16th Street NW", "Washington", "DC",
- "20036", "USA"));
-
- hotels.add(new Hotel(159, 4, "70 Park Avenue Hotel", "70 Park Avenue, 38th St", "New York",
- "NY", "10016", "USA"));
-
- hotels.add(new Hotel(198, 4, "Parc 55", "55 Cyril Magnin Street", "San Francisco", "CA",
- "94102", "USA"));
-
- hotels.add(new Hotel(189, 4, "Conrad Miami", "1395 Brickell Ave", "Miami", "FL", "33131",
- "USA"));
-
- hotels.add(new Hotel(111, 4, "Grand Hyatt", "345 Stockton Street", "San Francisco", "CA",
- "94108", "USA"));
-
- hotels.add(new Hotel(54, 1, "Super 8 Eau Claire Campus Area", "1151 W MacArthur Ave",
- "Eau Claire", "WI", "54701", "USA"));
-
- hotels.add(new Hotel(199, 4, "San Francisco Marriott", "55 Fourth Street", "San Francisco",
- "CA", "94103", "USA"));
-
- hotels.add(new Hotel(543, 4, "Hilton Diagonal Mar", "Passeig del Taulat 262-264",
- "Barcelona", "Catalunya", "08019", "ES"));
-
- hotels.add(new Hotel(335, 5, "Hilton Tel Aviv", "Independence Park", "Tel Aviv", null,
- "63405", "IL"));
-
- hotels.add(new Hotel(242, 5, "InterContinental Hotel Tokyo Bay", "1-15-2 Kaigan", "Tokyo",
- "Minato", "105", "JP"));
-
- hotels.add(new Hotel(130, 4, "Hotel Beaulac", " Esplanade Léopold-Robert 2", "Neuchatel",
- null, "2000", "CH"));
-
- hotels.add(new Hotel(266, 5, "Conrad Treasury Place", "130 William Street", "Brisbane",
- "QL", "4001", "AU"));
-
- hotels.add(new Hotel(170, 4, "Ritz-Carlton Montreal", "1228 Sherbrooke St West",
- "Montreal", "Quebec", "H3G1H6", "CA"));
-
- hotels.add(new Hotel(179, 4, "Ritz-Carlton Atlanta", "181 Peachtree St NE", "Atlanta",
- "GA", "30303", "USA"));
-
- hotels.add(new Hotel(145, 4, "Swissotel Sydney", "68 Market Street", "Sydney", "NSW",
- "2000", "AU"));
-
- hotels.add(new Hotel(178, 4, "Melié White House", "Albany Street Regents Park", "London",
- null, "NW13UP", "GB"));
-
- hotels.add(new Hotel(159, 3, "Hotel Allegro", "171 W Randolph Street", "Chicago", "IL",
- "60601", "USA"));
-
- hotels.add(new Hotel(296, 5, "Caesars Palace", "3570 Las Vegas Blvd S", "Las Vegas", "NV",
- "89109", "USA"));
-
- hotels.add(new Hotel(300, 4, "Mandalay Bay Resort & Casino", "3950 Las Vegas Blvd S",
- "Las Vegas", "NV", "89119", "USA"));
-
- hotels.add(new Hotel(100, 2, "Hotel Cammerpoorte", "Nationalestraat 38-40", "Antwerp",
- null, "2000", "BE"));
-
- LOGGER.info("-- Loading initial demo data");
- create(users);
- create(hotels);
-
- List<User> userList = dao.findWithNamedQuery(User.ALL);
- LOGGER.info("Users " + userList);
- LOGGER.info("-- Data Loaded. Exit");
- }
-
- private void create(List<?> entities)
- {
- for (Object e : entities)
- {
- dao.create(e);
- }
- }
-
-}
View
21 src/main/java/com/tap5/hotelbooking/services/HotelBookingModule.java
@@ -6,11 +6,14 @@
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.SubModule;
+import org.apache.tapestry5.ioc.services.ApplicationDefaults;
+import org.apache.tapestry5.ioc.services.SymbolProvider;
+import org.apache.tapestry5.services.ComponentRequestFilter;
import org.apache.tapestry5.services.ComponentRequestHandler;
import org.apache.tapestry5.validator.ValidatorMacro;
-import com.tap5.hotelbooking.data.HotelBookingConstants;
-import com.tap5.hotelbooking.domain.HibernateModule;
+import com.tap5.hotelbooking.dal.DataModule;
+import com.tap5.hotelbooking.dal.HibernateModule;
import com.tap5.hotelbooking.security.AuthenticationFilter;
/**
@@ -18,7 +21,7 @@
* configure and extend Tapestry, or to place your own service definitions.
*/
@SubModule(
-{ HibernateModule.class, DemoDataModule.class })
+{ HibernateModule.class, DataModule.class })
public class HotelBookingModule
{
public static void bind(ServiceBinder binder)
@@ -26,15 +29,14 @@ public static void bind(ServiceBinder binder)
binder.bind(Authenticator.class, BasicAuthenticator.class);
}
- public static void contributeApplicationDefaults(
+ @ApplicationDefaults
+ @Contribute(SymbolProvider.class)
+ public static void configureTapestryHotelBooking(
MappedConfiguration<String, String> configuration)
{
configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
configuration.add(SymbolConstants.APPLICATION_VERSION, "1.0-SNAPSHOT");
- configuration.add(HotelBookingConstants.DEFAULT_PAGE, "Search");
- configuration.add(HotelBookingConstants.SIGNIN_PAGE, "Signin");
- configuration.add(HotelBookingConstants.SIGNUP_PAGE, "Signup");
}
@Contribute(ValidatorMacro.class)
@@ -44,10 +46,9 @@ public static void combineValidators(MappedConfiguration<String, String> configu
configuration.add("password", "required, minlength=6, maxlength=12");
}
- @SuppressWarnings(
- { "rawtypes", "unchecked" })
@Contribute(ComponentRequestHandler.class)
- public static void contributeComponentRequestHandler(OrderedConfiguration configuration)
+ public static void contributeComponentRequestHandler(
+ OrderedConfiguration<ComponentRequestFilter> configuration)
{
configuration.addInstance("RequiresLogin", AuthenticationFilter.class);
}
View
2  src/test/java/com/tap5/hotelbooking/test/integration/BaseIntegrationTestSuite.java
@@ -12,6 +12,4 @@
public abstract class BaseIntegrationTestSuite extends SeleniumTestCase
{
-
-
}
View
21 src/test/java/com/tap5/hotelbooking/test/integration/BookHotelTest.java
@@ -1,7 +1,6 @@
package com.tap5.hotelbooking.test.integration;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
@@ -11,7 +10,7 @@
*/
public class BookHotelTest extends BaseIntegrationTestSuite
{
- @Test(testName = "signin")
+ @Test(priority = 1, groups="booking")
public void signin()
{
open("/signin");
@@ -29,7 +28,7 @@ public void signin()
/**
* Check wildcards
*/
- @Test(testName = "bookProcess", dependsOnMethods = "signin")
+ @Test(priority = 2, groups="booking")
public void bookProcess()
{
open("/view/1");
@@ -39,8 +38,11 @@ public void bookProcess()
click("//form[@id='startBookingForm']//input[@type='submit']");
waitForPageToLoad();
- assertEquals(getXpathCount("//ul[@id='workspace']/li"), 1, "There is only one booking in progress");
-
+ assertEquals(
+ getXpathCount("//ul[@id='workspace']/li"),
+ 1,
+ "There is only one booking in progress");
+
// Set user information
type("id=creditCardNumber", "1234567812345678");
select("id=creditCardType", "value=MasterCard");
@@ -51,7 +53,7 @@ public void bookProcess()
assertTrue(isTextPresent("129"));
click("//form[@id='confirmForm']//input[@type='submit']");
waitForPageToLoad();
-
+
// Cancel confirmation
assertEquals(getXpathCount("//ul[@id='your-bookings']/li"), 1);
click("//ul[@id='your-bookings']/li/a");
@@ -59,9 +61,8 @@ public void bookProcess()
assertFalse(isElementPresent("id=your-bookings"));
}
- @AfterClass(alwaysRun = true)
- @Override
- public void cleanup()
+ @Test(priority = 3, groups="booking")
+ public void logout()
{
open("/search");
waitForPageToLoad();
@@ -70,7 +71,7 @@ public void cleanup()
isElementPresent("id=logout"),
"Authenticated user should be able to logout");
click("id=logout");
- super.cleanup();
+ waitForPageToLoad();
}
}
View
28 src/test/java/com/tap5/hotelbooking/test/integration/SearchPageTest.java
@@ -1,7 +1,6 @@
package com.tap5.hotelbooking.test.integration;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
@@ -11,7 +10,7 @@
*/
public class SearchPageTest extends BaseIntegrationTestSuite
{
- @Test(testName = "signin")
+ @Test(priority = 10, groups="search")
public void signin()
{
open("/signin");
@@ -29,7 +28,7 @@ public void signin()
/**
* Check wildcards
*/
- @Test(testName = "wildcardSearch", dependsOnMethods = "signin")
+ @Test(priority = 11, groups="search")
public void wildcardSearch()
{
open("/search");
@@ -39,13 +38,15 @@ public void wildcardSearch()
select("id=rowsPerPage", "value=10");
click("//form[@id='searchForm']//input[@type='submit']");
- waitForCondition("selenium.getXpathCount(\"//div[@class='t-data-grid-pager']/a\") == 2", "15000");
+ waitForCondition(
+ "selenium.getXpathCount(\"//div[@class='t-data-grid-pager']/a\") == 2",
+ "15000");
}
-
+
/**
* Check wildcards with 20 results per page
*/
- @Test(testName = "changePagePerResult", dependsOnMethods = "signin")
+ @Test(priority = 12, groups="search")
public void changePagePerResult()
{
open("/search");
@@ -54,21 +55,22 @@ public void changePagePerResult()
type("query", "*");
select("id=rowsPerPage", "value=20");
click("//form[@id='searchForm']//input[@type='submit']");
- waitForCondition("selenium.getXpathCount(\"//div[@class='t-data-grid-pager']/a\") == 1", "15000");
+ waitForCondition(
+ "selenium.getXpathCount(\"//div[@class='t-data-grid-pager']/a\") == 1",
+ "15000");
}
-
- @AfterClass(alwaysRun = true)
- @Override
- public void cleanup()
+
+ @Test(priority = 13, groups="search")
+ public void logout()
{
open("/search");
waitForPageToLoad();
-
+
Assert.assertTrue(
isElementPresent("id=logout"),
"Authenticated user should be able to logout");
click("id=logout");
- super.cleanup();
+ waitForPageToLoad();
}
}
View
26 src/test/java/com/tap5/hotelbooking/test/services/TestModule.java
@@ -1,26 +0,0 @@
-package com.tap5.hotelbooking.test.services;
-
-import org.apache.tapestry5.hibernate.HibernateSymbols;
-import org.apache.tapestry5.ioc.Configuration;
-import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.services.LibraryMapping;
-
-/**
- * Test application module.
- *
- * @author karesti
- */
-public class TestModule
-{
-
- public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration)
- {
- configuration.add(new LibraryMapping("test", "com.tap5.hotelbooking.test"));
- }
-
- public static void contributeApplicationDefauls(
- MappedConfiguration<String, String> configuration)
- {
- configuration.add(HibernateSymbols.DEFAULT_CONFIGURATION, "false");
- }
-}
View
5 src/test/java/com/tap5/hotelbooking/test/unit/BaseUnitTestSuite.java
@@ -6,8 +6,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import com.tap5.hotelbooking.services.HotelBookingModule;
-
/**
* Base test case class that provides the necessary to load tapestry services
*
@@ -30,8 +28,7 @@
@BeforeClass
public void setup()
{
- pageTester = new PageTester("com.tap5.hotelbooking", "hotel-booking", "src/main/webapp",
- HotelBookingModule.class);
+ pageTester = new PageTester("com.tap5.hotelbooking", "hotel-booking", "src/main/webapp");
registry = pageTester.getRegistry();
}
Please sign in to comment.
Something went wrong with that request. Please try again.