[seam-commits] Seam SVN: r14585 - in branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests: src/test/java/org/jboss/seam/example/contactlist/test and 1 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Apr 16 07:49:54 EDT 2012
Author: maschmid
Date: 2012-04-16 07:49:54 -0400 (Mon, 16 Apr 2012)
New Revision: 14585
Removed:
branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/resources-integration/web.xml
Modified:
branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/pom.xml
branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/java/org/jboss/seam/example/contactlist/test/ContactListTest.java
Log:
contactlist example deseamtested
Modified: branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/pom.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/pom.xml 2012-04-16 09:45:41 UTC (rev 14584)
+++ branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/pom.xml 2012-04-16 11:49:54 UTC (rev 14585)
@@ -77,13 +77,21 @@
</dependency>
<dependency>
+ <groupId>org.jboss.arquillian.extension</groupId>
+ <artifactId>arquillian-seam2</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.spec.javax.el</groupId>
<artifactId>jboss-el-api_2.2_spec</artifactId>
</dependency>
+
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
+
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
Modified: branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/java/org/jboss/seam/example/contactlist/test/ContactListTest.java
===================================================================
--- branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/java/org/jboss/seam/example/contactlist/test/ContactListTest.java 2012-04-16 09:45:41 UTC (rev 14584)
+++ branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/java/org/jboss/seam/example/contactlist/test/ContactListTest.java 2012-04-16 11:49:54 UTC (rev 14585)
@@ -5,16 +5,20 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OverProtocol;
import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.Component;
+import org.jboss.seam.contexts.Lifecycle;
import org.jboss.seam.example.contactlist.Contact;
-import org.jboss.seam.mock.JUnitSeamTest;
+import org.jboss.seam.framework.EntityHome;
+import org.jboss.seam.framework.EntityQuery;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
+import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
-public class ContactListTest extends JUnitSeamTest
+public class ContactListTest
{
@Deployment(name="ContactListTest")
@@ -25,10 +29,6 @@
WebArchive web = er.getAsType(WebArchive.class, "contactlist-web.war");
web.addClasses(ContactListTest.class);
-
- // Install org.jboss.seam.mock.MockSeamListener
- web.delete("/WEB-INF/web.xml");
- web.addAsWebInfResource("web.xml");
return er;
}
@@ -36,141 +36,64 @@
@Test
public void testList() throws Exception
{
- new NonFacesRequest("/search.xhtml")
- {
- @Override
- protected void renderResponse() throws Exception
- {
- List<Contact> contacts = (List<Contact>) getValue("#{contacts.resultList}");
- assert contacts.size()==5;
- }
- }.run();
+ EntityQuery<Contact> contacts = (EntityQuery<Contact>)Component.getInstance("contacts");
+ List<Contact> contactsList = (List<Contact>) (contacts.getResultList());
+ assertEquals(5, contactsList.size());
}
@Test
public void testSearch() throws Exception
{
- new FacesRequest("/search.xhtml")
- {
- @Override
- protected void updateModelValues() throws Exception
- {
- setValue("#{exampleContact.firstName}", "Norman");
- }
- @Override
- protected void invokeApplication() throws Exception
- {
- setOutcome("/search.xhtml");
- }
- @Override
- protected void afterRequest()
- {
- assert !isRenderResponseBegun();
- }
- }.run();
+ Contact exampleContact = (Contact)Component.getInstance("exampleContact");
+ exampleContact.setFirstName("Norman");
+
+ EntityQuery<Contact> contacts = (EntityQuery<Contact>)Component.getInstance("contacts");
+ List<Contact> contactsList = (List<Contact>) (contacts.getResultList());
+ assertEquals(1, contactsList.size());
- new NonFacesRequest("/search.xhtml")
- {
- @Override
- protected void beforeRequest()
- {
- setParameter("firstName", "Norman");
- }
- @Override
- protected void renderResponse() throws Exception
- {
- List<Contact> contacts = (List<Contact>) getValue("#{contacts.resultList}");
- System.out.println(contacts.size());
- assert contacts.size()==1;
- }
- }.run();
+ Lifecycle.endCall();
- new FacesRequest("/search.xhtml")
- {
- @Override
- protected void updateModelValues() throws Exception
- {
- setValue("#{exampleContact.lastName}", "King");
- }
- @Override
- protected void invokeApplication() throws Exception
- {
- setOutcome("/search.xhtml");
- }
- @Override
- protected void afterRequest()
- {
- assert !isRenderResponseBegun();
- }
- }.run();
+ Lifecycle.beginCall();
+
+ exampleContact = (Contact)Component.getInstance("exampleContact");
+ exampleContact.setLastName("King");
- new NonFacesRequest("/search.xhtml")
- {
- @Override
- protected void beforeRequest()
- {
- setParameter("lastName", "King");
- }
- @Override
- protected void renderResponse() throws Exception
- {
- List<Contact> contacts = (List<Contact>) getValue("#{contacts.resultList}");
- assert contacts.size()==1;
- }
- }.run();
+ contacts = (EntityQuery<Contact>)Component.getInstance("contacts");
+ contactsList = (List<Contact>) (contacts.getResultList());
+ assertEquals(1, contactsList.size());
+
+ Lifecycle.endCall();
}
- String contactId;
+ Long contactId;
@Test
public void testCreateDeleteContact() throws Exception
{
- new FacesRequest("/editContact.xhtml")
- {
- @Override
- protected void updateModelValues() throws Exception
- {
- setValue("#{contact.firstName}", "Emmanuel");
- setValue("#{contact.lastName}", "Bernard");
- setValue("#{contact.city}", "Paris");
- }
- @Override
- protected void invokeApplication() throws Exception
- {
- assert invokeMethod("#{contactHome.persist}").equals("persisted");
- contactId = getValue("#{contactHome.id}").toString();
- }
- }.run();
+ Contact contact = (Contact) Component.getInstance("contact");
+ contact.setFirstName("Emmanuel");
+ contact.setLastName("Bernard");
+ contact.setCity("Paris");
- new NonFacesRequest("/viewContact.xhtml")
- {
- @Override
- protected void beforeRequest()
- {
- setParameter("contactId", contactId);
- }
- @Override
- protected void renderResponse() throws Exception
- {
- assert getValue("#{contact.firstName}").equals("Emmanuel");
- assert getValue("#{contact.lastName}").equals("Bernard");
- assert getValue("#{contact.city}").equals("Paris");
- }
- }.run();
+ EntityHome<Contact> contactHome = (EntityHome<Contact>)Component.getInstance("contactHome");
+ assertEquals("persisted", contactHome.persist());
+ contactId = (Long)contactHome.getId();
+
+ Lifecycle.endCall();
+ Lifecycle.beginCall();
+
+ contactHome = (EntityHome<Contact>)Component.getInstance("contactHome");
+ contactHome.setId(contactId);
+ contact = (Contact) Component.getInstance("contact");
+ assertEquals("Emmanuel", contact.getFirstName());
+ assertEquals("Bernard", contact.getLastName());
+ assertEquals("Paris", contact.getCity());
+
+ Lifecycle.endCall();
+ Lifecycle.beginCall();
- new FacesRequest("/viewContact.xhtml")
- {
- @Override
- protected void beforeRequest()
- {
- setPageParameter( "contactId", new Long(contactId) );
- }
- @Override
- protected void invokeApplication() throws Exception
- {
- assert invokeMethod("#{contactHome.remove}").equals("removed");
- }
- }.run();
+ contactHome = (EntityHome<Contact>)Component.getInstance("contactHome");
+ contactHome.setId(contactId);
+ assertEquals("removed", contactHome.remove());
}
-
}
Deleted: branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/resources-integration/web.xml
===================================================================
--- branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/resources-integration/web.xml 2012-04-16 09:45:41 UTC (rev 14584)
+++ branches/community/Seam_2_3/examples-ee6/contactlist/contactlist-tests/src/test/resources-integration/web.xml 2012-04-16 11:49:54 UTC (rev 14585)
@@ -1,12 +0,0 @@
-<?xml version="1.0" ?>
-
-<web-app version="3.0"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
-
- <listener>
- <listener-class>org.jboss.seam.mock.MockSeamListener</listener-class>
- </listener>
-
-</web-app>
More information about the seam-commits
mailing list