Author: christian.bauer(a)jboss.com
Date: 2008-02-26 01:31:00 -0500 (Tue, 26 Feb 2008)
New Revision: 7475
Modified:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/BasicNodeOperations.java
Log:
JBSEAM-2671, too much document content didn't trigger validation
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2008-02-26
02:09:39 UTC (rev 7474)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2008-02-26
06:31:00 UTC (rev 7475)
@@ -22,6 +22,7 @@
import org.jboss.seam.wiki.core.renderer.MacroWikiTextRenderer;
import org.jboss.seam.wiki.core.model.*;
import org.jboss.seam.wiki.preferences.Preferences;
+import org.hibernate.validator.Length;
import static javax.faces.application.FacesMessage.SEVERITY_INFO;
import java.util.*;
@@ -331,6 +332,8 @@
/* -------------------------- Public Features ------------------------------ */
+ // TODO: We need to duplicate this here, otherwise it will only validated on
persist():
http://jira.jboss.com/jira/browse/JBSEAM-2671
+ @Length(min = 0, max = 32768)
public String getFormContent() {
// Load the document content and resolve links
if (formContent == null) syncInstanceToFormContent(getParentNode());
Modified:
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/BasicNodeOperations.java
===================================================================
---
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/BasicNodeOperations.java 2008-02-26
02:09:39 UTC (rev 7474)
+++
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/BasicNodeOperations.java 2008-02-26
06:31:00 UTC (rev 7475)
@@ -10,13 +10,12 @@
import org.hibernate.Session;
import org.hibernate.ejb.HibernateEntityManagerFactory;
import org.jboss.seam.core.Conversation;
+import org.jboss.seam.faces.Redirect;
import org.jboss.seam.wiki.core.action.DirectoryHome;
import org.jboss.seam.wiki.core.action.DocumentHome;
import org.jboss.seam.wiki.core.model.WikiDirectory;
import org.jboss.seam.wiki.core.model.WikiDocument;
-import org.jboss.seam.wiki.core.model.WikiNode;
import org.jboss.seam.wiki.test.util.DBUnitSeamTest;
-import org.jboss.seam.faces.Redirect;
import org.testng.annotations.Test;
public class BasicNodeOperations extends DBUnitSeamTest {
@@ -55,7 +54,6 @@
assert dirHome.getChildDocuments().size() == 1;
assert dirHome.getMenuItems().size() == 0;
assert dirHome.getAvailableMenuItems().size() == 0;
- assert dirHome.getChildNodes().size() == 1;
}
}.run();
@@ -138,6 +136,31 @@
}
@Test
+ public void createDocumentTooMuchContent() throws Exception {
+
+ final String conversationId = new NonFacesRequest("/docEdit_d.xhtml")
{
+ protected void beforeRequest() {
+ setParameter("parentDirectoryId", "3");
+ }
+ }.run();
+
+ new FacesRequest("/docEdit_d.xhtml") {
+
+ protected void beforeRequest() {
+ setParameter("cid", conversationId);
+ }
+
+ protected void processValidations() throws Exception {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i <= 40000; i++) builder.append("a");
+ validateValue("#{documentHome.formContent}",
builder.toString());
+ assert isValidationFailure();
+ }
+
+ }.run();
+ }
+
+ @Test
public void setDefaultDocument() throws Exception {
final String conversationId = new NonFacesRequest("/dirEdit_d.xhtml")
{