[jboss-cvs] jboss-seam/examples/nestedbooking/src/org/jboss/seam/example/booking/test ...
Peter Muir
peter at bleepbleep.org.uk
Tue Dec 4 10:45:49 EST 2007
User: pmuir
Date: 07/12/04 10:45:49
Modified: examples/nestedbooking/src/org/jboss/seam/example/booking/test
BookingTest.java testng.xml
Log:
First pass at JBSEAM-2294
Revision Changes Path
1.2 +144 -41 jboss-seam/examples/nestedbooking/src/org/jboss/seam/example/booking/test/BookingTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BookingTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/nestedbooking/src/org/jboss/seam/example/booking/test/BookingTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- BookingTest.java 25 Nov 2007 13:12:00 -0000 1.1
+++ BookingTest.java 4 Dec 2007 15:45:49 -0000 1.2
@@ -1,4 +1,4 @@
-//$Id: BookingTest.java,v 1.1 2007/11/25 13:12:00 pmuir Exp $
+//$Id: BookingTest.java,v 1.2 2007/12/04 15:45:49 pmuir Exp $
package org.jboss.seam.example.booking.test;
import java.util.Calendar;
@@ -29,7 +29,7 @@
new FacesRequest() {
@Override
- protected void invokeApplication() throws Exception
+ protected void invokeApplication()
{
Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
setValue("#{identity.username}", "gavin");
@@ -42,7 +42,7 @@
new FacesRequest("/main.xhtml") {
@Override
- protected void updateModelValues() throws Exception
+ protected void updateModelValues()
{
setValue("#{hotelSearch.searchString}", "Union Square");
}
@@ -65,10 +65,11 @@
}.run();
- String id = new FacesRequest("/hotel.xhtml") {
+ final String id = new FacesRequest("/main.xhtml") {
@Override
- protected void invokeApplication() throws Exception {
+ protected void invokeApplication()
+ {
HotelBooking hotelBooking = (HotelBooking) getInstance("hotelBooking");
DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels");
assert hotels.getRowCount()==1;
@@ -86,7 +87,7 @@
}.run();
- id = new FacesRequest("/hotel.xhtml", id) {
+ new FacesRequest("/hotel.xhtml", id) {
@Override
protected void invokeApplication()
@@ -109,13 +110,21 @@
}.run();
+
new FacesRequest("/book.xhtml", id) {
+ @Override @SuppressWarnings("deprecation")
+ protected void updateModelValues()
+ {
+ Date now = new Date();
+ setValue("#{booking.checkinDate}", now);
+ setValue("#{booking.checkoutDate}", now);
+ }
+
@Override
- protected void processValidations() throws Exception
+ protected void invokeApplication()
{
- validateValue("#{booking.creditCard}", "123");
- assert isValidationFailure();
+ assert invokeMethod("#{hotelBooking.setBookingDates}")==null;
}
@Override
@@ -123,7 +132,8 @@
{
Iterator messages = FacesContext.getCurrentInstance().getMessages();
assert messages.hasNext();
- assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit card number must 16 digits long");
+ FacesMessage message = (FacesMessage) messages.next();
+ assert message.getSummary().equals("Check out date must be later than check in date");
assert !messages.hasNext();
assert Manager.instance().isLongRunningConversation();
}
@@ -132,42 +142,112 @@
new FacesRequest("/book.xhtml", id) {
+ @Override @SuppressWarnings("deprecation")
+ protected void updateModelValues()
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 2);
+ setValue("#{booking.checkoutDate}", cal.getTime() );
+ }
+
@Override
- protected void processValidations() throws Exception
+ protected void invokeApplication()
{
- validateValue("#{booking.creditCardName}", "");
- assert isValidationFailure();
+ assert "rooms".equals(invokeMethod("#{hotelBooking.setBookingDates}"));
}
@Override
protected void renderResponse()
{
- Iterator messages = FacesContext.getCurrentInstance().getMessages();
- assert messages.hasNext();
- assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit card name is required");
- assert !messages.hasNext();
assert Manager.instance().isLongRunningConversation();
}
}.run();
- new FacesRequest("/book.xhtml", id) {
+ new FacesRequest("/rooms.xhtml", id)
+ {
- @Override @SuppressWarnings("deprecation")
- protected void updateModelValues() throws Exception
+ @Override
+ protected void renderResponse()
{
- setValue("#{booking.creditCard}", "1234567891021234");
- setValue("#{booking.creditCardName}", "GAVIN KING");
- setValue("#{booking.beds}", 2);
- Date now = new Date();
- setValue("#{booking.checkinDate}", now);
- setValue("#{booking.checkoutDate}", now);
+ assert getValue("#{booking.user}")!=null;
+ assert getValue("#{booking.hotel}")!=null;
+ assert getValue("#{booking.checkinDate}")!=null;
+ assert getValue("#{booking.checkoutDate}")!=null;
+ assert getValue("#{booking.roomPreference}").equals(getValue("#{hotel.standardRoom}"));
+ assert getValue("#{booking.creditCard}")==null;
+ assert getValue("#{booking.creditCardName}")==null;
+
+ assert getValue("#{availableRooms.rowCount}").equals(new Integer(2));
+ DataModel availableRooms = (DataModel) getValue("#{availableRooms}");
+ availableRooms.setRowIndex(0);
+ assert "Cozy Room".equals(getValue("#{availableRooms.rowData.name}"));
+ availableRooms.setRowIndex(1);
+ assert "Spectacular Room".equals(getValue("#{availableRooms.rowData.name}"));
+ }
+
+ }.run();
+
+ final String nestedId = new FacesRequest("/rooms.xhtml", id)
+ {
+
+ @Override
+ protected void applyRequestValues()
+ {
+ DataModel availableRooms = (DataModel) getValue("#{availableRooms}");
+ availableRooms.setRowIndex(0);
}
@Override
protected void invokeApplication()
{
- assert invokeMethod("#{hotelBooking.setBookingDetails}")==null;
+ assert getValue("#{booking.roomPreference}")!=null;
+ assert "Cozy Room".equals(getValue("#{booking.roomPreference.name}"));
+ assert "payment".equals(invokeAction("#{roomPreference.selectPreference}"));
+ System.out.println("here");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert Manager.instance().isLongRunningConversation();
+ assert Manager.instance().isNestedConversation();
+ }
+
+ }.run();
+
+ System.out.println(id + "/" + nestedId);
+ // Hmm, need this to move to the new, nested, conversation
+ // TODO This is probably a bug in SeamTest, not sure where
+ new NonFacesRequest("/payment.xhtml", nestedId)
+ {
+
+ @Override
+ protected void renderResponse()
+ {
+ System.out.println("here");
+ assert Manager.instance().isLongRunningConversation();
+ assert Manager.instance().isNestedConversation();
+
+ assert getValue("#{booking.user}")!=null;
+ assert getValue("#{booking.hotel}")!=null;
+ assert getValue("#{booking.checkinDate}")!=null;
+ assert getValue("#{booking.checkoutDate}")!=null;
+ assert getValue("#{booking.roomPreference}")!=null;
+ assert getValue("#{booking.creditCard}")==null;
+ assert getValue("#{booking.creditCardName}")==null;
+ }
+
+ }.run();
+
+ new FacesRequest("/payment.xhtml", nestedId)
+ {
+
+ @Override
+ protected void processValidations()
+ {
+ validateValue("#{booking.creditCard}", "123");
+ assert isValidationFailure();
}
@Override
@@ -175,39 +255,62 @@
{
Iterator messages = FacesContext.getCurrentInstance().getMessages();
assert messages.hasNext();
- FacesMessage message = (FacesMessage) messages.next();
- assert message.getSummary().equals("Check out date must be later than check in date");
+ assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit card number must 16 digits long");
assert !messages.hasNext();
assert Manager.instance().isLongRunningConversation();
+ assert Manager.instance().isNestedConversation();
}
}.run();
- new FacesRequest("/book.xhtml", id) {
+ new FacesRequest("/payment.xhtml", nestedId)
+ {
- @Override @SuppressWarnings("deprecation")
- protected void updateModelValues() throws Exception
+ @Override
+ protected void processValidations()
{
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.DAY_OF_MONTH, 2);
- setValue("#{booking.checkoutDate}", cal.getTime() );
+ validateValue("#{booking.creditCardName}", "");
+ assert isValidationFailure();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Iterator messages = FacesContext.getCurrentInstance().getMessages();
+ assert messages.hasNext();
+ assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit card name is required");
+ assert !messages.hasNext();
+ assert Manager.instance().isLongRunningConversation();
+ assert Manager.instance().isNestedConversation();
+ }
+
+ }.run();
+
+ new FacesRequest("/payment.xhtml", nestedId)
+ {
+ @Override
+ protected void updateModelValues()
+ {
+ setValue("#{booking.creditCard}", "1234567891021234");
+ setValue("#{booking.creditCardName}", "GAVIN KING");
}
@Override
protected void invokeApplication()
{
- invokeMethod("#{hotelBooking.setBookingDetails}");
+ assert "confirm".equals(invokeAction("#{roomPreference.requestConfirmation}"));
}
@Override
protected void renderResponse()
{
assert Manager.instance().isLongRunningConversation();
+ assert Manager.instance().isNestedConversation();
}
}.run();
- new FacesRequest("/confirm.xhtml", id) {
+ new FacesRequest("/confirm.xhtml", nestedId) {
@Override
protected void invokeApplication()
1.2 +4 -14 jboss-seam/examples/nestedbooking/src/org/jboss/seam/example/booking/test/testng.xml
(In the diff below, changes in quantity of whitespace are not shown.)
Index: testng.xml
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/nestedbooking/src/org/jboss/seam/example/booking/test/testng.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- testng.xml 25 Nov 2007 13:12:00 -0000 1.1
+++ testng.xml 4 Dec 2007 15:45:49 -0000 1.2
@@ -1,22 +1,12 @@
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
-<suite name="Hotel Booking" verbose="2" parallel="false">
+<suite name="Nested Hotel Booking" verbose="2" parallel="false">
- <test name="Login">
- <classes>
- <class name="org.jboss.seam.example.booking.test.LoginTest"/>
- </classes>
- </test>
-
- <test name="Booking">
+ <test name="Nested Hotel Booking">
<classes>
+ <!-- <class name="org.jboss.seam.example.booking.test.LoginTest"/>-->
<class name="org.jboss.seam.example.booking.test.BookingTest"/>
- </classes>
- </test>
-
- <test name="Change Password">
- <classes>
- <class name="org.jboss.seam.example.booking.test.ChangePasswordTest"/>
+ <!-- <class name="org.jboss.seam.example.booking.test.ChangePasswordTest"/>-->
</classes>
</test>
More information about the jboss-cvs-commits
mailing list